Skip to content

Commit f8e088d

Browse files
authored
gdb/libpython.py: Update PyLongObjectPtr docstring (GH-118438)
1 parent a6b610a commit f8e088d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Tools/gdb/libpython.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def proxyval(self, visited):
255255
256256
Derived classes will override this.
257257
258-
For example, a PyIntObject* with ob_ival 42 in the inferior process
258+
For example, a PyLongObjectPtr* with long_value 42 in the inferior process
259259
should result in an int(42) in this process.
260260
261261
visited: a set of all gdb.Value pyobject pointers already visited
@@ -867,7 +867,7 @@ class PyLongObjectPtr(PyObjectPtr):
867867

868868
def proxyval(self, visited):
869869
'''
870-
Python's Include/longobjrep.h has this declaration:
870+
Python's Include/longinterpr.h has this declaration:
871871
872872
typedef struct _PyLongValue {
873873
uintptr_t lv_tag; /* Number of digits, sign and flags */
@@ -876,14 +876,18 @@ def proxyval(self, visited):
876876
877877
struct _longobject {
878878
PyObject_HEAD
879-
_PyLongValue long_value;
879+
_PyLongValue long_value;
880880
};
881881
882882
with this description:
883883
The absolute value of a number is equal to
884-
SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
885-
Negative numbers are represented with ob_size < 0;
886-
zero is represented by ob_size == 0.
884+
SUM(for i=0 through ndigits-1) ob_digit[i] * 2**(PyLong_SHIFT*i)
885+
The sign of the value is stored in the lower 2 bits of lv_tag.
886+
- 0: Positive
887+
- 1: Zero
888+
- 2: Negative
889+
The third lowest bit of lv_tag is reserved for an immortality flag, but is
890+
not currently used.
887891
888892
where SHIFT can be either:
889893
#define PyLong_SHIFT 30

0 commit comments

Comments
 (0)