gh-145559: Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads() (#148145)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Alex Malyshev 2026-05-06 11:01:12 -04:00 committed by GitHub
parent 7b6c248d61
commit 646853df13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 109 additions and 76 deletions

View file

@ -1167,10 +1167,11 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
The caller is responsible to call PyErr_CheckSignals() to call Python signal
handlers if signals were received. */
void
_Py_DumpTraceback(int fd, PyThreadState *tstate)
const char*
PyUnstable_DumpTraceback(int fd, PyThreadState *tstate)
{
dump_traceback(fd, tstate, 1);
return NULL;
}
#if defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP)
@ -1264,16 +1265,16 @@ write_thread_id(int fd, PyThreadState *tstate, int is_current)
The caller is responsible to call PyErr_CheckSignals() to call Python signal
handlers if signals were received. */
const char* _Py_NO_SANITIZE_THREAD
_Py_DumpTracebackThreads(int fd, PyInterpreterState *interp,
PyThreadState *current_tstate,
Py_ssize_t max_threads)
PyUnstable_DumpTracebackThreads(int fd, PyInterpreterState *interp,
PyThreadState *current_tstate,
Py_ssize_t max_threads)
{
if (max_threads == 0) {
max_threads = DEFAULT_MAX_NTHREADS;
}
if (current_tstate == NULL) {
/* _Py_DumpTracebackThreads() is called from signal handlers by
/* PyUnstable_DumpTracebackThreads() is called from signal handlers by
faulthandler.
SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL are synchronous signals