gecko-dev/ipc/glue/CrashReporterClient.cpp
Gabriele Svelto 76021a664b Bug 1555917 - Exception handler and crash reporter client cleanup r=froydnj
This patch includes multiple changes cleaning up various aspects of the crash
reporter client and exception handler:

* Some Unix-specific code was moved out from the base crashreporter client
  code and into the appropriate platform implementation
* Functions used to open files in the crashreporter client now accept C++
  `std::ios` flags instead of unreadable booleans
* Useless character conversion routines were removed from the
  minidump-analyzer
* Crash annotations are not serialized into a huge string anymore every time
  they change. They are all written out individually during an exception.
* `WriteEscapedMozCrashReason()` uses the exception-safe `my_strlen()` instead
  of plain `strlen()`
* The Windows-specific DLL-blocklist shutdown was removed from the Linux &
  macOS Breakpad callbacks
* The `CrashReporterHost`, `CrashReporterClient` and
  `CrashReporterMetadataShmem` classes now take `nsACString` references
  instead of `nsCString` ones since they never modify their contents

Differential Revision: https://phabricator.services.mozilla.com/D33267

--HG--
extra : moz-landing-system : lando
2019-05-31 21:54:03 +00:00

63 lines
1.8 KiB
C++

/* -*- 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 "CrashReporterClient.h"
#include "CrashReporterMetadataShmem.h"
#include "nsISupportsImpl.h"
namespace mozilla {
namespace ipc {
StaticMutex CrashReporterClient::sLock;
StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton;
CrashReporterClient::CrashReporterClient(const Shmem& aShmem)
: mMetadata(new CrashReporterMetadataShmem(aShmem)) {
MOZ_COUNT_CTOR(CrashReporterClient);
}
CrashReporterClient::~CrashReporterClient() {
MOZ_COUNT_DTOR(CrashReporterClient);
}
void CrashReporterClient::AnnotateCrashReport(CrashReporter::Annotation aKey,
const nsACString& aData) {
StaticMutexAutoLock lock(sLock);
mMetadata->AnnotateCrashReport(aKey, aData);
}
void CrashReporterClient::AppendAppNotes(const nsACString& aData) {
StaticMutexAutoLock lock(sLock);
mMetadata->AppendAppNotes(aData);
}
/* static */
void CrashReporterClient::InitSingletonWithShmem(const Shmem& aShmem) {
{
StaticMutexAutoLock lock(sLock);
MOZ_ASSERT(!sClientSingleton);
sClientSingleton = new CrashReporterClient(aShmem);
}
CrashReporter::NotifyCrashReporterClientCreated();
}
/* static */
void CrashReporterClient::DestroySingleton() {
StaticMutexAutoLock lock(sLock);
sClientSingleton = nullptr;
}
/* static */
RefPtr<CrashReporterClient> CrashReporterClient::GetSingleton() {
StaticMutexAutoLock lock(sLock);
return sClientSingleton;
}
} // namespace ipc
} // namespace mozilla