LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrettyStackTrace.h
Go to the documentation of this file.
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 
16 #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
17 #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
18 
19 #include "llvm/Support/Compiler.h"
20 
21 namespace llvm {
22  class raw_ostream;
23 
25 
26  /// PrettyStackTraceEntry - This class is used to represent a frame of the
27  /// "pretty" stack trace that is dumped when a program crashes. You can define
28  /// subclasses of this and declare them on the program stack: when they are
29  /// constructed and destructed, they will add their symbolic frames to a
30  /// virtual stack trace. This gets dumped out if the program crashes.
32  const PrettyStackTraceEntry *NextEntry;
34  void operator=(const PrettyStackTraceEntry&) LLVM_DELETED_FUNCTION;
35  public:
37  virtual ~PrettyStackTraceEntry();
38 
39  /// print - Emit information about this stack frame to OS.
40  virtual void print(raw_ostream &OS) const = 0;
41 
42  /// getNextEntry - Return the next entry in the list of frames.
43  const PrettyStackTraceEntry *getNextEntry() const { return NextEntry; }
44  };
45 
46  /// PrettyStackTraceString - This object prints a specified string (which
47  /// should not contain newlines) to the stream as the stack trace when a crash
48  /// occurs.
50  const char *Str;
51  public:
52  PrettyStackTraceString(const char *str) : Str(str) {}
53  virtual void print(raw_ostream &OS) const LLVM_OVERRIDE;
54  };
55 
56  /// PrettyStackTraceProgram - This object prints a specified program arguments
57  /// to the stream as the stack trace when a crash occurs.
59  int ArgC;
60  const char *const *ArgV;
61  public:
62  PrettyStackTraceProgram(int argc, const char * const*argv)
63  : ArgC(argc), ArgV(argv) {
65  }
66  virtual void print(raw_ostream &OS) const LLVM_OVERRIDE;
67  };
68 
69 } // end namespace llvm
70 
71 #endif
PrettyStackTraceProgram(int argc, const char *const *argv)
void EnablePrettyStackTrace()
const PrettyStackTraceEntry * getNextEntry() const
getNextEntry - Return the next entry in the list of frames.
PrettyStackTraceString(const char *str)
virtual void print(raw_ostream &OS) const LLVM_OVERRIDE
print - Emit information about this stack frame to OS.
virtual void print(raw_ostream &OS) const LLVM_OVERRIDE
print - Emit information about this stack frame to OS.
#define LLVM_DELETED_FUNCTION
Definition: Compiler.h:137
virtual void print(raw_ostream &OS) const =0
print - Emit information about this stack frame to OS.
#define LLVM_OVERRIDE
Definition: Compiler.h:155