Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.8 KiB

  1. //===- llvm/Support/PrettyStackTrace.h - Pretty Crash Handling --*- 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 the PrettyStackTraceEntry class, which is used to make
  11. // crashes give more contextual information about what the program was doing
  12. // when it crashed.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
  16. #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
  17. #include "llvm/Support/Compiler.h"
  18. namespace llvm {
  19. class raw_ostream;
  20. /// DisablePrettyStackTrace - Set this to true to disable this module. This
  21. /// might be necessary if the host application installs its own signal
  22. /// handlers which conflict with the ones installed by this module.
  23. /// Defaults to false.
  24. extern bool DisablePrettyStackTrace;
  25. /// PrettyStackTraceEntry - This class is used to represent a frame of the
  26. /// "pretty" stack trace that is dumped when a program crashes. You can define
  27. /// subclasses of this and declare them on the program stack: when they are
  28. /// constructed and destructed, they will add their symbolic frames to a
  29. /// virtual stack trace. This gets dumped out if the program crashes.
  30. class PrettyStackTraceEntry {
  31. const PrettyStackTraceEntry *NextEntry;
  32. PrettyStackTraceEntry(const PrettyStackTraceEntry &) LLVM_DELETED_FUNCTION;
  33. void operator=(const PrettyStackTraceEntry&) LLVM_DELETED_FUNCTION;
  34. public:
  35. PrettyStackTraceEntry();
  36. virtual ~PrettyStackTraceEntry();
  37. /// print - Emit information about this stack frame to OS.
  38. virtual void print(raw_ostream &OS) const = 0;
  39. /// getNextEntry - Return the next entry in the list of frames.
  40. const PrettyStackTraceEntry *getNextEntry() const { return NextEntry; }
  41. };
  42. /// PrettyStackTraceString - This object prints a specified string (which
  43. /// should not contain newlines) to the stream as the stack trace when a crash
  44. /// occurs.
  45. class PrettyStackTraceString : public PrettyStackTraceEntry {
  46. const char *Str;
  47. public:
  48. PrettyStackTraceString(const char *str) : Str(str) {}
  49. virtual void print(raw_ostream &OS) const LLVM_OVERRIDE;
  50. };
  51. /// PrettyStackTraceProgram - This object prints a specified program arguments
  52. /// to the stream as the stack trace when a crash occurs.
  53. class PrettyStackTraceProgram : public PrettyStackTraceEntry {
  54. int ArgC;
  55. const char *const *ArgV;
  56. public:
  57. PrettyStackTraceProgram(int argc, const char * const*argv)
  58. : ArgC(argc), ArgV(argv) {}
  59. virtual void print(raw_ostream &OS) const LLVM_OVERRIDE;
  60. };
  61. } // end namespace llvm
  62. #endif