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