added GenerateNow()
[wxWidgets.git] / include / wx / msw / crashrpt.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/crashrpt.h
3 // Purpose: helpers for the structured exception handling (SEH) under Win32
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 13.07.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_CRASHRPT_H_
13 #define _WX_MSW_CRASHRPT_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_CRASHREPORT
18
19 struct _EXCEPTION_POINTERS;
20
21 // ----------------------------------------------------------------------------
22 // crash report generation flags
23 // ----------------------------------------------------------------------------
24
25 enum
26 {
27 // we always report where the crash occured
28 wxCRASH_REPORT_LOCATION = 0,
29
30 // if this flag is given, the call stack is dumped
31 //
32 // this results in dump/crash report as small as possible, this is the
33 // default flag
34 wxCRASH_REPORT_STACK = 1,
35
36 // if this flag is given, the values of the local variables are dumped
37 //
38 // note that with the current implementation it requires dumping the full
39 // process address space and so this will result in huge dump file and will
40 // take some time to generate
41 //
42 // it's probably not a good idea to use this by default, start with default
43 // mini dump and ask your users to set WX_CRASH_FLAGS environment variable
44 // to 2 or 4 if you need more information in the dump
45 wxCRASH_REPORT_LOCALS = 2,
46
47 // if this flag is given, the values of all global variables are dumped
48 //
49 // this creates a much larger mini dump than just wxCRASH_REPORT_STACK but
50 // still much smaller than wxCRASH_REPORT_LOCALS one
51 wxCRASH_REPORT_GLOBALS = 4,
52
53 // default is to create the smallest possible crash report
54 wxCRASH_REPORT_DEFAULT = wxCRASH_REPORT_LOCATION | wxCRASH_REPORT_STACK
55 };
56
57 // ----------------------------------------------------------------------------
58 // wxCrashContext: information about the crash context
59 // ----------------------------------------------------------------------------
60
61 struct WXDLLIMPEXP_BASE wxCrashContext
62 {
63 // initialize this object with the given information or from the current
64 // global exception info which is only valid inside wxApp::OnFatalException
65 wxCrashContext(_EXCEPTION_POINTERS *ep = NULL);
66
67 // get the name for this exception code
68 wxString GetExceptionString() const;
69
70
71 // exception code
72 size_t code;
73
74 // exception address
75 void *addr;
76
77 // machine-specific registers vaues
78 struct
79 {
80 #ifdef __INTEL__
81 wxInt32 eax, ebx, ecx, edx, esi, edi,
82 ebp, esp, eip,
83 cs, ds, es, fs, gs, ss,
84 flags;
85 #endif // __INTEL__
86 } regs;
87 };
88
89 // ----------------------------------------------------------------------------
90 // wxCrashReport: this class is used to create crash reports
91 // ----------------------------------------------------------------------------
92
93 struct WXDLLIMPEXP_BASE wxCrashReport
94 {
95 // set the name of the file to which the report is written, it is
96 // constructed from the .exe name by default
97 static void SetFileName(const wxChar *filename);
98
99 // return the current file name
100 static const wxChar *GetFileName();
101
102 // write the exception report to the file, return true if it could be done
103 // or false otherwise
104 //
105 // if ep pointer is NULL, the global exception info which is valid only
106 // inside wxApp::OnFatalException() is used
107 static bool Generate(int flags = wxCRASH_REPORT_DEFAULT,
108 _EXCEPTION_POINTERS *ep = NULL);
109
110
111 // generate a crash report from outside of wxApp::OnFatalException(), this
112 // can be used to take "snapshots" of the program in wxApp::OnAssert() for
113 // example
114 static bool GenerateNow(int flags = wxCRASH_REPORT_DEFAULT);
115 };
116
117 #endif // wxUSE_CRASHREPORT
118
119 #endif // _WX_MSW_CRASHRPT_H_
120