2010-11-24 14:15:03 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set sw=4 ts=8 et tw=80 :
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2010-11-24 14:15:03 +00:00
|
|
|
#include "CrashReporterParent.h"
|
2013-06-03 10:14:37 +00:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2013-09-23 21:30:40 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
2011-06-08 19:56:31 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2013-09-30 17:38:05 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "nsExceptionHandler.h"
|
|
|
|
#endif
|
|
|
|
|
2010-11-24 14:15:03 +00:00
|
|
|
using namespace base;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2012-09-08 17:20:59 +00:00
|
|
|
void
|
|
|
|
CrashReporterParent::AnnotateCrashReport(const nsCString& key,
|
|
|
|
const nsCString& data)
|
2011-06-08 19:56:31 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
mNotes.Put(key, data);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CrashReporterParent::RecvAppendAppNotes(const nsCString& data)
|
|
|
|
{
|
|
|
|
mAppNotes.Append(data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-03 10:14:37 +00:00
|
|
|
mozilla::ipc::IProtocol*
|
|
|
|
CrashReporterParent::CloneProtocol(Channel* aChannel,
|
|
|
|
mozilla::ipc::ProtocolCloneContext* aCtx)
|
|
|
|
{
|
2013-09-30 17:38:05 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-06-03 10:14:37 +00:00
|
|
|
ContentParent* contentParent = aCtx->GetContentParent();
|
|
|
|
CrashReporter::ThreadId childThreadId = contentParent->Pid();
|
|
|
|
GeckoProcessType childProcessType =
|
|
|
|
contentParent->Process()->GetProcessType();
|
|
|
|
|
|
|
|
nsAutoPtr<PCrashReporterParent> actor(
|
|
|
|
contentParent->AllocPCrashReporterParent(childThreadId,
|
|
|
|
childProcessType)
|
|
|
|
);
|
|
|
|
if (!actor ||
|
|
|
|
!contentParent->RecvPCrashReporterConstructor(actor,
|
|
|
|
childThreadId,
|
|
|
|
childThreadId)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return actor.forget();
|
2013-09-30 17:38:05 +00:00
|
|
|
#else
|
|
|
|
MOZ_CRASH("Not Implemented");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
2013-06-03 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 14:15:03 +00:00
|
|
|
CrashReporterParent::CrashReporterParent()
|
2013-09-02 08:41:57 +00:00
|
|
|
:
|
2011-06-08 19:56:31 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-09-02 08:41:57 +00:00
|
|
|
mNotes(4),
|
2011-06-08 19:56:31 +00:00
|
|
|
#endif
|
2014-02-14 08:43:51 +00:00
|
|
|
mStartTime(::time(nullptr))
|
2013-09-02 08:41:57 +00:00
|
|
|
, mInitialized(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CrashReporterParent);
|
2010-11-24 14:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CrashReporterParent::~CrashReporterParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CrashReporterParent);
|
|
|
|
}
|
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
void
|
|
|
|
CrashReporterParent::SetChildData(const NativeThreadId& tid,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& processType)
|
2011-06-08 19:56:31 +00:00
|
|
|
{
|
|
|
|
mInitialized = true;
|
|
|
|
mMainThread = tid;
|
|
|
|
mProcessType = processType;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2012-07-11 02:20:05 +00:00
|
|
|
bool
|
|
|
|
CrashReporterParent::GenerateCrashReportForMinidump(nsIFile* minidump,
|
|
|
|
const AnnotationTable* processNotes)
|
|
|
|
{
|
|
|
|
if (!CrashReporter::GetIDFromMinidump(minidump, mChildDumpID))
|
|
|
|
return false;
|
|
|
|
return GenerateChildData(processNotes);
|
|
|
|
}
|
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
bool
|
|
|
|
CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mInitialized);
|
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString type;
|
2011-06-08 19:56:31 +00:00
|
|
|
switch (mProcessType) {
|
|
|
|
case GeckoProcessType_Content:
|
|
|
|
type = NS_LITERAL_CSTRING("content");
|
|
|
|
break;
|
|
|
|
case GeckoProcessType_Plugin:
|
|
|
|
type = NS_LITERAL_CSTRING("plugin");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("unknown process type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mNotes.Put(NS_LITERAL_CSTRING("ProcessType"), type);
|
|
|
|
|
|
|
|
char startTime[32];
|
2012-08-07 07:06:29 +00:00
|
|
|
sprintf(startTime, "%lld", static_cast<long long>(mStartTime));
|
2011-06-08 19:56:31 +00:00
|
|
|
mNotes.Put(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(startTime));
|
|
|
|
|
|
|
|
if (!mAppNotes.IsEmpty())
|
|
|
|
mNotes.Put(NS_LITERAL_CSTRING("Notes"), mAppNotes);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-11-24 14:15:03 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|