//
// in any case, the user may override by defining wxUSE_DBGHELP himself
#ifndef wxUSE_DBGHELP
- #ifdef DBHLPAPI
+ #ifdef DBHLPAPI
#define wxUSE_DBGHELP 1
#else
#define wxUSE_DBGHELP 0
// classes
// ----------------------------------------------------------------------------
+// low level wxBusyCursor replacement: we use Win32 API directly here instead
+// of going through wxWindows calls as this could be dangerous
+class BusyCursor
+{
+public:
+ BusyCursor()
+ {
+ HCURSOR hcursorBusy = ::LoadCursor(NULL, IDC_WAIT);
+ m_hcursorOld = ::SetCursor(hcursorBusy);
+ }
+
+ ~BusyCursor()
+ {
+ if ( m_hcursorOld )
+ {
+ ::SetCursor(m_hcursorOld);
+ }
+ }
+
+private:
+ HCURSOR m_hcursorOld;
+};
+
// the real crash report generator
class wxCrashReportImpl
{
#endif // wxUSE_DBGHELP
-// Remove warning
-#if wxUSE_DBGHELP && !wxUSE_MINIDUMP
- #define WXUNUSED_LOCAL(x) x
+bool wxCrashReportImpl::Generate(
+#if wxUSE_DBGHELP
+ int flags
#else
- #define WXUNUSED_LOCAL WXUNUSED
+ int WXUNUSED(flags)
#endif
-
-bool wxCrashReportImpl::Generate(int WXUNUSED_LOCAL(flags))
+)
{
if ( m_hFile == INVALID_HANDLE_VALUE )
return false;
HANDLE hModuleCrash = OutputBasicContext(pExceptionRecord, pCtx);
#endif // !wxUSE_MINIDUMP
+ // show to the user that we're doing something...
+ BusyCursor busyCursor;
+
+ // user-specified crash report flags override those specified by the
+ // programmer
+ TCHAR envFlags[64];
+ DWORD dwLen = ::GetEnvironmentVariable
+ (
+ _T("WX_CRASH_FLAGS"),
+ envFlags,
+ WXSIZEOF(envFlags)
+ );
+
+ int flagsEnv;
+ if ( dwLen && dwLen < WXSIZEOF(envFlags) &&
+ wxSscanf(envFlags, _T("%d"), &flagsEnv) == 1 )
+ {
+ flags = flagsEnv;
+ }
// for everything else we need dbghelp.dll
wxDynamicLibrary dllDbgHelp(_T("dbghelp.dll"), wxDL_VERBATIM);
minidumpExcInfo.ClientPointers = FALSE; // in our own address space
// do generate the dump
+ MINIDUMP_TYPE dumpFlags;
+ if ( flags & wxCRASH_REPORT_LOCALS )
+ {
+ // the only way to get local variables is to dump the entire
+ // process memory space -- but this makes for huge (dozens or
+ // even hundreds of Mb) files
+ dumpFlags = MiniDumpWithFullMemory;
+ }
+ else if ( flags & wxCRASH_REPORT_GLOBALS )
+ {
+ // MiniDumpWriteDump() has the option for dumping just the data
+ // segment which contains all globals -- exactly what we need
+ dumpFlags = MiniDumpWithDataSegs;
+ }
+ else // minimal dump
+ {
+ dumpFlags = MiniDumpNormal;
+ }
+
if ( !MiniDumpWriteDump
(
::GetCurrentProcess(),
::GetCurrentProcessId(),
m_hFile, // file to write to
- MiniDumpNormal, // just the minimum
+ dumpFlags, // kind of dump to craete
&minidumpExcInfo,
NULL, // no extra user-defined data
NULL // no callbacks