Skip to content

Commit 89bf337

Browse files
[3.13] gh-115773: Add sizes to debug offset structure (GH-120112) (#121283)
gh-115773: Add sizes to debug offset structure (GH-120112) (cherry picked from commit b180788) Co-authored-by: Pablo Galindo Salgado <[email protected]>
1 parent 78e96bd commit 89bf337

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Include/internal/pycore_runtime.h

+10
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ typedef struct _Py_DebugOffsets {
5555
uint64_t version;
5656
// Runtime state offset;
5757
struct _runtime_state {
58+
uint64_t size;
5859
uint64_t finalizing;
5960
uint64_t interpreters_head;
6061
} runtime_state;
6162

6263
// Interpreter state offset;
6364
struct _interpreter_state {
65+
uint64_t size;
6466
uint64_t next;
6567
uint64_t threads_head;
6668
uint64_t gc;
@@ -74,6 +76,7 @@ typedef struct _Py_DebugOffsets {
7476

7577
// Thread state offset;
7678
struct _thread_state{
79+
uint64_t size;
7780
uint64_t prev;
7881
uint64_t next;
7982
uint64_t interp;
@@ -84,6 +87,7 @@ typedef struct _Py_DebugOffsets {
8487

8588
// InterpreterFrame offset;
8689
struct _interpreter_frame {
90+
uint64_t size;
8791
uint64_t previous;
8892
uint64_t executable;
8993
uint64_t instr_ptr;
@@ -93,12 +97,14 @@ typedef struct _Py_DebugOffsets {
9397

9498
// CFrame offset;
9599
struct _cframe {
100+
uint64_t size;
96101
uint64_t current_frame;
97102
uint64_t previous;
98103
} cframe;
99104

100105
// Code object offset;
101106
struct _code_object {
107+
uint64_t size;
102108
uint64_t filename;
103109
uint64_t name;
104110
uint64_t linetable;
@@ -111,21 +117,25 @@ typedef struct _Py_DebugOffsets {
111117

112118
// PyObject offset;
113119
struct _pyobject {
120+
uint64_t size;
114121
uint64_t ob_type;
115122
} pyobject;
116123

117124
// PyTypeObject object offset;
118125
struct _type_object {
126+
uint64_t size;
119127
uint64_t tp_name;
120128
} type_object;
121129

122130
// PyTuple object offset;
123131
struct _tuple_object {
132+
uint64_t size;
124133
uint64_t ob_item;
125134
} tuple_object;
126135

127136
// Unicode object offset;
128137
struct _unicode_object {
138+
uint64_t size;
129139
uint64_t state;
130140
uint64_t length;
131141
size_t asciiobject_size;

Include/internal/pycore_runtime_init.h

+9
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ extern PyTypeObject _PyExc_MemoryError;
3535
.cookie = "xdebugpy", \
3636
.version = PY_VERSION_HEX, \
3737
.runtime_state = { \
38+
.size = sizeof(_PyRuntimeState), \
3839
.finalizing = offsetof(_PyRuntimeState, _finalizing), \
3940
.interpreters_head = offsetof(_PyRuntimeState, interpreters.head), \
4041
}, \
4142
.interpreter_state = { \
43+
.size = sizeof(PyInterpreterState), \
4244
.next = offsetof(PyInterpreterState, next), \
4345
.threads_head = offsetof(PyInterpreterState, threads.head), \
4446
.gc = offsetof(PyInterpreterState, gc), \
@@ -50,6 +52,7 @@ extern PyTypeObject _PyExc_MemoryError;
5052
.gil_runtime_state_holder = offsetof(PyInterpreterState, _gil.last_holder), \
5153
}, \
5254
.thread_state = { \
55+
.size = sizeof(PyThreadState), \
5356
.prev = offsetof(PyThreadState, prev), \
5457
.next = offsetof(PyThreadState, next), \
5558
.interp = offsetof(PyThreadState, interp), \
@@ -58,13 +61,15 @@ extern PyTypeObject _PyExc_MemoryError;
5861
.native_thread_id = offsetof(PyThreadState, native_thread_id), \
5962
}, \
6063
.interpreter_frame = { \
64+
.size = sizeof(_PyInterpreterFrame), \
6165
.previous = offsetof(_PyInterpreterFrame, previous), \
6266
.executable = offsetof(_PyInterpreterFrame, f_executable), \
6367
.instr_ptr = offsetof(_PyInterpreterFrame, instr_ptr), \
6468
.localsplus = offsetof(_PyInterpreterFrame, localsplus), \
6569
.owner = offsetof(_PyInterpreterFrame, owner), \
6670
}, \
6771
.code_object = { \
72+
.size = sizeof(PyCodeObject), \
6873
.filename = offsetof(PyCodeObject, co_filename), \
6974
.name = offsetof(PyCodeObject, co_name), \
7075
.linetable = offsetof(PyCodeObject, co_linetable), \
@@ -75,15 +80,19 @@ extern PyTypeObject _PyExc_MemoryError;
7580
.co_code_adaptive = offsetof(PyCodeObject, co_code_adaptive), \
7681
}, \
7782
.pyobject = { \
83+
.size = sizeof(PyObject), \
7884
.ob_type = offsetof(PyObject, ob_type), \
7985
}, \
8086
.type_object = { \
87+
.size = sizeof(PyTypeObject), \
8188
.tp_name = offsetof(PyTypeObject, tp_name), \
8289
}, \
8390
.tuple_object = { \
91+
.size = sizeof(PyTupleObject), \
8492
.ob_item = offsetof(PyTupleObject, ob_item), \
8593
}, \
8694
.unicode_object = { \
95+
.size = sizeof(PyUnicodeObject), \
8796
.state = offsetof(PyUnicodeObject, _base._base.state), \
8897
.length = offsetof(PyUnicodeObject, _base._base.length), \
8998
.asciiobject_size = sizeof(PyASCIIObject), \

0 commit comments

Comments
 (0)