gh-138122: Add blocking mode for accurate stack traces in Tachyon (#142998)

This commit is contained in:
Pablo Galindo Salgado 2025-12-23 10:49:47 +00:00 committed by GitHub
parent f9704f1d84
commit 81c8eb85e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 855 additions and 77 deletions

View file

@ -33,6 +33,9 @@ extern "C" {
#ifdef __linux__
# include <elf.h>
# include <sys/uio.h>
# include <sys/ptrace.h>
# include <sys/wait.h>
# include <dirent.h>
# if INTPTR_MAX == INT64_MAX
# define Elf_Ehdr Elf64_Ehdr
# define Elf_Shdr Elf64_Shdr
@ -43,6 +46,17 @@ extern "C" {
# define Elf_Phdr Elf32_Phdr
# endif
# include <sys/mman.h>
// PTRACE options - define if not available
# ifndef PTRACE_SEIZE
# define PTRACE_SEIZE 0x4206
# endif
# ifndef PTRACE_INTERRUPT
# define PTRACE_INTERRUPT 0x4207
# endif
# ifndef PTRACE_EVENT_STOP
# define PTRACE_EVENT_STOP 128
# endif
#endif
#if defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX
@ -55,6 +69,7 @@ extern "C" {
# include <mach/mach_vm.h>
# include <mach/machine.h>
# include <mach/task_info.h>
# include <mach/thread_act.h>
# include <sys/mman.h>
# include <sys/proc.h>
# include <sys/sysctl.h>
@ -169,7 +184,7 @@ _Py_RemoteDebug_InitProcHandle(proc_handle_t *handle, pid_t pid) {
}
#elif defined(MS_WINDOWS)
handle->hProcess = OpenProcess(
PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_QUERY_INFORMATION,
PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_QUERY_INFORMATION | PROCESS_SUSPEND_RESUME,
FALSE, pid);
if (handle->hProcess == NULL) {
PyErr_SetFromWindowsErr(0);