]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/crashrpt.cpp
Applied patch [ 807164 ] fixes for core library
[wxWidgets.git] / src / msw / crashrpt.cpp
index 10996846cd1da47d75423341007b78d85ca38480..9dd8850bb0ac58a1098ce032b98903b0dd848e35 100644 (file)
@@ -432,10 +432,10 @@ wxCrashReportImpl::FormatSimpleValue(BasicType bt,
         {
             static const size_t NUM_CHARS = 32;
 
         {
             static const size_t NUM_CHARS = 32;
 
-            const wxChar * const pc = *(PSTR *)pAddress;
-            if ( !::IsBadStringPtr(pc, NUM_CHARS) )
+            const char * const pc = *(PSTR *)pAddress;
+            if ( !::IsBadStringPtrA(pc, NUM_CHARS) )
             {
             {
-                s << _T('"') << wxString(pc, NUM_CHARS) << _T('"');
+                s << _T('"') << wxString(pc, wxConvLibc, NUM_CHARS) << _T('"');
 
                 handled = true;
             }
 
                 handled = true;
             }
@@ -494,6 +494,12 @@ wxCrashReportImpl::FormatField(DWORD64 modBase,
 {
     wxString s;
 
 {
     wxString s;
 
+    // avoid infinite recursion
+    if ( level > 10 )
+    {
+        return s;
+    }
+
     const HANDLE hProcess = GetCurrentProcess();
 
     DWORD dwTag = 0;
     const HANDLE hProcess = GetCurrentProcess();
 
     DWORD dwTag = 0;
@@ -674,7 +680,9 @@ wxCrashReportImpl::FormatSymbol(PSYMBOL_INFO pSym, STACKFRAME *sf)
         pVariable = (DWORD_PTR)pSym->Address;
     }
 
         pVariable = (DWORD_PTR)pSym->Address;
     }
 
-    s << pSym->Name << _T(" = ") << FormatAnyValue(pSym, (PVOID)pVariable);
+    s << wxString(pSym->Name, wxConvLibc)
+      << _T(" = ")
+      << FormatAnyValue(pSym, (PVOID)pVariable);
 
     return s;
 }
 
     return s;
 }
@@ -916,10 +924,10 @@ void wxCrashReportImpl::OutputGlobals(HANDLE hModule)
 bool wxCrashReportImpl::ResolveSymFunctions(const wxDynamicLibrary& dllDbgHelp)
 {
     #define LOAD_SYM_FUNCTION(name)                                           \
 bool wxCrashReportImpl::ResolveSymFunctions(const wxDynamicLibrary& dllDbgHelp)
 {
     #define LOAD_SYM_FUNCTION(name)                                           \
-        name = (name ## _t) dllDbgHelp.GetSymbol(#name);                      \
+        name = (name ## _t) dllDbgHelp.GetSymbol(_T(#name));                  \
         if ( !name )                                                          \
         {                                                                     \
         if ( !name )                                                          \
         {                                                                     \
-            Output(_T("\r\nFunction ") __XFILE__(#name)                       \
+            Output(_T("\r\nFunction ") _T(#name)                              \
                    _T("() not found.\r\n"));                                  \
             return false;                                                     \
         }
                    _T("() not found.\r\n"));                                  \
             return false;                                                     \
         }
@@ -997,7 +1005,14 @@ wxString wxCrashReportImpl::GetExceptionString(DWORD dwCode)
 
 #endif // wxUSE_DBGHELP
 
 
 #endif // wxUSE_DBGHELP
 
-bool wxCrashReportImpl::Generate(int flags)
+// Remove warning
+#if wxUSE_DBGHELP
+#define _WXUNUSED(x) x
+#else
+#define _WXUNUSED WXUNUSED
+#endif
+
+bool wxCrashReportImpl::Generate(int _WXUNUSED(flags))
 {
     if ( m_hFile == INVALID_HANDLE_VALUE )
         return false;
 {
     if ( m_hFile == INVALID_HANDLE_VALUE )
         return false;
@@ -1020,7 +1035,7 @@ bool wxCrashReportImpl::Generate(int flags)
     {
         if ( ResolveSymFunctions(dllDbgHelp) )
         {
     {
         if ( ResolveSymFunctions(dllDbgHelp) )
         {
-            SymSetOptions(SYMOPT_DEFERRED_LOADS);
+            SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME);
 
             // Initialize DbgHelp
             if ( SymInitialize(GetCurrentProcess(), NULL, TRUE /* invade */) )
 
             // Initialize DbgHelp
             if ( SymInitialize(GetCurrentProcess(), NULL, TRUE /* invade */) )
@@ -1037,8 +1052,8 @@ bool wxCrashReportImpl::Generate(int flags)
         }
         else
         {
         }
         else
         {
-            Output(_T("Please update your dbghelp.dll version, "
-                      "at least version 5.1 is needed!\r\n"));
+            Output(_T("Please update your dbghelp.dll version, ")
+                   _T("at least version 5.1 is needed!\r\n"));
         }
     }
     else
         }
     }
     else
@@ -1047,8 +1062,8 @@ bool wxCrashReportImpl::Generate(int flags)
                _T("from Microsoft to get more detailed crash information!"));
     }
 
                _T("from Microsoft to get more detailed crash information!"));
     }
 
-    Output(_T("\r\nLatest dbghelp.dll is available at "
-              "http://www.microsoft.com/whdc/ddk/debugging/\r\n"));
+    Output(_T("\r\nLatest dbghelp.dll is available at ")
+           _T("http://www.microsoft.com/whdc/ddk/debugging/\r\n"));
 
 #else // !wxUSE_DBGHELP
     Output(_T("Support for crash report generation was not included ")
 
 #else // !wxUSE_DBGHELP
     Output(_T("Support for crash report generation was not included ")
@@ -1118,7 +1133,7 @@ bool wxHandleFatalExceptions(bool doit)
                          );
 
         wxStrncat(gs_reportFilename, fname,
                          );
 
         wxStrncat(gs_reportFilename, fname,
-                  WXSIZEOF(gs_reportFilename) - strlen(gs_reportFilename) - 1);
+                  WXSIZEOF(gs_reportFilename) - wxStrlen(gs_reportFilename) - 1);
     }
 
     return true;
     }
 
     return true;
@@ -1132,7 +1147,16 @@ extern unsigned long wxGlobalSEHandler(EXCEPTION_POINTERS *pExcPtrs)
         wxGlobalSEInformation = pExcPtrs;
 
         // give the user a chance to do something special about this
         wxGlobalSEInformation = pExcPtrs;
 
         // give the user a chance to do something special about this
-        wxTheApp->OnFatalException();
+        __try
+        {
+            wxTheApp->OnFatalException();
+        }
+        __except ( EXCEPTION_EXECUTE_HANDLER )
+        {
+            // nothing to do here, just ignore the exception inside the
+            // exception handler
+            ;
+        }
 
         wxGlobalSEInformation = NULL;
 
 
         wxGlobalSEInformation = NULL;