error_signals.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __ERROR_SIGNAL_H
  2. #define __ERROR_SIGNAL_H
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/syscall.h>
  6. #include <signal.h>
  7. #include <setjmp.h> // Yes, I used setjmp and longjmp. What cha gonna to do about it?
  8. #include "StackTrace.h"
  9. #include <sys/types.h>
  10. class error_signals:public StackTrace
  11. {
  12. public:
  13. pid_t thread_id;
  14. bool in_use;
  15. jmp_buf position;
  16. error_signals *next;
  17. int *LineNumbers[CALL_STACK_SIZE]; // These pointers point to the LineNumber property of the Debug object for that stack layer.
  18. void SaveLineNumbers(); // Save line numbers before the stack is trashed by longjmp.
  19. static error_signals *GetThread(pid_t thread_id); // Returns a thread from error_thread_list matching thread_id or nullptr.
  20. static error_signals *AddThread(pid_t thread_id); // Adds a thread to error_thread_list.
  21. static void ReleaseThread(pid_t thread_id); // Set an error signal in error_thread_list in_use = false for the thread_id.
  22. static pid_t GetThreadID(); // Return the thread id of the current thread.
  23. static void Handler(int signum); // The signal handler function.
  24. static void AddHandlers(); // Make the signal handlers point to error_signals::Handler.
  25. static void DeleteThreads(); // Delete all items in the error_thread_list.
  26. static void RemoveHandlers(); // Set the signal handlers to not point to error_signals::Handler.
  27. StackTrace *GetStackTrace();
  28. };
  29. extern error_signals *error_thread_list;
  30. #endif