8000 Add debug offsets that can help in free threaded builds · python/cpython@41d291c · GitHub
[go: up one dir, main page]

Skip to content

Commit 41d291c

Browse files
committed
Add debug offsets that can help in free threaded builds
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent e001027 commit 41d291c

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Include/internal/pycore_runtime.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ typedef struct _Py_AuditHookEntry {
5353
typedef struct _Py_DebugOffsets {
5454
char cookie[8];
5555
uint64_t version;
56+
uint64_t free_threaded;
5657
// Runtime state offset;
5758
struct _runtime_state {
5859
uint64_t size;
@@ -70,6 +71,7 @@ typedef struct _Py_DebugOffsets {
7071
uint64_t imports_modules;
7172
uint64_t sysdict;
7273
uint64_t builtins;
74+
uint64_t _gil;
7375
uint64_t ceval_gil;
7476
uint64_t gil_runtime_state_locked;
7577
uint64_t gil_runtime_state_holder;
@@ -122,14 +124,50 @@ typedef struct _Py_DebugOffsets {
122124
struct _type_object {
123125
uint64_t size;
124126
uint64_t tp_name;
127+
uint64_t tp_repr;
128+
uint64_t tp_flags;
125129
} type_object;
126130

127131
// PyTuple object offset;
128132
struct _tuple_object {
129133
uint64_t size;
130134
uint64_t ob_item;
135+
uint64_t ob_size;
131136
} tuple_object;
132137

138+
// PyList object offset;
139+
struct _list_object {
140+
uint64_t size;
141+
uint64_t ob_item;
142+
} list_object;
143+
144+
// PyDict object offset;
145+
struct _dict_object {
146+
uint64_t size;
147+
uint64_t ma_keys;
148+
uint64_t ma_values;
149+
} dict_object;
150+
151+
// PyFloat object offset;
152+
struct _float_object {
153+
uint64_t size;
154+
uint64_t ob_fval;
155+
} float_object;
156+
157+
// PyLong object offset;
158+
struct _long_object {
159+
uint64_t size;
160+
uint64_t lv_tag;
161+
uint64_t ob_digit;
162+
} long_object;
163+
164+
// PyBytes object offset;
165+
struct _bytes_object {
166+
uint64_t size;
167+
uint64_t ob_size;
168+
uint64_t ob_sval;
169+
} bytes_object;
170+
133171
// Unicode object offset;
134172
struct _unicode_object {
135173
uint64_t size;

Include/internal/pycore_runtime_init.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern PyTypeObject _PyExc_MemoryError;
3434
.debug_offsets = { \
3535
.cookie = "xdebugpy", \
3636
.version = PY_VERSION_HEX, \
37+
.free_threaded = Py_GIL_DISABLED, \
3738
.runtime_state = { \
3839
.size = sizeof(_PyRuntimeState), \
3940
.finalizing = offsetof(_PyRuntimeState, _finalizing), \
@@ -48,6 +49,7 @@ extern PyTypeObject _PyExc_MemoryError;
4849
.imports_modules = offsetof(PyInterpreterState, imports.modules), \
4950
.sysdict = offsetof(PyInterpreterState, sysdict), \
5051
.builtins = offsetof(PyInterpreterState, builtins), \
52+
._gil = offsetof(PyInterpreterState, _gil), \
5153
.ceval_gil = offsetof(PyInterpreterState, ceval.gil), \
5254
.gil_runtime_state_locked = offsetof(PyInterpreterState, _gil.locked), \
5355
.gil_runtime_state_holder = offsetof(PyInterpreterState, _gil.last_holder), \
@@ -90,10 +92,36 @@ extern PyTypeObject _PyExc_MemoryError;
9092
.type_object = { \
9193
.size = sizeof(PyTypeObject), \
9294
.tp_name = offsetof(PyTypeObject, tp_name), \
95+
.tp_repr = offsetof(PyTypeObject, tp_repr), \
96+
.tp_flags = offsetof(PyTypeObject, tp_flags), \
9397
}, \
9498
.tuple_object = { \
9599
.size = sizeof(PyTupleObject), \
96100
.ob_item = offsetof(PyTupleObject, ob_item), \
101+
.ob_size = offsetof(PyTupleObject, ob_base.ob_size), \
102+
}, \
103+
.list_object = { \
104+
.size = sizeof(PyListObject), \
105+
.ob_item = offsetof(PyListObject, ob_item), \
106+
}, \
107+
.dict_object = { \
108+
.size = sizeof(PyDictObject), \
109+
.ma_keys = offsetof(PyDictObject, ma_keys), \
110+
.ma_values = offsetof(PyDictObject, ma_values), \
111+
}, \
112+
.float_object = { \
113+
.size = sizeof(PyFloatObject), \
114+
.ob_fval = offsetof(PyFloatObject, ob_fval), \
115+
}, \
116+
.long_object = { \
117+
.size = sizeof(PyLongObject), \
118+
.lv_tag = offsetof(_PyLongValue, lv_tag), \
119+
.ob_digit = offsetof(_PyLongValue, ob_digit), \
120+
}, \
121+
.bytes_object = { \
122+
.size = sizeof(PyBytesObject), \
123+
.ob_size = offsetof(PyBytesObject, ob_base.ob_size), \
124+
.ob_sval = offsetof(PyBytesObject, ob_sval), \
97125
}, \
98126
.unicode_object = { \
99127
.size = sizeof(PyUnicodeObject), \

0 commit comments

Comments
 (0)
0