--- a/ipc/glue/CrashReporterClient.cpp
+++ b/ipc/glue/CrashReporterClient.cpp
@@ -3,17 +3,16 @@
/* 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 "CrashReporterClient.h"
#include "CrashReporterMetadataShmem.h"
#include "nsISupportsImpl.h"
-#ifdef MOZ_CRASHREPORTER
namespace mozilla {
namespace ipc {
StaticMutex CrashReporterClient::sLock;
StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton;
CrashReporterClient::CrashReporterClient(const Shmem& aShmem)
: mMetadata(new CrashReporterMetadataShmem(aShmem))
@@ -60,9 +59,8 @@ CrashReporterClient::DestroySingleton()
CrashReporterClient::GetSingleton()
{
StaticMutexAutoLock lock(sLock);
return sClientSingleton;
}
} // namespace ipc
} // namespace mozilla
-#endif // MOZ_CRASHREPORTER
--- a/ipc/glue/CrashReporterClient.h
+++ b/ipc/glue/CrashReporterClient.h
@@ -7,17 +7,16 @@
#ifndef mozilla_ipc_CrashReporterClient_h
#define mozilla_ipc_CrashReporterClient_h
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Unused.h"
#include "mozilla/ipc/Shmem.h"
-#ifdef MOZ_CRASHREPORTER
namespace mozilla {
namespace ipc {
class CrashReporterMetadataShmem;
class CrashReporterClient
{
public:
@@ -73,12 +72,11 @@ private:
static StaticRefPtr<CrashReporterClient> sClientSingleton;
private:
UniquePtr<CrashReporterMetadataShmem> mMetadata;
};
} // namespace ipc
} // namespace mozilla
-#endif // MOZ_CRASHREPORTER
#endif // mozilla_ipc_CrashReporterClient_h
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -5,37 +5,34 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CrashReporterHost.h"
#include "CrashReporterMetadataShmem.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/Sprintf.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/Telemetry.h"
-#ifdef MOZ_CRASHREPORTER
-# include "nsExceptionHandler.h"
-# include "nsIAsyncShutdown.h"
-# include "nsICrashService.h"
-#endif
+#include "nsExceptionHandler.h"
+#include "nsIAsyncShutdown.h"
+#include "nsICrashService.h"
namespace mozilla {
namespace ipc {
CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType,
const Shmem& aShmem,
ThreadId aThreadId)
: mProcessType(aProcessType),
mShmem(aShmem),
mThreadId(aThreadId),
mStartTime(::time(nullptr)),
mFinalized(false)
{
}
-#ifdef MOZ_CRASHREPORTER
bool
CrashReporterHost::GenerateCrashReport(base::ProcessId aPid)
{
if (!TakeCrashedChildMinidump(aPid, nullptr)) {
return false;
}
return FinalizeCrashReport();
}
@@ -283,12 +280,11 @@ CrashReporterHost::NotifyCrashService(Ge
Telemetry::Accumulate(Telemetry::SUBPROCESS_CRASHES_WITH_DUMP, telemetryKey, 1);
}
void
CrashReporterHost::AddNote(const nsCString& aKey, const nsCString& aValue)
{
mExtraNotes.Put(aKey, aValue);
}
-#endif
} // namespace ipc
} // namespace mozilla
--- a/ipc/glue/CrashReporterHost.h
+++ b/ipc/glue/CrashReporterHost.h
@@ -7,41 +7,34 @@
#ifndef mozilla_ipc_CrashReporterHost_h
#define mozilla_ipc_CrashReporterHost_h
#include <functional>
#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 {
namespace ipc {
class GeckoChildProcessHost;
// This is the newer replacement for CrashReporterParent. It is created in
// response to a InitCrashReporter message on a top-level actor, and simply
// holds the metadata shmem alive until the process ends. When the process
// terminates abnormally, the top-level should call GenerateCrashReport to
// automatically integrate metadata.
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:
template <typename T>
class CallbackWrapper {
public:
void Init(std::function<void(T)>&& aCallback, bool aAsync)
{
@@ -94,17 +87,16 @@ public:
std::function<void(T)> mCallback;
nsCOMPtr<nsIThread> mTargetThread;
};
CrashReporterHost(GeckoProcessType aProcessType,
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.
bool GenerateCrashReport(base::ProcessId aPid);
// Given an existing minidump for a crashed child process, take ownership of
// it from IPDL. After this, FinalizeCrashReport may be called.
RefPtr<nsIFile> TakeCrashedChildMinidump(base::ProcessId aPid, uint32_t* aOutSequence);
@@ -144,31 +136,28 @@ public:
bool HasMinidump() const {
return !mDumpID.IsEmpty();
}
const nsString& MinidumpID() const {
MOZ_ASSERT(HasMinidump());
return mDumpID;
}
-#endif
private:
static void AsyncAddCrash(int32_t aProcessType, int32_t aCrashType,
const nsString& aChildDumpID);
private:
CallbackWrapper<bool> mCreateMinidumpCallback;
GeckoProcessType mProcessType;
Shmem mShmem;
ThreadId mThreadId;
time_t mStartTime;
-#ifdef MOZ_CRASHREPORTER
AnnotationTable mExtraNotes;
-#endif
nsString mDumpID;
bool mFinalized;
nsCOMPtr<nsIFile> mTargetDump;
};
} // namespace ipc
} // namespace mozilla
--- a/ipc/glue/CrashReporterMetadataShmem.cpp
+++ b/ipc/glue/CrashReporterMetadataShmem.cpp
@@ -203,17 +203,16 @@ private:
}
private:
const uint8_t* mCursor;
const uint8_t* mEnd;
EntryType mEntryType;
};
-#ifdef MOZ_CRASHREPORTER
void
CrashReporterMetadataShmem::ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes)
{
for (MetadataShmemReader reader(aShmem); !reader.Done(); reader.Next()) {
switch (reader.Type()) {
case EntryType::Annotation: {
nsCString key, value;
if (!reader.Read(key) || !reader.Read(value)) {
@@ -224,12 +223,11 @@ CrashReporterMetadataShmem::ReadAppNotes
break;
}
default:
NS_ASSERTION(false, "Unknown metadata entry type");
break;
}
}
}
-#endif
} // namespace ipc
} // namespace mozilla
--- a/ipc/glue/CrashReporterMetadataShmem.h
+++ b/ipc/glue/CrashReporterMetadataShmem.h
@@ -23,19 +23,17 @@ class CrashReporterMetadataShmem
public:
explicit CrashReporterMetadataShmem(const Shmem& aShmem);
~CrashReporterMetadataShmem();
// Metadata writers. These must only be called in child processes.
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();
private:
Shmem mShmem;
AnnotationTable mNotes;
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -218,21 +218,19 @@ uint32_t
GeckoChildProcessHost::GetUniqueID()
{
return sNextUniqueID++;
}
void
GeckoChildProcessHost::PrepareLaunch()
{
-#ifdef MOZ_CRASHREPORTER
if (CrashReporter::GetEnabled()) {
CrashReporter::OOPInit();
}
-#endif
#ifdef XP_WIN
if (mProcessType == GeckoProcessType_Plugin) {
InitWindowsGroupID();
}
#if defined(MOZ_CONTENT_SANDBOX)
// We need to get the pref here as the process is launched off main thread.
@@ -766,47 +764,46 @@ GeckoChildProcessHost::PerformAsyncLaunc
// Add the application directory path (-appdir path)
AddAppDirToCommandLine(childArgv);
// Tmp dir that the GPU process should use for crash reports. This arg is
// always populated (but possibly with an empty value) for a GPU child process.
if (mProcessType == GeckoProcessType_GPU) {
nsCOMPtr<nsIFile> file;
-# ifdef MOZ_CRASHREPORTER
CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file));
-# endif // MOZ_CRASHREPORTER
nsAutoCString path;
if (file) {
file->GetNativePath(path);
}
childArgv.push_back(path.get());
}
childArgv.push_back(pidstring);
-# 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) {
- mFileMap.push_back(std::pair<int,int>(childCrashFd, childCrashRemapFd));
- // "true" == crash reporting enabled
- childArgv.push_back("true");
+ 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) {
+ mFileMap.push_back(std::pair<int,int>(childCrashFd, childCrashRemapFd));
+ // "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)
}
- 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)
# if defined(XP_LINUX) && defined(MOZ_SANDBOX)
{
int srcFd, dstFd;
SandboxReporter::Singleton()
->GetClientFileDescriptorMapping(&srcFd, &dstFd);
mFileMap.push_back(std::make_pair(srcFd, dstFd));
}
@@ -1023,34 +1020,32 @@ GeckoChildProcessHost::PerformAsyncLaunc
// Win app model id
cmdLine.AppendLooseValue(mGroupId.get());
// Tmp dir that the GPU process should use for crash reports. This arg is
// always populated (but possibly with an empty value) for a GPU child process.
if (mProcessType == GeckoProcessType_GPU) {
nsCOMPtr<nsIFile> file;
-# ifdef MOZ_CRASHREPORTER
CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file));
-# endif // MOZ_CRASHREPORTER
nsString path;
if (file) {
MOZ_ALWAYS_SUCCEEDS(file->GetPath(path));
}
std::wstring wpath(path.get());
cmdLine.AppendLooseValue(wpath);
}
// Process id
cmdLine.AppendLooseValue(UTF8ToWide(pidstring));
-# if defined(MOZ_CRASHREPORTER)
- cmdLine.AppendLooseValue(
- UTF8ToWide(CrashReporter::GetChildNotificationPipe()));
-# endif // defined(MOZ_CRASHREPORTER)
+ const char* childNotificationPipe = CrashReporter::GetChildNotificationPipe();
+ if (childNotificationPipe) {
+ cmdLine.AppendLooseValue(UTF8ToWide(childNotificationPipe));
+ }
// Process type
cmdLine.AppendLooseValue(UTF8ToWide(childProcessType));
# if defined(XP_WIN) && defined(MOZ_SANDBOX)
if (shouldSandboxCurrentProcess) {
if (mSandboxBroker.LaunchApp(cmdLine.program().c_str(),
cmdLine.command_line_string().c_str(),
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -20,19 +20,17 @@
#ifdef XP_WIN
#include "mozilla/TimeStamp_windows.h"
#endif
#include "mozilla/TypeTraits.h"
#include "mozilla/IntegerTypeTraits.h"
#include <stdint.h>
-#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
-#endif
#include "nsID.h"
#include "nsIWidget.h"
#include "nsMemory.h"
#include "nsString.h"
#include "nsTArray.h"
#include "js/StructuredClone.h"
#include "nsCSSPropertyID.h"
@@ -122,26 +120,22 @@ struct EnumSerializer {
static void Write(Message* aMsg, const paramType& aValue) {
MOZ_RELEASE_ASSERT(EnumValidator::IsLegalValue(aValue));
WriteParam(aMsg, uintParamType(aValue));
}
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);
return true;
}
};
template <typename E,
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -669,20 +669,18 @@ MessageChannel::CanSend() const
MonitorAutoLock lock(*mMonitor);
return Connected();
}
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
// Clear mWorkerThread to avoid posting to it in the future.
MonitorAutoLock lock(*mMonitor);
mWorkerLoop = nullptr;
}
@@ -696,20 +694,18 @@ MessageChannel::Clear()
// through this channel after it's Clear()'ed can cause this process to
// crash.
//
// In practice, mListener owns the channel, so the channel gets deleted
// before mListener. But just to be safe, mListener is a weak pointer.
#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
if (gParentProcessBlocker == this) {
gParentProcessBlocker = nullptr;
}
--- a/ipc/glue/MessageLink.cpp
+++ b/ipc/glue/MessageLink.cpp
@@ -9,19 +9,17 @@
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/BrowserProcessSubThread.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "chrome/common/ipc_channel.h"
#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"
using namespace mozilla;
using namespace std;
// We rely on invariants about the lifetime of the transport:
@@ -156,20 +154,18 @@ ProcessLink::EchoMessage(Message *msg)
msg));
// OnEchoMessage takes ownership of |msg|
}
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");
}
if (!mChan->mIsPostponingSends) {
mChan->AssertWorkerThread();
}
mChan->mMonitor->AssertCurrentThreadOwns();
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -23,34 +23,34 @@
#include "mozilla/Unused.h"
#include "nsPrintfCString.h"
#if defined(MOZ_SANDBOX) && defined(XP_WIN)
#define TARGET_SANDBOX_EXPORTS
#include "mozilla/sandboxTarget.h"
#endif
-#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN)
+#if defined(XP_WIN)
#include "aclapi.h"
#include "sddl.h"
#include "mozilla/TypeTraits.h"
#endif
#include "nsAutoPtr.h"
using namespace IPC;
using base::GetCurrentProcId;
using base::ProcessHandle;
using base::ProcessId;
namespace mozilla {
-#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN)
+#if defined(XP_WIN)
// Generate RAII classes for LPTSTR and PSECURITY_DESCRIPTOR.
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedLPTStr, \
RemovePointer<LPTSTR>::Type, \
::LocalFree)
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPSecurityDescriptor, \
RemovePointer<PSECURITY_DESCRIPTOR>::Type, \
::LocalFree)
#endif
@@ -204,49 +204,45 @@ bool DuplicateHandle(HANDLE aSourceHandl
}
#endif
// Finally, see if we already have access to the process.
ScopedProcessHandle targetProcess(OpenProcess(PROCESS_DUP_HANDLE,
FALSE,
aTargetProcessId));
if (!targetProcess) {
-#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("IPCTransportFailureReason"),
NS_LITERAL_CSTRING("Failed to open target process."));
-#endif
return false;
}
return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle,
targetProcess, aTargetHandle,
aDesiredAccess, FALSE, aOptions);
}
#endif
-#ifdef MOZ_CRASHREPORTER
void
AnnotateSystemError()
{
int64_t error = 0;
#if defined(XP_WIN)
error = ::GetLastError();
#elif defined(OS_POSIX)
error = errno;
#endif
if (error) {
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("IPCSystemError"),
nsPrintfCString("%" PRId64, error));
}
}
-#endif
-#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX)
+#if defined(XP_MACOSX)
void
AnnotateCrashReportWithErrno(const char* tag, int error)
{
CrashReporter::AnnotateCrashReport(
nsCString(tag),
nsPrintfCString("%d", error));
}
#endif
@@ -283,28 +279,26 @@ FatalError(const char* aProtocolName, co
{
ProtocolErrorBreakpoint(aMsg);
nsAutoCString formattedMessage("IPDL error [");
formattedMessage.AppendASCII(aProtocolName);
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.
formattedMessage.AppendLiteral("\". Intentionally crashing.");
NS_ERROR(formattedMessage.get());
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorProtocol"),
nsDependentCString(aProtocolName));
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.");
NS_RUNTIMEABORT(formattedMessage.get());
}
}
void
@@ -616,21 +610,17 @@ IToplevelProtocol::SetOtherProcessId(bas
{
mOtherPid = aOtherPid;
}
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
IToplevelProtocol::Open(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherPid,
MessageLoop* aThread,
mozilla::ipc::Side aSide)
{
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -568,21 +568,17 @@ DuplicateHandle(HANDLE aSourceHandle,
DWORD aDesiredAccess,
DWORD aOptions);
#endif
/**
* 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
* set up a new top-level protocol:
*
* Endpoint<PFooParent> parentEp;
* Endpoint<PFooChild> childEp;
* nsresult rv;
@@ -691,17 +687,17 @@ private:
Endpoint& operator=(const Endpoint&) = delete;
bool mValid;
mozilla::ipc::Transport::Mode mMode;
TransportDescriptor mTransport;
ProcessId mMyPid, mOtherPid;
};
-#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX)
+#if defined(XP_MACOSX)
void AnnotateCrashReportWithErrno(const char* tag, int error);
#else
static inline void AnnotateCrashReportWithErrno(const char* tag, int error)
{}
#endif
// This function is used internally to create a pair of Endpoints. See the
// comment above Endpoint for a description of how it might be used.
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -2546,23 +2546,16 @@ class _GenerateProtocolActorCode(ipdl.as
cf.addthings([
_DISCLAIMER,
Whitespace.NL,
CppDirective(
'include',
'"'+ _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]
cf.addthings((
[ Whitespace.NL ]
+ [ CppDirective(
'include',
'"%s.h"' % (inc)) for inc in self.protocolCxxIncludes ]
--- a/ipc/mscom/COMPtrHolder.h
+++ b/ipc/mscom/COMPtrHolder.h
@@ -11,19 +11,17 @@
#include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Move.h"
#include "mozilla/mscom/ProxyStream.h"
#include "mozilla/mscom/Ptr.h"
#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 {
template<typename Interface, const IID& _IID>
class COMPtrHolder
{
public:
@@ -207,20 +205,18 @@ struct ParamTraits<mozilla::mscom::COMPt
return false;
}
}
paramType::EnvType env;
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;
}
typename paramType::COMPtrType ptr;
if (!proxyStream.GetInterface(mozilla::mscom::getter_AddRefs(ptr))) {
return false;
}
--- a/ipc/mscom/Interceptor.cpp
+++ b/ipc/mscom/Interceptor.cpp
@@ -16,43 +16,31 @@
#include "mozilla/mscom/Objref.h"
#include "mozilla/mscom/Registration.h"
#include "mozilla/mscom/Utils.h"
#include "MainThreadUtils.h"
#include "mozilla/Assertions.h"
#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__); \
nsPrintfCString hrAsStr("0x%08X", (HRESULT)hr); \
CrashReporter::AnnotateCrashReport(location, hrAsStr); \
MOZ_DIAGNOSTIC_ASSERT(SUCCEEDED((HRESULT)hr)); \
return hr; \
}
-#else
-
-#define ENSURE_HR_SUCCEEDED(hr) \
- if (FAILED((HRESULT)hr)) { \
- return hr; \
- }
-
-#endif // defined(MOZ_CRASHREPORTER)
-
namespace mozilla {
namespace mscom {
namespace detail {
class LiveSet final
{
public:
LiveSet()
--- a/ipc/mscom/MainThreadRuntime.cpp
+++ b/ipc/mscom/MainThreadRuntime.cpp
@@ -8,19 +8,19 @@
#if defined(ACCESSIBILITY)
#include "mozilla/a11y/Compatibility.h"
#endif
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
-#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
#include "nsExceptionHandler.h"
-#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
#include "nsWindowsHelpers.h"
#include "nsXULAppAPI.h"
#include <accctrl.h>
#include <aclapi.h>
#include <objbase.h>
#include <objidl.h>
@@ -45,32 +45,32 @@ namespace mscom {
MainThreadRuntime* MainThreadRuntime::sInstance = nullptr;
MainThreadRuntime::MainThreadRuntime()
: mInitResult(E_UNEXPECTED)
#if defined(ACCESSIBILITY)
, mActCtxRgn(a11y::Compatibility::GetActCtxResourceId())
#endif // defined(ACCESSIBILITY)
{
-#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
GeckoProcessType procType = XRE_GetProcessType();
if (procType == GeckoProcessType_Default ||
procType == GeckoProcessType_Content) {
auto actctx = ActivationContext::GetCurrent();
nsAutoCString strActCtx;
if (actctx.isOk()) {
strActCtx.AppendPrintf("0x%p", actctx.unwrap());
} else {
strActCtx.AppendPrintf("HRESULT 0x%08X", actctx.unwrapErr());
}
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AssemblyManifestCtx"),
strActCtx);
}
-#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
// We must be the outermost COM initialization on this thread. The COM runtime
// cannot be configured once we start manipulating objects
MOZ_ASSERT(mStaRegion.IsValidOutermost());
if (NS_WARN_IF(!mStaRegion.IsValidOutermost())) {
return;
}
--- a/ipc/mscom/ProxyStream.cpp
+++ b/ipc/mscom/ProxyStream.cpp
@@ -1,31 +1,28 @@
/* -*- 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 "mozilla/Move.h"
-#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
#include "HandlerData.h"
#include "mozilla/a11y/Platform.h"
#include "mozilla/mscom/ActivationContext.h"
-#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
#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 <windows.h>
#include <objbase.h>
#include <shlwapi.h>
namespace mozilla {
namespace mscom {
@@ -41,68 +38,60 @@ ProxyStream::ProxyStream()
// reconstructing the stream from a buffer anyway.
ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf,
const int aInitBufSize, Environment* aEnv)
: mGlobalLockedBuf(nullptr)
, mHGlobal(nullptr)
, 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;
}
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;
}
// NB: We can't check for a null mStream until after we have checked for
// the zero aInitBufSize above. This is because InitStream will also fail
// 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) && defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
const uint32_t expectedStreamLen = GetOBJREFSize(WrapNotNull(mStream));
nsAutoCString strActCtx;
nsAutoString manifestPath;
-#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
HRESULT unmarshalResult = S_OK;
// We need to convert to an interface here otherwise we mess up const
// correctness with IPDL. We'll request an IUnknown and then QI the
// actual interface later.
-#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
auto marshalFn = [this, &strActCtx, &manifestPath, &unmarshalResult, &aIID, aEnv]() -> void
#else
auto marshalFn = [this, &unmarshalResult, &aIID, aEnv]() -> void
-#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
{
if (aEnv) {
bool pushOk = aEnv->Push();
MOZ_DIAGNOSTIC_ASSERT(pushOk);
if (!pushOk) {
return;
}
}
@@ -111,26 +100,26 @@ ProxyStream::ProxyStream(REFIID aIID, co
if (!aEnv) {
return;
}
bool popOk = aEnv->Pop();
MOZ_DIAGNOSTIC_ASSERT(popOk);
});
-#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
auto curActCtx = ActivationContext::GetCurrent();
if (curActCtx.isOk()) {
strActCtx.AppendPrintf("0x%p", curActCtx.unwrap());
} else {
strActCtx.AppendPrintf("HRESULT 0x%08X", curActCtx.unwrapErr());
}
ActivationContext::GetCurrentManifestPath(manifestPath);
-#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
unmarshalResult =
::CoUnmarshalInterface(mStream, aIID, getter_AddRefs(mUnmarshaledProxy));
MOZ_ASSERT(SUCCEEDED(unmarshalResult));
};
if (XRE_IsParentProcess()) {
// We'll marshal this stuff directly using the current thread, therefore its
@@ -138,17 +127,16 @@ ProxyStream::ProxyStream(REFIID aIID, co
marshalFn();
} else {
// When marshaling in child processes, we want to force the MTA.
EnsureMTA mta(marshalFn);
}
mStream = nullptr;
-#if defined(MOZ_CRASHREPORTER)
if (FAILED(unmarshalResult) || !mUnmarshaledProxy) {
nsPrintfCString hrAsStr("0x%08X", unmarshalResult);
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("CoUnmarshalInterfaceResult"), hrAsStr);
AnnotateInterfaceRegistration(aIID);
if (!mUnmarshaledProxy) {
CrashReporter::AnnotateCrashReport(kCrashReportKey,
NS_LITERAL_CSTRING("!mUnmarshaledProxy"));
@@ -171,17 +159,16 @@ ProxyStream::ProxyStream(REFIID aIID, co
strExpectedStreamLen);
nsAutoCString actualStreamLen;
actualStreamLen.AppendInt(aInitBufSize);
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ActualStreamLen"),
actualStreamLen);
#endif // defined(ACCESSIBILITY)
}
-#endif // defined(MOZ_CRASHREPORTER)
}
ProxyStream::ProxyStream(ProxyStream&& aOther)
: mGlobalLockedBuf(nullptr)
, mHGlobal(nullptr)
, mBufSize(0)
, mPreserveStream(false)
{
@@ -303,27 +290,21 @@ ProxyStream::ProxyStream(REFIID aIID, IU
int streamSize = 0;
DWORD mshlFlags = mPreserveStream ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_NORMAL;
HRESULT createStreamResult = S_OK;
HRESULT marshalResult = S_OK;
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();
MOZ_DIAGNOSTIC_ASSERT(pushOk);
if (!pushOk) {
return;
}
}
@@ -338,19 +319,19 @@ ProxyStream::ProxyStream(REFIID aIID, IU
});
createStreamResult = ::CreateStreamOnHGlobal(nullptr, TRUE,
getter_AddRefs(stream));
if (FAILED(createStreamResult)) {
return;
}
-#if defined(MOZ_CRASHREPORTER)
+#if defined(ACCESSIBILITY)
ActivationContext::GetCurrentManifestPath(manifestPath);
-#endif // defined(MOZ_CRASHREPORTER)
+#endif // defined(ACCESSIBILITY)
marshalResult = ::CoMarshalInterface(stream, aIID, aObject, MSHCTX_LOCAL,
nullptr, mshlFlags);
MOZ_DIAGNOSTIC_ASSERT(marshalResult != E_INVALIDARG);
if (FAILED(marshalResult)) {
return;
}
@@ -370,17 +351,16 @@ ProxyStream::ProxyStream(REFIID aIID, IU
// We'll marshal this stuff directly using the current thread, therefore its
// stub will reside in the same apartment as the current thread.
marshalFn();
} else {
// When marshaling in child processes, we want to force the MTA.
EnsureMTA mta(marshalFn);
}
-#if defined(MOZ_CRASHREPORTER)
if (FAILED(createStreamResult)) {
nsPrintfCString hrAsStr("0x%08X", createStreamResult);
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("CreateStreamOnHGlobalFailure"),
hrAsStr);
}
if (FAILED(marshalResult)) {
@@ -400,50 +380,43 @@ ProxyStream::ProxyStream(REFIID aIID, IU
}
if (FAILED(getHGlobalResult)) {
nsPrintfCString hrAsStr("0x%08X", getHGlobalResult);
CrashReporter::AnnotateCrashReport(
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;
}
if (!hglobal) {
return;
}
mGlobalLockedBuf = reinterpret_cast<BYTE*>(::GlobalLock(hglobal));
mHGlobal = hglobal;
// If we couldn't get the stream size directly from mStream, we may use
// 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<int>(::GlobalSize(hglobal));
}
-#if defined(MOZ_CRASHREPORTER)
nsAutoCString strBufSize;
strBufSize.AppendInt(mBufSize);
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSize"),
strBufSize);
-#endif // defined(MOZ_CRASHREPORTER)
}
} // namespace mscom
} // namespace mozilla
--- a/ipc/mscom/RegistrationAnnotator.h
+++ b/ipc/mscom/RegistrationAnnotator.h
@@ -2,20 +2,16 @@
/* 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 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 {
void AnnotateInterfaceRegistration(REFIID aIid);
void AnnotateClassRegistration(REFCLSID aClsid);
} // namespace mscom
} // namespace mozilla
--- a/ipc/mscom/moz.build
+++ b/ipc/mscom/moz.build
@@ -27,24 +27,20 @@ SOURCES += [
UNIFIED_SOURCES += [
'AgileReference.cpp',
'EnsureMTA.cpp',
'MainThreadClientInfo.cpp',
'MainThreadRuntime.cpp',
'Objref.cpp',
'PassthruProxy.cpp',
'ProxyStream.cpp',
+ 'RegistrationAnnotator.cpp',
'Utils.cpp',
]
-if CONFIG['MOZ_CRASHREPORTER']:
- UNIFIED_SOURCES += [
- 'RegistrationAnnotator.cpp',
- ]
-
if CONFIG['ACCESSIBILITY']:
DIRS += [
'oop',
]
EXPORTS.mozilla.mscom += [
'ActivationContext.h',
'DispatchForwarder.h',