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

This commit is contained in:
Michael Layzell 2015-07-13 17:29:40 -04:00
parent e61511e53b
commit 3103a27863
2 changed files with 40 additions and 1 deletions

View File

@ -21,6 +21,16 @@
#include "nsTraceRefcnt.h"
#endif
// In libraries where the user wants to enable crash reporting when MOZ_CRASH is enabled,
// MOZ_CRASH_CRASHREPORT must be defined, and the MOZ_ReportMozCrashToCrashReporter method
// must be provided by the library. This ifdef defines the macro within libXUL, when
// MOZ_CRASHREPORTER is enabled. The implementation of MOZ_ReportMozCrashToCrashReporter
// for libXUL is defined in /toolkit/xre/nsAppRunner.cpp
#if defined(MOZ_CRASHREPORTER) && defined(MOZILLA_INTERNAL_API) && \
!defined(MOZILLA_EXTERNAL_LINKAGE)
# define MOZ_CRASH_CRASHREPORT
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@ -123,6 +133,15 @@ __declspec(dllimport) void* __stdcall GetCurrentProcess(void);
extern "C" {
#endif
#ifdef MOZ_CRASH_CRASHREPORT
/*
* Associates the given string with a crash report. This function must be
* provided by the library which mfbt is being used in if MOZ_CRASH_CRASHREPORT
* is defined (by default, MOZ_CRASH_CRASHREPORT is only defined in libXUL).
*/
void MOZ_ReportMozCrashToCrashReporter(const char* aStr);
#endif // MOZ_CRASH_CRASHREPORT
/*
* Prints |aStr| as an assertion failure (using aFilename and aLine as the
* location of the assertion) to the standard debug-output channel.
@ -249,7 +268,15 @@ __declspec(noreturn) __inline void MOZ_NoReturn() {}
* corrupted.
*/
#ifndef DEBUG
# define MOZ_CRASH(...) MOZ_REALLY_CRASH()
# ifdef MOZ_CRASH_CRASHREPORT
# define MOZ_CRASH(...) \
do { \
MOZ_ReportMozCrashToCrashReporter("" __VA_ARGS__); \
MOZ_REALLY_CRASH(); \
} while (0)
# else
# define MOZ_CRASH(...) MOZ_REALLY_CRASH()
# endif
#else
# define MOZ_CRASH(...) \
do { \
@ -509,5 +536,6 @@ struct AssertionConditionType
#endif
#undef MOZ_DUMP_ASSERTION_STACK
#undef MOZ_CRASH_CRASHREPORT
#endif /* mozilla_Assertions_h */

View File

@ -193,6 +193,17 @@
#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
#include "nsIPrefService.h"
#include "nsIMemoryInfoDumper.h"
// Provide MOZ_ReportMozCrashToCrashReporter for reporting MOZ_CRASH errors
// See /mfbt/Assertions.h for more information
extern "C" {
void
MOZ_ReportMozCrashToCrashReporter(const char* aStr)
{
nsDependentCString msg(aStr);
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("MOZ_CRASH"), msg);
}
}
#endif
#include "base/command_line.h"