Remove PCrashReporter. (bug 1338310, r=billm)

This commit is contained in:
David Anderson 2017-02-21 11:24:26 -08:00
Родитель c881027454
Коммит dfac09e59c
8 изменённых файлов: 7 добавлений и 512 удалений

Просмотреть файл

@ -1,24 +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 "mozilla/plugins/PluginModuleChild.h"
#include "ContentChild.h"
#include "CrashReporterChild.h"
#include "nsXULAppAPI.h"
using mozilla::plugins::PluginModuleChild;
namespace mozilla {
namespace dom {
/*static*/
PCrashReporterChild*
CrashReporterChild::GetCrashReporter()
{
return nullptr;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,32 +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 mozilla_dom_CrashReporterChild_h
#define mozilla_dom_CrashReporterChild_h
#include "mozilla/dom/PCrashReporterChild.h"
namespace mozilla {
namespace dom {
class CrashReporterChild :
public PCrashReporterChild
{
public:
CrashReporterChild() {
MOZ_COUNT_CTOR(CrashReporterChild);
}
~CrashReporterChild() {
MOZ_COUNT_DTOR(CrashReporterChild);
}
static PCrashReporterChild* GetCrashReporter();
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_CrashReporterChild_h

Просмотреть файл

@ -1,146 +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 "CrashReporterParent.h"
#include "mozilla/Sprintf.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/ipc/CrashReporterHost.h"
#include "nsAutoPtr.h"
#include "nsXULAppAPI.h"
#include <time.h>
#include "mozilla/Telemetry.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#include "nsICrashService.h"
#include "mozilla/SyncRunnable.h"
#include "nsThreadUtils.h"
#endif
namespace mozilla {
namespace dom {
using namespace mozilla::ipc;
void
CrashReporterParent::AnnotateCrashReport(const nsCString& key,
const nsCString& data)
{
#ifdef MOZ_CRASHREPORTER
mNotes.Put(key, data);
#endif
}
void
CrashReporterParent::ActorDestroy(ActorDestroyReason aWhy)
{
// Implement me! Bug 1005155
}
mozilla::ipc::IPCResult
CrashReporterParent::RecvAppendAppNotes(const nsCString& data)
{
mAppNotes.Append(data);
return IPC_OK();
}
CrashReporterParent::CrashReporterParent()
:
#ifdef MOZ_CRASHREPORTER
mNotes(4),
#endif
mStartTime(::time(nullptr))
, mInitialized(false)
{
MOZ_COUNT_CTOR(CrashReporterParent);
}
CrashReporterParent::~CrashReporterParent()
{
MOZ_COUNT_DTOR(CrashReporterParent);
}
void
CrashReporterParent::SetChildData(const NativeThreadId& tid,
const uint32_t& processType)
{
mInitialized = true;
mMainThread = tid;
mProcessType = GeckoProcessType(processType);
}
#ifdef MOZ_CRASHREPORTER
bool
CrashReporterParent::GenerateCrashReportForMinidump(nsIFile* minidump,
const AnnotationTable* processNotes)
{
if (!CrashReporter::GetIDFromMinidump(minidump, mChildDumpID)) {
return false;
}
bool result = GenerateChildData(processNotes);
FinalizeChildData();
return result;
}
bool
CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
{
MOZ_ASSERT(mInitialized);
if (mChildDumpID.IsEmpty()) {
NS_WARNING("problem with GenerateChildData: no child dump id yet!");
return false;
}
nsAutoCString type;
switch (mProcessType) {
case GeckoProcessType_Content:
type = NS_LITERAL_CSTRING("content");
break;
case GeckoProcessType_Plugin:
case GeckoProcessType_GMPlugin:
type = NS_LITERAL_CSTRING("plugin");
break;
default:
NS_ERROR("unknown process type");
break;
}
mNotes.Put(NS_LITERAL_CSTRING("ProcessType"), type);
char startTime[32];
SprintfLiteral(startTime, "%lld", static_cast<long long>(mStartTime));
mNotes.Put(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(startTime));
if (!mAppNotes.IsEmpty()) {
mNotes.Put(NS_LITERAL_CSTRING("Notes"), mAppNotes);
}
// Append these notes to the end of the extra file based on the current
// dump id we obtained from CreatePairedMinidumps.
bool ret = CrashReporter::AppendExtraData(mChildDumpID, mNotes);
if (ret && processNotes) {
ret = CrashReporter::AppendExtraData(mChildDumpID, *processNotes);
}
if (!ret) {
NS_WARNING("problem appending child data to .extra");
}
return ret;
}
void
CrashReporterParent::FinalizeChildData()
{
MOZ_ASSERT(mInitialized);
CrashReporterHost::NotifyCrashService(mProcessType, mChildDumpID, &mNotes);
mNotes.Clear();
}
#endif
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,197 +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 mozilla_dom_CrashReporterParent_h
#define mozilla_dom_CrashReporterParent_h
#include "mozilla/dom/PCrashReporterParent.h"
#include "mozilla/dom/TabMessageUtils.h"
#include "nsIFile.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#include "nsDataHashtable.h"
#endif
namespace mozilla {
namespace dom {
class CrashReporterParent : public PCrashReporterParent
{
#ifdef MOZ_CRASHREPORTER
typedef CrashReporter::AnnotationTable AnnotationTable;
#endif
public:
CrashReporterParent();
virtual ~CrashReporterParent();
#ifdef MOZ_CRASHREPORTER
/*
* Attempt to create a bare-bones crash report, along with extra process-
* specific annotations present in the given AnnotationTable. Calls
* GenerateChildData and FinalizeChildData.
*
* @returns true if successful, false otherwise.
*/
template<class Toplevel>
bool
GenerateCrashReport(Toplevel* t, const AnnotationTable* processNotes);
/**
* Apply child process annotations to an existing paired mindump generated
* with GeneratePairedMinidump.
*
* Be careful about calling generate apis immediately after this call,
* see FinalizeChildData.
*
* @param processNotes (optional) - Additional notes to append. Annotations
* stored in mNotes will also be applied. processNotes can be null.
* @returns true if successful, false otherwise.
*/
bool
GenerateChildData(const AnnotationTable* processNotes);
/**
* Handles main thread finalization tasks after a report has been
* generated. Does the following:
* - register the finished report with the crash service manager
* - records telemetry related data about crashes
*
* Be careful about calling generate apis immediately after this call,
* if this api is called on a non-main thread it will fire off a runnable
* to complete its work async.
*/
void
FinalizeChildData();
/*
* Attempt to generate a full paired dump complete with any child
* annoations, and finalizes the report. Note this call is only valid
* on the main thread. Calling on a background thread will fail.
*
* @returns true if successful, false otherwise.
*/
template<class Toplevel>
bool
GenerateCompleteMinidump(Toplevel* t);
/**
* Submits a raw minidump handed in, calls GenerateChildData and
* FinalizeChildData. Used by content plugins and gmp.
*
* @returns true if successful, false otherwise.
*/
bool
GenerateCrashReportForMinidump(nsIFile* minidump,
const AnnotationTable* processNotes);
#endif // MOZ_CRASHREPORTER
/*
* Initialize this reporter with data from the child process.
*/
void
SetChildData(const NativeThreadId& id, const uint32_t& processType);
/*
* Returns the ID of the child minidump.
* GeneratePairedMinidump or GenerateCrashReport must be called first.
*/
const nsString& ChildDumpID() const {
return mChildDumpID;
}
/*
* Add an annotation to our internally tracked list of annotations.
* Callers must apply these notes using GenerateChildData otherwise
* the notes will get dropped.
*/
void
AnnotateCrashReport(const nsCString& aKey, const nsCString& aData);
protected:
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual mozilla::ipc::IPCResult RecvAnnotateCrashReport(const nsCString& aKey,
const nsCString& aData) override
{
AnnotateCrashReport(aKey, aData);
return IPC_OK();
}
virtual mozilla::ipc::IPCResult RecvAppendAppNotes(const nsCString& aData) override;
#ifdef MOZ_CRASHREPORTER
void
NotifyCrashService();
#endif
#ifdef MOZ_CRASHREPORTER
AnnotationTable mNotes;
#endif
nsCString mAppNotes;
nsString mChildDumpID;
// stores the child main thread id
NativeThreadId mMainThread;
time_t mStartTime;
// stores the child process type
GeckoProcessType mProcessType;
bool mInitialized;
};
#ifdef MOZ_CRASHREPORTER
template<class Toplevel>
inline bool
CrashReporterParent::GenerateCrashReport(Toplevel* t,
const AnnotationTable* processNotes)
{
nsCOMPtr<nsIFile> crashDump;
if (t->TakeMinidump(getter_AddRefs(crashDump), nullptr) &&
CrashReporter::GetIDFromMinidump(crashDump, mChildDumpID)) {
bool result = GenerateChildData(processNotes);
FinalizeChildData();
return result;
}
return false;
}
template<class Toplevel>
inline bool
CrashReporterParent::GenerateCompleteMinidump(Toplevel* t)
{
mozilla::ipc::ScopedProcessHandle child;
if (!NS_IsMainThread()) {
NS_WARNING("GenerateCompleteMinidump can't be called on non-main thread.");
return false;
}
#ifdef XP_MACOSX
child = t->Process()->GetChildTask();
#else
if (!base::OpenPrivilegedProcessHandle(t->OtherPid(), &child.rwget())) {
NS_WARNING("Failed to open child process handle.");
return false;
}
#endif
nsCOMPtr<nsIFile> childDump;
if (CrashReporter::CreateMinidumpsAndPair(child,
mMainThread,
NS_LITERAL_CSTRING("browser"),
nullptr, // pair with a dump of this process and thread
getter_AddRefs(childDump)) &&
CrashReporter::GetIDFromMinidump(childDump, mChildDumpID)) {
bool result = GenerateChildData(nullptr);
FinalizeChildData();
return result;
}
return false;
}
#endif
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_CrashReporterParent_h

Просмотреть файл

@ -1,30 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set sw=4 ts=8 et 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 protocol PContent;
include protocol PPluginModule;
include protocol PGMP;
namespace mozilla {
namespace dom {
struct Mapping {
nsCString library_name;
nsCString file_id;
uintptr_t start_address;
size_t mapping_length;
size_t file_offset;
};
async protocol PCrashReporter {
parent:
async AnnotateCrashReport(nsCString key, nsCString data);
async AppendAppNotes(nsCString data);
async __delete__();
};
}
}

Просмотреть файл

@ -24,8 +24,6 @@ EXPORTS.mozilla.dom += [
'ContentProcess.h',
'ContentProcessManager.h',
'CPOWManagerGetter.h',
'CrashReporterChild.h',
'CrashReporterParent.h',
'FilePickerParent.h',
'MemoryReportRequest.h',
'nsIContentChild.h',
@ -54,7 +52,6 @@ UNIFIED_SOURCES += [
'ContentPrefs.cpp',
'ContentProcess.cpp',
'ContentProcessManager.cpp',
'CrashReporterParent.cpp',
'DatePickerParent.cpp',
'FilePickerParent.cpp',
'MemoryReportRequest.cpp',
@ -73,12 +70,9 @@ UNIFIED_SOURCES += [
'URLClassifierParent.cpp',
]
# CrashReporterChild.cpp cannot be compiled in unified mode because of name clashes
# in OS X headers.
# ContentChild.cpp cannot be compiled in unified mode on linux due to Time conflict
SOURCES += [
'ContentChild.cpp',
'CrashReporterChild.cpp',
'ProcessHangMonitor.cpp',
]
@ -92,7 +86,6 @@ IPDL_SOURCES += [
'PContentBridge.ipdl',
'PContentPermission.ipdlh',
'PContentPermissionRequest.ipdl',
'PCrashReporter.ipdl',
'PCycleCollectWithLogs.ipdl',
'PDatePicker.ipdl',
'PDocumentRenderer.ipdl',

Просмотреть файл

@ -32,7 +32,6 @@
#include "mozilla/plugins/StreamNotifyChild.h"
#include "mozilla/plugins/BrowserStreamChild.h"
#include "mozilla/plugins/PluginStreamChild.h"
#include "mozilla/dom/CrashReporterChild.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"

Просмотреть файл

@ -11,8 +11,6 @@
#include "nsDirectoryService.h"
#include "nsDataHashtable.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/dom/CrashReporterChild.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/Services.h"
#include "nsIObserverService.h"
#include "mozilla/Unused.h"
@ -20,6 +18,7 @@
#include "mozilla/Sprintf.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
@ -111,8 +110,6 @@ using google_breakpad::FileID;
using google_breakpad::PageAllocator;
#endif
using namespace mozilla;
using mozilla::dom::CrashReporterChild;
using mozilla::dom::PCrashReporterChild;
using mozilla::ipc::CrashReporterClient;
namespace CrashReporter {
@ -2259,28 +2256,6 @@ EnqueueDelayedNote(DelayedNote* aNote)
gDelayedAnnotations->AppendElement(aNote);
}
class CrashReporterHelperRunnable : public Runnable {
public:
explicit CrashReporterHelperRunnable(const nsACString& aKey,
const nsACString& aData)
: mKey(aKey)
, mData(aData)
, mAppendAppNotes(false)
{}
explicit CrashReporterHelperRunnable(const nsACString& aData)
: mKey()
, mData(aData)
, mAppendAppNotes(true)
{}
NS_IMETHOD Run() override;
private:
nsCString mKey;
nsCString mData;
bool mAppendAppNotes;
};
nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
{
if (!GetEnabled())
@ -2298,23 +2273,10 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
return NS_OK;
}
// Otherwise, we have to handle this on the main thread since we will go
// through IPDL.
if (!NS_IsMainThread()) {
// Child process needs to handle this in the main thread:
nsCOMPtr<nsIRunnable> r = new CrashReporterHelperRunnable(key, data);
NS_DispatchToMainThread(r);
return NS_OK;
}
// EnqueueDelayedNote() can only be called on the main thread.
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_ASSERT(NS_IsMainThread());
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
if (!reporter) {
EnqueueDelayedNote(new DelayedNote(key, data));
return NS_OK;
}
if (!reporter->SendAnnotateCrashReport(nsCString(key), escapedData))
return NS_ERROR_FAILURE;
EnqueueDelayedNote(new DelayedNote(key, data));
return NS_OK;
}
@ -2383,22 +2345,10 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data)
return NS_OK;
}
if (!NS_IsMainThread()) {
// Child process needs to handle this in the main thread:
nsCOMPtr<nsIRunnable> r = new CrashReporterHelperRunnable(data);
NS_DispatchToMainThread(r);
return NS_OK;
}
// EnqueueDelayedNote can only be called on the main thread.
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_ASSERT(NS_IsMainThread());
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
if (!reporter) {
EnqueueDelayedNote(new DelayedNote(data));
return NS_OK;
}
if (!reporter->SendAppendAppNotes(escapedData))
return NS_ERROR_FAILURE;
EnqueueDelayedNote(new DelayedNote(data));
return NS_OK;
}
@ -2408,24 +2358,6 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data)
return AnnotateCrashReport(NS_LITERAL_CSTRING("Notes"), *notesField);
}
nsresult CrashReporterHelperRunnable::Run()
{
// We expect this to be in the child process' main thread. If it isn't,
// something is happening we didn't design for.
MOZ_ASSERT(!XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
// Don't just leave the assert, paranoid about infinite recursion
if (NS_IsMainThread()) {
if (mAppendAppNotes) {
return AppendAppNotesToCrashReport(mData);
} else {
return AnnotateCrashReport(mKey, mData);
}
}
return NS_ERROR_FAILURE;
}
// Returns true if found, false if not found.
bool GetAnnotation(const nsACString& key, nsACString& data)
{