Bug 1183355 - Annotate crash reports triggered by MOZ_CRASH in release builds, r=froydnj

This commit is contained in:
Michael Layzell 2015-09-29 11:14:50 -04:00
parent 840c45ae20
commit e4681ea6a5
3 changed files with 41 additions and 1 deletions

View File

@ -21,6 +21,20 @@
#include "nsTraceRefcnt.h"
#endif
#if defined(MOZ_CRASHREPORTER) && defined(MOZILLA_INTERNAL_API) && \
!defined(MOZILLA_EXTERNAL_LINKAGE) && defined(__cplusplus)
# define MOZ_CRASH_CRASHREPORT
namespace CrashReporter {
// This declaration is present here as well as in nsExceptionHandler.h
// nsExceptionHandler.h is not directly included in this file as it includes
// windows.h, which can cause problems when it is imported into some files due
// to the number of macros defined.
// XXX If you change this definition - also change the definition in
// nsExceptionHandler.h
void AnnotateMozCrashReason(const char* aReason);
} // namespace CrashReporter
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@ -249,7 +263,15 @@ __declspec(noreturn) __inline void MOZ_NoReturn() {}
* corrupted.
*/
#ifndef DEBUG
# define MOZ_CRASH(...) MOZ_REALLY_CRASH()
# ifdef MOZ_CRASH_CRASHREPORT
# define MOZ_CRASH(...) \
do { \
CrashReporter::AnnotateMozCrashReason("MOZ_CRASH(" __VA_ARGS__ ")"); \
MOZ_REALLY_CRASH(); \
} while (0)
# else
# define MOZ_CRASH(...) MOZ_REALLY_CRASH()
# endif
#else
# define MOZ_CRASH(...) \
do { \
@ -509,5 +531,6 @@ struct AssertionConditionType
#endif
#undef MOZ_DUMP_ASSERTION_STACK
#undef MOZ_CRASH_CRASHREPORT
#endif /* mozilla_Assertions_h */

View File

@ -185,6 +185,7 @@ static char const * const kCrashEventAnnotations[] = {
// "TotalPageFile"
// "TotalPhysicalMemory"
// "TotalVirtualMemory"
// "MozCrashReason"
};
static const char kCrashMainID[] = "crash.main.2\n";
@ -453,6 +454,13 @@ Concat(XP_CHAR* str, const XP_CHAR* toAppend, int* size)
return str;
}
static const char* gMozCrashReason = nullptr;
void AnnotateMozCrashReason(const char* aReason)
{
gMozCrashReason = aReason;
}
static size_t gOOMAllocationSize = 0;
void AnnotateOOMAllocationSize(size_t size)
@ -841,6 +849,12 @@ bool MinidumpCallback(
#undef WRITE_STATEX_FIELD
}
#endif // XP_WIN
if (gMozCrashReason) {
WriteAnnotation(apiData, "MozCrashReason", gMozCrashReason);
WriteAnnotation(eventFile, "MozCrashReason", gMozCrashReason);
}
if (oomAllocationSizeBuffer[0]) {
WriteAnnotation(apiData, "OOMAllocationSize", oomAllocationSizeBuffer);
WriteAnnotation(eventFile, "OOMAllocationSize", oomAllocationSizeBuffer);

View File

@ -71,6 +71,9 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data);
nsresult RemoveCrashReportAnnotation(const nsACString& key);
nsresult AppendAppNotesToCrashReport(const nsACString& data);
// NOTE: If you change this definition, also change the definition in Assertions.h
// as it is intended to be defining this same function.
void AnnotateMozCrashReason(const char* aReason);
void AnnotateOOMAllocationSize(size_t size);
nsresult SetGarbageCollecting(bool collecting);
void SetEventloopNestingLevel(uint32_t level);