Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:18:06

0001 #ifndef Py_INTERNAL_FAULTHANDLER_H
0002 #define Py_INTERNAL_FAULTHANDLER_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 #ifdef HAVE_SIGACTION
0012 #  include <signal.h>
0013 #endif
0014 
0015 
0016 #ifndef MS_WINDOWS
0017    /* register() is useless on Windows, because only SIGSEGV, SIGABRT and
0018       SIGILL can be handled by the process, and these signals can only be used
0019       with enable(), not using register() */
0020 #  define FAULTHANDLER_USER
0021 #endif
0022 
0023 
0024 #ifdef HAVE_SIGACTION
0025 /* Using an alternative stack requires sigaltstack()
0026    and sigaction() SA_ONSTACK */
0027 #  ifdef HAVE_SIGALTSTACK
0028 #    define FAULTHANDLER_USE_ALT_STACK
0029 #  endif
0030 typedef struct sigaction _Py_sighandler_t;
0031 #else
0032 typedef PyOS_sighandler_t _Py_sighandler_t;
0033 #endif  // HAVE_SIGACTION
0034 
0035 
0036 #ifdef FAULTHANDLER_USER
0037 struct faulthandler_user_signal {
0038     int enabled;
0039     PyObject *file;
0040     int fd;
0041     int all_threads;
0042     int chain;
0043     _Py_sighandler_t previous;
0044     PyInterpreterState *interp;
0045 };
0046 #endif /* FAULTHANDLER_USER */
0047 
0048 
0049 struct _faulthandler_runtime_state {
0050     struct {
0051         int enabled;
0052         PyObject *file;
0053         int fd;
0054         int all_threads;
0055         PyInterpreterState *interp;
0056 #ifdef MS_WINDOWS
0057         void *exc_handler;
0058 #endif
0059     } fatal_error;
0060 
0061     struct {
0062         PyObject *file;
0063         int fd;
0064         PY_TIMEOUT_T timeout_us;   /* timeout in microseconds */
0065         int repeat;
0066         PyInterpreterState *interp;
0067         int exit;
0068         char *header;
0069         size_t header_len;
0070         /* The main thread always holds this lock. It is only released when
0071            faulthandler_thread() is interrupted before this thread exits, or at
0072            Python exit. */
0073         PyThread_type_lock cancel_event;
0074         /* released by child thread when joined */
0075         PyThread_type_lock running;
0076     } thread;
0077 
0078 #ifdef FAULTHANDLER_USER
0079     struct faulthandler_user_signal *user_signals;
0080 #endif
0081 
0082 #ifdef FAULTHANDLER_USE_ALT_STACK
0083     stack_t stack;
0084     stack_t old_stack;
0085 #endif
0086 };
0087 
0088 #define _faulthandler_runtime_state_INIT \
0089     { \
0090         .fatal_error = { \
0091             .fd = -1, \
0092         }, \
0093     }
0094 
0095 
0096 #ifdef __cplusplus
0097 }
0098 #endif
0099 #endif /* !Py_INTERNAL_FAULTHANDLER_H */