Fix a ton of comment typos found by codespell. Patch by
[oota-llvm.git] / include / llvm / Support / PrettyStackTrace.h
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 namespace llvm {
20   class raw_ostream;
21
22   /// DisablePrettyStackTrace - Set this to true to disable this module. This
23   /// might be necessary if the host application installs its own signal
24   /// handlers which conflict with the ones installed by this module.
25   /// Defaults to false.
26   extern bool DisablePrettyStackTrace;
27
28   /// PrettyStackTraceEntry - This class is used to represent a frame of the
29   /// "pretty" stack trace that is dumped when a program crashes. You can define
30   /// subclasses of this and declare them on the program stack: when they are
31   /// constructed and destructed, they will add their symbolic frames to a
32   /// virtual stack trace.  This gets dumped out if the program crashes.
33   class PrettyStackTraceEntry {
34     const PrettyStackTraceEntry *NextEntry;
35     PrettyStackTraceEntry(const PrettyStackTraceEntry &); // DO NOT IMPLEMENT
36     void operator=(const PrettyStackTraceEntry&);         // DO NOT IMPLEMENT
37   public:
38     PrettyStackTraceEntry();
39     virtual ~PrettyStackTraceEntry();
40
41     /// print - Emit information about this stack frame to OS.
42     virtual void print(raw_ostream &OS) const = 0;
43
44     /// getNextEntry - Return the next entry in the list of frames.
45     const PrettyStackTraceEntry *getNextEntry() const { return NextEntry; }
46   };
47
48   /// PrettyStackTraceString - This object prints a specified string (which
49   /// should not contain newlines) to the stream as the stack trace when a crash
50   /// occurs.
51   class PrettyStackTraceString : public PrettyStackTraceEntry {
52     const char *Str;
53   public:
54     PrettyStackTraceString(const char *str) : Str(str) {}
55     virtual void print(raw_ostream &OS) const;
56   };
57
58   /// PrettyStackTraceProgram - This object prints a specified program arguments
59   /// to the stream as the stack trace when a crash occurs.
60   class PrettyStackTraceProgram : public PrettyStackTraceEntry {
61     int ArgC;
62     const char *const *ArgV;
63   public:
64     PrettyStackTraceProgram(int argc, const char * const*argv)
65       : ArgC(argc), ArgV(argv) {}
66     virtual void print(raw_ostream &OS) const;
67   };
68
69 } // end namespace llvm
70
71 #endif