From 4e368f8199a61c6319621ad1b9d6c352f0319f41 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 30 Mar 2018 08:50:58 +0200 Subject: Remove base conditional code for crash reporter and injector. --- xpcom/base/CycleCollectedJSContext.cpp | 26 ---------- xpcom/base/nsCrashOnException.cpp | 11 ----- xpcom/base/nsCycleCollector.cpp | 12 ----- xpcom/base/nsDebugImpl.cpp | 22 --------- xpcom/base/nsObjCExceptions.h | 15 ------ xpcom/build/nsXULAppAPI.h | 11 ----- xpcom/system/moz.build | 5 -- xpcom/tests/gtest/TestDeadlockDetector.cpp | 14 +----- xpcom/tests/gtest/TestPLDHash.cpp | 15 ------ xpcom/tests/gtest/TestSTLWrappers.cpp | 14 ------ xpcom/threads/HangMonitor.cpp | 13 ----- xpcom/threads/nsThread.cpp | 79 ------------------------------ xpcom/threads/nsThread.h | 10 ---- 13 files changed, 1 insertion(+), 246 deletions(-) (limited to 'xpcom') diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 87e123078..4af8fe4dd 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -82,10 +82,6 @@ #include "nsJSUtils.h" #include "nsWrapperCache.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include "nsIException.h" #include "nsIPlatformInfo.h" #include "nsThread.h" @@ -539,10 +535,6 @@ CycleCollectedJSContext::Initialize(JSContext* aParentContext, JS_SetSweepZoneCallback(mJSContext, XPCStringConvert::ClearZoneCache); JS::SetBuildIdOp(mJSContext, GetBuildId); JS::SetWarningReporter(mJSContext, MozCrashWarningReporter); -#ifdef MOZ_CRASHREPORTER - js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( - CrashReporter::AnnotateOOMAllocationSize); -#endif static js::DOMCallbacks DOMcallbacks = { InstanceClassHasProtoAtDepth @@ -1607,16 +1599,6 @@ CycleCollectedJSContext::AnnotateAndSetOutOfMemory(OOMState* aStatePtr, MOZ_ASSERT(mJSContext); *aStatePtr = aNewState; -#ifdef MOZ_CRASHREPORTER - CrashReporter::AnnotateCrashReport(aStatePtr == &mOutOfMemoryState - ? NS_LITERAL_CSTRING("JSOutOfMemory") - : NS_LITERAL_CSTRING("JSLargeAllocationFailure"), - aNewState == OOMState::Reporting - ? NS_LITERAL_CSTRING("Reporting") - : aNewState == OOMState::Reported - ? NS_LITERAL_CSTRING("Reported") - : NS_LITERAL_CSTRING("Recovered")); -#endif } void @@ -1630,14 +1612,6 @@ CycleCollectedJSContext::OnGC(JSGCStatus aStatus) 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. FinalizeDeferredThings(JS::WasIncrementalGC(mJSContext) ? FinalizeIncrementally : diff --git a/xpcom/base/nsCrashOnException.cpp b/xpcom/base/nsCrashOnException.cpp index 0f8042531..06c48738f 100644 --- a/xpcom/base/nsCrashOnException.cpp +++ b/xpcom/base/nsCrashOnException.cpp @@ -8,22 +8,11 @@ #include "nsCOMPtr.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 ca7057628..721ae9065 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -188,10 +188,6 @@ #include "mozilla/Telemetry.h" #include "mozilla/ThreadLocal.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - using namespace mozilla; //#define COLLECT_TIME_DEBUG @@ -3150,14 +3146,6 @@ nsCycleCollector::ScanWhiteNodes(bool aFullySynchGraphBuild) } if (pi->mInternalRefs > pi->mRefCount) { -#ifdef MOZ_CRASHREPORTER - const char* piName = "Unknown"; - if (pi->mParticipant) { - piName = pi->mParticipant->ClassName(); - } - nsPrintfCString msg("More references to an object than its refcount, for class %s", piName); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CycleCollector"), msg); -#endif MOZ_CRASH(); } diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index 36288d203..96487acda 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -11,9 +11,6 @@ #include "nsDebugImpl.h" #include "nsDebug.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -#endif #include "nsString.h" #include "nsXULAppAPI.h" #include "prprf.h" @@ -380,22 +377,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. - if (XRE_IsParentProcess()) { - // Don't include the PID in the crash report annotation to - // allow faceting on crash-stats.mozilla.org. - nsCString note("xpcom_runtime_abort("); - note += nonPIDBuf.buffer; - note += ")"; - CrashReporter::AppendAppNotesToCrashReport(note); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"), - nsDependentCString(nonPIDBuf.buffer)); - } -#endif // MOZ_CRASHREPORTER - #if defined(DEBUG) && defined(_WIN32) RealBreak(); #endif @@ -600,8 +581,5 @@ 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 e63c92af5..b3ed532ec 100644 --- a/xpcom/base/nsObjCExceptions.h +++ b/xpcom/base/nsObjCExceptions.h @@ -17,12 +17,6 @@ #import #endif -#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus) -#include "nsICrashReporter.h" -#include "nsCOMPtr.h" -#include "nsServiceManagerUtils.h" -#endif - #include #include #include "nsError.h" @@ -47,15 +41,6 @@ nsObjCExceptionLog(NSException* aException) NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]", [aException name], [aException reason]); -#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus) - // Attach exception info to the crash report. - nsCOMPtr crashReporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashReporter) { - crashReporter->AppendObjCExceptionInfoToAppNotes(static_cast(aException)); - } -#endif - #ifdef DEBUG @try { // Try to get stack information out of the exception. 10.5 returns the stack diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 426a58f06..aae248ca1 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -426,17 +426,6 @@ XRE_API(const char*, 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, - uint32_t* aSequence)) - -// Used in child processes. -XRE_API(bool, - XRE_SetRemoteExceptionHandler, (const char* aPipe)) -#endif - namespace mozilla { namespace gmp { class GMPLoader; diff --git a/xpcom/system/moz.build b/xpcom/system/moz.build index 8a4f88efe..1d8e7ea1f 100644 --- a/xpcom/system/moz.build +++ b/xpcom/system/moz.build @@ -18,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 646ee3e1d..877c5f5c3 100644 --- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -15,12 +15,6 @@ #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; @@ -62,13 +56,7 @@ private: void DisableCrashReporter() { -#ifdef MOZ_CRASHREPORTER - nsCOMPtr crashreporter = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (crashreporter) { - crashreporter->SetEnabled(false); - } -#endif + /*** STUB ***/ } //----------------------------------------------------------------------------- diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index e7a73ae1b..4405b102c 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -21,10 +21,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. @@ -46,17 +42,6 @@ TestCrashyOperation(void (*aCrashyOperation)()) ASSERT_NE(pid, -1); if (pid == 0) { - // 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"); aCrashyOperation(); diff --git a/xpcom/tests/gtest/TestSTLWrappers.cpp b/xpcom/tests/gtest/TestSTLWrappers.cpp index 9559548a3..295aa7434 100644 --- a/xpcom/tests/gtest/TestSTLWrappers.cpp +++ b/xpcom/tests/gtest/TestSTLWrappers.cpp @@ -10,12 +10,6 @@ # 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 #ifdef _MSC_VER @@ -40,14 +34,6 @@ 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 71cc67ca4..bd415be50 100644 --- a/xpcom/threads/HangMonitor.cpp +++ b/xpcom/threads/HangMonitor.cpp @@ -22,10 +22,6 @@ #include "nsThreadUtils.h" #include "nsXULAppAPI.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #ifdef XP_WIN #include #endif @@ -111,15 +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()) { - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Hang"), - NS_LITERAL_CSTRING("1")); - } -#endif - NS_RUNTIMEABORT("HangMonitor triggered"); } diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index 63bd28ca3..7c1af08f4 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -39,12 +39,6 @@ #include "nsThreadSyncDispatch.h" #include "LeakRefPtr.h" -#ifdef MOZ_CRASHREPORTER -#include "nsServiceManagerUtils.h" -#include "nsICrashReporter.h" -#include "mozilla/dom/ContentChild.h" -#endif - #ifdef XP_LINUX #include #include @@ -520,73 +514,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 -// than every 3 minutes -// If |aShouldSave == kForceReport|, a report will be saved regardless of -// whether the process is low on memory or not. However, it will still not be -// saved if a report was saved less than 3 minutes ago. -bool -nsThread::SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave) -{ - // Keep an eye on memory usage (cheap, ~7ms) somewhat frequently, - // but save memory reports (expensive, ~75ms) less frequently. - const size_t kLowMemoryCheckSeconds = 30; - const size_t kLowMemorySaveSeconds = 3 * 60; - - static TimeStamp nextCheck = TimeStamp::NowLoRes() - + TimeDuration::FromSeconds(kLowMemoryCheckSeconds); - static bool recentlySavedReport = false; // Keeps track of whether a report - // was saved last time we checked - - // Are we checking again too soon? - TimeStamp now = TimeStamp::NowLoRes(); - if ((aShouldSave == ShouldSaveMemoryReport::kMaybeReport || - recentlySavedReport) && now < nextCheck) { - return false; - } - - bool needMemoryReport = (aShouldSave == ShouldSaveMemoryReport::kForceReport); -#ifdef XP_WIN // XXX implement on other platforms as needed - // If the report is forced there is no need to check whether it is necessary - if (aShouldSave != ShouldSaveMemoryReport::kForceReport) { - const size_t LOWMEM_THRESHOLD_VIRTUAL = 200 * 1024 * 1024; - MEMORYSTATUSEX statex; - statex.dwLength = sizeof(statex); - if (GlobalMemoryStatusEx(&statex)) { - if (statex.ullAvailVirtual < LOWMEM_THRESHOLD_VIRTUAL) { - needMemoryReport = true; - } - } - } -#endif - - if (needMemoryReport) { - if (XRE_IsContentProcess()) { - dom::ContentChild* cc = dom::ContentChild::GetSingleton(); - if (cc) { - cc->SendNotifyLowMemory(); - } - } else { - nsCOMPtr cr = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - if (cr) { - cr->SaveMemoryReport(); - } - } - recentlySavedReport = true; - nextCheck = now + TimeDuration::FromSeconds(kLowMemorySaveSeconds); - } else { - recentlySavedReport = false; - nextCheck = now + TimeDuration::FromSeconds(kLowMemoryCheckSeconds); - } - - return recentlySavedReport; -} -#endif - #ifdef MOZ_CANARY int sCanaryOutputFD = -1; #endif @@ -1459,12 +1386,6 @@ nsThread::DoMainThreadSpecificProcessing(bool aReallyWait) } } } - -#ifdef MOZ_CRASHREPORTER - if (!ShuttingDown()) { - SaveMemoryReportNearOOM(ShouldSaveMemoryReport::kMaybeReport); - } -#endif } //----------------------------------------------------------------------------- diff --git a/xpcom/threads/nsThread.h b/xpcom/threads/nsThread.h index 836123747..037ef1952 100644 --- a/xpcom/threads/nsThread.h +++ b/xpcom/threads/nsThread.h @@ -83,16 +83,6 @@ public: void WaitForAllAsynchronousShutdowns(); -#ifdef MOZ_CRASHREPORTER - enum class ShouldSaveMemoryReport - { - kMaybeReport, - kForceReport - }; - - static bool SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave); -#endif - private: void DoMainThreadSpecificProcessing(bool aReallyWait); -- cgit v1.2.3