Skip to content

Commit c9bdfbe

Browse files
authored
gh-106597: Add more offsets to _Py_DebugOffsets (#121311)
Add more offsets to _Py_DebugOffsets We add a few more offsets that are required by some out-of-process tools, such as [Austin](https://github.com/p403n1x87/austin).
1 parent 9d3c9b8 commit c9bdfbe

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Include/internal/pycore_runtime.h

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef struct _Py_DebugOffsets {
6363
// Interpreter state offset;
6464
struct _interpreter_state {
6565
uint64_t size;
66+
uint64_t id;
6667
uint64_t next;
6768
uint64_t threads_head;
6869
uint64_t gc;
@@ -83,6 +84,8 @@ typedef struct _Py_DebugOffsets {
8384
uint64_t current_frame;
8485
uint64_t thread_id;
8586
uint64_t native_thread_id;
87+
uint64_t datastack_chunk;
88+
uint64_t status;
8689
} thread_state;
8790

8891
// InterpreterFrame offset;
@@ -107,6 +110,7 @@ typedef struct _Py_DebugOffsets {
107110
uint64_t size;
108111
uint64_t filename;
109112
uint64_t name;
113+
uint64_t qualname;
110114
uint64_t linetable;
111115
uint64_t firstlineno;
112116
uint64_t argcount;
@@ -140,6 +144,12 @@ typedef struct _Py_DebugOffsets {
140144
uint64_t length;
141145
size_t asciiobject_size;
142146
} unicode_object;
147+
148+
// GC runtime state offset;
149+
struct _gc {
150+
uint64_t size;
151+
uint64_t collecting;
152+
} gc;
143153
} _Py_DebugOffsets;
144154

145155
/* Reference tracer state */

Include/internal/pycore_runtime_init.h

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern PyTypeObject _PyExc_MemoryError;
4141
}, \
4242
.interpreter_state = { \
4343
.size = sizeof(PyInterpreterState), \
44+
.id = offsetof(PyInterpreterState, id), \
4445
.next = offsetof(PyInterpreterState, next), \
4546
.threads_head = offsetof(PyInterpreterState, threads.head), \
4647
.gc = offsetof(PyInterpreterState, gc), \
@@ -59,6 +60,8 @@ extern PyTypeObject _PyExc_MemoryError;
5960
.current_frame = offsetof(PyThreadState, current_frame), \
6061
.thread_id = offsetof(PyThreadState, thread_id), \
6162
.native_thread_id = offsetof(PyThreadState, native_thread_id), \
63+
.datastack_chunk = offsetof(PyThreadState, datastack_chunk), \
64+
.status = offsetof(PyThreadState, _status), \
6265
}, \
6366
.interpreter_frame = { \
6467
.size = sizeof(_PyInterpreterFrame), \
@@ -72,6 +75,7 @@ extern PyTypeObject _PyExc_MemoryError;
7275
.size = sizeof(PyCodeObject), \
7376
.filename = offsetof(PyCodeObject, co_filename), \
7477
.name = offsetof(PyCodeObject, co_name), \
78+
.qualname = offsetof(PyCodeObject, co_qualname), \
7579
.linetable = offsetof(PyCodeObject, co_linetable), \
7680
.firstlineno = offsetof(PyCodeObject, co_firstlineno), \
7781
.argcount = offsetof(PyCodeObject, co_argcount), \
@@ -97,6 +101,10 @@ extern PyTypeObject _PyExc_MemoryError;
97101
.length = offsetof(PyUnicodeObject, _base._base.length), \
98102
.asciiobject_size = sizeof(PyASCIIObject), \
99103
}, \
104+
.gc = { \
105+
.size = sizeof(struct _gc_runtime_state), \
106+
.collecting = offsetof(struct _gc_runtime_state, collecting), \
107+
}, \
100108
}, \
101109
.allocators = { \
102110
.standard = _pymem_allocators_standard_INIT(runtime), \

0 commit comments

Comments
 (0)