Signals.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //===- llvm/Support/Signals.h - Signal Handling support ----------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines some helpful functions for dealing with the possibility of
  11. // unix signals occurring while your program is running.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_SUPPORT_SIGNALS_H
  15. #define LLVM_SUPPORT_SIGNALS_H
  16. #include <string>
  17. #include <llvm/ADT/StringRef.h> // HLSL Change - StringRef is, in fact, referenced directly
  18. namespace llvm {
  19. class StringRef;
  20. class raw_ostream;
  21. namespace sys {
  22. /// This function runs all the registered interrupt handlers, including the
  23. /// removal of files registered by RemoveFileOnSignal.
  24. void RunInterruptHandlers();
  25. /// This function registers signal handlers to ensure that if a signal gets
  26. /// delivered that the named file is removed.
  27. /// @brief Remove a file if a fatal signal occurs.
  28. bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr);
  29. /// This function removes a file from the list of files to be removed on
  30. /// signal delivery.
  31. void DontRemoveFileOnSignal(StringRef Filename);
  32. /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
  33. /// process, print a stack trace and then exit.
  34. /// @brief Print a stack trace if a fatal signal occurs.
  35. void PrintStackTraceOnErrorSignal(bool DisableCrashReporting = false);
  36. /// Disable all system dialog boxes that appear when the process crashes.
  37. void DisableSystemDialogsOnCrash();
  38. /// \brief Print the stack trace using the given \c raw_ostream object.
  39. void PrintStackTrace(raw_ostream &OS);
  40. /// AddSignalHandler - Add a function to be called when an abort/kill signal
  41. /// is delivered to the process. The handler can have a cookie passed to it
  42. /// to identify what instance of the handler it is.
  43. void AddSignalHandler(void (*FnPtr)(void *), void *Cookie);
  44. /// This function registers a function to be called when the user "interrupts"
  45. /// the program (typically by pressing ctrl-c). When the user interrupts the
  46. /// program, the specified interrupt function is called instead of the program
  47. /// being killed, and the interrupt function automatically disabled. Note
  48. /// that interrupt functions are not allowed to call any non-reentrant
  49. /// functions. An null interrupt function pointer disables the current
  50. /// installed function. Note also that the handler may be executed on a
  51. /// different thread on some platforms.
  52. /// @brief Register a function to be called when ctrl-c is pressed.
  53. void SetInterruptFunction(void (*IF)());
  54. } // End sys namespace
  55. } // End llvm namespace
  56. #endif