mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-91048: Add better error messages for remote debugging for CI builds (#134682)
This commit is contained in:
parent
965662ee4a
commit
0909d6d8e8
8 changed files with 540 additions and 129 deletions
33
Modules/clinic/_remote_debugging_module.c.h
generated
33
Modules/clinic/_remote_debugging_module.c.h
generated
|
|
@ -10,7 +10,7 @@ preserve
|
|||
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
|
||||
|
||||
PyDoc_STRVAR(_remote_debugging_RemoteUnwinder___init____doc__,
|
||||
"RemoteUnwinder(pid, *, all_threads=False)\n"
|
||||
"RemoteUnwinder(pid, *, all_threads=False, debug=False)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Initialize a new RemoteUnwinder object for debugging a remote Python process.\n"
|
||||
|
|
@ -19,6 +19,8 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder___init____doc__,
|
|||
" pid: Process ID of the target Python process to debug\n"
|
||||
" all_threads: If True, initialize state for all threads in the process.\n"
|
||||
" If False, only initialize for the main thread.\n"
|
||||
" debug: If True, chain exceptions to explain the sequence of events that\n"
|
||||
" lead to the exception.\n"
|
||||
"\n"
|
||||
"The RemoteUnwinder provides functionality to inspect and debug a running Python\n"
|
||||
"process, including examining thread states, stack frames and other runtime data.\n"
|
||||
|
|
@ -30,7 +32,8 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder___init____doc__,
|
|||
|
||||
static int
|
||||
_remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self,
|
||||
int pid, int all_threads);
|
||||
int pid, int all_threads,
|
||||
int debug);
|
||||
|
||||
static int
|
||||
_remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
|
|
@ -38,7 +41,7 @@ _remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObje
|
|||
int return_value = -1;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
|
||||
#define NUM_KEYWORDS 2
|
||||
#define NUM_KEYWORDS 3
|
||||
static struct {
|
||||
PyGC_Head _this_is_not_used;
|
||||
PyObject_VAR_HEAD
|
||||
|
|
@ -47,7 +50,7 @@ _remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObje
|
|||
} _kwtuple = {
|
||||
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
||||
.ob_hash = -1,
|
||||
.ob_item = { &_Py_ID(pid), &_Py_ID(all_threads), },
|
||||
.ob_item = { &_Py_ID(pid), &_Py_ID(all_threads), &_Py_ID(debug), },
|
||||
};
|
||||
#undef NUM_KEYWORDS
|
||||
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
||||
|
|
@ -56,19 +59,20 @@ _remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObje
|
|||
# define KWTUPLE NULL
|
||||
#endif // !Py_BUILD_CORE
|
||||
|
||||
static const char * const _keywords[] = {"pid", "all_threads", NULL};
|
||||
static const char * const _keywords[] = {"pid", "all_threads", "debug", NULL};
|
||||
static _PyArg_Parser _parser = {
|
||||
.keywords = _keywords,
|
||||
.fname = "RemoteUnwinder",
|
||||
.kwtuple = KWTUPLE,
|
||||
};
|
||||
#undef KWTUPLE
|
||||
PyObject *argsbuf[2];
|
||||
PyObject *argsbuf[3];
|
||||
PyObject * const *fastargs;
|
||||
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
||||
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
|
||||
int pid;
|
||||
int all_threads = 0;
|
||||
int debug = 0;
|
||||
|
||||
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
|
||||
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
|
||||
|
|
@ -82,12 +86,21 @@ _remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObje
|
|||
if (!noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
all_threads = PyObject_IsTrue(fastargs[1]);
|
||||
if (all_threads < 0) {
|
||||
if (fastargs[1]) {
|
||||
all_threads = PyObject_IsTrue(fastargs[1]);
|
||||
if (all_threads < 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!--noptargs) {
|
||||
goto skip_optional_kwonly;
|
||||
}
|
||||
}
|
||||
debug = PyObject_IsTrue(fastargs[2]);
|
||||
if (debug < 0) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional_kwonly:
|
||||
return_value = _remote_debugging_RemoteUnwinder___init___impl((RemoteUnwinderObject *)self, pid, all_threads);
|
||||
return_value = _remote_debugging_RemoteUnwinder___init___impl((RemoteUnwinderObject *)self, pid, all_threads, debug);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
|
|
@ -240,4 +253,4 @@ _remote_debugging_RemoteUnwinder_get_async_stack_trace(PyObject *self, PyObject
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=654772085f1f4bf6 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=774ec34aa653402d input=a9049054013a1b77]*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue