diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index bf832b965cfb..da2f54d001cb 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -37,10 +37,6 @@ #include "nsWrapperCache.h" #include "nsStringBuffer.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include "nsIException.h" #include "nsIPlatformInfo.h" #include "nsThread.h" diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index 03a3e9018019..319ff1bac656 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -81,6 +81,7 @@ #include "nsCycleCollectionParticipant.h" #include "nsCycleCollector.h" #include "nsDOMJSUtils.h" +#include "nsExceptionHandler.h" #include "nsJSUtils.h" #include "nsWrapperCache.h" #include "nsStringBuffer.h" @@ -90,10 +91,6 @@ #include "ProfilerMarkerPayload.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include "nsIException.h" #include "nsIPlatformInfo.h" #include "nsThread.h" @@ -545,10 +542,9 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSContext* aCx) JS_SetExternalStringSizeofCallback(aCx, SizeofExternalStringCallback); JS::SetBuildIdOp(aCx, GetBuildId); JS::SetWarningReporter(aCx, MozCrashWarningReporter); -#ifdef MOZ_CRASHREPORTER - js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( - CrashReporter::AnnotateOOMAllocationSize); -#endif + + js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( + CrashReporter::AnnotateOOMAllocationSize); static js::DOMCallbacks DOMcallbacks = { InstanceClassHasProtoAtDepth @@ -1447,7 +1443,6 @@ CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr, OOMState aNewState) { *aStatePtr = aNewState; -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(aStatePtr == &mOutOfMemoryState ? NS_LITERAL_CSTRING("JSOutOfMemory") : NS_LITERAL_CSTRING("JSLargeAllocationFailure"), @@ -1456,7 +1451,6 @@ CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr, : aNewState == OOMState::Reported ? NS_LITERAL_CSTRING("Reported") : NS_LITERAL_CSTRING("Recovered")); -#endif } void @@ -1469,14 +1463,12 @@ CycleCollectedJSRuntime::OnGC(JSContext* aContext, mZonesWaitingForGC.Clear(); break; case JSGC_END: { -#ifdef MOZ_CRASHREPORTER if (mOutOfMemoryState == OOMState::Reported) { AnnotateAndSetOutOfMemory(&mOutOfMemoryState, OOMState::Recovered); } if (mLargeAllocationFailureState == OOMState::Reported) { AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Recovered); } -#endif // Do any deferred finalization of native objects. Normally we do this // incrementally for an incremental GC, and immediately for a diff --git a/xpcom/base/nsCrashOnException.cpp b/xpcom/base/nsCrashOnException.cpp index 0f8042531fda..9c42ad02d8bd 100644 --- a/xpcom/base/nsCrashOnException.cpp +++ b/xpcom/base/nsCrashOnException.cpp @@ -6,24 +6,21 @@ #include "nsCrashOnException.h" #include "nsCOMPtr.h" +#include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#endif namespace mozilla { static int ReportException(EXCEPTION_POINTERS* aExceptionInfo) { -#ifdef MOZ_CRASHREPORTER nsCOMPtr cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (cr) { cr->WriteMinidumpForException(aExceptionInfo); } -#endif + return EXCEPTION_EXECUTE_HANDLER; } diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index f51d2fe6e266..2ddb40864bab 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -167,6 +167,7 @@ #include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionNoteRootCallback.h" #include "nsDeque.h" +#include "nsExceptionHandler.h" #include "nsCycleCollector.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" @@ -191,10 +192,6 @@ #include "mozilla/Telemetry.h" #include "mozilla/ThreadLocal.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - using namespace mozilla; struct NurseryPurpleBufferEntry @@ -668,14 +665,12 @@ PtrInfo::AnnotatedReleaseAssert(bool aCondition, const char* aMessage) return; } -#ifdef MOZ_CRASHREPORTER const char* piName = "Unknown"; if (mParticipant) { piName = mParticipant->ClassName(); } nsPrintfCString msg("%s, for class %s", aMessage, piName); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CycleCollector"), msg); -#endif MOZ_CRASH(); } diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index a81528a349c0..ff2bb299f29c 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -13,9 +13,7 @@ #include "MainThreadUtils.h" #include "nsDebugImpl.h" #include "nsDebug.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -#endif +#include "nsExceptionHandler.h" #include "nsString.h" #include "nsXULAppAPI.h" #include "prprf.h" @@ -392,7 +390,6 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr, return; case NS_DEBUG_ABORT: { -#if defined(MOZ_CRASHREPORTER) // Updating crash annotations in the child causes us to do IPC. This can // really cause trouble if we're asserting from within IPC code. So we // have to do without the annotations in that case. @@ -406,7 +403,6 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr, CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"), nsDependentCString(nonPIDBuf.buffer)); } -#endif // MOZ_CRASHREPORTER #if defined(DEBUG) && defined(_WIN32) RealBreak(); @@ -614,8 +610,6 @@ NS_ErrorAccordingToNSPR() void NS_ABORT_OOM(size_t aSize) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateOOMAllocationSize(aSize); -#endif MOZ_CRASH("OOM"); } diff --git a/xpcom/base/nsObjCExceptions.h b/xpcom/base/nsObjCExceptions.h index e63c92af5786..d6c1ee1a994e 100644 --- a/xpcom/base/nsObjCExceptions.h +++ b/xpcom/base/nsObjCExceptions.h @@ -17,7 +17,7 @@ #import #endif -#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus) +#if defined(__cplusplus) #include "nsICrashReporter.h" #include "nsCOMPtr.h" #include "nsServiceManagerUtils.h" @@ -47,7 +47,7 @@ nsObjCExceptionLog(NSException* aException) NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]", [aException name], [aException reason]); -#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus) +#if defined(__cplusplus) // Attach exception info to the crash report. nsCOMPtr crashReporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 881596cf0cb2..80546d1bacce 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -403,7 +403,6 @@ XRE_API(void, XRE_API(void, XRE_SetProcessType, (const char* aProcessTypeString)) -#if defined(MOZ_CRASHREPORTER) // Used in the "master" parent process hosting the crash server XRE_API(bool, XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump, @@ -412,7 +411,6 @@ XRE_API(bool, // Used in child processes. XRE_API(bool, XRE_SetRemoteExceptionHandler, (const char* aPipe)) -#endif namespace mozilla { namespace gmp { diff --git a/xpcom/system/moz.build b/xpcom/system/moz.build index 2be77e7f0878..700ac2b0e109 100644 --- a/xpcom/system/moz.build +++ b/xpcom/system/moz.build @@ -6,6 +6,7 @@ XPIDL_SOURCES += [ 'nsIBlocklistService.idl', + 'nsICrashReporter.idl', 'nsIDeviceSensors.idl', 'nsIGConfService.idl', 'nsIGeolocationProvider.idl', @@ -17,9 +18,4 @@ XPIDL_SOURCES += [ 'nsIXULRuntime.idl', ] -if CONFIG['MOZ_CRASHREPORTER']: - XPIDL_SOURCES += [ - 'nsICrashReporter.idl', - ] - XPIDL_MODULE = 'xpcom_system' diff --git a/xpcom/tests/gtest/TestDeadlockDetector.cpp b/xpcom/tests/gtest/TestDeadlockDetector.cpp index f829817dfe03..8b9898b70e74 100644 --- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -8,20 +8,17 @@ #include "prthread.h" -#include "nsTArray.h" +#include "nsCOMPtr.h" +#include "nsICrashReporter.h" #include "nsMemory.h" +#include "nsServiceManagerUtils.h" +#include "nsTArray.h" #include "mozilla/CondVar.h" #include "mozilla/RecursiveMutex.h" #include "mozilla/ReentrantMonitor.h" #include "mozilla/Mutex.h" -#ifdef MOZ_CRASHREPORTER -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" -#endif - #include "gtest/gtest.h" using namespace mozilla; @@ -74,13 +71,11 @@ private: void DisableCrashReporter() { -#ifdef MOZ_CRASHREPORTER nsCOMPtr crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif } //----------------------------------------------------------------------------- diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index 7291732faa5d..41ac2d5d04dc 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -6,6 +6,7 @@ #include "PLDHashTable.h" #include "nsCOMPtr.h" +#include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" #include "gtest/gtest.h" @@ -21,10 +22,6 @@ extern unsigned int _gdb_sleep_duration; #endif -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#endif - // We can test that certain operations cause expected aborts by forking // and then checking that the child aborted in the expected way (i.e. via // MOZ_CRASH). We skip this for the following configurations. @@ -49,13 +46,11 @@ TestCrashyOperation(void (*aCrashyOperation)()) // Disable the crashreporter -- writing a crash dump in the child will // prevent the parent from writing a subsequent dump. Crashes here are // expected, so we don't want their stacks to show up in the log anyway. -#ifdef MOZ_CRASHREPORTER nsCOMPtr crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif // Child: perform the crashy operation. fprintf(stderr, "TestCrashyOperation: The following crash is expected. Do not panic.\n"); diff --git a/xpcom/tests/gtest/TestSTLWrappers.cpp b/xpcom/tests/gtest/TestSTLWrappers.cpp index c4ea9824c0c3..2aaa3466d0c1 100644 --- a/xpcom/tests/gtest/TestSTLWrappers.cpp +++ b/xpcom/tests/gtest/TestSTLWrappers.cpp @@ -10,11 +10,9 @@ # error "failed to wrap " #endif -#ifdef MOZ_CRASHREPORTER #include "nsCOMPtr.h" #include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" -#endif // gcc errors out if we |try ... catch| with -fno-exceptions, but we // can still test on windows @@ -41,13 +39,11 @@ void ShouldAbort() _gdb_sleep_duration = 0; #endif -#ifdef MOZ_CRASHREPORTER nsCOMPtr crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif std::vector v; int rv = 1; diff --git a/xpcom/threads/HangMonitor.cpp b/xpcom/threads/HangMonitor.cpp index 851d1f707903..09a599dd56b0 100644 --- a/xpcom/threads/HangMonitor.cpp +++ b/xpcom/threads/HangMonitor.cpp @@ -14,6 +14,7 @@ #include "mozilla/Telemetry.h" #include "mozilla/StaticPtr.h" #include "mozilla/UniquePtr.h" +#include "nsExceptionHandler.h" #include "nsReadableUtils.h" #include "nsThreadUtils.h" #include "mozilla/StackWalk.h" @@ -21,10 +22,6 @@ #include "nsXULAppAPI.h" #include "GeckoProfiler.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #ifdef XP_WIN #include #endif @@ -110,7 +107,6 @@ Crash() } #endif -#ifdef MOZ_CRASHREPORTER // If you change this, you must also deal with the threadsafety of AnnotateCrashReport in // non-chrome processes! if (GeckoProcessType_Default == XRE_GetProcessType()) { @@ -118,7 +114,6 @@ Crash() NS_LITERAL_CSTRING("1")); CrashReporter::SetMinidumpAnalysisAllThreads(); } -#endif MOZ_CRASH("HangMonitor triggered"); } diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index aade5eda7af4..8eeb9daca843 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -38,16 +38,14 @@ #include "mozilla/TimeStamp.h" #include "mozilla/Unused.h" #include "mozilla/dom/ScriptSettings.h" +#include "nsICrashReporter.h" #include "nsThreadSyncDispatch.h" +#include "nsServiceManagerUtils.h" #include "GeckoProfiler.h" #include "InputEventStatistics.h" #include "ThreadEventTarget.h" -#ifdef MOZ_CRASHREPORTER -#include "nsServiceManagerUtils.h" -#include "nsICrashReporter.h" #include "mozilla/dom/ContentChild.h" -#endif #ifdef XP_LINUX #include @@ -476,7 +474,6 @@ nsThread::ThreadFunc(void* aArg) //----------------------------------------------------------------------------- -#ifdef MOZ_CRASHREPORTER // Tell the crash reporter to save a memory report if our heuristics determine // that an OOM failure is likely to occur soon. // Memory usage will not be checked more than every 30 seconds or saved more @@ -541,7 +538,6 @@ nsThread::SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave) return recentlySavedReport; } -#endif #ifdef MOZ_CANARY int sCanaryOutputFD = -1; @@ -1207,11 +1203,9 @@ nsThread::DoMainThreadSpecificProcessing(bool aReallyWait) } } -#ifdef MOZ_CRASHREPORTER if (!ShuttingDown()) { SaveMemoryReportNearOOM(ShouldSaveMemoryReport::kMaybeReport); } -#endif } NS_IMETHODIMP diff --git a/xpcom/threads/nsThread.h b/xpcom/threads/nsThread.h index 33ae13963ac7..00049a2c8e4f 100644 --- a/xpcom/threads/nsThread.h +++ b/xpcom/threads/nsThread.h @@ -87,7 +87,6 @@ public: void WaitForAllAsynchronousShutdowns(); -#ifdef MOZ_CRASHREPORTER enum class ShouldSaveMemoryReport { kMaybeReport, @@ -95,7 +94,6 @@ public: }; static bool SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave); -#endif static const uint32_t kRunnableNameBufSize = 1000; static mozilla::Array sMainThreadRunnableName; diff --git a/xpcom/threads/nsThreadUtils.cpp b/xpcom/threads/nsThreadUtils.cpp index 309ab99f71e7..472fc0bed06f 100644 --- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -10,10 +10,9 @@ #include "mozilla/TimeStamp.h" #include "LeakRefPtr.h" #include "nsComponentManagerUtils.h" +#include "nsExceptionHandler.h" #include "nsITimer.h" -#include "nsComponentManagerUtils.h" - #ifdef MOZILLA_INTERNAL_API # include "nsThreadManager.h" #else @@ -28,10 +27,6 @@ #include #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - using namespace mozilla; #ifndef XPCOM_GLUE_AVOID_NSPR @@ -517,9 +512,7 @@ void NS_SetCurrentThreadName(const char* aName) { PR_SetCurrentThreadName(aName); -#ifdef MOZ_CRASHREPORTER CrashReporter::SetCurrentThreadName(aName); -#endif } #ifdef MOZILLA_INTERNAL_API