Bug 958348 - Allow swapping the current and previous exception filters. r=dmajor

This commit is contained in:
David Major 2014-01-29 17:07:35 -05:00
parent 06258b976a
commit d48db5158b

View File

@ -322,9 +322,17 @@ nsTArray<nsAutoPtr<DelayedNote> >* gDelayedAnnotations;
typedef LPTOP_LEVEL_EXCEPTION_FILTER (WINAPI *SetUnhandledExceptionFilter_func)
(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
static SetUnhandledExceptionFilter_func stub_SetUnhandledExceptionFilter = 0;
static LPTOP_LEVEL_EXCEPTION_FILTER previousUnhandledExceptionFilter = nullptr;
static WindowsDllInterceptor gKernel32Intercept;
static bool gBlockUnhandledExceptionFilter = true;
static void NotePreviousUnhandledExceptionFilter()
{
// Set a dummy value to get the previous filter, then restore
previousUnhandledExceptionFilter = SetUnhandledExceptionFilter(nullptr);
SetUnhandledExceptionFilter(previousUnhandledExceptionFilter);
}
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI
patched_SetUnhandledExceptionFilter (LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
{
@ -333,6 +341,13 @@ patched_SetUnhandledExceptionFilter (LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExce
return stub_SetUnhandledExceptionFilter(lpTopLevelExceptionFilter);
}
if (lpTopLevelExceptionFilter == previousUnhandledExceptionFilter) {
// OK to swap back and forth between the previous filter
previousUnhandledExceptionFilter =
stub_SetUnhandledExceptionFilter(lpTopLevelExceptionFilter);
return previousUnhandledExceptionFilter;
}
// intercept attempts to change the filter
return nullptr;
}
@ -1018,6 +1033,10 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
MinidumpDescriptor descriptor(tempPath.get());
#endif
#ifdef XP_WIN
NotePreviousUnhandledExceptionFilter();
#endif
gExceptionHandler = new google_breakpad::
ExceptionHandler(
#ifdef XP_LINUX