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