summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorAndrej <azhilenkov@gmail.com>2024-05-02 08:57:45 (GMT)
committerGitHub <noreply@github.com>2024-05-02 08:57:45 (GMT)
commitf8e088df2a87f613ee23ea4f6787f87d9196b9de (patch)
tree006c1a26b94b7790fe723f15c9c5a6ba6c42a4d5 /Tools
parenta6b610a94bee0e4436aee2825c14f05ec2f22f75 (diff)
downloadcpython-f8e088df2a87f613ee23ea4f6787f87d9196b9de.zip
cpython-f8e088df2a87f613ee23ea4f6787f87d9196b9de.tar.gz
cpython-f8e088df2a87f613ee23ea4f6787f87d9196b9de.tar.bz2
gdb/libpython.py: Update PyLongObjectPtr docstring (GH-118438)
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/gdb/libpython.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 74165ac..5fdc812 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -255,7 +255,7 @@ class PyObjectPtr(object):
Derived classes will override this.
- For example, a PyIntObject* with ob_ival 42 in the inferior process
+ For example, a PyLongObjectPtr* with long_value 42 in the inferior process
should result in an int(42) in this process.
visited: a set of all gdb.Value pyobject pointers already visited
@@ -867,7 +867,7 @@ class PyLongObjectPtr(PyObjectPtr):
def proxyval(self, visited):
'''
- Python's Include/longobjrep.h has this declaration:
+ Python's Include/longinterpr.h has this declaration:
typedef struct _PyLongValue {
uintptr_t lv_tag; /* Number of digits, sign and flags */
@@ -876,14 +876,18 @@ class PyLongObjectPtr(PyObjectPtr):
struct _longobject {
PyObject_HEAD
- _PyLongValue long_value;
+ _PyLongValue long_value;
};
with this description:
The absolute value of a number is equal to
- SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
- Negative numbers are represented with ob_size < 0;
- zero is represented by ob_size == 0.
+ SUM(for i=0 through ndigits-1) ob_digit[i] * 2**(PyLong_SHIFT*i)
+ The sign of the value is stored in the lower 2 bits of lv_tag.
+ - 0: Positive
+ - 1: Zero
+ - 2: Negative
+ The third lowest bit of lv_tag is reserved for an immortality flag, but is
+ not currently used.
where SHIFT can be either:
#define PyLong_SHIFT 30