1 //===- llvm/Support/PrettyStackTrace.h - Pretty Crash Handling --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the PrettyStackTraceEntry class, which is used to make
11 // crashes give more contextual information about what the program was doing
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
17 #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
22 /// PrettyStackTraceEntry - This class is used to represent a frame of the
23 /// "pretty" stack trace that is dumped when a program crashes. You can define
24 /// subclasses of this and declare them on the program stack: when they are
25 /// constructed and destructed, they will add their symbolic frames to a
26 /// virtual stack trace. This gets dumped out if the program crashes.
27 class PrettyStackTraceEntry {
28 const PrettyStackTraceEntry *NextEntry;
29 PrettyStackTraceEntry(const PrettyStackTraceEntry &); // DO NOT IMPLEMENT
30 void operator=(const PrettyStackTraceEntry&); // DO NOT IMPLEMENT
32 PrettyStackTraceEntry();
33 virtual ~PrettyStackTraceEntry();
35 /// print - Emit information about this stack frame to OS.
36 virtual void print(raw_ostream &OS) const = 0;
38 /// getNextEntry - Return the next entry in the list of frames.
39 const PrettyStackTraceEntry *getNextEntry() const { return NextEntry; }
42 /// PrettyStackTraceString - This object prints a specified string (which
43 /// should not contain newlines) to the stream as the stack trace when a crash
45 class PrettyStackTraceString : public PrettyStackTraceEntry {
48 PrettyStackTraceString(const char *str) : Str(str) {}
49 virtual void print(raw_ostream &OS) const;
52 /// PrettyStackTraceProgram - This object prints a specified program arguments
53 /// to the stream as the stack trace when a crash occurs.
54 class PrettyStackTraceProgram : public PrettyStackTraceEntry {
56 const char *const *ArgV;
58 PrettyStackTraceProgram(int argc, const char * const*argv)
59 : ArgC(argc), ArgV(argv) {}
60 virtual void print(raw_ostream &OS) const;
63 } // end namespace llvm