PyErr_FormatUnraisable("Error executing debugger script %s", path);
}
}
+
+int _PyRunRemoteDebugger(PyThreadState *tstate)
+{
+ const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
+ if (config->remote_debug == 1
+ && tstate->remote_debugger_support.debugger_pending_call == 1)
+ {
+ tstate->remote_debugger_support.debugger_pending_call = 0;
+
+ // Immediately make a copy in case of a race with another debugger
+ // process that's trying to write to the buffer. At least this way
+ // we'll be internally consistent: what we audit is what we run.
+ const size_t pathsz
+ = sizeof(tstate->remote_debugger_support.debugger_script_path);
+
+ char *path = PyMem_Malloc(pathsz);
+ if (path) {
+ // And don't assume the debugger correctly null terminated it.
+ memcpy(
+ path,
+ tstate->remote_debugger_support.debugger_script_path,
+ pathsz);
+ path[pathsz - 1] = '\0';
+ if (*path) {
+ run_remote_debugger_script(path);
+ }
+ PyMem_Free(path);
+ }
+ }
+ return 0;
+}
+
#endif
/* Do periodic things, like check for signals and async I/0.
}
#if defined(Py_REMOTE_DEBUG) && defined(Py_SUPPORTS_REMOTE_DEBUG)
- const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
- if (config->remote_debug == 1
- && tstate->remote_debugger_support.debugger_pending_call == 1)
- {
- tstate->remote_debugger_support.debugger_pending_call = 0;
-
- // Immediately make a copy in case of a race with another debugger
- // process that's trying to write to the buffer. At least this way
- // we'll be internally consistent: what we audit is what we run.
- const size_t pathsz
- = sizeof(tstate->remote_debugger_support.debugger_script_path);
-
- char *path = PyMem_Malloc(pathsz);
- if (path) {
- // And don't assume the debugger correctly null terminated it.
- memcpy(
- path,
- tstate->remote_debugger_support.debugger_script_path,
- pathsz);
- path[pathsz - 1] = '\0';
- if (*path) {
- run_remote_debugger_script(path);
- }
- PyMem_Free(path);
- }
- }
+ _PyRunRemoteDebugger(tstate);
#endif
return 0;