Skip to content

Commit 6f6b4cd

Browse files
committed
gh-131591: Implement PEP 768
1 parent 18249d9 commit 6f6b4cd

18 files changed

+978
-2
lines changed

Include/cpython/initconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ typedef struct PyConfig {
143143
int faulthandler;
144144
int tracemalloc;
145145
int perf_profiling;
146+
int remote_debug;
146147
int import_time;
147148
int code_debug_ranges;
148149
int show_ref_count;

Include/cpython/pystate.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
2929
#define PyTrace_C_RETURN 6
3030
#define PyTrace_OPCODE 7
3131

32+
/* Remote debugger support */
33+
# define MAX_SCRIPT_PATH_SIZE 512
34+
typedef struct _remote_debugger_support {
35+
int enabled;
36+
int debugger_pending_call;
37+
char debugger_script_path[MAX_SCRIPT_PATH_SIZE];
38+
} _PyRemoteDebuggerSupport;
39+
3240
typedef struct _err_stackitem {
3341
/* This struct represents a single execution context where we might
3442
* be currently handling an exception. It is a per-coroutine state
@@ -202,6 +210,7 @@ struct _ts {
202210
The PyThreadObject must hold the only reference to this value.
203211
*/
204212
PyObject *threading_local_sentinel;
213+
_PyRemoteDebuggerSupport remote_debugger_support;
205214
};
206215

207216
# define Py_C_RECURSION_LIMIT 5000

Include/internal/pycore_debug_offsets.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ typedef struct _Py_DebugOffsets {
206206
uint64_t gi_iframe;
207207
uint64_t gi_frame_state;
208208
} gen_object;
209+
210+
struct _debugger_support {
211+
uint64_t eval_breaker;
212+
uint64_t remote_debugger_support;
213+
uint64_t remote_debugging_enabled;
214+
uint64_t debugger_pending_call;
215+
uint64_t debugger_script_path;
216+
uint64_t debugger_script_path_size;
217+
} debugger_support;
209218
} _Py_DebugOffsets;
210219

211220

@@ -326,6 +335,14 @@ typedef struct _Py_DebugOffsets {
326335
.gi_iframe = offsetof(PyGenObject, gi_iframe), \
327336
.gi_frame_state = offsetof(PyGenObject, gi_frame_state), \
328337
}, \
338+
.debugger_support = { \
339+
.eval_breaker = offsetof(PyThreadState, eval_breaker), \
340+
.remote_debugger_support = offsetof(PyThreadState, remote_debugger_support), \
341+
.remote_debugging_enabled = offsetof(PyInterpreterState, config.remote_debug), \
342+
.debugger_pending_call = offsetof(_PyRemoteDebuggerSupport, debugger_pending_call), \
343+
.debugger_script_path = offsetof(_PyRemoteDebuggerSupport, debugger_script_path), \
344+
.debugger_script_path_size = MAX_SCRIPT_PATH_SIZE, \
345+
}, \
329346
}
330347

331348

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ struct _Py_global_strings {
676676
STRUCT_FOR_ID(salt)
677677
STRUCT_FOR_ID(sched_priority)
678678
STRUCT_FOR_ID(scheduler)
679+
STRUCT_FOR_ID(script)
679680
STRUCT_FOR_ID(second)
680681
STRUCT_FOR_ID(security_attributes)
681682
STRUCT_FOR_ID(seek)

Include/internal/pycore_interp_structs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ struct _is {
936936
_PyThreadStateImpl _initial_thread;
937937
// _initial_thread should be the last field of PyInterpreterState.
938938
// See https://github.com/python/cpython/issues/127117.
939-
940939
#if !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)
941940
uint64_t next_stackref;
942941
_Py_hashtable_t *open_stackrefs_table;

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_sysmodule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ extern int _PySys_ClearAttrString(PyInterpreterState *interp,
2424
extern int _PySys_SetFlagObj(Py_ssize_t pos, PyObject *new_value);
2525
extern int _PySys_SetIntMaxStrDigits(int maxdigits);
2626

27+
extern int _PySysRemoteDebug_SendExec(int pid, int tid, const char *debugger_script_path);
28+
2729
#ifdef __cplusplus
2830
}
2931
#endif

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ PYTHON_OBJS= \
506506
Python/suggestions.o \
507507
Python/perf_trampoline.o \
508508
Python/perf_jit_trampoline.o \
509+
Python/remote_debugging.o \
509510
Python/$(DYNLOADFILE) \
510511
$(LIBOBJS) \
511512
$(MACHDEP_OBJS) \

0 commit comments

Comments
 (0)