diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 005d91e9f7d7..caecb20cd3b0 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -53,7 +53,10 @@ #include "Logging.h" #endif +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif + #include "nsImageFrame.h" #include "nsINamed.h" #include "nsIObserverService.h" @@ -1366,9 +1369,11 @@ nsAccessibilityService::Init() NS_ADDREF(gApplicationAccessible); // will release in Shutdown() gApplicationAccessible->Init(); +#ifdef MOZ_CRASHREPORTER CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("Accessibility"), NS_LITERAL_CSTRING("Active")); +#endif #ifdef XP_WIN sPendingPlugins = new nsTArray >; diff --git a/accessible/windows/msaa/Compatibility.cpp b/accessible/windows/msaa/Compatibility.cpp index 3f5145816515..44db96beda73 100644 --- a/accessible/windows/msaa/Compatibility.cpp +++ b/accessible/windows/msaa/Compatibility.cpp @@ -7,8 +7,10 @@ #include "Compatibility.h" #include "mozilla/WindowsVersion.h" +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" #include "nsPrintfCString.h" +#endif // defined(MOZ_CRASHREPORTER) #include "nsUnicharUtils.h" #include "nsWindowsDllInterceptor.h" #include "nsWinUtils.h" @@ -217,9 +219,11 @@ Compatibility::Init() // Note we collect some AT statistics/telemetry here for convenience. InitConsumers(); +#ifdef MOZ_CRASHREPORTER CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityInProcClient"), nsPrintfCString("0x%X", sConsumers)); +#endif // Gather telemetry uint32_t temp = sConsumers; @@ -407,11 +411,13 @@ UseIAccessibleProxyStub() return true; } +#if defined(MOZ_CRASHREPORTER) // If we reach this point then something is seriously wrong with the // IAccessible configuration in the computer's registry. Let's annotate this // so that we can easily determine this condition during crash analysis. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IAccessibleConfig"), NS_LITERAL_CSTRING("NoSystemTypeLibOrPS")); +#endif // defined(MOZ_CRASHREPORTER) return false; } diff --git a/accessible/windows/msaa/LazyInstantiator.cpp b/accessible/windows/msaa/LazyInstantiator.cpp index 0cf597e746e2..4a4382954f2e 100644 --- a/accessible/windows/msaa/LazyInstantiator.cpp +++ b/accessible/windows/msaa/LazyInstantiator.cpp @@ -17,7 +17,6 @@ #include "nsAccessibilityService.h" #include "nsWindowsHelpers.h" #include "nsCOMPtr.h" -#include "nsExceptionHandler.h" #include "nsIFile.h" #include "nsXPCOM.h" #include "RootAccessibleWrap.h" @@ -27,6 +26,10 @@ #include "mozilla/Telemetry.h" #endif // defined(MOZ_TELEMETRY_REPORTING) +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #include #if !defined(STATE_SYSTEM_NORMAL) @@ -302,7 +305,7 @@ LazyInstantiator::ShouldInstantiate(const DWORD aClientTid) a11y::SetInstantiator(filePath); } -#if defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) if (!mTelemetryThread) { // Call GatherTelemetry on a background thread because it does I/O on // the executable file to retrieve version information. @@ -315,12 +318,12 @@ LazyInstantiator::ShouldInstantiate(const DWORD aClientTid) new AccumulateRunnable(this))); NS_NewThread(getter_AddRefs(mTelemetryThread), runnable); } -#endif // defined(MOZ_TELEMETRY_REPORTING) +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) return true; } -#if defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) /** * Appends version information in the format "|a.b.c.d". * If there is no version information, we append nothing. @@ -403,9 +406,11 @@ LazyInstantiator::AccumulateTelemetry(const nsString& aValue) Telemetry::ScalarSet(Telemetry::ScalarID::A11Y_INSTANTIATORS, aValue); #endif // defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_CRASHREPORTER) CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityClient"), NS_ConvertUTF16toUTF8(aValue)); +#endif // defined(MOZ_CRASHREPORTER) } if (mTelemetryThread) { @@ -413,7 +418,7 @@ LazyInstantiator::AccumulateTelemetry(const nsString& aValue) mTelemetryThread = nullptr; } } -#endif // defined(MOZ_TELEMETRY_REPORTING) +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) RootAccessibleWrap* LazyInstantiator::ResolveRootAccWrap() diff --git a/accessible/windows/msaa/LazyInstantiator.h b/accessible/windows/msaa/LazyInstantiator.h index c04d452e762b..e8669b39bb15 100644 --- a/accessible/windows/msaa/LazyInstantiator.h +++ b/accessible/windows/msaa/LazyInstantiator.h @@ -87,7 +87,7 @@ private: bool ShouldInstantiate(const DWORD aClientTid); bool GetClientExecutableName(const DWORD aClientTid, nsIFile** aOutClientExe); -#if defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) class AccumulateRunnable final : public Runnable { public: @@ -120,7 +120,7 @@ private: void AppendVersionInfo(nsIFile* aClientExe, nsAString& aStrToAppend); void GatherTelemetry(nsIFile* aClientExe, AccumulateRunnable* aRunnable); void AccumulateTelemetry(const nsString& aValue); -#endif // defined(MOZ_TELEMETRY_REPORTING) +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) /** * @return S_OK if we have a valid mRealRoot to invoke methods on @@ -152,9 +152,9 @@ private: RootAccessibleWrap* mWeakRootAccWrap; IAccessible* mWeakAccessible; IDispatch* mWeakDispatch; -#if defined(MOZ_TELEMETRY_REPORTING) +#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) nsCOMPtr mTelemetryThread; -#endif // defined(MOZ_TELEMETRY_REPORTING) +#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) }; } // namespace a11y diff --git a/browser/base/content/test/general/browser_restore_isAppTab.js b/browser/base/content/test/general/browser_restore_isAppTab.js index 0393d0e985cc..1a1e4d67145e 100644 --- a/browser/base/content/test/general/browser_restore_isAppTab.js +++ b/browser/base/content/test/general/browser_restore_isAppTab.js @@ -86,9 +86,8 @@ add_task(async function navigate() { }); add_task(async function crash() { - if (!gMultiProcessBrowser || !AppConstants.MOZ_CRASHREPORTER) { + if (!gMultiProcessBrowser || !("nsICrashReporter" in Ci)) return; - } let tab = BrowserTestUtils.addTab(gBrowser, DUMMY); let browser = tab.linkedBrowser; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 0f3a5c57daad..e0622aa74844 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2424,10 +2424,12 @@ nsDocShell::GetUseRemoteTabs(bool* aUseRemoteTabs) NS_IMETHODIMP nsDocShell::SetRemoteTabs(bool aUseRemoteTabs) { +#ifdef MOZ_CRASHREPORTER if (aUseRemoteTabs) { CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("DOMIPCEnabled"), NS_LITERAL_CSTRING("1")); } +#endif mUseRemoteTabs = aUseRemoteTabs; return NS_OK; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 402c4c53b8f1..bb14e4a3ebf8 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -7936,7 +7936,7 @@ CheckCrossStyleBackendAdoption(nsIDocument* aOldDoc, if (styleDataTypes.isEmpty()) { return; } - +#ifdef MOZ_CRASHREPORTER // We are adopting node with pre-existing style data across style // backend. We want some more information to help diagnose when that // can happen. @@ -8001,7 +8001,7 @@ CheckCrossStyleBackendAdoption(nsIDocument* aOldDoc, } note.Append('\n'); CrashReporter::AppendAppNotesToCrashReport(note); - +#endif // MOZ_CRASHREPORTER MOZ_CRASH("Must not adopt a node with pre-existing style data " "into a document with different style backend"); } diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 4d754c679e64..9384eb1b6764 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -214,7 +214,6 @@ #include "DomainPolicy.h" #include "mozilla/dom/ipc/StructuredCloneData.h" #include "mozilla/dom/time/DateCacheCleaner.h" -#include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/net/NeckoMessageUtils.h" #include "mozilla/widget/PuppetBidiKeyboard.h" #include "mozilla/RemoteSpellCheckEngineChild.h" @@ -229,6 +228,9 @@ #ifdef MOZ_WIDGET_GTK #include "nsAppRunner.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "mozilla/ipc/CrashReporterClient.h" +#endif #ifdef MOZ_CODE_COVERAGE #include "mozilla/CodeCoverageHandler.h" @@ -647,7 +649,9 @@ ContentChild::Init(MessageLoop* aIOLoop, } #endif +#ifdef MOZ_CRASHREPORTER CrashReporterClient::InitSingleton(this); +#endif mID = aChildID; mIsForBrowser = aIsForBrowser; @@ -1697,6 +1701,7 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker) sandboxEnabled = StartMacOSContentSandbox(); #endif +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxEnabled"), sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); @@ -1709,6 +1714,7 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker) #endif /* XP_LINUX && !OS_ANDROID */ CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("RemoteType"), NS_ConvertUTF16toUTF8(GetRemoteType())); +#endif /* MOZ_CRASHREPORTER */ #endif /* MOZ_CONTENT_SANDBOX */ return IPC_OK(); @@ -2343,8 +2349,9 @@ ContentChild::ActorDestroy(ActorDestroyReason why) } mIsAlive = false; +# ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); - +# endif XRE_ShutdownChildProcess(); #endif // NS_FREE_PERMANENT_DATA } @@ -2369,9 +2376,10 @@ ContentChild::ProcessingError(Result aCode, const char* aReason) MOZ_CRASH("not reached"); } +#if defined(MOZ_CRASHREPORTER) nsDependentCString reason(aReason); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ipc_channel_error"), reason); - +#endif MOZ_CRASH("Content child abort due to IPC error"); } @@ -2952,9 +2960,10 @@ ContentChild::RecvShutdown() // to wait for that event loop to finish. Otherwise we could prematurely // terminate an "unload" or "pagehide" event handler (which might be doing a // sync XHR, for example). +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"), NS_LITERAL_CSTRING("RecvShutdown")); - +#endif MOZ_ASSERT(NS_IsMainThread()); RefPtr mainThread = nsThreadManager::get().GetCurrentThread(); // Note that we only have to check the recursion count for the current @@ -3010,13 +3019,18 @@ ContentChild::RecvShutdown() // parent closes. StartForceKillTimer(); +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"), NS_LITERAL_CSTRING("SendFinishShutdown (sending)")); bool sent = SendFinishShutdown(); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"), sent ? NS_LITERAL_CSTRING("SendFinishShutdown (sent)") : NS_LITERAL_CSTRING("SendFinishShutdown (failed)")); - +#else + // Ignore errors here. If this fails, the parent will kill us after a + // timeout. + Unused << SendFinishShutdown(); +#endif return IPC_OK(); } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 5f6a949a6cc3..767297e75f8d 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -67,7 +67,6 @@ #include "mozilla/hal_sandbox/PHalParent.h" #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/BackgroundParent.h" -#include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/FileDescriptorUtils.h" #include "mozilla/ipc/PChildToParentStreamParent.h" #include "mozilla/ipc/TestShellParent.h" @@ -151,7 +150,6 @@ #include "nsIDOMChromeWindow.h" #include "nsIWindowWatcher.h" #include "nsPIWindowWatcher.h" -#include "nsThread.h" #include "nsWindowWatcher.h" #include "nsIXULRuntime.h" #include "mozilla/dom/nsMixedContentBlocker.h" @@ -250,6 +248,11 @@ #include "mozilla/widget/AudioSession.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "nsThread.h" +#include "mozilla/ipc/CrashReporterHost.h" +#endif + #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" #endif @@ -270,7 +273,9 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); using base::KillProcess; +#ifdef MOZ_CRASHREPORTER using namespace CrashReporter; +#endif using namespace mozilla::dom::power; using namespace mozilla::media; using namespace mozilla::embedding; @@ -1725,6 +1730,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why) props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true); +#ifdef MOZ_CRASHREPORTER // There's a window in which child processes can crash // after IPC is established, but before a crash reporter // is created. @@ -1741,6 +1747,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why) } props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID); } +#endif } nsAutoString cpId; cpId.AppendInt(static_cast(this->ChildID())); @@ -3053,6 +3060,7 @@ ContentParent::KillHard(const char* aReason) mCalledKillHard = true; mForceKillTimer = nullptr; +#if defined(MOZ_CRASHREPORTER) // We're about to kill the child process associated with this content. // Something has gone wrong to get us here, so we generate a minidump // of the parent and child for submission to the crash server. @@ -3085,17 +3093,19 @@ ContentParent::KillHard(const char* aReason) true); return; } - +#endif OnGenerateMinidumpComplete(false); } void ContentParent::OnGenerateMinidumpComplete(bool aDumpResult) { +#if defined(MOZ_CRASHREPORTER) if (mCrashReporter && aDumpResult) { // CrashReporterHost::GenerateMinidumpAndPair() is successful. mCreatedPairedMinidumps = mCrashReporter->FinalizeCrashReport(); } +#endif Unused << aDumpResult; // Don't care about result if no minidump was requested. @@ -3136,11 +3146,12 @@ ContentParent::FriendlyName(nsAString& aName, bool aAnonymize) mozilla::ipc::IPCResult ContentParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { +#ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique( GeckoProcessType_Content, aShmem, aThreadId); - +#endif return IPC_OK(); } @@ -4936,7 +4947,9 @@ ContentParent::RecvNotifyLowMemory() Telemetry::ScalarAdd(Telemetry::ScalarID::DOM_CONTENTPROCESS_TROUBLED_DUE_TO_MEMORY, 1); +#ifdef MOZ_CRASHREPORTER nsThread::SaveMemoryReportNearOOM(nsThread::ShouldSaveMemoryReport::kForceReport); +#endif return IPC_OK(); } diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index e88d458e1b75..e45e32e618a0 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -1283,8 +1283,9 @@ private: nsTHashtable mActivePermissionKeys; nsTArray mBlobURLs; - +#ifdef MOZ_CRASHREPORTER UniquePtr mCrashReporter; +#endif static uint64_t sNextTabParentId; static nsDataHashtable sNextTabParents; diff --git a/dom/ipc/ProcessHangMonitor.cpp b/dom/ipc/ProcessHangMonitor.cpp index cbce82acd4ce..7d86e8abeed3 100644 --- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -23,12 +23,14 @@ #include "mozilla/Unused.h" #include "mozilla/WeakPtr.h" -#include "nsExceptionHandler.h" #include "nsIFrameLoader.h" #include "nsIHangReport.h" #include "nsITabParent.h" #include "nsPluginHost.h" #include "nsThreadUtils.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif #include "base/task.h" #include "base/thread.h" @@ -608,6 +610,7 @@ HangMonitorParent::HangMonitorParent(ProcessHangMonitor* aMonitor) HangMonitorParent::~HangMonitorParent() { +#ifdef MOZ_CRASHREPORTER MutexAutoLock lock(mBrowserCrashDumpHashLock); for (auto iter = mBrowserCrashDumpIds.Iter(); !iter.Done(); iter.Next()) { @@ -616,6 +619,7 @@ HangMonitorParent::~HangMonitorParent() CrashReporter::DeleteMinidumpFilesForID(crashId); } } +#endif } void @@ -768,6 +772,7 @@ bool HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd, nsString& aCrashId) { +#ifdef MOZ_CRASHREPORTER MutexAutoLock lock(mBrowserCrashDumpHashLock); if (!mBrowserCrashDumpIds.Get(aPhd.pluginId(), &aCrashId)) { nsCOMPtr browserDump; @@ -783,6 +788,7 @@ HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd, } } } +#endif // MOZ_CRASHREPORTER return false; } @@ -885,10 +891,11 @@ HangMonitorParent::CleanupPluginHang(uint32_t aPluginId, bool aRemoveFiles) return; } mBrowserCrashDumpIds.Remove(aPluginId); - +#ifdef MOZ_CRASHREPORTER if (aRemoveFiles && !crashId.IsEmpty()) { CrashReporter::DeleteMinidumpFilesForID(crashId); } +#endif } void diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 77b45215db6f..b8428f9df587 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -59,7 +59,9 @@ #include "nsEmbedCID.h" #include "nsGlobalWindow.h" #include +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "nsFilePickerProxy.h" #include "mozilla/dom/Element.h" #include "nsGlobalWindow.h" @@ -1192,7 +1194,9 @@ TabChild::RecvLoadURL(const nsCString& aURI, NS_WARNING("WebNavigation()->LoadURI failed. Eating exception, what else can I do?"); } +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), aURI); +#endif return IPC_OK(); } diff --git a/dom/ipc/TabMessageUtils.h b/dom/ipc/TabMessageUtils.h index 4052fa42a5dc..4656d7c57c60 100644 --- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -8,11 +8,14 @@ #define TABMESSAGE_UTILS_H #include "ipc/IPCMessageUtils.h" -#include "nsExceptionHandler.h" #include "nsIDOMEvent.h" #include "nsPIDOMWindow.h" #include "nsCOMPtr.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + namespace mozilla { namespace dom { struct RemoteDOMEvent @@ -24,7 +27,12 @@ struct RemoteDOMEvent bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, mozilla::dom::RemoteDOMEvent* aResult); +#ifdef MOZ_CRASHREPORTER typedef CrashReporter::ThreadId NativeThreadId; +#else +// unused in this case +typedef int32_t NativeThreadId; +#endif } // namespace dom } // namespace mozilla diff --git a/dom/media/gmp/GMPChild.cpp b/dom/media/gmp/GMPChild.cpp index 60a1a7313d58..2922a77d7b93 100644 --- a/dom/media/gmp/GMPChild.cpp +++ b/dom/media/gmp/GMPChild.cpp @@ -246,7 +246,9 @@ GMPChild::Init(const nsAString& aPluginPath, return false; } +#ifdef MOZ_CRASHREPORTER CrashReporterClient::InitSingleton(this); +#endif mPluginPath = aPluginPath; @@ -615,8 +617,9 @@ GMPChild::ActorDestroy(ActorDestroyReason aWhy) ProcessChild::QuickExit(); } +#ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); - +#endif XRE_ShutdownChildProcess(); } diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index 5feb1666f973..b811ee63dfb1 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -7,13 +7,11 @@ #include "mozilla/Logging.h" #include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h" -#include "nsPrintfCString.h" #include "nsThreadUtils.h" #include "nsIRunnable.h" #include "nsIWritablePropertyBag2.h" #include "mozIGeckoMediaPluginService.h" #include "mozilla/AbstractThread.h" -#include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/SSE.h" #include "mozilla/SyncRunnable.h" @@ -30,8 +28,12 @@ using mozilla::ipc::GeckoChildProcessHost; +#ifdef MOZ_CRASHREPORTER +#include "nsPrintfCString.h" +#include "mozilla/ipc/CrashReporterHost.h" using CrashReporter::AnnotationTable; using CrashReporter::GetIDFromMinidump; +#endif #include "mozilla/Telemetry.h" @@ -450,6 +452,7 @@ GMPParent::EnsureProcessLoaded() return NS_SUCCEEDED(rv); } +#ifdef MOZ_CRASHREPORTER void GMPParent::WriteExtraDataForMinidump() { @@ -494,12 +497,12 @@ GMPNotifyObservers(const uint32_t aPluginID, const nsACString& aPluginName, cons service->RunPluginCrashCallbacks(aPluginID, aPluginName); } } - +#endif void GMPParent::ActorDestroy(ActorDestroyReason aWhy) { LOGD("%s: (%d)", __FUNCTION__, (int)aWhy); - +#ifdef MOZ_CRASHREPORTER if (AbnormalShutdown == aWhy) { Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, NS_LITERAL_CSTRING("gmplugin"), 1); @@ -516,7 +519,7 @@ GMPParent::ActorDestroy(ActorDestroyReason aWhy) &GMPNotifyObservers, mPluginId, mDisplayName, dumpID); mMainThread->Dispatch(r.forget()); } - +#endif // warn us off trying to close again mState = GMPStateClosing; mAbnormalShutdownInProgress = true; @@ -537,11 +540,12 @@ GMPParent::ActorDestroy(ActorDestroyReason aWhy) mozilla::ipc::IPCResult GMPParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { +#ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique( GeckoProcessType_GMPlugin, aShmem, aThreadId); - +#endif return IPC_OK(); } diff --git a/dom/media/gmp/GMPParent.h b/dom/media/gmp/GMPParent.h index 7fa96bcb3e0c..22c144e754ae 100644 --- a/dom/media/gmp/GMPParent.h +++ b/dom/media/gmp/GMPParent.h @@ -153,8 +153,10 @@ private: RefPtr ReadGMPInfoFile(nsIFile* aFile); RefPtr ParseChromiumManifest(const nsAString& aJSON); // Main thread. RefPtr ReadChromiumManifestFile(nsIFile* aFile); // GMP thread. +#ifdef MOZ_CRASHREPORTER void WriteExtraDataForMinidump(); bool GetCrashID(nsString& aResult); +#endif void ActorDestroy(ActorDestroyReason aWhy) override; mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override; @@ -215,7 +217,9 @@ private: // to terminate gracefully. bool mHoldingSelfRef; +#ifdef MOZ_CRASHREPORTER UniquePtr mCrashReporter; +#endif const RefPtr mMainThread; }; diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index 573b9fed3026..7e8429bb800f 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -11,7 +11,6 @@ #include #include #include "prio.h" -#include "nsExceptionHandler.h" #include "nsNPAPIPlugin.h" #include "nsNPAPIPluginStreamListener.h" #include "nsNPAPIPluginInstance.h" @@ -104,6 +103,10 @@ #include "winbase.h" #endif +#if MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #include "npapi.h" using namespace mozilla; diff --git a/dom/plugins/base/nsPluginsDirDarwin.cpp b/dom/plugins/base/nsPluginsDirDarwin.cpp index 6a6a7ced0717..3422943b4583 100644 --- a/dom/plugins/base/nsPluginsDirDarwin.cpp +++ b/dom/plugins/base/nsPluginsDirDarwin.cpp @@ -26,7 +26,9 @@ #include "mozilla/UniquePtr.h" #include "nsCocoaFeatures.h" +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" +#endif #include #include @@ -422,13 +424,14 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary) NS_WARNING(msg.get()); return NS_ERROR_FAILURE; } - +#if defined(MOZ_CRASHREPORTER) // The block above assumes that "fbplugin" is the filename of the plugin // to be blocked, or that the filename starts with "fbplugin_". But we // don't yet know for sure if this is always true. So for the time being // record extra information in our crash logs. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"), fileName); +#endif } // It's possible that our plugin has 2 entry points that'll give us mime type @@ -438,14 +441,14 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary) // Sadly we have to load the library for this to work. rv = LoadPlugin(outLibrary); - +#if defined(MOZ_CRASHREPORTER) if (nsCocoaFeatures::OnYosemiteOrLater()) { // If we didn't crash in LoadPlugin(), change the previous annotation so we // don't sow confusion. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"), NS_LITERAL_CSTRING("Didn't crash, please ignore")); } - +#endif if (NS_FAILED(rv)) return rv; diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index b225e710af09..4eec1df646e7 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -22,9 +22,10 @@ #include "nsString.h" #include "nsTArray.h" #include "mozilla/Logging.h" -#include "nsExceptionHandler.h" #include "nsHashKeys.h" - +#ifdef MOZ_CRASHREPORTER +# include "nsExceptionHandler.h" +#endif #ifdef XP_MACOSX #include "PluginInterposeOSX.h" #else diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index c4e3895c29c3..0ee7895b98dd 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -27,8 +27,6 @@ # include "nsX11ErrorHandler.h" # include "mozilla/X11Util.h" #endif - -#include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" #include "mozilla/plugins/PluginInstanceChild.h" #include "mozilla/plugins/StreamNotifyChild.h" @@ -50,6 +48,10 @@ #include "PluginUtilsOSX.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "mozilla/ipc/CrashReporterClient.h" +#endif + #ifdef MOZ_GECKO_PROFILER #include "ChildProfilerController.h" #endif @@ -748,9 +750,10 @@ PluginModuleChild::RecvInitPluginModuleChild(Endpoint&& aEnd mozilla::ipc::IPCResult PluginModuleChild::AnswerInitCrashReporter(Shmem&& aShmem, mozilla::dom::NativeThreadId* aOutId) { +#ifdef MOZ_CRASHREPORTER CrashReporterClient::InitSingletonWithShmem(aShmem); *aOutId = CrashReporter::CurrentThreadId(); - +#endif return IPC_OK(); } @@ -789,8 +792,9 @@ PluginModuleChild::ActorDestroy(ActorDestroyReason why) // doesn't matter why we're being destroyed; it's up to us to // initiate (clean) shutdown +#ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); - +#endif XRE_ShutdownChildProcess(); } diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index e1983e7539f9..16f9d49da80b 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -10,8 +10,6 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentChild.h" -#include "mozilla/ipc/CrashReporterClient.h" -#include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/ipc/MessageChannel.h" #include "mozilla/ipc/ProtocolUtils.h" @@ -67,7 +65,12 @@ using namespace mozilla; using namespace mozilla::plugins; using namespace mozilla::plugins::parent; +#ifdef MOZ_CRASHREPORTER +#include "mozilla/ipc/CrashReporterClient.h" +#include "mozilla/ipc/CrashReporterHost.h" + using namespace CrashReporter; +#endif static const char kContentTimeoutPref[] = "dom.ipc.plugins.contentTimeoutSecs"; static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs"; @@ -522,6 +525,7 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded) RegisterSettingsCallbacks(); +#ifdef MOZ_CRASHREPORTER // If this fails, we're having IPC troubles, and we're doomed anyways. if (!InitCrashReporter()) { mShutdown = true; @@ -529,6 +533,7 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded) OnInitFailure(); return; } +#endif #if defined(XP_WIN) && defined(_X86_) // Protected mode only applies to Windows and only to x86. @@ -547,6 +552,7 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded) bool PluginModuleChromeParent::InitCrashReporter() { +#ifdef MOZ_CRASHREPORTER ipc::Shmem shmem; if (!ipc::CrashReporterClient::AllocShmem(this, &shmem)) { return false; @@ -564,6 +570,7 @@ PluginModuleChromeParent::InitCrashReporter() shmem, threadId); } +#endif return true; } @@ -581,7 +588,9 @@ PluginModuleParent::PluginModuleParent(bool aIsChrome) , mTaskFactory(this) , mSandboxLevel(0) , mIsFlashPlugin(false) +#ifdef MOZ_CRASHREPORTER , mCrashReporterMutex("PluginModuleChromeParent::mCrashReporterMutex") +#endif { } @@ -693,6 +702,7 @@ PluginModuleChromeParent::~PluginModuleChromeParent() mozilla::HangMonitor::UnregisterAnnotator(*this); } +#ifdef MOZ_CRASHREPORTER void PluginModuleChromeParent::WriteExtraDataForMinidump() { @@ -734,6 +744,7 @@ PluginModuleChromeParent::WriteExtraDataForMinidump() #endif } } +#endif // MOZ_CRASHREPORTER void PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout) @@ -989,6 +1000,7 @@ PluginModuleChromeParent::AnnotateHang(mozilla::HangMonitor::HangAnnotations& aA } } +#ifdef MOZ_CRASHREPORTER static bool CreatePluginMinidump(base::ProcessId processId, ThreadId childThread, nsIFile* parentMinidump, const nsACString& name) @@ -1000,6 +1012,7 @@ CreatePluginMinidump(base::ProcessId processId, ThreadId childThread, } return CreateAdditionalChildMinidump(handle, 0, parentMinidump, name); } +#endif bool PluginModuleChromeParent::ShouldContinueFromReplyTimeout() @@ -1054,6 +1067,7 @@ PluginModuleChromeParent::TakeFullMinidump(base::ProcessId aContentPid, std::function&& aCallback, bool aAsync) { +#ifdef MOZ_CRASHREPORTER mozilla::MutexAutoLock lock(mCrashReporterMutex); if (!mCrashReporter || !mTakeFullMinidumpCallback.IsEmpty()) { @@ -1097,8 +1111,12 @@ PluginModuleChromeParent::TakeFullMinidump(base::ProcessId aContentPid, } else { TakeBrowserAndPluginMinidumps(false, aContentPid, browserDumpId, aAsync); } +#else // MOZ_CRASHREPORTER + aCallback(NS_LITERAL_STRING("")); +#endif } +#ifdef MOZ_CRASHREPORTER void PluginModuleChromeParent::RetainPluginRef() { @@ -1217,6 +1235,8 @@ PluginModuleChromeParent::OnTakeFullMinidumpComplete(bool aReportsReady, } } +#endif // MOZ_CRASHREPORTER + void PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop, base::ProcessId aContentPid, @@ -1231,6 +1251,7 @@ PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop, } mTerminateChildProcessCallback.Init(Move(aCallback), aAsync); +#ifdef MOZ_CRASHREPORTER // Start by taking a full minidump if necessary, this is done early // because it also needs to lock the mCrashReporterMutex and Mutex doesn't // support recursive locking. @@ -1255,12 +1276,17 @@ PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop, } else { TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription); } + +#else + TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription); +#endif } void PluginModuleChromeParent::TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop, const nsCString& aMonitorDescription) { +#ifdef MOZ_CRASHREPORTER mCrashReporterMutex.AssertCurrentThreadOwns(); if (!mCrashReporter) { @@ -1284,6 +1310,7 @@ PluginModuleChromeParent::TerminateChildProcessOnDumpComplete(MessageLoop* aMsgL } } #endif // XP_WIN +#endif // MOZ_CRASHREPORTER mozilla::ipc::ScopedProcessHandle geckoChildProcess; bool childOpened = base::OpenProcessHandle(OtherPid(), @@ -1314,7 +1341,7 @@ PluginModuleChromeParent::TerminateChildProcessOnDumpComplete(MessageLoop* aMsgL if (!GetProcessCpuUsage(processHandles, mPluginCpuUsageOnHang)) { mPluginCpuUsageOnHang.Clear(); } -#endif +#endif // MOZ_CRASHREPORTER // this must run before the error notification from the channel, // or not at all @@ -1459,6 +1486,7 @@ PluginModuleChromeParent::OnHangUIContinue() } #endif // XP_WIN +#ifdef MOZ_CRASHREPORTER #ifdef MOZ_CRASHREPORTER_INJECTOR static void RemoveMinidump(nsIFile* minidump) @@ -1550,6 +1578,7 @@ PluginModuleChromeParent::ProcessFirstMinidump() } mCrashReporter->FinalizeCrashReport(); } +#endif void PluginModuleParent::ActorDestroy(ActorDestroyReason why) @@ -1588,7 +1617,9 @@ void PluginModuleChromeParent::ActorDestroy(ActorDestroyReason why) { if (why == AbnormalShutdown) { +#ifdef MOZ_CRASHREPORTER ProcessFirstMinidump(); +#endif Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, NS_LITERAL_CSTRING("plugin"), 1); } @@ -1625,11 +1656,11 @@ PluginModuleParent::NotifyPluginCrashed() nsString dumpID; nsString browserDumpID; - +#ifdef MOZ_CRASHREPORTER if (mCrashReporter && mCrashReporter->HasMinidump()) { dumpID = mCrashReporter->MinidumpID(); } - +#endif mPlugin->PluginCrashed(dumpID, browserDumpID); } diff --git a/dom/plugins/ipc/PluginModuleParent.h b/dom/plugins/ipc/PluginModuleParent.h index 0d5e28cd73c7..31142dab53e1 100644 --- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -21,7 +21,6 @@ #include "mozilla/Unused.h" #include "npapi.h" #include "npfunctions.h" -#include "nsExceptionHandler.h" #include "nsDataHashtable.h" #include "nsHashKeys.h" #include "nsIObserver.h" @@ -32,6 +31,10 @@ #endif #endif +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + class nsPluginTag; namespace mozilla { @@ -331,6 +334,7 @@ protected: RefPtr mTextureAllocatorForDirectBitmap; RefPtr mTextureAllocatorForDXGISurface; +#ifdef MOZ_CRASHREPORTER /** * This mutex protects the crash reporter when the Plugin Hang UI event * handler is executing off main thread. It is intended to protect both @@ -339,6 +343,7 @@ protected: */ mozilla::Mutex mCrashReporterMutex; UniquePtr mCrashReporter; +#endif // MOZ_CRASHREPORTER }; class PluginModuleContentParent : public PluginModuleParent @@ -453,6 +458,7 @@ class PluginModuleChromeParent } private: +#ifdef MOZ_CRASHREPORTER // The following methods are callbacks invoked after calling // TakeFullMinidump(). The methods are invoked in the following order: void TakeBrowserAndPluginMinidumps(bool aReportsReady, @@ -463,7 +469,7 @@ class PluginModuleChromeParent base::ProcessId aContentPid, const nsAString& aBrowserDumpId); - +#endif // The following method is the callback invoked after calling // TerminateChidlProcess(). void TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop, @@ -512,10 +518,12 @@ private: virtual bool ShouldContinueFromReplyTimeout() override; +#ifdef MOZ_CRASHREPORTER void ProcessFirstMinidump(); void WriteExtraDataForMinidump(); void RetainPluginRef(); void ReleasePluginRef(); +#endif PluginProcessParent* Process() const { return mSubprocess; } base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); } @@ -633,9 +641,10 @@ private: mozilla::SandboxPermissions mSandboxPermissions; #endif +#ifdef MOZ_CRASHREPORTER nsCOMPtr mBrowserDumpFile; TakeFullMinidumpCallback mTakeFullMinidumpCallback; - +#endif TerminateChildProcessCallback mTerminateChildProcessCallback; }; diff --git a/gfx/gl/GfxTexturesReporter.cpp b/gfx/gl/GfxTexturesReporter.cpp index 5fd8dbfa69ad..8007fe6b130a 100644 --- a/gfx/gl/GfxTexturesReporter.cpp +++ b/gfx/gl/GfxTexturesReporter.cpp @@ -6,10 +6,13 @@ #include #include -#include "nsExceptionHandler.h" #include "GfxTexturesReporter.h" #include "gfxPrefs.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + using namespace mozilla; using namespace mozilla::gl; @@ -73,5 +76,7 @@ GfxTexturesReporter::UpdateAmount(MemoryUse action, size_t amount) } } +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateTexturesSize(sAmount); +#endif } diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index 005402383d85..4bf5df38f010 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -144,11 +144,12 @@ GPUChild::RecvGraphicsError(const nsCString& aError) mozilla::ipc::IPCResult GPUChild::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { +#ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique( GeckoProcessType_GPU, aShmem, aThreadId); - +#endif return IPC_OK(); } @@ -251,10 +252,12 @@ void GPUChild::ActorDestroy(ActorDestroyReason aWhy) { if (aWhy == AbnormalShutdown) { +#ifdef MOZ_CRASHREPORTER if (mCrashReporter) { mCrashReporter->GenerateCrashReport(OtherPid()); mCrashReporter = nullptr; } +#endif Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU)), 1); diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index cf33371966c0..7462d3ecb920 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -100,8 +100,10 @@ GPUParent::Init(base::ProcessId aParentPid, // versions. GetIPCChannel()->SendBuildID(); +#ifdef MOZ_CRASHREPORTER // Init crash reporter support. CrashReporterClient::InitSingleton(this); +#endif // Ensure gfxPrefs are initialized. gfxPrefs::GetSingleton(); @@ -469,7 +471,9 @@ GPUParent::ActorDestroy(ActorDestroyReason aWhy) gfxVars::Shutdown(); gfxConfig::Shutdown(); gfxPrefs::DestroySingleton(); +#ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); +#endif XRE_ShutdownChildProcess(); } diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index 9a78170d8758..2ca67d2f32ea 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -39,9 +39,12 @@ #include "mozilla/dom/VideoDecoderManagerChild.h" #include "mozilla/dom/VideoDecoderManagerParent.h" #include "MediaPrefs.h" -#include "nsExceptionHandler.h" #include "nsPrintfCString.h" +#ifdef MOZ_CRASHREPORTER +# include "nsExceptionHandler.h" +#endif + #if defined(MOZ_WIDGET_ANDROID) #include "mozilla/widget/AndroidUiThread.h" #include "mozilla/layers/UiCompositorControllerChild.h" @@ -365,6 +368,7 @@ GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) mVsyncBridge = VsyncBridgeChild::Create(mVsyncIOThread, mProcessToken, Move(vsyncChild)); mGPUChild->SendInitVsyncBridge(Move(vsyncParent)); +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GPUProcessStatus"), NS_LITERAL_CSTRING("Running")); @@ -372,6 +376,7 @@ GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GPUProcessLaunchCount"), nsPrintfCString("%d", mNumProcessAttempts)); +#endif } static bool @@ -712,9 +717,11 @@ GPUProcessManager::DestroyProcess() mVsyncBridge = nullptr; } +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GPUProcessStatus"), NS_LITERAL_CSTRING("Destroyed")); +#endif } already_AddRefed diff --git a/gfx/src/DriverCrashGuard.cpp b/gfx/src/DriverCrashGuard.cpp index 6763114a0db2..cb4f6a8a1ebb 100644 --- a/gfx/src/DriverCrashGuard.cpp +++ b/gfx/src/DriverCrashGuard.cpp @@ -9,7 +9,9 @@ #include "gfxConfig.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "nsServiceManagerUtils.h" #include "nsString.h" #include "nsXULAppAPI.h" @@ -165,9 +167,11 @@ DriverCrashGuard::~DriverCrashGuard() dom::ContentChild::GetSingleton()->SendEndDriverCrashGuard(uint32_t(mType)); } +#ifdef MOZ_CRASHREPORTER // Remove the crash report annotation. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"), NS_LITERAL_CSTRING("")); +#endif } bool @@ -206,6 +210,7 @@ DriverCrashGuard::ActivateGuard() { mGuardActivated = true; +#ifdef MOZ_CRASHREPORTER // Anotate crash reports only if we're a real guard. Otherwise, we could // attribute a random parent process crash to a graphics problem in a child // process. @@ -213,6 +218,7 @@ DriverCrashGuard::ActivateGuard() CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"), NS_LITERAL_CSTRING("1")); } +#endif // If we're in the content process, the rest of the guarding is handled // in the parent. diff --git a/gfx/src/gfxCrashReporterUtils.cpp b/gfx/src/gfxCrashReporterUtils.cpp index 5a95c7e964aa..caed5e7fda63 100644 --- a/gfx/src/gfxCrashReporterUtils.cpp +++ b/gfx/src/gfxCrashReporterUtils.cpp @@ -5,6 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gfxCrashReporterUtils.h" + +#if defined(MOZ_CRASHREPORTER) +#define MOZ_GFXFEATUREREPORTER 1 +#endif + +#ifdef MOZ_GFXFEATUREREPORTER +#include "gfxCrashReporterUtils.h" #include // for strcmp #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 #include "mozilla/Services.h" // for GetObserverService @@ -130,3 +137,13 @@ ScopedGfxFeatureReporter::AppNote(const nsACString& aMessage) } } // end namespace mozilla + +#else + +namespace mozilla { +void ScopedGfxFeatureReporter::WriteAppNote(char) {} +void ScopedGfxFeatureReporter::AppNote(const nsACString&) {} + +} // namespace mozilla + +#endif diff --git a/gfx/tests/gtest/TestGfxPrefs.cpp b/gfx/tests/gtest/TestGfxPrefs.cpp index 83b2faeba505..eb79e8f40266 100644 --- a/gfx/tests/gtest/TestGfxPrefs.cpp +++ b/gfx/tests/gtest/TestGfxPrefs.cpp @@ -81,6 +81,7 @@ TEST(GfxPrefs, Set) { ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); } +#ifdef MOZ_CRASHREPORTER // Randomly test the function we use in nsExceptionHandler.cpp here: extern bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength); TEST(GfxPrefs, StringUtility) @@ -103,3 +104,4 @@ TEST(GfxPrefs, StringUtility) // It won't fit into 32: ASSERT_FALSE(SimpleNoCLibDtoA(testVal[4], testBuffer, sizeof(testBuffer)/2)); } +#endif diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index f9c89eb3cfa6..d56bc3626b2f 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -21,13 +21,16 @@ #include "mozilla/layers/DeviceAttachmentsD3D11.h" #include "mozilla/layers/MLGDeviceD3D11.h" #include "mozilla/layers/PaintThread.h" -#include "nsExceptionHandler.h" #include "nsIGfxInfo.h" -#include "nsPrintfCString.h" #include "nsString.h" #include #include +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#include "nsPrintfCString.h" +#endif + namespace mozilla { namespace gfx { @@ -769,10 +772,12 @@ DeviceManagerDx::MaybeResetAndReacquireDevices() Telemetry::Accumulate(Telemetry::DEVICE_RESET_REASON, uint32_t(resetReason)); } +#ifdef MOZ_CRASHREPORTER nsPrintfCString reasonString("%d", int(resetReason)); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("DeviceResetReason"), reasonString); +#endif bool createCompositorDevice = !!mCompositorDevice; bool createContentDevice = !!mContentDevice; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 74dcfde493ec..6331a5c853f9 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -70,7 +70,6 @@ #include "gfxGradientCache.h" #include "gfxUtils.h" // for NextPowerOfTwo -#include "nsExceptionHandler.h" #include "nsUnicodeRange.h" #include "nsServiceManagerUtils.h" #include "nsTArray.h" @@ -78,6 +77,9 @@ #include "nsIScreenManager.h" #include "FrameMetrics.h" #include "MainThreadUtils.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif #include "nsWeakReference.h" @@ -296,9 +298,12 @@ void CrashStatsLogForwarder::UpdateCrashReport() message << logAnnotation << Get<0>(it) << "]" << Get<1>(it) << " (t=" << Get<2>(it) << ") "; } +#ifdef MOZ_CRASHREPORTER nsCString reportString(message.str().c_str()); nsresult annotated = CrashReporter::AnnotateCrashReport(mCrashCriticalKey, reportString); - +#else + nsresult annotated = NS_ERROR_NOT_IMPLEMENTED; +#endif if (annotated != NS_OK) { printf("Crash Annotation %s: %s", mCrashCriticalKey.get(), message.str().c_str()); diff --git a/ipc/glue/CrashReporterClient.cpp b/ipc/glue/CrashReporterClient.cpp index 004ca3b57448..36da3971469d 100644 --- a/ipc/glue/CrashReporterClient.cpp +++ b/ipc/glue/CrashReporterClient.cpp @@ -8,6 +8,7 @@ #include "CrashReporterMetadataShmem.h" #include "nsISupportsImpl.h" +#ifdef MOZ_CRASHREPORTER namespace mozilla { namespace ipc { @@ -64,3 +65,4 @@ CrashReporterClient::GetSingleton() } // namespace ipc } // namespace mozilla +#endif // MOZ_CRASHREPORTER diff --git a/ipc/glue/CrashReporterClient.h b/ipc/glue/CrashReporterClient.h index fb3d386c5ec4..b25f3b5ce489 100644 --- a/ipc/glue/CrashReporterClient.h +++ b/ipc/glue/CrashReporterClient.h @@ -12,6 +12,7 @@ #include "mozilla/Unused.h" #include "mozilla/ipc/Shmem.h" +#ifdef MOZ_CRASHREPORTER namespace mozilla { namespace ipc { @@ -77,6 +78,7 @@ private: } // namespace ipc } // namespace mozilla +#endif // MOZ_CRASHREPORTER #endif // mozilla_ipc_CrashReporterClient_h diff --git a/ipc/glue/CrashReporterHost.cpp b/ipc/glue/CrashReporterHost.cpp index f9b247edfad2..f9542669ca6f 100644 --- a/ipc/glue/CrashReporterHost.cpp +++ b/ipc/glue/CrashReporterHost.cpp @@ -10,9 +10,11 @@ #include "mozilla/Sprintf.h" #include "mozilla/SyncRunnable.h" #include "mozilla/Telemetry.h" -#include "nsExceptionHandler.h" -#include "nsIAsyncShutdown.h" -#include "nsICrashService.h" +#ifdef MOZ_CRASHREPORTER +# include "nsExceptionHandler.h" +# include "nsIAsyncShutdown.h" +# include "nsICrashService.h" +#endif namespace mozilla { namespace ipc { @@ -28,6 +30,7 @@ CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType, { } +#ifdef MOZ_CRASHREPORTER bool CrashReporterHost::GenerateCrashReport(base::ProcessId aPid) { @@ -285,6 +288,7 @@ CrashReporterHost::AddNote(const nsCString& aKey, const nsCString& aValue) { mExtraNotes.Put(aKey, aValue); } +#endif } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/CrashReporterHost.h b/ipc/glue/CrashReporterHost.h index a3eb20791b0b..3c9e60d04e37 100644 --- a/ipc/glue/CrashReporterHost.h +++ b/ipc/glue/CrashReporterHost.h @@ -12,7 +12,9 @@ #include "mozilla/UniquePtr.h" #include "mozilla/ipc/Shmem.h" #include "base/process.h" +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "nsThreadUtils.h" namespace mozilla { @@ -28,8 +30,13 @@ class GeckoChildProcessHost; class CrashReporterHost { typedef mozilla::ipc::Shmem Shmem; +#ifdef MOZ_CRASHREPORTER typedef CrashReporter::AnnotationTable AnnotationTable; typedef CrashReporter::ThreadId ThreadId; +#else + // unused in this case + typedef int32_t ThreadId; +#endif public: @@ -92,6 +99,7 @@ public: const Shmem& aShmem, ThreadId aThreadId); +#ifdef MOZ_CRASHREPORTER // Helper function for generating a crash report for a process that probably // crashed (i.e., had an AbnormalShutdown in ActorDestroy). Returns true if // the process has a minidump attached and we were able to generate a report. @@ -141,6 +149,7 @@ public: MOZ_ASSERT(HasMinidump()); return mDumpID; } +#endif private: static void AsyncAddCrash(int32_t aProcessType, int32_t aCrashType, @@ -152,7 +161,9 @@ private: Shmem mShmem; ThreadId mThreadId; time_t mStartTime; +#ifdef MOZ_CRASHREPORTER AnnotationTable mExtraNotes; +#endif nsString mDumpID; bool mFinalized; nsCOMPtr mTargetDump; diff --git a/ipc/glue/CrashReporterMetadataShmem.cpp b/ipc/glue/CrashReporterMetadataShmem.cpp index 73a0cf9ab626..f579d5bb0ed8 100644 --- a/ipc/glue/CrashReporterMetadataShmem.cpp +++ b/ipc/glue/CrashReporterMetadataShmem.cpp @@ -208,6 +208,7 @@ private: EntryType mEntryType; }; +#ifdef MOZ_CRASHREPORTER void CrashReporterMetadataShmem::ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes) { @@ -228,6 +229,7 @@ CrashReporterMetadataShmem::ReadAppNotes(const Shmem& aShmem, CrashReporter::Ann } } } +#endif } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/CrashReporterMetadataShmem.h b/ipc/glue/CrashReporterMetadataShmem.h index ba0a6373e55e..d2d8670a22b8 100644 --- a/ipc/glue/CrashReporterMetadataShmem.h +++ b/ipc/glue/CrashReporterMetadataShmem.h @@ -28,7 +28,9 @@ public: void AnnotateCrashReport(const nsCString& aKey, const nsCString& aData); void AppendAppNotes(const nsCString& aData); +#ifdef MOZ_CRASHREPORTER static void ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes); +#endif private: void SyncNotesToShmem(); diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index dce113e07677..28e0ff7cb2d8 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -224,9 +224,11 @@ GeckoChildProcessHost::GetUniqueID() void GeckoChildProcessHost::PrepareLaunch() { +#ifdef MOZ_CRASHREPORTER if (CrashReporter::GetEnabled()) { CrashReporter::OOPInit(); } +#endif #if defined(XP_LINUX) && defined(MOZ_SANDBOX) SandboxLaunchPrepare(mProcessType, mLaunchOptions.get()); @@ -753,7 +755,9 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // always populated (but possibly with an empty value) for a GPU child process. if (mProcessType == GeckoProcessType_GPU) { nsCOMPtr file; +# ifdef MOZ_CRASHREPORTER CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file)); +# endif // MOZ_CRASHREPORTER nsAutoCString path; if (file) { file->GetNativePath(path); @@ -763,26 +767,26 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt childArgv.push_back(pidstring); - if (!CrashReporter::IsDummy()) { -# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) - int childCrashFd, childCrashRemapFd; - if (!CrashReporter::CreateNotificationPipeForChild( - &childCrashFd, &childCrashRemapFd)) { - return false; - } - - if (0 <= childCrashFd) { +# if defined(MOZ_CRASHREPORTER) +# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) + return false; + if (0 <= childCrashFd) { mLaunchOptions->fds_to_remap .push_back(std::pair(childCrashFd, childCrashRemapFd)); - childArgv.push_back("true"); - } else { - // "false" == crash reporting disabled - childArgv.push_back("false"); - } -# elif defined(MOZ_WIDGET_COCOA) // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) - childArgv.push_back(CrashReporter::GetChildNotificationPipe()); -# endif // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) + // "true" == crash reporting enabled + childArgv.push_back("true"); } + else { + // "false" == crash reporting disabled + childArgv.push_back("false"); + } +# elif defined(MOZ_WIDGET_COCOA) // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) + childArgv.push_back(CrashReporter::GetChildNotificationPipe()); +# endif // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) +# endif // defined(MOZ_CRASHREPORTER) # ifdef MOZ_WIDGET_COCOA // Add a mach port to the command line so the child can communicate its @@ -996,7 +1000,9 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // always populated (but possibly with an empty value) for a GPU child process. if (mProcessType == GeckoProcessType_GPU) { nsCOMPtr file; +# ifdef MOZ_CRASHREPORTER CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file)); +# endif // MOZ_CRASHREPORTER nsString path; if (file) { MOZ_ALWAYS_SUCCEEDS(file->GetPath(path)); @@ -1008,8 +1014,10 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // Process id cmdLine.AppendLooseValue(UTF8ToWide(pidstring)); +# if defined(MOZ_CRASHREPORTER) cmdLine.AppendLooseValue( UTF8ToWide(CrashReporter::GetChildNotificationPipe())); +# endif // defined(MOZ_CRASHREPORTER) // Process type cmdLine.AppendLooseValue(UTF8ToWide(childProcessType)); diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 843e8fb24fee..0f3f0008928e 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -25,7 +25,9 @@ #include +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "nsID.h" #include "nsIWidget.h" #include "nsMemory.h" @@ -125,12 +127,16 @@ struct EnumSerializer { static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uintParamType value; if (!ReadParam(aMsg, aIter, &value)) { +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"), NS_LITERAL_CSTRING("Bad iter")); +#endif return false; } else if (!EnumValidator::IsLegalValue(paramType(value))) { +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"), NS_LITERAL_CSTRING("Illegal value")); +#endif return false; } *aResult = paramType(value); diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 7f91401a21c7..647210b1f74e 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -674,8 +674,10 @@ void MessageChannel::WillDestroyCurrentMessageLoop() { #if defined(DEBUG) +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProtocolName"), nsDependentCString(mName)); +#endif MOZ_CRASH("MessageLoop destroyed before MessageChannel that's bound to it"); #endif @@ -699,8 +701,10 @@ MessageChannel::Clear() #if !defined(ANDROID) if (!Unsound_IsClosed()) { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProtocolName"), nsDependentCString(mName)); +#endif MOZ_CRASH("MessageChannel destroyed without being closed"); } #endif diff --git a/ipc/glue/MessageLink.cpp b/ipc/glue/MessageLink.cpp index b19673072a50..918f543f4384 100644 --- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -14,7 +14,9 @@ #include "mozilla/Assertions.h" #include "mozilla/DebugOnly.h" #include "nsDebug.h" +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "nsISupportsImpl.h" #include "nsPrintfCString.h" #include "nsXULAppAPI.h" @@ -159,8 +161,10 @@ void ProcessLink::SendMessage(Message *msg) { if (msg->size() > IPC::Channel::kMaximumMessageSize) { +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCMessageName"), nsDependentCString(msg->name())); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCMessageSize"), nsPrintfCString("%d", msg->size())); +#endif MOZ_CRASH("IPC message size is too large"); } diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index 3fd4ecd1ae64..a49a6f1472ca 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -28,7 +28,7 @@ #include "mozilla/sandboxTarget.h" #endif -#if defined(XP_WIN) +#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN) #include "aclapi.h" #include "sddl.h" @@ -45,7 +45,7 @@ using base::ProcessId; namespace mozilla { -#if defined(XP_WIN) +#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN) // Generate RAII classes for LPTSTR and PSECURITY_DESCRIPTOR. MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedLPTStr, \ RemovePointer::Type, \ @@ -209,9 +209,11 @@ bool DuplicateHandle(HANDLE aSourceHandle, FALSE, aTargetProcessId)); if (!targetProcess) { +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("IPCTransportFailureReason"), NS_LITERAL_CSTRING("Failed to open target process.")); +#endif return false; } @@ -221,6 +223,7 @@ bool DuplicateHandle(HANDLE aSourceHandle, } #endif +#ifdef MOZ_CRASHREPORTER void AnnotateSystemError() { @@ -236,8 +239,9 @@ AnnotateSystemError() nsPrintfCString("%" PRId64, error)); } } +#endif -#if defined(XP_MACOSX) +#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX) void AnnotateCrashReportWithErrno(const char* tag, int error) { @@ -284,6 +288,7 @@ FatalError(const char* aProtocolName, const char* aMsg, bool aIsParent) formattedMessage.AppendLiteral("]: \""); formattedMessage.AppendASCII(aMsg); if (aIsParent) { +#ifdef MOZ_CRASHREPORTER // We're going to crash the parent process because at this time // there's no other really nice way of getting a minidump out of // this process if we're off the main thread. @@ -294,6 +299,7 @@ FatalError(const char* aProtocolName, const char* aMsg, bool aIsParent) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorMsg"), nsDependentCString(aMsg)); AnnotateSystemError(); +#endif MOZ_CRASH("IPC FatalError in the parent process!"); } else { formattedMessage.AppendLiteral("\". abort()ing as a result."); @@ -611,7 +617,11 @@ bool IToplevelProtocol::TakeMinidump(nsIFile** aDump, uint32_t* aSequence) { MOZ_RELEASE_ASSERT(GetSide() == ParentSide); +#ifdef MOZ_CRASHREPORTER return XRE_TakeMinidumpForChild(OtherPid(), aDump, aSequence); +#else + return false; +#endif } bool diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index c9fa9767be52..4599a18d054a 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -573,7 +573,11 @@ DuplicateHandle(HANDLE aSourceHandle, * Annotate the crash reporter with the error code from the most recent system * call. Returns the system error. */ +#ifdef MOZ_CRASHREPORTER void AnnotateSystemError(); +#else +#define AnnotateSystemError() do { } while (0) +#endif /** * An endpoint represents one end of a partially initialized IPDL channel. To @@ -692,7 +696,7 @@ private: ProcessId mMyPid, mOtherPid; }; -#if defined(XP_MACOSX) +#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX) void AnnotateCrashReportWithErrno(const char* tag, int error); #else static inline void AnnotateCrashReportWithErrno(const char* tag, int error) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index ec3df4c33670..e9a9f16ed7e4 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -2566,6 +2566,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): '"'+ _protocolHeaderName(self.protocol, self.side) +'.h"') ] + setToIncludes(self.externalIncludes)) + if self.protocol.decl.type.isToplevel(): + cf.addthings([ + CppDirective('ifdef', 'MOZ_CRASHREPORTER'), + CppDirective(' include', '"nsXULAppAPI.h"'), + CppDirective('endif') + ]) + cppheaders = [CppDirective('include', '"%s"' % filename) for filename in ipdl.builtin.CppIncludes] diff --git a/ipc/mscom/COMPtrHolder.h b/ipc/mscom/COMPtrHolder.h index 758ca91e41e6..4972497adfb7 100644 --- a/ipc/mscom/COMPtrHolder.h +++ b/ipc/mscom/COMPtrHolder.h @@ -16,7 +16,9 @@ #if defined(MOZ_CONTENT_SANDBOX) #include "mozilla/SandboxSettings.h" #endif // defined(MOZ_CONTENT_SANDBOX) +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" +#endif // defined(MOZ_CRASHREPORTER) namespace mozilla { namespace mscom { @@ -210,8 +212,10 @@ struct ParamTraits> mozilla::mscom::ProxyStream proxyStream(_IID, buf.get(), length, &env); if (!proxyStream.IsValid()) { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamValid"), NS_LITERAL_CSTRING("false")); +#endif // defined(MOZ_CRASHREPORTER) return false; } diff --git a/ipc/mscom/Interceptor.cpp b/ipc/mscom/Interceptor.cpp index 4c398aa8d787..8a8930085522 100644 --- a/ipc/mscom/Interceptor.cpp +++ b/ipc/mscom/Interceptor.cpp @@ -22,12 +22,15 @@ #include "mozilla/DebugOnly.h" #include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" -#include "nsExceptionHandler.h" -#include "nsPrintfCString.h" #include "nsRefPtrHashtable.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" +#if defined(MOZ_CRASHREPORTER) + +#include "nsExceptionHandler.h" +#include "nsPrintfCString.h" + #define ENSURE_HR_SUCCEEDED(hr) \ if (FAILED((HRESULT)hr)) { \ nsPrintfCString location("ENSURE_HR_SUCCEEDED \"%s\": %u", __FILE__, __LINE__); \ @@ -37,6 +40,15 @@ return hr; \ } +#else + +#define ENSURE_HR_SUCCEEDED(hr) \ + if (FAILED((HRESULT)hr)) { \ + return hr; \ + } + +#endif // defined(MOZ_CRASHREPORTER) + namespace mozilla { namespace mscom { namespace detail { diff --git a/ipc/mscom/MainThreadRuntime.cpp b/ipc/mscom/MainThreadRuntime.cpp index 77070d7cfee9..9fb8d282c1f7 100644 --- a/ipc/mscom/MainThreadRuntime.cpp +++ b/ipc/mscom/MainThreadRuntime.cpp @@ -13,9 +13,9 @@ #include "mozilla/Assertions.h" #include "mozilla/RefPtr.h" #include "mozilla/UniquePtr.h" -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" -#endif // defined(ACCESSIBILITY) +#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) #include "nsWindowsHelpers.h" #include "nsXULAppAPI.h" @@ -50,7 +50,7 @@ MainThreadRuntime::MainThreadRuntime() , mActCtxRgn(a11y::Compatibility::GetActCtxResourceId()) #endif // defined(ACCESSIBILITY) { -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) GeckoProcessType procType = XRE_GetProcessType(); if (procType == GeckoProcessType_Default || procType == GeckoProcessType_Content) { @@ -65,7 +65,7 @@ MainThreadRuntime::MainThreadRuntime() CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AssemblyManifestCtx"), strActCtx); } -#endif // defined(ACCESSIBILITY) +#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) // We must be the outermost COM initialization on this thread. The COM runtime // cannot be configured once we start manipulating objects diff --git a/ipc/mscom/ProxyStream.cpp b/ipc/mscom/ProxyStream.cpp index a74043c124be..17bbfcfeeba7 100644 --- a/ipc/mscom/ProxyStream.cpp +++ b/ipc/mscom/ProxyStream.cpp @@ -5,20 +5,22 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/Move.h" -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) #include "HandlerData.h" #include "mozilla/a11y/Platform.h" #include "mozilla/mscom/ActivationContext.h" -#endif // defined(ACCESSIBILITY) +#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) #include "mozilla/mscom/EnsureMTA.h" #include "mozilla/mscom/ProxyStream.h" #include "mozilla/mscom/Utils.h" #include "mozilla/ScopeExit.h" +#if defined(MOZ_CRASHREPORTER) #include "mozilla/mscom/Objref.h" #include "nsExceptionHandler.h" #include "nsPrintfCString.h" #include "RegistrationAnnotator.h" +#endif #include #include @@ -44,11 +46,15 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, , mBufSize(aInitBufSize) , mPreserveStream(false) { +#if defined(MOZ_CRASHREPORTER) NS_NAMED_LITERAL_CSTRING(kCrashReportKey, "ProxyStreamUnmarshalStatus"); +#endif if (!aInitBufSize) { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(kCrashReportKey, NS_LITERAL_CSTRING("!aInitBufSize")); +#endif // defined(MOZ_CRASHREPORTER) // We marshaled a nullptr. Nothing else to do here. return; } @@ -56,8 +62,10 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, HRESULT createStreamResult = CreateStream(aInitBuf, aInitBufSize, getter_AddRefs(mStream)); if (FAILED(createStreamResult)) { +#if defined(MOZ_CRASHREPORTER) nsPrintfCString hrAsStr("0x%08X", createStreamResult); CrashReporter::AnnotateCrashReport(kCrashReportKey, hrAsStr); +#endif // defined(MOZ_CRASHREPORTER) return; } @@ -66,16 +74,18 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, // in that case, even though marshaling a nullptr is allowable. MOZ_ASSERT(mStream); if (!mStream) { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(kCrashReportKey, NS_LITERAL_CSTRING("!mStream")); +#endif // defined(MOZ_CRASHREPORTER) return; } -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) const uint32_t expectedStreamLen = GetOBJREFSize(WrapNotNull(mStream)); nsAutoCString strActCtx; nsAutoString manifestPath; -#endif // defined(ACCESSIBILITY) +#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) HRESULT unmarshalResult = S_OK; @@ -83,11 +93,11 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, // correctness with IPDL. We'll request an IUnknown and then QI the // actual interface later. -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) auto marshalFn = [this, &strActCtx, &manifestPath, &unmarshalResult, &aIID, aEnv]() -> void #else auto marshalFn = [this, &unmarshalResult, &aIID, aEnv]() -> void -#endif // defined(ACCESSIBILITY) +#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) { if (aEnv) { bool pushOk = aEnv->Push(); @@ -106,7 +116,7 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, MOZ_DIAGNOSTIC_ASSERT(popOk); }); -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) auto curActCtx = ActivationContext::GetCurrent(); if (curActCtx.isOk()) { strActCtx.AppendPrintf("0x%p", curActCtx.unwrap()); @@ -115,7 +125,7 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, } ActivationContext::GetCurrentManifestPath(manifestPath); -#endif // defined(ACCESSIBILITY) +#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) unmarshalResult = ::CoUnmarshalInterface(mStream, aIID, getter_AddRefs(mUnmarshaledProxy)); @@ -133,6 +143,7 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, mStream = nullptr; +#if defined(MOZ_CRASHREPORTER) if (FAILED(unmarshalResult) || !mUnmarshaledProxy) { nsPrintfCString hrAsStr("0x%08X", unmarshalResult); CrashReporter::AnnotateCrashReport( @@ -165,6 +176,7 @@ ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, actualStreamLen); #endif // defined(ACCESSIBILITY) } +#endif // defined(MOZ_CRASHREPORTER) } ProxyStream::ProxyStream(ProxyStream&& aOther) @@ -296,11 +308,17 @@ ProxyStream::ProxyStream(REFIID aIID, IUnknown* aObject, Environment* aEnv, HRESULT statResult = S_OK; HRESULT getHGlobalResult = S_OK; +#if defined(MOZ_CRASHREPORTER) nsAutoString manifestPath; auto marshalFn = [this, &aIID, aObject, mshlFlags, &stream, &streamSize, &hglobal, &createStreamResult, &marshalResult, &statResult, &getHGlobalResult, aEnv, &manifestPath]() -> void +#else + auto marshalFn = [this, &aIID, aObject, mshlFlags, &stream, &streamSize, + &hglobal, &createStreamResult, &marshalResult, &statResult, + &getHGlobalResult, aEnv]() -> void +#endif // defined(MOZ_CRASHREPORTER) { if (aEnv) { bool pushOk = aEnv->Push(); @@ -325,9 +343,9 @@ ProxyStream::ProxyStream(REFIID aIID, IUnknown* aObject, Environment* aEnv, return; } -#if defined(ACCESSIBILITY) +#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) ActivationContext::GetCurrentManifestPath(manifestPath); -#endif // defined(ACCESSIBILITY) +#endif // defined(MOZ_CRASHREPORTER) marshalResult = ::CoMarshalInterface(stream, aIID, aObject, MSHCTX_LOCAL, nullptr, mshlFlags); @@ -357,6 +375,7 @@ ProxyStream::ProxyStream(REFIID aIID, IUnknown* aObject, Environment* aEnv, EnsureMTA mta(marshalFn); } +#if defined(MOZ_CRASHREPORTER) if (FAILED(createStreamResult)) { nsPrintfCString hrAsStr("0x%08X", createStreamResult); CrashReporter::AnnotateCrashReport( @@ -386,12 +405,15 @@ ProxyStream::ProxyStream(REFIID aIID, IUnknown* aObject, Environment* aEnv, NS_LITERAL_CSTRING("GetHGlobalFromStreamFailure"), hrAsStr); } +#endif // defined(MOZ_CRASHREPORTER) mStream = mozilla::Move(stream); if (streamSize) { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSizeFrom"), NS_LITERAL_CSTRING("IStream::Stat")); +#endif // defined(MOZ_CRASHREPORTER) mBufSize = streamSize; } @@ -406,16 +428,20 @@ ProxyStream::ProxyStream(REFIID aIID, IUnknown* aObject, Environment* aEnv, // the size of the memory block allocated by the HGLOBAL, though it might // be larger than the actual stream size. if (!streamSize) { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSizeFrom"), NS_LITERAL_CSTRING("GlobalSize")); +#endif // defined(MOZ_CRASHREPORTER) mBufSize = static_cast(::GlobalSize(hglobal)); } +#if defined(MOZ_CRASHREPORTER) nsAutoCString strBufSize; strBufSize.AppendInt(mBufSize); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSize"), strBufSize); +#endif // defined(MOZ_CRASHREPORTER) } } // namespace mscom diff --git a/ipc/mscom/RegistrationAnnotator.h b/ipc/mscom/RegistrationAnnotator.h index e78ac1c1111b..b430bf20b8a3 100644 --- a/ipc/mscom/RegistrationAnnotator.h +++ b/ipc/mscom/RegistrationAnnotator.h @@ -7,6 +7,10 @@ #ifndef mozilla_mscom_RegistrationAnnotator_h #define mozilla_mscom_RegistrationAnnotator_h +#if !defined(MOZ_CRASHREPORTER) +#error "This header requires crash reporting to be enabled" +#endif + namespace mozilla { namespace mscom { diff --git a/ipc/mscom/moz.build b/ipc/mscom/moz.build index 1158e8c53666..72d15c2b0ede 100644 --- a/ipc/mscom/moz.build +++ b/ipc/mscom/moz.build @@ -32,10 +32,14 @@ UNIFIED_SOURCES += [ 'Objref.cpp', 'PassthruProxy.cpp', 'ProxyStream.cpp', - 'RegistrationAnnotator.cpp', 'Utils.cpp', ] +if CONFIG['MOZ_CRASHREPORTER']: + UNIFIED_SOURCES += [ + 'RegistrationAnnotator.cpp', + ] + if CONFIG['ACCESSIBILITY']: DIRS += [ 'oop', diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 436f78b0aea2..1bce26337689 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -18,7 +18,6 @@ #include "nsAutoPtr.h" #include "nsNetUtil.h" -#include "nsExceptionHandler.h" #include "nsIMemoryInfoDumper.h" #include "nsIMemoryReporter.h" #include "nsIObserverService.h" @@ -61,6 +60,10 @@ #include "nsIXULRuntime.h" #include "nsJSPrincipals.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #ifdef XP_WIN #include #endif @@ -749,7 +752,9 @@ XPCJSRuntime::GCSliceCallback(JSContext* cx, if (!self) return; +#ifdef MOZ_CRASHREPORTER CrashReporter::SetGarbageCollecting(progress == JS::GC_CYCLE_BEGIN); +#endif if (self->mPrevGCSliceCallback) (*self->mPrevGCSliceCallback)(cx, progress, desc); diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index ee22cfdf694f..6ec81970b1d9 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -13,7 +13,6 @@ #include "mozilla/Preferences.h" #include "nsServiceManagerUtils.h" #include "nsComponentManagerUtils.h" -#include "nsExceptionHandler.h" #include "nsIServiceManager.h" #include "nsIFile.h" #include "nsString.h" @@ -62,6 +61,11 @@ #include /* for isatty() */ #endif +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" +#endif + #ifdef ENABLE_TESTS #include "xpctest_private.h" #endif @@ -1189,8 +1193,9 @@ XRE_XPCShellMain(int argc, char** argv, char** envp, argv += 2; } +#ifdef MOZ_CRASHREPORTER const char* val = getenv("MOZ_CRASHREPORTER"); - if (val && *val && !CrashReporter::IsDummy()) { + if (val && *val) { rv = CrashReporter::SetExceptionHandler(greDir, true); if (NS_FAILED(rv)) { printf("CrashReporter::SetExceptionHandler failed!\n"); @@ -1198,6 +1203,7 @@ XRE_XPCShellMain(int argc, char** argv, char** envp, } MOZ_ASSERT(CrashReporter::GetEnabled()); } +#endif if (argc > 1 && !strcmp(argv[1], "--greomni")) { nsCOMPtr greOmni; @@ -1389,10 +1395,11 @@ XRE_XPCShellMain(int argc, char** argv, char** envp, rv = NS_ShutdownXPCOM( nullptr ); MOZ_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); +#ifdef MOZ_CRASHREPORTER // Shut down the crashreporter service to prevent leaking some strings it holds. - if (CrashReporter::GetEnabled()) { + if (CrashReporter::GetEnabled()) CrashReporter::UnsetExceptionHandler(); - } +#endif #ifdef MOZ_GECKO_PROFILER // This must precede NS_LogTerm(), otherwise xpcshell return non-zero diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 2c59a7cbe1f3..fcb6882bb6c0 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -25,7 +25,6 @@ #include "nsDOMTokenList.h" #include "nsDeviceContext.h" #include "nsIContentInlines.h" -#include "nsICrashReporter.h" #include "nsIDOMNode.h" #include "nsIDocumentInlines.h" #include "nsILoadContext.h" @@ -76,6 +75,10 @@ # include "mozmemory.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "nsICrashReporter.h" +#endif + using namespace mozilla; using namespace mozilla::css; using namespace mozilla::dom; @@ -2819,9 +2822,11 @@ void Gecko_AddBufferToCrashReport(const void* addr, size_t len) { MOZ_ASSERT(NS_IsMainThread()); +#ifdef MOZ_CRASHREPORTER nsCOMPtr cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); NS_ENSURE_TRUE_VOID(cr); cr->RegisterAppMemory((uint64_t) addr, len); +#endif } void @@ -2830,9 +2835,11 @@ Gecko_AnnotateCrashReport(const char* key_str, const char* value_str) MOZ_ASSERT(NS_IsMainThread()); nsDependentCString key(key_str); nsDependentCString value(value_str); +#ifdef MOZ_CRASHREPORTER nsCOMPtr cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); NS_ENSURE_TRUE_VOID(cr); cr->AnnotateCrashReport(key, value); +#endif } void diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 5279a5e5c4e3..531cbd58a60a 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -9,7 +9,6 @@ #include "nsAppDirectoryServiceDefs.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/Omnijar.h" #include "mozilla/Preferences.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" @@ -17,24 +16,28 @@ #include "mozilla/dom/SRIMetadata.h" #include "MainThreadUtils.h" #include "nsColor.h" -#include "nsDirectoryServiceDefs.h" -#include "nsDirectoryService.h" -#include "nsExceptionHandler.h" -#include "nsIChromeRegistry.h" #include "nsIConsoleService.h" #include "nsIFile.h" -#include "nsIObserverService.h" -#include "nsISimpleEnumerator.h" -#include "nsISubstitutingProtocolHandler.h" -#include "nsIXULRuntime.h" #include "nsNetUtil.h" +#include "nsIObserverService.h" +#include "nsServiceManagerUtils.h" +#include "nsIXULRuntime.h" #include "nsPresContext.h" #include "nsPrintfCString.h" -#include "nsServiceManagerUtils.h" #include "nsXULAppAPI.h" -#include "nsZipArchive.h" +// Includes for the crash report annotation in ErrorLoadingSheet. +#ifdef MOZ_CRASHREPORTER +#include "mozilla/Omnijar.h" +#include "nsDirectoryService.h" +#include "nsDirectoryServiceDefs.h" +#include "nsExceptionHandler.h" +#include "nsIChromeRegistry.h" +#include "nsISimpleEnumerator.h" +#include "nsISubstitutingProtocolHandler.h" #include "zlib.h" +#include "nsZipArchive.h" +#endif using namespace mozilla; using namespace mozilla::css; @@ -474,6 +477,7 @@ nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, LoadSheet(uri, aSheet, aParsingMode, aFailureAction); } +#ifdef MOZ_CRASHREPORTER static inline nsresult ComputeCRC32(nsIFile* aFile, uint32_t* aResult) { @@ -750,6 +754,7 @@ AnnotateCrashReport(nsIURI* aURI) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SheetLoadFailure"), NS_ConvertUTF16toUTF8(annotation)); } +#endif static void ErrorLoadingSheet(nsIURI* aURI, const char* aMsg, FailureAction aFailureAction) @@ -765,7 +770,10 @@ ErrorLoadingSheet(nsIURI* aURI, const char* aMsg, FailureAction aFailureAction) } } +#ifdef MOZ_CRASHREPORTER AnnotateCrashReport(aURI); +#endif + MOZ_CRASH_UNSAFE_OOL(errorMessage.get()); } @@ -792,8 +800,9 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, } } +#ifdef MOZ_CRASHREPORTER nsZipArchive::sFileCorruptedReason = nullptr; - +#endif nsresult rv = loader->LoadSheetSync(aURI, aParsingMode, true, aSheet); if (NS_FAILED(rv)) { ErrorLoadingSheet(aURI, diff --git a/memory/gtest/TestJemalloc.cpp b/memory/gtest/TestJemalloc.cpp index 2600df2edfbf..39fd1537f160 100644 --- a/memory/gtest/TestJemalloc.cpp +++ b/memory/gtest/TestJemalloc.cpp @@ -8,13 +8,15 @@ #include "mozilla/UniquePtr.h" #include "mozilla/Vector.h" #include "mozmemory.h" -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" #include "Utils.h" #include "gtest/gtest.h" +#ifdef MOZ_CRASHREPORTER +#include "nsCOMPtr.h" +#include "nsICrashReporter.h" +#include "nsServiceManagerUtils.h" +#endif #ifdef NIGHTLY_BUILD #if defined(DEBUG) && !defined(XP_WIN) && !defined(ANDROID) @@ -26,11 +28,13 @@ extern unsigned int _gdb_sleep_duration; #ifndef XP_DARWIN static void DisableCrashReporter() { +#ifdef MOZ_CRASHREPORTER nsCOMPtr crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } +#endif } // Wrap ASSERT_DEATH_IF_SUPPORTED to disable the crash reporter diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index ffaf578dad42..f6303aa31596 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -1991,7 +1991,9 @@ var BrowserApp = { // Crash reporter submit pref must be fetched from nsICrashReporter // service. case "datareporting.crashreporter.submitEnabled": - if (AppConstants.MOZ_CRASHREPORTER) { + let crashReporterBuilt = "nsICrashReporter" in Ci && + Services.appinfo instanceof Ci.nsICrashReporter; + if (crashReporterBuilt) { aSubject.setAsBool(Services.appinfo.submitReports); } break; @@ -2044,7 +2046,9 @@ var BrowserApp = { // Crash reporter preference is in a service; set and return. case "datareporting.crashreporter.submitEnabled": - if (AppConstants.MOZ_CRASHREPORTER) { + let crashReporterBuilt = "nsICrashReporter" in Ci && + Services.appinfo instanceof Ci.nsICrashReporter; + if (crashReporterBuilt) { Services.appinfo.submitReports = value; aSubject.setAsEmpty(); } diff --git a/mobile/android/components/SessionStore.js b/mobile/android/components/SessionStore.js index 3c5b077b8d87..b214235352bf 100644 --- a/mobile/android/components/SessionStore.js +++ b/mobile/android/components/SessionStore.js @@ -1239,7 +1239,8 @@ SessionStore.prototype = { }, _updateCrashReportURL: function ss_updateCrashReportURL(aWindow) { - if (!AppConstants.MOZ_CRASHREPORTER) { + let crashReporterBuilt = "nsICrashReporter" in Ci && Services.appinfo instanceof Ci.nsICrashReporter; + if (!crashReporterBuilt) { return; } diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 421340ca3ae8..7680cb8bce14 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -81,6 +81,10 @@ #include "plstr.h" #include "prlink.h" +#ifdef MOZ_CRASHREPORTER +#include "nsICrashReporter.h" +#endif + #ifdef XP_WIN #include "windows.h" #endif diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index 61588dddf120..0d70bf8ed520 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -9,13 +9,15 @@ #include "mozilla/DebugOnly.h" #include "ipc/IPCMessageUtils.h" -#include "nsExceptionHandler.h" -#include "nsPrintfCString.h" #include "nsStringGlue.h" #include "prio.h" #include "mozilla/net/DNS.h" #include "TimingStruct.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#include "nsPrintfCString.h" +#endif namespace IPC { @@ -100,11 +102,12 @@ struct ParamTraits aMsg->WriteBytes(aParam.local.path, sizeof(aParam.local.path)); #endif } else { +#ifdef MOZ_CRASHREPORTER if (XRE_IsParentProcess()) { nsPrintfCString msg("%d", aParam.raw.family); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Unknown NetAddr socket family"), msg); } - +#endif MOZ_CRASH("Unknown socket family"); } } diff --git a/security/sandbox/linux/glue/SandboxCrash.cpp b/security/sandbox/linux/glue/SandboxCrash.cpp index a07b12828054..5871c65da9d8 100644 --- a/security/sandbox/linux/glue/SandboxCrash.cpp +++ b/security/sandbox/linux/glue/SandboxCrash.cpp @@ -18,7 +18,9 @@ #include "mozilla/Unused.h" #include "mozilla/dom/Exceptions.h" #include "nsContentUtils.h" +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "mozilla/StackWalk.h" #include "nsString.h" #include "nsThreadUtils.h" @@ -104,8 +106,11 @@ static void SandboxCrash(int nr, siginfo_t *info, void *void_context) { pid_t pid = getpid(), tid = syscall(__NR_gettid); - bool dumped = CrashReporter::WriteMinidumpForSigInfo(nr, info, void_context); + bool dumped = false; +#ifdef MOZ_CRASHREPORTER + dumped = CrashReporter::WriteMinidumpForSigInfo(nr, info, void_context); +#endif if (!dumped) { SANDBOX_LOG_ERROR("crash reporter is disabled (or failed);" " trying stack trace:"); diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp index 9ba895696f26..406ed07d2eed 100644 --- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -12,7 +12,6 @@ #include "nsAutoPtr.h" #include "nsCollationCID.h" #include "nsEmbedCID.h" -#include "nsExceptionHandler.h" #include "nsThreadUtils.h" #include "mozStoragePrivateHelpers.h" #include "nsIXPConnect.h" @@ -27,6 +26,10 @@ #include "sqlite3.h" #include "mozilla/AutoSQLiteLifetime.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #ifdef XP_WIN // "windows.h" was included and it can #define lots of things we care about... #undef CompareString @@ -798,11 +801,13 @@ Service::Observe(nsISupports *, const char *aTopic, const char16_t *) getConnections(connections); for (uint32_t i = 0, n = connections.Length(); i < n; i++) { if (!connections[i]->isClosed()) { +#ifdef MOZ_CRASHREPORTER // getFilename is only the leaf name for the database file, // so it shouldn't contain privacy-sensitive information. CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("StorageConnectionNotClosed"), connections[i]->getFilename()); +#endif #ifdef DEBUG printf_stderr("Storage connection not closed: %s", connections[i]->getFilename().get()); diff --git a/testing/gtest/mozilla/GTestRunner.cpp b/testing/gtest/mozilla/GTestRunner.cpp index ea4cc8be6d10..09c74b1b9dd0 100644 --- a/testing/gtest/mozilla/GTestRunner.cpp +++ b/testing/gtest/mozilla/GTestRunner.cpp @@ -6,7 +6,9 @@ #include "GTestRunner.h" #include "gtest/gtest.h" #include "mozilla/Attributes.h" +#ifdef MOZ_CRASHREPORTER #include "nsICrashReporter.h" +#endif #include "testing/TestHarness.h" #include "prenv.h" #ifdef XP_WIN @@ -89,6 +91,7 @@ int RunGTestFunc(int* argc, char** argv) #ifdef XP_WIN mozilla::ipc::windows::InitUIThread(); #endif +#ifdef MOZ_CRASHREPORTER nsCOMPtr crashreporter; char *crashreporterStr = PR_GetEnv("MOZ_CRASHREPORTER"); if (crashreporterStr && !strcmp(crashreporterStr, "1")) { @@ -109,6 +112,7 @@ int RunGTestFunc(int* argc, char** argv) crashreporter->SetMinidumpPath(cwd); } } +#endif return RUN_ALL_TESTS(); } diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index 62fd1e4bb464..ecd7c35f29df 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -1088,7 +1088,7 @@ this.BrowserTestUtils = { } let dumpID; - if (AppConstants.MOZ_CRASHREPORTER) { + if ('nsICrashReporter' in Ci) { dumpID = subject.getPropertyAsAString('dumpID'); if (!dumpID) { return reject("dumpID was not present despite crash reporting " + diff --git a/toolkit/components/crashes/moz.build b/toolkit/components/crashes/moz.build index 4e0c56b463cd..613fe1aa9ad6 100644 --- a/toolkit/components/crashes/moz.build +++ b/toolkit/components/crashes/moz.build @@ -6,28 +6,26 @@ SPHINX_TREES['crash-manager'] = 'docs' +EXTRA_COMPONENTS += [ + 'CrashService.js', + 'CrashService.manifest', +] + +EXTRA_JS_MODULES += [ + 'CrashManager.jsm', +] + +TESTING_JS_MODULES += [ + 'CrashManagerTest.jsm', +] + +XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] + XPIDL_MODULE = 'toolkit_crashservice' XPIDL_SOURCES += [ 'nsICrashService.idl', ] -if CONFIG['MOZ_CRASHREPORTER']: - EXTRA_COMPONENTS += [ - 'CrashService.js', - 'CrashService.manifest', - ] - - EXTRA_JS_MODULES += [ - 'CrashManager.jsm', - ] - - TESTING_JS_MODULES += [ - 'CrashManagerTest.jsm', - ] - - XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] - with Files('**'): BUG_COMPONENT = ('Toolkit', 'Crash Reporting') - diff --git a/toolkit/components/moz.build b/toolkit/components/moz.build index fe51e74b413d..f8c1d7a3c80b 100644 --- a/toolkit/components/moz.build +++ b/toolkit/components/moz.build @@ -26,7 +26,6 @@ DIRS += [ 'commandlines', 'contentprefs', 'contextualidentity', - 'crashes', 'crashmonitor', 'diskspacewatcher', 'downloads', @@ -81,6 +80,9 @@ if CONFIG['MOZ_BUILD_APP'] != 'mobile/android': if CONFIG['NS_PRINTING']: DIRS += ['printing'] +if CONFIG['MOZ_CRASHREPORTER']: + DIRS += ['crashes'] + if CONFIG['BUILD_CTYPES']: DIRS += ['ctypes'] diff --git a/toolkit/components/places/tests/gtest/places_test_harness_tail.h b/toolkit/components/places/tests/gtest/places_test_harness_tail.h index 48d0a46d4b26..a6e3e0c54963 100644 --- a/toolkit/components/places/tests/gtest/places_test_harness_tail.h +++ b/toolkit/components/places/tests/gtest/places_test_harness_tail.h @@ -6,7 +6,9 @@ #include "nsWidgetsCID.h" #include "nsIComponentRegistrar.h" +#ifdef MOZ_CRASHREPORTER #include "nsICrashReporter.h" +#endif #ifndef TEST_NAME #error "Must #define TEST_NAME before including places_test_harness_tail.h" diff --git a/toolkit/components/terminator/nsTerminator.cpp b/toolkit/components/terminator/nsTerminator.cpp index bb1521bb2bf5..87d406dd45ea 100644 --- a/toolkit/components/terminator/nsTerminator.cpp +++ b/toolkit/components/terminator/nsTerminator.cpp @@ -29,7 +29,9 @@ #include "nsIObserverService.h" #include "nsIPrefService.h" +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" +#endif #include "GeckoProfiler.h" #include "nsThreadUtils.h" @@ -163,8 +165,9 @@ RunWatchdog(void* arg) } // Shutdown is apparently dead. Crash the process. +#if defined(MOZ_CRASHREPORTER) CrashReporter::SetMinidumpAnalysisAllThreads(); - +#endif MOZ_CRASH("Shutdown too long, probably frozen, causing a crash."); } } @@ -552,11 +555,13 @@ nsTerminator::UpdateTelemetry() void nsTerminator::UpdateCrashReport(const char* aTopic) { +#if defined(MOZ_CRASHREPORTER) // In case of crash, we wish to know where in shutdown we are nsAutoCString report(aTopic); Unused << CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ShutdownProgress"), report); +#endif // defined(MOZ_CRASHREPORTER) } diff --git a/toolkit/crashreporter/jar.mn b/toolkit/crashreporter/jar.mn index 0a7f39ddc880..a69b3caa87d5 100644 --- a/toolkit/crashreporter/jar.mn +++ b/toolkit/crashreporter/jar.mn @@ -3,7 +3,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. toolkit.jar: -#ifdef MOZ_CRASHREPORTER content/global/crashes.xhtml (content/crashes.xhtml) content/global/crashes.js (content/crashes.js) -#endif diff --git a/toolkit/crashreporter/moz.build b/toolkit/crashreporter/moz.build index cb843d333847..a9734bac51ab 100644 --- a/toolkit/crashreporter/moz.build +++ b/toolkit/crashreporter/moz.build @@ -6,120 +6,110 @@ SPHINX_TREES['crashreporter'] = 'docs' +if CONFIG['OS_ARCH'] == 'WINNT': + DIRS += [ + 'google-breakpad/src/common', + 'google-breakpad/src/processor', + 'breakpad-windows-libxul', + ] + + if CONFIG['MSVC_HAS_DIA_SDK']: + DIRS += ['google-breakpad/src/tools/windows/dump_syms'] + + if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: + DIRS += ['breakpad-windows-standalone'] + +elif CONFIG['OS_ARCH'] == 'Darwin': + DIRS += [ + 'breakpad-client', + 'breakpad-client/mac/crash_generation', + 'breakpad-client/mac/handler', + 'google-breakpad/src/common', + 'google-breakpad/src/common/mac', + 'google-breakpad/src/processor', + 'google-breakpad/src/tools/mac/dump_syms', + ] + +elif CONFIG['OS_ARCH'] == 'Linux': + DIRS += [ + 'breakpad-client', + 'breakpad-client/linux/', + 'google-breakpad/src/common', + 'google-breakpad/src/common/linux', + 'google-breakpad/src/processor', + 'google-breakpad/src/tools/linux/dump_syms', + ] + + +DIRS += [ + 'client', + 'minidump-analyzer', +] + +if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: + DIRS += ['injector'] + UNIFIED_SOURCES += [ + 'InjectCrashReporter.cpp', + 'LoadLibraryRemote.cpp', + ] + +if CONFIG['ENABLE_TESTS']: + DIRS += ['test/gtest'] + +TEST_DIRS += ['test'] + EXPORTS += [ 'nsExceptionHandler.h', ] -JAR_MANIFESTS += ['jar.mn'] - -UNIFIED_SOURCES = [ - 'nsExceptionHandlerUtils.cpp', +UNIFIED_SOURCES += [ + 'nsExceptionHandler.cpp', + 'ThreadAnnotation.cpp', ] +if CONFIG['OS_ARCH'] == 'Darwin': + UNIFIED_SOURCES += [ + 'mac_utils.mm', + ] + +EXTRA_JS_MODULES += [ + 'CrashReports.jsm', + 'CrashSubmit.jsm', + 'KeyValueParser.jsm', +] + +include('/ipc/chromium/chromium-config.mozbuild') + FINAL_LIBRARY = 'xul' -if CONFIG['MOZ_CRASHREPORTER']: - if CONFIG['OS_ARCH'] == 'WINNT': - DIRS += [ - 'google-breakpad/src/common', - 'google-breakpad/src/processor', - 'breakpad-windows-libxul', - ] - - if CONFIG['MSVC_HAS_DIA_SDK']: - DIRS += ['google-breakpad/src/tools/windows/dump_syms'] - - if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: - DIRS += ['breakpad-windows-standalone'] - - elif CONFIG['OS_ARCH'] == 'Darwin': - DIRS += [ - 'breakpad-client', - 'breakpad-client/mac/crash_generation', - 'breakpad-client/mac/handler', - 'google-breakpad/src/common', - 'google-breakpad/src/common/mac', - 'google-breakpad/src/processor', - 'google-breakpad/src/tools/mac/dump_syms', - ] - - elif CONFIG['OS_ARCH'] == 'Linux': - DIRS += [ - 'breakpad-client', - 'breakpad-client/linux/', - 'google-breakpad/src/common', - 'google-breakpad/src/common/linux', - 'google-breakpad/src/processor', - 'google-breakpad/src/tools/linux/dump_syms', - ] - - - DIRS += [ - 'client', - 'minidump-analyzer', - ] - - if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: - DIRS += ['injector'] - UNIFIED_SOURCES += [ - 'InjectCrashReporter.cpp', - 'LoadLibraryRemote.cpp', - ] - - if CONFIG['ENABLE_TESTS']: - DIRS += ['test/gtest'] - - TEST_DIRS += ['test'] - - UNIFIED_SOURCES += [ - 'nsExceptionHandler.cpp', - 'ThreadAnnotation.cpp', - ] - - if CONFIG['OS_ARCH'] == 'Darwin': - UNIFIED_SOURCES += [ - 'mac_utils.mm', - ] - - EXTRA_JS_MODULES += [ - 'CrashReports.jsm', - 'CrashSubmit.jsm', - 'KeyValueParser.jsm', - ] - - include('/ipc/chromium/chromium-config.mozbuild') - - if CONFIG['OS_TARGET'] == 'Android': - DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION'] - DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION'] - DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME'] - # NDK5 workarounds - DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True - DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True - LOCAL_INCLUDES += [ - '/toolkit/crashreporter/google-breakpad/src/common/android/include', - ] - - DEFINES['UNICODE'] = True - DEFINES['_UNICODE'] = True - +if CONFIG['OS_TARGET'] == 'Android': + DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION'] + DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION'] + DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME'] + # NDK5 workarounds + DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True + DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True LOCAL_INCLUDES += [ - 'google-breakpad/src', + '/toolkit/crashreporter/google-breakpad/src/common/android/include', ] - PYTHON_UNITTEST_MANIFESTS += [ - 'tools/python.ini', - ] +DEFINES['UNICODE'] = True +DEFINES['_UNICODE'] = True - include('/toolkit/crashreporter/crashreporter.mozbuild') +JAR_MANIFESTS += ['jar.mn'] - if CONFIG['GNU_CXX']: - CXXFLAGS += ['-Wno-shadow'] -else: - UNIFIED_SOURCES += [ - 'nsDummyExceptionHandler.cpp', - ] +LOCAL_INCLUDES += [ + 'google-breakpad/src', +] +PYTHON_UNITTEST_MANIFESTS += [ + 'tools/python.ini', +] + +include('/toolkit/crashreporter/crashreporter.mozbuild') with Files('**'): BUG_COMPONENT = ('Toolkit', 'Crash Reporting') + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wno-shadow'] diff --git a/toolkit/crashreporter/nsDummyExceptionHandler.cpp b/toolkit/crashreporter/nsDummyExceptionHandler.cpp deleted file mode 100644 index b40c26b66777..000000000000 --- a/toolkit/crashreporter/nsDummyExceptionHandler.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsExceptionHandler.h" -#include "nsExceptionHandlerUtils.h" - -namespace CrashReporter { - -void -AnnotateOOMAllocationSize(size_t size) -{ -} - -void -AnnotateTexturesSize(size_t size) -{ -} - -void -AnnotatePendingIPC(size_t aNumOfPendingIPC, - uint32_t aTopPendingIPCCount, - const char* aTopPendingIPCName, - uint32_t aTopPendingIPCType) -{ -} - -nsresult -SetExceptionHandler(nsIFile* aXREDirectory, - bool force/*=false*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -bool -GetEnabled() -{ - return false; -} - -bool -GetMinidumpPath(nsAString& aPath) -{ - return false; -} - -nsresult -SetMinidumpPath(const nsAString& aPath) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -SetupExtraData(nsIFile* aAppDataDirectory, - const nsACString& aBuildID) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -UnsetExceptionHandler() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -AnnotateCrashReport(const nsACString& key, - const nsACString& data) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -RemoveCrashReportAnnotation(const nsACString& key) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -SetGarbageCollecting(bool collecting) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void -SetEventloopNestingLevel(uint32_t level) -{ -} - -void -SetMinidumpAnalysisAllThreads() -{ -} - -nsresult -AppendAppNotesToCrashReport(const nsACString& data) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -bool -GetAnnotation(const nsACString& key, nsACString& data) -{ - return false; -} - -nsresult -RegisterAppMemory(void* ptr, size_t length) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -UnregisterAppMemory(void* ptr) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void -SetIncludeContextHeap(bool aValue) -{ -} - -bool -GetServerURL(nsACString& aServerURL) -{ - return false; -} - -nsresult -SetServerURL(const nsACString& aServerURL) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -SetRestartArgs(int argc, char** argv) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -#ifdef XP_WIN32 -nsresult -WriteMinidumpForException(EXCEPTION_POINTERS* aExceptionInfo) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -#endif - -#ifdef XP_LINUX -bool -WriteMinidumpForSigInfo(int signo, - siginfo_t* info, - void* uc) -{ - return false; -} -#endif - -#ifdef XP_MACOSX -nsresult -AppendObjCExceptionInfoToAppNotes(void *inException) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -#endif - -nsresult -GetSubmitReports(bool* aSubmitReports) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -SetSubmitReports(bool aSubmitReports) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void -SetProfileDirectory(nsIFile* aDir) -{ -} - -void -SetUserAppDataDirectory(nsIFile* aDir) -{ -} - -void -UpdateCrashEventsDir() -{ -} - -bool -GetCrashEventsDir(nsAString& aPath) -{ - return false; -} - -void -SetMemoryReportFile(nsIFile* aFile) -{ -} - -nsresult -GetDefaultMemoryReportFile(nsIFile** aFile) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void -SetTelemetrySessionId(const nsACString& id) -{ -} - -void -DeleteMinidumpFilesForID(const nsAString& id) -{ -} - -bool -GetMinidumpForID(const nsAString& id, nsIFile** minidump) -{ - return false; -} - -bool -GetIDFromMinidump(nsIFile* minidump, nsAString& id) -{ - return false; -} - -bool -GetExtraFileForID(const nsAString& id, - nsIFile** extraFile) -{ - return false; -} - -bool -GetExtraFileForMinidump(nsIFile* minidump, - nsIFile** extraFile) -{ - return false; -} - -bool -AppendExtraData(const nsAString& id, - const AnnotationTable& data) -{ - return false; -} - -bool -AppendExtraData(nsIFile* extraFile, - const AnnotationTable& data) -{ - return false; -} - -void -OOPInit() -{ -} - -void -GetChildProcessTmpDir(nsIFile** aOutTmpDir) -{ -} - -#if defined(XP_WIN) || defined(XP_MACOSX) -const char* -GetChildNotificationPipe() -{ - return nullptr; -} -#endif - -#ifdef MOZ_CRASHREPORTER_INJECTOR -void -InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb) -{ -} - -void -UnregisterInjectorCallback(DWORD processID) -{ -} - -#endif // MOZ_CRASHREPORTER_INJECTOR - -bool -GetLastRunCrashID(nsAString& id) -{ - return false; -} - -#if defined(XP_WIN) || defined(XP_MACOSX) -void -InitChildProcessTmpDir(nsIFile* aDirOverride) -{ -} -#endif // defined(XP_WIN) || defined(XP_MACOSX) - -#if defined(XP_WIN) -bool -SetRemoteExceptionHandler(const nsACString& crashPipe) -{ - return false; -} - -#elif defined(XP_LINUX) - -bool -CreateNotificationPipeForChild(int* childCrashFd, int* childCrashRemapFd) -{ - return false; -} - -bool -SetRemoteExceptionHandler() -{ - return false; -} - -#elif defined(XP_MACOSX) - -bool -SetRemoteExceptionHandler(const nsACString& crashPipe) -{ - return false; -} -#endif // XP_WIN - -bool -TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, uint32_t* aSequence) -{ - return false; -} - -void -RenameAdditionalHangMinidump(nsIFile* minidump, nsIFile* childMinidump, - const nsACString& name) -{ -} - -ThreadId -CurrentThreadId() -{ - return -1; -} - -bool -TakeMinidump(nsIFile** aResult, bool aMoveToPending) -{ - return false; -} - -void -CreateMinidumpsAndPair(ProcessHandle aTargetPid, - ThreadId aTargetBlamedThread, - const nsACString& aIncomingPairName, - nsIFile* aIncomingDumpToPair, - nsIFile** aMainDumpOut, - std::function&& aCallback, - bool aAsync) -{ -} - -bool -CreateAdditionalChildMinidump(ProcessHandle childPid, - ThreadId childBlamedThread, - nsIFile* parentMinidump, - const nsACString& name) -{ - return false; -} - -bool -UnsetRemoteExceptionHandler() -{ - return false; -} - -#if defined(MOZ_WIDGET_ANDROID) -void -SetNotificationPipeForChild(int childCrashFd) -{ -} - -void -AddLibraryMapping(const char* library_name, - uintptr_t start_address, - size_t mapping_length, - size_t file_offset) -{ -} -#endif - -// From ThreadAnnotation.cpp - -void -InitThreadAnnotation() -{ -} - -void -SetCurrentThreadName(const char* aName) -{ -} - -void -GetFlatThreadAnnotation(const std::function& aCallback) -{ -} - -void -ShutdownThreadAnnotation() -{ -} - -} // namespace CrashReporter diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 2ff8efdc583a..65fcf51c9b8f 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsExceptionHandler.h" -#include "nsExceptionHandlerUtils.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" @@ -88,6 +87,7 @@ using mozilla::InjectCrashRunnable; #include #include +#include "mozilla/double-conversion.h" #include "mozilla/IOInterposer.h" #include "mozilla/mozalloc_oom.h" #include "mozilla/WindowsDllBlocklist.h" @@ -413,6 +413,54 @@ typedef std::map MappingMap; #endif } +// Format a non-negative double to a string, without using C-library functions, +// which need to be avoided (.e.g. bug 1240160, comment 10). Leave the utility +// non-file static so that we can gtest it. Return false if we failed to +// get the formatting done correctly. +bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength) +{ + // aBufferLength is the size of the buffer. Be paranoid. + aBuffer[aBufferLength-1] = '\0'; + + if (aValue < 0) { + return false; + } + + int length, point, i; + bool sign; + bool ok = true; + double_conversion::DoubleToStringConverter::DoubleToAscii( + aValue, + double_conversion::DoubleToStringConverter::SHORTEST, + 8, + aBuffer, + aBufferLength, + &sign, + &length, + &point); + + // length does not account for the 0 terminator. + if (length > point && (length+1) < (aBufferLength-1)) { + // We have to insert a decimal point. Not worried about adding a leading zero + // in the < 1 (point == 0) case. + aBuffer[length+1] = '\0'; + for (i=length; i>point; i-=1) { + aBuffer[i] = aBuffer[i-1]; + } + aBuffer[i] = '.'; // Not worried about locales + } else if (length < point) { + // Trailing zeros scenario + for (i=length; i= aBufferLength-2) { + ok = false; + } + aBuffer[i] = '0'; + } + aBuffer[i] = '\0'; + } + return ok; +} + namespace CrashReporter { #ifdef XP_LINUX diff --git a/toolkit/crashreporter/nsExceptionHandler.h b/toolkit/crashreporter/nsExceptionHandler.h index d56f906a4c0d..55fca418aa54 100644 --- a/toolkit/crashreporter/nsExceptionHandler.h +++ b/toolkit/crashreporter/nsExceptionHandler.h @@ -3,12 +3,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// This header has two implementations, the real one in nsExceptionHandler.cpp -// and a dummy in nsDummyExceptionHandler.cpp. The latter is used in builds -// configured with --disable-crashreporter. If you add or remove a function -// from this header you must update both implementations otherwise you'll break -// builds that disable the crash reporter. - #ifndef nsExceptionHandler_h__ #define nsExceptionHandler_h__ @@ -40,19 +34,6 @@ template class nsDataHashtable; class nsCStringHashKey; namespace CrashReporter { - -/** - * Returns true if the crash reporter is using the dummy implementation. - */ -static inline bool -IsDummy() { -#ifdef MOZ_CRASHREPORTER - return false; -#else - return true; -#endif -} - nsresult SetExceptionHandler(nsIFile* aXREDirectory, bool force=false); nsresult UnsetExceptionHandler(); diff --git a/toolkit/crashreporter/nsExceptionHandlerUtils.cpp b/toolkit/crashreporter/nsExceptionHandlerUtils.cpp deleted file mode 100644 index 85dec96164a8..000000000000 --- a/toolkit/crashreporter/nsExceptionHandlerUtils.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsExceptionHandlerUtils.h" - -#include "mozilla/double-conversion.h" - -// Format a non-negative double to a string, without using C-library functions, -// which need to be avoided (.e.g. bug 1240160, comment 10). Return false if -// we failed to get the formatting done correctly. -bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength) -{ - // aBufferLength is the size of the buffer. Be paranoid. - aBuffer[aBufferLength-1] = '\0'; - - if (aValue < 0) { - return false; - } - - int length, point, i; - bool sign; - bool ok = true; - double_conversion::DoubleToStringConverter::DoubleToAscii( - aValue, - double_conversion::DoubleToStringConverter::SHORTEST, - 8, - aBuffer, - aBufferLength, - &sign, - &length, - &point); - - // length does not account for the 0 terminator. - if (length > point && (length+1) < (aBufferLength-1)) { - // We have to insert a decimal point. Not worried about adding a leading zero - // in the < 1 (point == 0) case. - aBuffer[length+1] = '\0'; - for (i=length; i>point; i-=1) { - aBuffer[i] = aBuffer[i-1]; - } - aBuffer[i] = '.'; // Not worried about locales - } else if (length < point) { - // Trailing zeros scenario - for (i=length; i= aBufferLength-2) { - ok = false; - } - aBuffer[i] = '0'; - } - aBuffer[i] = '\0'; - } - return ok; -} diff --git a/toolkit/crashreporter/nsExceptionHandlerUtils.h b/toolkit/crashreporter/nsExceptionHandlerUtils.h deleted file mode 100644 index 59c720621bfd..000000000000 --- a/toolkit/crashreporter/nsExceptionHandlerUtils.h +++ /dev/null @@ -1,12 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsExceptionHandlerUtils_h__ -#define nsExceptionHandlerUtils_h__ - -bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength); - -#endif // nsExceptionHandlerUtils_h__ diff --git a/toolkit/moz.build b/toolkit/moz.build index 220189d5df65..074978a6a4d1 100644 --- a/toolkit/moz.build +++ b/toolkit/moz.build @@ -7,7 +7,6 @@ DIRS += [ 'components', 'content', - 'crashreporter', 'forgetaboutsite', 'locales', 'modules', @@ -47,6 +46,9 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': DIRS += ['system/androidproxy'] +if CONFIG['MOZ_CRASHREPORTER']: + DIRS += ['crashreporter'] + TEST_HARNESS_FILES.testing.mochitest.browser.toolkit.crashreporter.test.browser += [ 'crashreporter/test/browser/crashreport.sjs', ] diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index 94b4974a1201..8004b6a45f00 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -2201,7 +2201,8 @@ this.XPIProvider = { Services.obs.notifyObservers(null, "chrome-flush-caches"); } - if (AppConstants.MOZ_CRASHREPORTER) { + if ("nsICrashReporter" in Ci && + Services.appinfo instanceof Ci.nsICrashReporter) { // Annotate the crash report with relevant add-on information. try { Services.appinfo.annotateCrashReport("Theme", this.currentSkin); @@ -2762,16 +2763,14 @@ this.XPIProvider = { * Adds a list of currently active add-ons to the next crash report. */ addAddonsToCrashReporter() { - if (!(Services.appinfo instanceof Ci.nsICrashReporter) || - !AppConstants.MOZ_CRASHREPORTER) { + if (!("nsICrashReporter" in Ci) || + !(Services.appinfo instanceof Ci.nsICrashReporter)) return; - } // In safe mode no add-ons are loaded so we should not include them in the // crash report - if (Services.appinfo.inSafeMode) { + if (Services.appinfo.inSafeMode) return; - } let data = Array.from(XPIStates.enabledAddons(), a => encoded`${a.id}:${a.version}`).join(","); diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 6820dd55e713..266b2e1a6db7 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -40,7 +40,6 @@ const MAX_TIME_DIFFERENCE = 3000; const MAKE_FILE_OLD_DIFFERENCE = 10 * 3600 * 1000; Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm"); -Components.utils.import("resource://gre/modules/AppConstants.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/FileUtils.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); @@ -371,9 +370,8 @@ function isNightlyChannel() { * The version of the add-on */ function do_check_in_crash_annotation(aId, aVersion) { - if (!AppConstants.MOZ_CRASHREPORTER) { + if (!("nsICrashReporter" in AM_Ci)) return; - } if (!("Add-ons" in gAppInfo.annotations)) { do_check_false(true); @@ -394,9 +392,8 @@ function do_check_in_crash_annotation(aId, aVersion) { * The version of the add-on */ function do_check_not_in_crash_annotation(aId, aVersion) { - if (!AppConstants.MOZ_CRASHREPORTER) { + if (!("nsICrashReporter" in AM_Ci)) return; - } if (!("Add-ons" in gAppInfo.annotations)) { do_check_true(true); diff --git a/toolkit/xre/nsAndroidStartup.cpp b/toolkit/xre/nsAndroidStartup.cpp index 34e04bd60798..5f57be71cc25 100644 --- a/toolkit/xre/nsAndroidStartup.cpp +++ b/toolkit/xre/nsAndroidStartup.cpp @@ -29,12 +29,14 @@ GeckoStart(JNIEnv* env, char** argv, int argc, const StaticXREAppData& aAppData) { mozilla::jni::SetGeckoThreadEnv(env); +#ifdef MOZ_CRASHREPORTER const struct mapping_info *info = getLibraryMapping(); while (info->name) { CrashReporter::AddLibraryMapping(info->name, info->base, info->len, info->offset); info++; } +#endif if (!argv) { LOG("Failed to get arguments for GeckoStart\n"); diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index c52cde360024..386213efebb4 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -200,6 +200,7 @@ #include "jprof.h" #endif +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" @@ -208,6 +209,7 @@ #if defined(XP_LINUX) && !defined(ANDROID) #include "mozilla/widget/LSBUtils.h" #endif +#endif #include "base/command_line.h" #include "GTestRunner.h" @@ -702,8 +704,10 @@ class nsXULAppInfo : public nsIXULAppInfo, #ifdef XP_WIN public nsIWinAppHelper, #endif +#ifdef MOZ_CRASHREPORTER public nsICrashReporter, public nsIFinishDumpingCallback, +#endif public nsIXULRuntime { @@ -714,8 +718,10 @@ public: NS_DECL_NSIXULAPPINFO NS_DECL_NSIXULRUNTIME NS_DECL_NSIOBSERVER +#ifdef MOZ_CRASHREPORTER NS_DECL_NSICRASHREPORTER NS_DECL_NSIFINISHDUMPINGCALLBACK +#endif #ifdef XP_WIN NS_DECL_NSIWINAPPHELPER #endif @@ -728,8 +734,10 @@ NS_INTERFACE_MAP_BEGIN(nsXULAppInfo) #ifdef XP_WIN NS_INTERFACE_MAP_ENTRY(nsIWinAppHelper) #endif +#ifdef MOZ_CRASHREPORTER NS_INTERFACE_MAP_ENTRY(nsICrashReporter) NS_INTERFACE_MAP_ENTRY(nsIFinishDumpingCallback) +#endif NS_INTERFACE_MAP_ENTRY(nsIPlatformInfo) NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIXULAppInfo, gAppData || XRE_IsContentProcess()) @@ -1198,6 +1206,7 @@ nsXULAppInfo::GetUserCanElevate(bool *aUserCanElevate) } #endif +#ifdef MOZ_CRASHREPORTER NS_IMETHODIMP nsXULAppInfo::GetEnabled(bool *aEnabled) { @@ -1427,6 +1436,7 @@ nsXULAppInfo::Callback(nsISupports* aData) CrashReporter::SetMemoryReportFile(file); return NS_OK; } +#endif static const nsXULAppInfo kAppInfo; static nsresult AppInfoConstructor(nsISupports* aOuter, @@ -1534,7 +1544,7 @@ static const mozilla::Module::ContractIDEntry kXREContracts[] = { { XULRUNTIME_SERVICE_CONTRACTID, &kAPPINFO_CID }, #ifdef MOZ_CRASHREPORTER { NS_CRASHREPORTER_CONTRACTID, &kAPPINFO_CID }, -#endif // MOZ_CRASHREPORTER +#endif { NS_PROFILESERVICE_CONTRACTID, &kProfileServiceCID }, { NS_NATIVEAPPSUPPORT_CONTRACTID, &kNativeAppSupportCID }, { nullptr } @@ -2894,6 +2904,7 @@ static void RestoreStateForAppInitiatedRestart() } } +#ifdef MOZ_CRASHREPORTER // When we first initialize the crash reporter we don't have a profile, // so we set the minidump path to $TEMP. Once we have a profile, // we set it to $PROFILE/minidumps, creating the directory @@ -2918,6 +2929,7 @@ static void MakeOrSetMinidumpPath(nsIFile* profD) CrashReporter::SetMinidumpPath(pathStr); } } +#endif const XREAppData* gAppData = nullptr; @@ -3308,6 +3320,7 @@ XREMain::XRE_mainInit(bool* aExitFlag) if (NS_FAILED(rv)) return 1; +#ifdef MOZ_CRASHREPORTER if (EnvHasValue("MOZ_CRASHREPORTER")) { mAppData->flags |= NS_XRE_ENABLE_CRASH_REPORTER; } @@ -3393,6 +3406,7 @@ XREMain::XRE_mainInit(bool* aExitFlag) } } } +#endif #if defined(MOZ_SANDBOX) && defined(XP_WIN) if (mAppData->sandboxBrokerServices) { @@ -3542,17 +3556,21 @@ XREMain::XRE_mainInit(bool* aExitFlag) } } +#ifdef MOZ_CRASHREPORTER if (cpuUpdateRevision > 0) { CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CPUMicrocodeVersion"), nsPrintfCString("0x%x", cpuUpdateRevision)); } +#endif } #endif +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SafeMode"), gSafeMode ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); +#endif // Handle --no-remote and --new-instance command line arguments. Setup // the environment to better accommodate other components and various @@ -3616,6 +3634,7 @@ XREMain::XRE_mainInit(bool* aExitFlag) return 0; } +#ifdef MOZ_CRASHREPORTER #ifdef XP_WIN /** * Uses WMI to read some manufacturer information that may be useful for @@ -3709,6 +3728,8 @@ AnnotateLSBRelease(void*) #endif // defined(XP_LINUX) && !defined(ANDROID) +#endif + #ifdef XP_WIN static void ReadAheadDll(const wchar_t* dllName) { wchar_t dllPath[MAX_PATH]; @@ -4167,10 +4188,12 @@ XREMain::XRE_mainStartup(bool* aExitFlag) mozilla::Telemetry::SetProfileDir(mProfD); +#ifdef MOZ_CRASHREPORTER if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) MakeOrSetMinidumpPath(mProfD); CrashReporter::SetProfileDirectory(mProfD); +#endif nsAutoCString version; BuildVersion(version); @@ -4261,6 +4284,7 @@ XREMain::XRE_mainStartup(bool* aExitFlag) return 0; } +#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) void AddSandboxAnnotations() { @@ -4291,6 +4315,7 @@ void AddSandboxAnnotations() sandboxCapable ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); } #endif /* MOZ_CONTENT_SANDBOX */ +#endif /* MOZ_CRASHREPORTER */ /* * XRE_mainRun - Command line startup, profile migration, and @@ -4325,6 +4350,7 @@ XREMain::XRE_mainRun() rv = mScopedXPCOM->SetWindowCreator(mNativeApp); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); +#ifdef MOZ_CRASHREPORTER // tell the crash reporter to also send the release channel nsCOMPtr prefs = do_GetService("@mozilla.org/preferences-service;1", &rv); if (NS_SUCCEEDED(rv)) { @@ -4358,6 +4384,8 @@ XREMain::XRE_mainRun() #if defined(XP_LINUX) && !defined(ANDROID) PR_CreateThread(PR_USER_THREAD, AnnotateLSBRelease, 0, PR_PRIORITY_LOW, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); +#endif + #endif if (mStartOffline) { @@ -4487,9 +4515,11 @@ XREMain::XRE_mainRun() OverrideDefaultLocaleIfNeeded(); +#ifdef MOZ_CRASHREPORTER nsCString userAgentLocale; LocaleService::GetInstance()->GetAppLocaleAsLangTag(userAgentLocale); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("useragent_locale"), userAgentLocale); +#endif appStartup->GetShuttingDown(&mShuttingDown); @@ -4580,8 +4610,10 @@ XREMain::XRE_mainRun() (void)appStartup->DoneStartingUp(); +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("StartupCrash"), NS_LITERAL_CSTRING("0")); +#endif appStartup->GetShuttingDown(&mShuttingDown); } @@ -4634,16 +4666,20 @@ XREMain::XRE_mainRun() sandboxInfo.Test(SandboxInfo::kEnabledForContent)); Telemetry::Accumulate(Telemetry::SANDBOX_MEDIA_ENABLED, sandboxInfo.Test(SandboxInfo::kEnabledForMedia)); +#if defined(MOZ_CRASHREPORTER) nsAutoCString flagsString; flagsString.AppendInt(sandboxInfo.AsInteger()); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString); +#endif /* MOZ_CRASHREPORTER */ #endif /* MOZ_SANDBOX && XP_LINUX */ +#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) AddSandboxAnnotations(); #endif /* MOZ_CONTENT_SANDBOX */ +#endif /* MOZ_CRASHREPORTER */ { rv = appStartup->Run(); @@ -4868,9 +4904,10 @@ XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) rv = LaunchChild(mNativeApp, true); } +#ifdef MOZ_CRASHREPORTER if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) CrashReporter::UnsetExceptionHandler(); - +#endif return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1; } @@ -4882,8 +4919,10 @@ XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) } #endif +#ifdef MOZ_CRASHREPORTER if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) CrashReporter::UnsetExceptionHandler(); +#endif XRE_DeinitCommandLine(); diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 57e4f8b4d6fb..c9c01692a3f6 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -243,7 +243,9 @@ void XRE_SetAndroidChildFds (JNIEnv* env, int crashFd, int ipcFd) { mozilla::jni::SetGeckoThreadEnv(env); +#if defined(MOZ_CRASHREPORTER) CrashReporter::SetNotificationPipeForChild(crashFd); +#endif // defined(MOZ_CRASHREPORTER) IPC::Channel::SetClientChannelFd(ipcFd); } #endif // defined(MOZ_WIDGET_ANDROID) @@ -268,6 +270,7 @@ XRE_SetProcessType(const char* aProcessTypeString) } } +#if defined(MOZ_CRASHREPORTER) // FIXME/bug 539522: this out-of-place function is stuck here because // IPDL wants access to this crashreporter interface, and // crashreporter is built in such a way to make that awkward @@ -289,6 +292,7 @@ XRE_SetRemoteExceptionHandler(const char* aPipe/*= 0*/) # error "OOP crash reporter unsupported on this platform" #endif } +#endif // if defined(MOZ_CRASHREPORTER) #if defined(XP_WIN) void @@ -300,6 +304,7 @@ SetTaskbarGroupId(const nsString& aId) } #endif +#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) void AddContentSandboxLevelAnnotation() @@ -313,6 +318,7 @@ AddContentSandboxLevelAnnotation() } } #endif /* MOZ_CONTENT_SANDBOX */ +#endif /* MOZ_CRASHREPORTER */ namespace { @@ -477,37 +483,35 @@ XRE_InitChildProcess(int aArgc, SetupErrorHandling(aArgv[0]); - if (!CrashReporter::IsDummy()) { - if (aArgc < 1) { - return NS_ERROR_FAILURE; - } +#if defined(MOZ_CRASHREPORTER) + if (aArgc < 1) + return NS_ERROR_FAILURE; + const char* const crashReporterArg = aArgv[--aArgc]; - const char* const crashReporterArg = aArgv[--aArgc]; - -#if defined(XP_WIN) || defined(XP_MACOSX) - // on windows and mac, |crashReporterArg| is the named pipe on which the - // server is listening for requests, or "-" if crash reporting is - // disabled. - if (0 != strcmp("-", crashReporterArg) && - !XRE_SetRemoteExceptionHandler(crashReporterArg)) { - // Bug 684322 will add better visibility into this condition - NS_WARNING("Could not setup crash reporting\n"); - } -#elif defined(OS_LINUX) - // on POSIX, |crashReporterArg| is "true" if crash reporting is - // enabled, false otherwise - if (0 != strcmp("false", crashReporterArg) && - !XRE_SetRemoteExceptionHandler(nullptr)) { - // Bug 684322 will add better visibility into this condition - NS_WARNING("Could not setup crash reporting\n"); - } -#else -# error "OOP crash reporting unsupported on this platform" -#endif +# if defined(XP_WIN) || defined(XP_MACOSX) + // on windows and mac, |crashReporterArg| is the named pipe on which the + // server is listening for requests, or "-" if crash reporting is + // disabled. + if (0 != strcmp("-", crashReporterArg) && + !XRE_SetRemoteExceptionHandler(crashReporterArg)) { + // Bug 684322 will add better visibility into this condition + NS_WARNING("Could not setup crash reporting\n"); } +# elif defined(OS_LINUX) + // on POSIX, |crashReporterArg| is "true" if crash reporting is + // enabled, false otherwise + if (0 != strcmp("false", crashReporterArg) && + !XRE_SetRemoteExceptionHandler(nullptr)) { + // Bug 684322 will add better visibility into this condition + NS_WARNING("Could not setup crash reporting\n"); + } +# else +# error "OOP crash reporting unsupported on this platform" +# endif // For Init/Shutdown thread name annotations in the crash reporter. CrashReporter::InitThreadAnnotationRAII annotation; +#endif // if defined(MOZ_CRASHREPORTER) gArgv = aArgv; gArgc = aArgc; @@ -668,9 +672,11 @@ XRE_InitChildProcess(int aArgc, return NS_ERROR_FAILURE; } +#ifdef MOZ_CRASHREPORTER #if defined(XP_WIN) || defined(XP_MACOSX) CrashReporter::InitChildProcessTmpDir(crashReportTmpDir); #endif +#endif #if defined(XP_WIN) // Set child processes up such that they will get killed after the @@ -687,8 +693,10 @@ XRE_InitChildProcess(int aArgc, OverrideDefaultLocaleIfNeeded(); +#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) AddContentSandboxLevelAnnotation(); +#endif #endif // Run the UI event loop on the main thread. diff --git a/toolkit/xre/nsX11ErrorHandler.cpp b/toolkit/xre/nsX11ErrorHandler.cpp index abf2f278f6ab..15bddd7290b7 100644 --- a/toolkit/xre/nsX11ErrorHandler.cpp +++ b/toolkit/xre/nsX11ErrorHandler.cpp @@ -117,6 +117,7 @@ X11Error(Display *display, XErrorEvent *event) { } } +#ifdef MOZ_CRASHREPORTER switch (XRE_GetProcessType()) { case GeckoProcessType_Default: case GeckoProcessType_Plugin: @@ -126,6 +127,7 @@ X11Error(Display *display, XErrorEvent *event) { default: ; // crash report notes not supported. } +#endif #ifdef DEBUG // The resource id is unlikely to be useful in a crash report without diff --git a/widget/ContentCache.cpp b/widget/ContentCache.cpp index db084c4f0ad5..64be8adb18f6 100644 --- a/widget/ContentCache.cpp +++ b/widget/ContentCache.cpp @@ -15,7 +15,9 @@ #include "mozilla/TextComposition.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/TabParent.h" +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif // #ifdef MOZ_CRASHREPORTER #include "nsIWidget.h" namespace mozilla { @@ -1111,7 +1113,9 @@ ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent) GetBoolName(mWidgetHasComposition), mPendingCompositionCount, mCommitStringByRequest)); +#ifdef MOZ_CRASHREPORTER mDispatchedEventMessages.AppendElement(aEvent.mMessage); +#endif // #ifdef MOZ_CRASHREPORTER // We must be able to simulate the selection because // we might not receive selection updates in time @@ -1189,7 +1193,9 @@ ContentCacheInParent::OnSelectionEvent( GetBoolName(aSelectionEvent.mUseNativeLineBreak), mPendingEventsNeedingAck, GetBoolName(mWidgetHasComposition), mPendingCompositionCount)); +#ifdef MOZ_CRASHREPORTER mDispatchedEventMessages.AppendElement(aSelectionEvent.mMessage); +#endif // #ifdef MOZ_CRASHREPORTER mPendingEventsNeedingAck++; } @@ -1206,22 +1212,27 @@ ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget, "aMessage=%s), mPendingEventsNeedingAck=%u, mPendingCompositionCount=%" PRIu8, this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck, mPendingCompositionCount)); +#ifdef MOZ_CRASHREPORTER mReceivedEventMessages.AppendElement(aMessage); +#endif // #ifdef MOZ_CRASHREPORTER if (WidgetCompositionEvent::IsFollowedByCompositionEnd(aMessage) || aMessage == eCompositionCommitRequestHandled) { +#ifdef MOZ_CRASHREPORTER if (mPendingCompositionCount == 1) { RemoveUnnecessaryEventMessageLog(); } +#endif // #ifdef MOZ_CRASHREPORTER if (NS_WARN_IF(!mPendingCompositionCount)) { +#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nThere is no pending composition but received %s " "message from the remote child\n\n", ToChar(aMessage)); AppendEventMessageLog(info); CrashReporter::AppendAppNotesToCrashReport(info); - +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("No pending composition but received unexpected commit event"); } @@ -1241,11 +1252,13 @@ ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget, } if (NS_WARN_IF(!mPendingEventsNeedingAck)) { +#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nThere is no pending events but received %s " "message from the remote child\n\n", ToChar(aMessage)); AppendEventMessageLog(info); CrashReporter::AppendAppNotesToCrashReport(info); +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("No pending event message but received unexpected event"); } if (--mPendingEventsNeedingAck) { @@ -1277,10 +1290,11 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget, // composition events for cleaning up TextComposition and handle the // request as it's handled asynchronously. if (mPendingCompositionCount > 1) { +#ifdef MOZ_CRASHREPORTER mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eToOldCompositionReceived); - +#endif // #ifdef MOZ_CRASHREPORTER return false; } @@ -1290,10 +1304,11 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget, // TextComposition. So, this shouldn't do nothing and TextComposition // should handle the request as it's handled asynchronously. if (mIsPendingLastCommitEvent) { +#ifdef MOZ_CRASHREPORTER mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eToCommittedCompositionReceived); - +#endif // #ifdef MOZ_CRASHREPORTER return false; } @@ -1302,10 +1317,11 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget, if (!IMEStateManager::DoesTabParentHaveIMEFocus(&mTabParent)) { // Use the latest composition string which may not be handled in the // remote process for avoiding data loss. +#ifdef MOZ_CRASHREPORTER mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eReceivedAfterTabParentBlur); - +#endif // #ifdef MOZ_CRASHREPORTER aCommittedString = mCompositionString; return true; } @@ -1316,11 +1332,11 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget, MOZ_LOG(sContentCacheLog, LogLevel::Warning, (" 0x%p RequestToCommitComposition(), " "does nothing due to no composition", this)); - +#ifdef MOZ_CRASHREPORTER mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eReceivedButNoTextComposition); - +#endif // #ifdef MOZ_CRASHREPORTER return false; } @@ -1347,10 +1363,11 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget, // normally. On the other hand, TextComposition instance in the remote // process won't dispatch following composition events and will be // destroyed by IMEStateManager::DispatchCompositionEvent(). +#ifdef MOZ_CRASHREPORTER mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eHandledAsynchronously); - +#endif // #ifdef MOZ_CRASHREPORTER return false; } @@ -1362,9 +1379,10 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget, // IMEStateManager::DispatchCompositionEvent() at receiving the // eCompositionCommit event (Note that TextComposition instance in this // process was already destroyed). +#ifdef MOZ_CRASHREPORTER mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult::eHandledSynchronously); - +#endif // #ifdef MOZ_CRASHREPORTER return true; } @@ -1461,6 +1479,8 @@ ContentCacheInParent::FlushPendingNotifications(nsIWidget* aWidget) } } +#ifdef MOZ_CRASHREPORTER + void ContentCacheInParent::RemoveUnnecessaryEventMessageLog() { @@ -1548,6 +1568,8 @@ ContentCacheInParent::AppendEventMessageLog(nsACString& aLog) const aLog.AppendLiteral("\n"); } +#endif // #ifdef MOZ_CRASHREPORTER + /***************************************************************************** * mozilla::ContentCache::TextRectArray *****************************************************************************/ diff --git a/widget/ContentCache.h b/widget/ContentCache.h index b085c5fe8a16..ae4b93403d9c 100644 --- a/widget/ContentCache.h +++ b/widget/ContentCache.h @@ -410,6 +410,7 @@ private: IMENotification mPendingLayoutChange; IMENotification mPendingCompositionUpdate; +#ifdef MOZ_CRASHREPORTER // Log of event messages to be output to crash report. nsTArray mDispatchedEventMessages; nsTArray mReceivedEventMessages; @@ -449,6 +450,7 @@ private: } nsTArray mRequestIMEToCommitCompositionResults; +#endif // #ifdef MOZ_CRASHREPORTER // mTabParent is owner of the instance. dom::TabParent& MOZ_NON_OWNING_REF mTabParent; @@ -505,6 +507,7 @@ private: void FlushPendingNotifications(nsIWidget* aWidget); +#ifdef MOZ_CRASHREPORTER /** * Remove unnecessary messages from mDispatchedEventMessages and * mReceivedEventMessages. @@ -515,6 +518,7 @@ private: * Append event message log to aLog. */ void AppendEventMessageLog(nsACString& aLog) const; +#endif // #ifdef MOZ_CRASHREPORTER }; } // namespace mozilla diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index d8031d3813ec..fd28fc69a6bf 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -38,6 +38,10 @@ #include "gfxConfig.h" #include "DriverCrashGuard.h" +#if defined(MOZ_CRASHREPORTER) +#include "nsExceptionHandler.h" +#endif + using namespace mozilla::widget; using namespace mozilla; using mozilla::MutexAutoLock; diff --git a/widget/GfxInfoX11.cpp b/widget/GfxInfoX11.cpp index 94083648cb61..8bb54a99136f 100644 --- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -11,12 +11,14 @@ #include #include #include "nsCRTGlue.h" -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" #include "prenv.h" #include "GfxInfoX11.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" +#endif namespace mozilla { namespace widget { @@ -174,8 +176,9 @@ GfxInfo::GetData() mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.Append('\n'); } - +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); +#endif return; } @@ -191,8 +194,9 @@ GfxInfo::GetData() if (mHasTextureFromPixmap) note.AppendLiteral(" -- texture_from_pixmap"); note.Append('\n'); - +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(note); +#endif // determine the major OpenGL version. That's the first integer in the version string. mGLMajorVersion = strtol(mVersion.get(), 0, 10); diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp index 13d097e380c1..846e0625e366 100644 --- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -8,15 +8,17 @@ #include "GLContextProvider.h" #include "nsUnicharUtils.h" #include "prenv.h" -#include "nsExceptionHandler.h" #include "nsHashKeys.h" -#include "nsICrashReporter.h" #include "nsVersionComparator.h" #include "AndroidBridge.h" #include "nsIWindowWatcher.h" #include "nsServiceManagerUtils.h" +#if defined(MOZ_CRASHREPORTER) +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" +#endif namespace mozilla { namespace widget { @@ -348,6 +350,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) void GfxInfo::AddCrashReportAnnotations() { +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), mGLStrings->Vendor()); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), @@ -361,6 +364,7 @@ GfxInfo::AddCrashReportAnnotations() note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get()); CrashReporter::AppendAppNotesToCrashReport(note); +#endif } const nsTArray& diff --git a/widget/android/jni/Utils.cpp b/widget/android/jni/Utils.cpp index a928814bd8a1..73d739f48af8 100644 --- a/widget/android/jni/Utils.cpp +++ b/widget/android/jni/Utils.cpp @@ -9,7 +9,10 @@ #include "GeneratedJNIWrappers.h" #include "AndroidBuild.h" #include "nsAppShell.h" + +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif namespace mozilla { namespace jni { @@ -203,6 +206,7 @@ bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) { bool result = true; +#ifdef MOZ_CRASHREPORTER result &= NS_SUCCEEDED(CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("JavaStackTrace"), String::Ref::From(aStack)->ToCString())); @@ -215,6 +219,7 @@ bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\n") + appNotes->ToCString()); } +#endif // MOZ_CRASHREPORTER if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) { NS_ABORT_OOM(0); // Unknown OOM size diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index a176794bf8f4..729b4f11e309 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -9,13 +9,11 @@ #include "base/message_loop.h" #include "base/task.h" #include "mozilla/Hal.h" -#include "nsExceptionHandler.h" #include "nsIScreen.h" #include "nsIScreenManager.h" #include "nsWindow.h" #include "nsThreadUtils.h" #include "nsICommandLineRunner.h" -#include "nsICrashReporter.h" #include "nsIObserverService.h" #include "nsIAppStartup.h" #include "nsIGeolocationProvider.h" @@ -60,6 +58,11 @@ #include "mozilla/Logging.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "nsICrashReporter.h" +#include "nsExceptionHandler.h" +#endif + #include "AndroidAlerts.h" #include "AndroidUiThread.h" #include "ANRReporter.h" diff --git a/widget/cocoa/GfxInfo.mm b/widget/cocoa/GfxInfo.mm index fd73d8bcec5c..aceba29ffd16 100644 --- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -10,9 +10,7 @@ #include "GfxInfo.h" #include "nsUnicharUtils.h" -#include "nsExceptionHandler.h" #include "nsCocoaFeatures.h" -#include "nsICrashReporter.h" #include "mozilla/Preferences.h" #include @@ -20,7 +18,11 @@ #import #import +#if defined(MOZ_CRASHREPORTER) +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" +#endif using namespace mozilla; using namespace mozilla::widget; @@ -273,6 +275,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) void GfxInfo::AddCrashReportAnnotations() { +#if defined(MOZ_CRASHREPORTER) nsString deviceID, vendorID, driverVersion; nsAutoCString narrowDeviceID, narrowVendorID, narrowDriverVersion; @@ -298,6 +301,7 @@ GfxInfo::AddCrashReportAnnotations() note.AppendLiteral(", AdapterDeviceID: "); note.Append(narrowDeviceID); CrashReporter::AppendAppNotesToCrashReport(note); +#endif } // We don't support checking driver versions on Mac. diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index d051dae44601..bf42b4f8c095 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -19,7 +19,6 @@ #include "mozilla/TouchEvents.h" #include "nsArrayUtils.h" -#include "nsExceptionHandler.h" #include "nsObjCExceptions.h" #include "nsCOMPtr.h" #include "nsThreadUtils.h" @@ -84,6 +83,9 @@ #include "nsAccessibilityService.h" #include "mozilla/a11y/Platform.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif #include "mozilla/Preferences.h" @@ -5517,30 +5519,31 @@ GetIntegerDeltaForEvent(NSEvent* aEvent) #if !defined(RELEASE_OR_BETA) || defined(DEBUG) if (!Preferences::GetBool("intl.allow-insecure-text-input", false) && mGeckoChild && mTextInputHandler && mTextInputHandler->IsFocused()) { +#ifdef MOZ_CRASHREPORTER NSWindow* window = [self window]; NSString* info = [NSString stringWithFormat:@"\nview [%@], window [%@], window is key %i, is fullscreen %i, app is active %i", self, window, [window isKeyWindow], ([window styleMask] & (1 << 14)) != 0, [NSApp isActive]]; nsAutoCString additionalInfo([info UTF8String]); - +#endif if (mGeckoChild->GetInputContext().IsPasswordEditor() && !TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A password editor has focus, but not in secure input mode" - +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + NS_LITERAL_CSTRING(CRASH_MESSAGE)); CrashReporter::AppendAppNotesToCrashReport(additionalInfo); - +#endif MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } else if (!mGeckoChild->GetInputContext().IsPasswordEditor() && TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A non-password editor has focus, but in secure input mode" - +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + NS_LITERAL_CSTRING(CRASH_MESSAGE)); CrashReporter::AppendAppNotesToCrashReport(additionalInfo); - +#endif MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } diff --git a/widget/nsBaseAppShell.cpp b/widget/nsBaseAppShell.cpp index 6be0d37a4461..40915acecace 100644 --- a/widget/nsBaseAppShell.cpp +++ b/widget/nsBaseAppShell.cpp @@ -6,7 +6,9 @@ #include "base/message_loop.h" #include "nsBaseAppShell.h" +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" +#endif #include "nsThreadUtils.h" #include "nsIObserverService.h" #include "nsServiceManagerUtils.h" @@ -318,14 +320,18 @@ void nsBaseAppShell::IncrementEventloopNestingLevel() { ++mEventloopNestingLevel; +#if defined(MOZ_CRASHREPORTER) CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); +#endif } void nsBaseAppShell::DecrementEventloopNestingLevel() { --mEventloopNestingLevel; +#if defined(MOZ_CRASHREPORTER) CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); +#endif } // Called from the main thread diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp index f71b324a0495..9548b6ea56b1 100644 --- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -18,13 +18,15 @@ #include "mozilla/Preferences.h" #include "mozilla/gfx/DeviceManagerDx.h" #include "mozilla/gfx/Logging.h" -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" #include "nsPrintfCString.h" #include "jsapi.h" #include +#if defined(MOZ_CRASHREPORTER) +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" +#endif using namespace mozilla; using namespace mozilla::gfx; @@ -852,6 +854,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) return NS_OK; } +#if defined(MOZ_CRASHREPORTER) /* Cisco's VPN software can cause corruption of the floating point state. * Make a note of this in our crash reports so that some weird crashes * make more sense */ @@ -866,10 +869,12 @@ CheckForCiscoVPN() { CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Cisco VPN\n")); } } +#endif void GfxInfo::AddCrashReportAnnotations() { +#if defined(MOZ_CRASHREPORTER) CheckForCiscoVPN(); if (mHasDriverVersionMismatch) { @@ -949,6 +954,8 @@ GfxInfo::AddCrashReportAnnotations() note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2)); } CrashReporter::AppendAppNotesToCrashReport(note); + +#endif } static OperatingSystem diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index e29c0b0655d9..50e2cb837aa4 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -12,7 +12,9 @@ #include "mozilla/TextEvents.h" #include "nsAlgorithm.h" +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" +#endif #include "nsGkAtoms.h" #include "nsIIdleServiceInternal.h" #include "nsIWindowsRegKey.h" @@ -2694,6 +2696,8 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const return mIsPrintableKey; } +#ifdef MOZ_CRASHREPORTER + static nsCString GetResultOfInSendMessageEx() { @@ -2726,6 +2730,8 @@ GetResultOfInSendMessageEx() return result; } +#endif // #ifdef MOZ_CRASHREPORTER + bool NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, const MSG& aCharMsg2) const @@ -2969,6 +2975,7 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) } if (doCrash) { +#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nPeekMessage() failed to remove char message! " "\nActive keyboard layout=0x%08X (%s), " "\nHandling message: %s, InSendMessageEx()=%s, " @@ -2994,7 +3001,7 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) CrashReporter::AppendAppNotesToCrashReport( NS_LITERAL_CSTRING("\nThere is no message in any window")); } - +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); } @@ -3113,6 +3120,7 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) "nextKeyMsg=%s, kFoundCharMsg=%s", this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(), ToString(kFoundCharMsg).get())); +#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nPeekMessage() removed unexpcted char message! " "\nActive keyboard layout=0x%08X (%s), " "\nHandling message: %s, InSendMessageEx()=%s, " @@ -3150,13 +3158,14 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) CrashReporter::AppendAppNotesToCrashReport( NS_LITERAL_CSTRING("\nThere is no key message in any windows.")); } - +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("PeekMessage() removed unexpected message"); } MOZ_LOG(sNativeKeyLogger, LogLevel::Error, ("%p NativeKey::GetFollowingCharMessage(), FAILED, removed messages " "are all WM_NULL, nextKeyMsg=%s", this, ToString(nextKeyMsg).get())); +#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nWe lost following char message! " "\nActive keyboard layout=0x%08X (%s), " "\nHandling message: %s, InSendMessageEx()=%s, \n" @@ -3167,6 +3176,7 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) GetResultOfInSendMessageEx().get(), ToString(kFoundCharMsg).get()); CrashReporter::AppendAppNotesToCrashReport(info); +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); return false; } diff --git a/widget/windows/moz.build b/widget/windows/moz.build index 66806a8fa0a6..8215ca5efd7f 100644 --- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -42,7 +42,6 @@ UNIFIED_SOURCES += [ 'InProcessWinCompositorWidget.cpp', 'JumpListItem.cpp', 'KeyboardLayout.cpp', - 'LSPAnnotator.cpp', 'nsAppShell.cpp', 'nsClipboard.cpp', 'nsColorPicker.cpp', @@ -88,6 +87,11 @@ SOURCES += [ 'WinMouseScrollHandler.cpp', ] +if CONFIG['MOZ_CRASHREPORTER']: + UNIFIED_SOURCES += [ + 'LSPAnnotator.cpp', + ] + if CONFIG['NS_PRINTING']: UNIFIED_SOURCES += [ 'nsDeviceContextSpecWin.cpp', diff --git a/widget/windows/nsAppShell.cpp b/widget/windows/nsAppShell.cpp index f3d5b16e6c40..4ea292d959b4 100644 --- a/widget/windows/nsAppShell.cpp +++ b/widget/windows/nsAppShell.cpp @@ -164,7 +164,9 @@ nsAppShell::~nsAppShell() nsresult nsAppShell::Init() { +#ifdef MOZ_CRASHREPORTER LSPAnnotate(); +#endif mLastNativeEventScheduled = TimeStamp::NowLoRes(); diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index da2f54d001cb..bf832b965cfb 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -37,6 +37,10 @@ #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 319ff1bac656..03a3e9018019 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -81,7 +81,6 @@ #include "nsCycleCollectionParticipant.h" #include "nsCycleCollector.h" #include "nsDOMJSUtils.h" -#include "nsExceptionHandler.h" #include "nsJSUtils.h" #include "nsWrapperCache.h" #include "nsStringBuffer.h" @@ -91,6 +90,10 @@ #include "ProfilerMarkerPayload.h" #endif +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #include "nsIException.h" #include "nsIPlatformInfo.h" #include "nsThread.h" @@ -542,9 +545,10 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSContext* aCx) JS_SetExternalStringSizeofCallback(aCx, SizeofExternalStringCallback); JS::SetBuildIdOp(aCx, GetBuildId); JS::SetWarningReporter(aCx, MozCrashWarningReporter); - - js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( - CrashReporter::AnnotateOOMAllocationSize); +#ifdef MOZ_CRASHREPORTER + js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( + CrashReporter::AnnotateOOMAllocationSize); +#endif static js::DOMCallbacks DOMcallbacks = { InstanceClassHasProtoAtDepth @@ -1443,6 +1447,7 @@ CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr, OOMState aNewState) { *aStatePtr = aNewState; +#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(aStatePtr == &mOutOfMemoryState ? NS_LITERAL_CSTRING("JSOutOfMemory") : NS_LITERAL_CSTRING("JSLargeAllocationFailure"), @@ -1451,6 +1456,7 @@ CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr, : aNewState == OOMState::Reported ? NS_LITERAL_CSTRING("Reported") : NS_LITERAL_CSTRING("Recovered")); +#endif } void @@ -1463,12 +1469,14 @@ 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 9c42ad02d8bd..0f8042531fda 100644 --- a/xpcom/base/nsCrashOnException.cpp +++ b/xpcom/base/nsCrashOnException.cpp @@ -6,21 +6,24 @@ #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 2ddb40864bab..f51d2fe6e266 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -167,7 +167,6 @@ #include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionNoteRootCallback.h" #include "nsDeque.h" -#include "nsExceptionHandler.h" #include "nsCycleCollector.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" @@ -192,6 +191,10 @@ #include "mozilla/Telemetry.h" #include "mozilla/ThreadLocal.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + using namespace mozilla; struct NurseryPurpleBufferEntry @@ -665,12 +668,14 @@ 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 ff2bb299f29c..a81528a349c0 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -13,7 +13,9 @@ #include "MainThreadUtils.h" #include "nsDebugImpl.h" #include "nsDebug.h" -#include "nsExceptionHandler.h" +#ifdef MOZ_CRASHREPORTER +# include "nsExceptionHandler.h" +#endif #include "nsString.h" #include "nsXULAppAPI.h" #include "prprf.h" @@ -390,6 +392,7 @@ 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. @@ -403,6 +406,7 @@ 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(); @@ -610,6 +614,8 @@ 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 d6c1ee1a994e..e63c92af5786 100644 --- a/xpcom/base/nsObjCExceptions.h +++ b/xpcom/base/nsObjCExceptions.h @@ -17,7 +17,7 @@ #import #endif -#if defined(__cplusplus) +#if defined(MOZ_CRASHREPORTER) && 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(__cplusplus) +#if defined(MOZ_CRASHREPORTER) && 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 80546d1bacce..881596cf0cb2 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -403,6 +403,7 @@ 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, @@ -411,6 +412,7 @@ 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 700ac2b0e109..2be77e7f0878 100644 --- a/xpcom/system/moz.build +++ b/xpcom/system/moz.build @@ -6,7 +6,6 @@ XPIDL_SOURCES += [ 'nsIBlocklistService.idl', - 'nsICrashReporter.idl', 'nsIDeviceSensors.idl', 'nsIGConfService.idl', 'nsIGeolocationProvider.idl', @@ -18,4 +17,9 @@ 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 8b9898b70e74..f829817dfe03 100644 --- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -8,17 +8,20 @@ #include "prthread.h" -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsMemory.h" -#include "nsServiceManagerUtils.h" #include "nsTArray.h" +#include "nsMemory.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; @@ -71,11 +74,13 @@ 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 41ac2d5d04dc..7291732faa5d 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -6,7 +6,6 @@ #include "PLDHashTable.h" #include "nsCOMPtr.h" -#include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" #include "gtest/gtest.h" @@ -22,6 +21,10 @@ 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,11 +49,13 @@ 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 2aaa3466d0c1..c4ea9824c0c3 100644 --- a/xpcom/tests/gtest/TestSTLWrappers.cpp +++ b/xpcom/tests/gtest/TestSTLWrappers.cpp @@ -10,9 +10,11 @@ # 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 @@ -39,11 +41,13 @@ 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 09a599dd56b0..851d1f707903 100644 --- a/xpcom/threads/HangMonitor.cpp +++ b/xpcom/threads/HangMonitor.cpp @@ -14,7 +14,6 @@ #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" @@ -22,6 +21,10 @@ #include "nsXULAppAPI.h" #include "GeckoProfiler.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #ifdef XP_WIN #include #endif @@ -107,6 +110,7 @@ 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()) { @@ -114,6 +118,7 @@ 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 8eeb9daca843..aade5eda7af4 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -38,14 +38,16 @@ #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 @@ -474,6 +476,7 @@ 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 @@ -538,6 +541,7 @@ nsThread::SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave) return recentlySavedReport; } +#endif #ifdef MOZ_CANARY int sCanaryOutputFD = -1; @@ -1203,9 +1207,11 @@ 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 00049a2c8e4f..33ae13963ac7 100644 --- a/xpcom/threads/nsThread.h +++ b/xpcom/threads/nsThread.h @@ -87,6 +87,7 @@ public: void WaitForAllAsynchronousShutdowns(); +#ifdef MOZ_CRASHREPORTER enum class ShouldSaveMemoryReport { kMaybeReport, @@ -94,6 +95,7 @@ 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 472fc0bed06f..309ab99f71e7 100644 --- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -10,9 +10,10 @@ #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 @@ -27,6 +28,10 @@ #include #endif +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + using namespace mozilla; #ifndef XPCOM_GLUE_AVOID_NSPR @@ -512,7 +517,9 @@ void NS_SetCurrentThreadName(const char* aName) { PR_SetCurrentThreadName(aName); +#ifdef MOZ_CRASHREPORTER CrashReporter::SetCurrentThreadName(aName); +#endif } #ifdef MOZILLA_INTERNAL_API