Skip to content

Commit de2154a

Browse files
committed
Address feedback
Signed-off-by: Pablo Galindo <[email protected]>
1 parent ff5d47e commit de2154a

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

Include/internal/pycore_runtime.h

+39-4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ typedef struct _Py_AuditHookEntry {
5454
} _Py_AuditHookEntry;
5555

5656
typedef struct _Py_DebugOffsets {
57+
char cookie[8];
58+
uint64_t version;
5759
// Runtime state offset;
5860
struct _runtime_state {
5961
off_t finalizing;
@@ -69,6 +71,8 @@ typedef struct _Py_DebugOffsets {
6971
off_t sysdict;
7072
off_t builtins;
7173
off_t ceval_gil;
74+
off_t gil_runtime_state_locked;
75+
off_t gil_runtime_state_holder;
7276
} interpreter_state;
7377

7478
// Thread state offset;
@@ -78,16 +82,23 @@ typedef struct _Py_DebugOffsets {
7882
off_t interp;
7983
off_t cframe;
8084
off_t thread_id;
85+
off_t native_thread_id;
8186
} thread_state;
8287

83-
// Frame object offset;
84-
struct _frame_object {
88+
// InterpreterFrame offset;
89+
struct _interpreter_frame {
8590
off_t previous;
8691
off_t executable;
8792
off_t prev_instr;
8893
off_t localsplus;
8994
off_t owner;
90-
} frame_object;
95+
} interpreter_frame;
96+
97+
// CFrame offset;
98+
struct _cframe {
99+
off_t current_frame;
100+
off_t previous;
101+
} cframe;
91102

92103
// Code object offset;
93104
struct _code_object {
@@ -97,8 +108,24 @@ typedef struct _Py_DebugOffsets {
97108
off_t firstlineno;
98109
off_t argcount;
99110
off_t localsplusnames;
111+
off_t localspluskinds;
100112
off_t co_code_adaptive;
101113
} code_object;
114+
115+
// PyObject offset;
116+
struct _pyobject {
117+
off_t ob_type;
118+
} pyobject;
119+
120+
// PyTypeObject object offset;
121+
struct _type_object {
122+
off_t tp_name;
123+
} type_object;
124+
125+
// PyTuple object offset;
126+
struct _tuple_object {
127+
off_t ob_item;
128+
} tuple_object;
102129
} _Py_DebugOffsets;
103130

104131
/* Full Python runtime state */
@@ -111,8 +138,16 @@ typedef struct pyruntimestate {
111138
* debuggers. Out of process debuggers will use the offsets contained in this
112139
* field to be able to locate other fields in several interpreter structures
113140
* in a way that doesn't require them to know the exact layout of those
114-
* structures */
141+
* structures.
142+
*
143+
* IMPORTANT:
144+
* This struct is **NOT** backwards compatible between minor version of the
145+
* interpreter and the members, order of members and size can change between
146+
* minor versions. This struct is only guaranteed to be stable between patch
147+
* versions for a given minor version of the interpreter.
148+
*/
115149
_Py_DebugOffsets debug_offsets;
150+
116151
/* Has been initialized to a safe state.
117152
118153
In order to be effective, this must be set to 0 during or right

Include/internal/pycore_runtime_init.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ extern PyTypeObject _PyExc_MemoryError;
2424
#define _PyRuntimeState_INIT(runtime) \
2525
{ \
2626
.debug_offsets = { \
27+
.cookie = "xdebugpy", \
28+
.version = PY_VERSION_HEX, \
2729
.runtime_state = { \
2830
.finalizing = offsetof(_PyRuntimeState, _finalizing), \
2931
.interpreters_head = offsetof(_PyRuntimeState, interpreters.head), \
@@ -36,30 +38,47 @@ extern PyTypeObject _PyExc_MemoryError;
3638
.sysdict = offsetof(PyInterpreterState, sysdict), \
3739
.builtins = offsetof(PyInterpreterState, builtins), \
3840
.ceval_gil = offsetof(PyInterpreterState, ceval.gil), \
41+
.gil_runtime_state_locked = offsetof(PyInterpreterState, _gil.locked), \
42+
.gil_runtime_state_holder = offsetof(PyInterpreterState, _gil.last_holder), \
3943
}, \
4044
.thread_state = { \
4145
.prev = offsetof(PyThreadState, prev), \
4246
.next = offsetof(PyThreadState, next), \
4347
.interp = offsetof(PyThreadState, interp), \
4448
.cframe = offsetof(PyThreadState, cframe), \
4549
.thread_id = offsetof(PyThreadState, thread_id), \
50+
.native_thread_id = offsetof(PyThreadState, native_thread_id), \
4651
}, \
47-
.frame_object = { \
52+
.interpreter_frame = { \
4853
.previous = offsetof(_PyInterpreterFrame, previous), \
4954
.executable = offsetof(_PyInterpreterFrame, f_executable), \
5055
.prev_instr = offsetof(_PyInterpreterFrame, prev_instr), \
5156
.localsplus = offsetof(_PyInterpreterFrame, localsplus), \
5257
.owner = offsetof(_PyInterpreterFrame, owner), \
5358
}, \
59+
.cframe = { \
60+
.current_frame = offsetof(_PyCFrame, current_frame), \
61+
.previous = offsetof(_PyCFrame, previous), \
62+
}, \
5463
.code_object = { \
5564
.filename = offsetof(PyCodeObject, co_filename), \
5665
.name = offsetof(PyCodeObject, co_name), \
5766
.linetable = offsetof(PyCodeObject, co_linetable), \
5867
.firstlineno = offsetof(PyCodeObject, co_firstlineno), \
5968
.argcount = offsetof(PyCodeObject, co_argcount), \
6069
.localsplusnames = offsetof(PyCodeObject, co_localsplusnames), \
70+
.localspluskinds = offsetof(PyCodeObject, co_localspluskinds), \
6171
.co_code_adaptive = offsetof(PyCodeObject, co_code_adaptive), \
6272
}, \
73+
.pyobject = { \
74+
.ob_type = offsetof(PyObject, ob_type), \
75+
}, \
76+
.type_object = { \
77+
.tp_name = offsetof(PyTypeObject, tp_name), \
78+
}, \
79+
.tuple_object = { \
80+
.ob_item = offsetof(PyTupleObject, ob_item), \
81+
}, \
6382
}, \
6483
.allocators = { \
6584
.standard = _pymem_allocators_standard_INIT(runtime), \

0 commit comments

Comments
 (0)