]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/crashrpt.h
Initial commit for Laurent Humbertclaude's Windows slave.
[wxWidgets.git] / include / wx / msw / crashrpt.h
CommitLineData
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
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 9// Licence: wxWindows licence
9c640715
VZ
10///////////////////////////////////////////////////////////////////////////////
11
83dee24c
VZ
12#ifndef _WX_MSW_CRASHRPT_H_
13#define _WX_MSW_CRASHRPT_H_
9c640715
VZ
14
15#include "wx/defs.h"
16
83dee24c
VZ
17#if wxUSE_CRASHREPORT
18
19struct _EXCEPTION_POINTERS;
9c640715
VZ
20
21// ----------------------------------------------------------------------------
83dee24c 22// crash report generation flags
9c640715
VZ
23// ----------------------------------------------------------------------------
24
50bea100
VZ
25enum
26{
3103e8a9 27 // we always report where the crash occurred
50bea100
VZ
28 wxCRASH_REPORT_LOCATION = 0,
29
30 // if this flag is given, the call stack is dumped
8d008965
VZ
31 //
32 // this results in dump/crash report as small as possible, this is the
33 // default flag
50bea100
VZ
34 wxCRASH_REPORT_STACK = 1,
35
36 // if this flag is given, the values of the local variables are dumped
8d008965 37 //
83dee24c
VZ
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
50bea100
VZ
45 wxCRASH_REPORT_LOCALS = 2,
46
47 // if this flag is given, the values of all global variables are dumped
48 //
83dee24c
VZ
49 // this creates a much larger mini dump than just wxCRASH_REPORT_STACK but
50 // still much smaller than wxCRASH_REPORT_LOCALS one
47e94ded
VZ
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
50bea100
VZ
55};
56
83dee24c
VZ
57// ----------------------------------------------------------------------------
58// wxCrashContext: information about the crash context
59// ----------------------------------------------------------------------------
60
61struct 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
50bea100
VZ
89// ----------------------------------------------------------------------------
90// wxCrashReport: this class is used to create crash reports
91// ----------------------------------------------------------------------------
92
93struct WXDLLIMPEXP_BASE wxCrashReport
9c640715
VZ
94{
95 // set the name of the file to which the report is written, it is
96 // constructed from the .exe name by default
fe267c2f 97 static void SetFileName(const wxString& filename);
9c640715
VZ
98
99 // return the current file name
fe267c2f 100 static wxString GetFileName();
9c640715
VZ
101
102 // write the exception report to the file, return true if it could be done
103 // or false otherwise
83dee24c
VZ
104 //
105 // if ep pointer is NULL, the global exception info which is valid only
106 // inside wxApp::OnFatalException() is used
47e94ded 107 static bool Generate(int flags = wxCRASH_REPORT_DEFAULT,
83dee24c
VZ
108 _EXCEPTION_POINTERS *ep = NULL);
109
47e94ded
VZ
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);
9c640715
VZ
115};
116
83dee24c 117#endif // wxUSE_CRASHREPORT
9c640715 118
83dee24c 119#endif // _WX_MSW_CRASHRPT_H_
9c640715 120