]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/crashrpt.cpp
do take the toolbar into account for Windows CE, otherwise the menus overlap with...
[wxWidgets.git] / src / msw / crashrpt.cpp
index d9882ca5db9b0b21de082990be7a9a404f5644a4..7762c9848a4c461c720b7c1c2309e2464d2c4f16 100644 (file)
@@ -77,7 +77,7 @@
 //
 // in any case, the user may override by defining wxUSE_DBGHELP himself
 #ifndef wxUSE_DBGHELP
 //
 // 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
         #define wxUSE_DBGHELP 1
     #else
         #define wxUSE_DBGHELP 0
@@ -172,6 +172,29 @@ enum SymbolTag
 // classes
 // ----------------------------------------------------------------------------
 
 // 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
 {
 // the real crash report generator
 class wxCrashReportImpl
 {
@@ -1066,14 +1089,13 @@ wxString wxCrashReportImpl::GetExceptionString(DWORD dwCode)
 
 #endif // wxUSE_DBGHELP
 
 
 #endif // wxUSE_DBGHELP
 
-// Remove warning
-#if wxUSE_DBGHELP && !wxUSE_MINIDUMP
-    #define WXUNUSED_LOCAL(x) x
+bool wxCrashReportImpl::Generate(
+#if wxUSE_DBGHELP
+    int flags
 #else
 #else
-    #define WXUNUSED_LOCAL WXUNUSED
+    int WXUNUSED(flags)
 #endif
 #endif
-
-bool wxCrashReportImpl::Generate(int WXUNUSED_LOCAL(flags))
+)
 {
     if ( m_hFile == INVALID_HANDLE_VALUE )
         return false;
 {
     if ( m_hFile == INVALID_HANDLE_VALUE )
         return false;
@@ -1092,6 +1114,25 @@ bool wxCrashReportImpl::Generate(int WXUNUSED_LOCAL(flags))
     HANDLE hModuleCrash = OutputBasicContext(pExceptionRecord, pCtx);
 #endif // !wxUSE_MINIDUMP
 
     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);
 
     // for everything else we need dbghelp.dll
     wxDynamicLibrary dllDbgHelp(_T("dbghelp.dll"), wxDL_VERBATIM);
@@ -1107,12 +1148,31 @@ bool wxCrashReportImpl::Generate(int WXUNUSED_LOCAL(flags))
             minidumpExcInfo.ClientPointers = FALSE; // in our own address space
 
             // do generate the dump
             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
             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
                     &minidumpExcInfo,
                     NULL,                       // no extra user-defined data
                     NULL                        // no callbacks