Path: blob/main/Include/internal/pycore_faulthandler.h
12 views
#ifndef Py_INTERNAL_FAULTHANDLER_H1#define Py_INTERNAL_FAULTHANDLER_H2#ifdef __cplusplus3extern "C" {4#endif56#ifndef Py_BUILD_CORE7# error "this header requires Py_BUILD_CORE define"8#endif910#ifdef HAVE_SIGACTION11# include <signal.h>12#endif131415#ifndef MS_WINDOWS16/* register() is useless on Windows, because only SIGSEGV, SIGABRT and17SIGILL can be handled by the process, and these signals can only be used18with enable(), not using register() */19# define FAULTHANDLER_USER20#endif212223#ifdef HAVE_SIGACTION24/* Using an alternative stack requires sigaltstack()25and sigaction() SA_ONSTACK */26# ifdef HAVE_SIGALTSTACK27# define FAULTHANDLER_USE_ALT_STACK28# endif29typedef struct sigaction _Py_sighandler_t;30#else31typedef PyOS_sighandler_t _Py_sighandler_t;32#endif // HAVE_SIGACTION333435#ifdef FAULTHANDLER_USER36struct faulthandler_user_signal {37int enabled;38PyObject *file;39int fd;40int all_threads;41int chain;42_Py_sighandler_t previous;43PyInterpreterState *interp;44};45#endif /* FAULTHANDLER_USER */464748struct _faulthandler_runtime_state {49struct {50int enabled;51PyObject *file;52int fd;53int all_threads;54PyInterpreterState *interp;55#ifdef MS_WINDOWS56void *exc_handler;57#endif58} fatal_error;5960struct {61PyObject *file;62int fd;63PY_TIMEOUT_T timeout_us; /* timeout in microseconds */64int repeat;65PyInterpreterState *interp;66int exit;67char *header;68size_t header_len;69/* The main thread always holds this lock. It is only released when70faulthandler_thread() is interrupted before this thread exits, or at71Python exit. */72PyThread_type_lock cancel_event;73/* released by child thread when joined */74PyThread_type_lock running;75} thread;7677#ifdef FAULTHANDLER_USER78struct faulthandler_user_signal *user_signals;79#endif8081#ifdef FAULTHANDLER_USE_ALT_STACK82stack_t stack;83stack_t old_stack;84#endif85};8687#define _faulthandler_runtime_state_INIT \88{ \89.fatal_error = { \90.fd = -1, \91}, \92}939495#ifdef __cplusplus96}97#endif98#endif /* !Py_INTERNAL_FAULTHANDLER_H */99100101