gh-138122: Add --subprocesses flag to profile child processes in tachyon (#142636)

This commit is contained in:
Pablo Galindo Salgado 2025-12-15 12:11:40 +00:00 committed by GitHub
parent 14e6052b43
commit 6658e2cb07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 2702 additions and 562 deletions

View file

@ -8,23 +8,24 @@
#ifndef Py_REMOTE_DEBUGGING_H
#define Py_REMOTE_DEBUGGING_H
/* _GNU_SOURCE must be defined before any system headers */
#define _GNU_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
#define _GNU_SOURCE
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif
#include "Python.h"
#include <internal/pycore_debug_offsets.h> // _Py_DebugOffsets
#include <internal/pycore_frame.h> // FRAME_SUSPENDED_YIELD_FROM
#include <internal/pycore_interpframe.h> // FRAME_OWNED_BY_INTERPRETER
#include <internal/pycore_llist.h> // struct llist_node
#include <internal/pycore_long.h> // _PyLong_GetZero
#include <internal/pycore_stackref.h> // Py_TAG_BITS
#include "internal/pycore_debug_offsets.h" // _Py_DebugOffsets
#include "internal/pycore_frame.h" // FRAME_SUSPENDED_YIELD_FROM
#include "internal/pycore_interpframe.h" // FRAME_OWNED_BY_INTERPRETER
#include "internal/pycore_llist.h" // struct llist_node
#include "internal/pycore_long.h" // _PyLong_GetZero
#include "internal/pycore_stackref.h" // Py_TAG_BITS
#include "../../Python/remote_debug.h"
#include <assert.h>
@ -40,10 +41,17 @@ extern "C" {
# define HAVE_PROCESS_VM_READV 0
#endif
#if defined(__APPLE__) && TARGET_OS_OSX
#include <libproc.h>
#include <sys/types.h>
#define MAX_NATIVE_THREADS 4096
#if defined(__APPLE__)
#include <TargetConditionals.h>
# if !defined(TARGET_OS_OSX)
/* Older macOS SDKs do not define TARGET_OS_OSX */
# define TARGET_OS_OSX 1
# endif
# if TARGET_OS_OSX
# include <libproc.h>
# include <sys/types.h>
# define MAX_NATIVE_THREADS 4096
# endif
#endif
#ifdef MS_WINDOWS
@ -581,6 +589,16 @@ extern int process_thread_for_async_stack_trace(
void *context
);
/* ============================================================================
* SUBPROCESS ENUMERATION FUNCTION DECLARATIONS
* ============================================================================ */
/* Get all child PIDs of a process.
* Returns a new Python list of PIDs, or NULL on error with exception set.
* If recursive is true, includes all descendants (children, grandchildren, etc.)
*/
extern PyObject *enumerate_child_pids(pid_t target_pid, int recursive);
#ifdef __cplusplus
}
#endif