Bug 1301022 - Add an API for annotating pending IPC messages. r=ted

MozReview-Commit-ID: GiAMUnjYjvI

--HG--
extra : rebase_source : a40f81a4878205b5edb71ca8ec2f24dc35c677eb
This commit is contained in:
Ting-Yu Chou 2016-09-20 14:10:43 +08:00
Родитель 56a7b3961a
Коммит 7d65559dd1
3 изменённых файлов: 78 добавлений и 8 удалений

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

@ -507,12 +507,7 @@ class MessageChannel : HasResultCodes
topCount = curCount;
}
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("NumberOfPendingIPC"),
nsPrintfCString("%zu", q.size()));
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("TopPendingIPCCount"),
nsPrintfCString("%u", topCount));
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("TopPendingIPCName"),
nsPrintfCString("%s(0x%x)", topName, topType));
CrashReporter::AnnotatePendingIPC(q.size(), topCount, topName, topType);
mozalloc_handle_oom(n * sizeof(T));
}

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

@ -579,6 +579,22 @@ void AnnotateTexturesSize(size_t size)
gTexturesSize = size;
}
static size_t gNumOfPendingIPC = 0;
static uint32_t gTopPendingIPCCount = 0;
static const char* gTopPendingIPCName = nullptr;
static uint32_t gTopPendingIPCType = 0;
void AnnotatePendingIPC(size_t aNumOfPendingIPC,
uint32_t aTopPendingIPCCount,
const char* aTopPendingIPCName,
uint32_t aTopPendingIPCType)
{
gNumOfPendingIPC = aNumOfPendingIPC;
gTopPendingIPCCount = aTopPendingIPCCount;
gTopPendingIPCName = aTopPendingIPCName;
gTopPendingIPCType = aTopPendingIPCType;
}
#ifndef XP_WIN
// Like Windows CopyFile for *nix
bool copy_file(const char* from, const char* to)
@ -880,6 +896,19 @@ bool MinidumpCallback(
XP_STOA(gTexturesSize, texturesSizeBuffer, 10);
}
char numOfPendingIPCBuffer[32] = "";
char topPendingIPCCountBuffer[32] = "";
char topPendingIPCTypeBuffer[11] = "0x";
if (gNumOfPendingIPC) {
XP_STOA(gNumOfPendingIPC, numOfPendingIPCBuffer, 10);
if (gTopPendingIPCCount) {
XP_STOA(gTopPendingIPCCount, topPendingIPCCountBuffer, 10);
}
if (gTopPendingIPCType) {
XP_STOA(gTopPendingIPCType, &topPendingIPCTypeBuffer[2], 16);
}
}
// calculate time since last crash (if possible), and store
// the time of this crash.
time_t crashTime;
@ -1028,6 +1057,23 @@ bool MinidumpCallback(
WriteAnnotation(eventFile, "TextureUsage", texturesSizeBuffer);
}
if (numOfPendingIPCBuffer[0]) {
WriteAnnotation(apiData, "NumberOfPendingIPC", numOfPendingIPCBuffer);
WriteAnnotation(eventFile, "NumberOfPendingIPC", numOfPendingIPCBuffer);
if (topPendingIPCCountBuffer[0]) {
WriteAnnotation(apiData, "TopPendingIPCCount", topPendingIPCCountBuffer);
WriteAnnotation(eventFile, "TopPendingIPCCount", topPendingIPCCountBuffer);
}
if (gTopPendingIPCName) {
WriteAnnotation(apiData, "TopPendingIPCName", gTopPendingIPCName);
WriteAnnotation(eventFile, "TopPendingIPCName", gTopPendingIPCName);
}
if (topPendingIPCTypeBuffer[2]) {
WriteAnnotation(apiData, "TopPendingIPCType", topPendingIPCTypeBuffer);
WriteAnnotation(eventFile, "TopPendingIPCType", topPendingIPCTypeBuffer);
}
}
if (memoryReportPath) {
WriteLiteral(apiData, "ContainsMemoryReport=1\n");
WriteLiteral(eventFile, "ContainsMemoryReport=1\n");
@ -1314,6 +1360,32 @@ PrepareChildExceptionTimeAnnotations()
if (gMozCrashReason) {
WriteAnnotation(apiData, "MozCrashReason", gMozCrashReason);
}
char numOfPendingIPCBuffer[32] = "";
char topPendingIPCCountBuffer[32] = "";
char topPendingIPCTypeBuffer[11] = "0x";
if (gNumOfPendingIPC) {
XP_STOA(gNumOfPendingIPC, numOfPendingIPCBuffer, 10);
if (gTopPendingIPCCount) {
XP_STOA(gTopPendingIPCCount, topPendingIPCCountBuffer, 10);
}
if (gTopPendingIPCType) {
XP_STOA(gTopPendingIPCType, &topPendingIPCTypeBuffer[2], 16);
}
}
if (numOfPendingIPCBuffer[0]) {
WriteAnnotation(apiData, "NumberOfPendingIPC", numOfPendingIPCBuffer);
if (topPendingIPCCountBuffer[0]) {
WriteAnnotation(apiData, "TopPendingIPCCount", topPendingIPCCountBuffer);
}
if (gTopPendingIPCName) {
WriteAnnotation(apiData, "TopPendingIPCName", gTopPendingIPCName);
}
if (topPendingIPCTypeBuffer[2]) {
WriteAnnotation(apiData, "TopPendingIPCType", topPendingIPCTypeBuffer);
}
}
}
#ifdef XP_WIN

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

@ -77,11 +77,14 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data);
// as it is intended to be defining this same function.
void AnnotateMozCrashReason(const char* aReason);
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 SetGarbageCollecting(bool collecting);
void SetEventloopNestingLevel(uint32_t level);
void AnnotateTexturesSize(size_t size);
nsresult SetRestartArgs(int argc, char** argv);
nsresult SetupExtraData(nsIFile* aAppDataDirectory,
const nsACString& aBuildID);