Bug 1277448 patch 4 - Send a MozCrashReason annotation for NS_RUNTIMEABORT instead of AbortMessage. r?froydnj
This excludes the PID and the line number that are present in the
AbortMessage annotation, and formats the annotation somewhat
consistently with other MozCrashReason annotations. (It adds file and
function name information that is not present in them; the file
information will added to them in patch 5, but I don't see how to add
the function information to them.)
This uses the same printing mechanism already used in this function so
that we don't add any additional crashing risk by using the heap.
This removes the AbortMessage annotation and the xpcom_runtime_abort()
note. However, these were only present in crashes in the parent
process; MozCrashReason shows up for child process crashes as well. It
therefore moves to a more reliable and single way to find and search for
the abort messages in crash-stats.
MozReview-Commit-ID: AI6Iw2KsFAZ
--- a/toolkit/crashreporter/test/unit/test_crash_runtimeabort.js
+++ b/toolkit/crashreporter/test/unit/test_crash_runtimeabort.js
@@ -7,15 +7,14 @@ function run_test()
// Try crashing with a runtime abort
do_crash(function() {
crashType = CrashTestUtils.CRASH_RUNTIMEABORT;
crashReporter.annotateCrashReport("TestKey", "TestValue");
},
function(mdump, extra) {
do_check_eq(extra.TestKey, "TestValue");
- do_check_true(/xpcom_runtime_abort/.test(extra.Notes));
do_check_false("OOMAllocationSize" in extra);
- do_check_true(/Intentional crash/.test(extra.AbortMessage));
+ do_check_true(/^NS_RUNTIMEABORT\(Intentional crash\), file .*\/toolkit\/crashreporter\/test\/nsTestCrasher.cpp, function Crash$/.test(extra.MozCrashReason));
},
// process will exit with a zero exit status
true);
}
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -385,27 +385,37 @@ NS_DebugBreak(uint32_t aSeverity, const
return;
case NS_DEBUG_BREAK:
Break(buf.buffer);
return;
case NS_DEBUG_ABORT: {
#if defined(MOZ_CRASHREPORTER)
- // Updating crash annotations in the child causes us to do IPC. This can
- // really cause trouble if we're asserting from within IPC code. So we
- // have to do without the annotations in that case.
- if (XRE_IsParentProcess()) {
- nsCString note("xpcom_runtime_abort(");
- note += buf.buffer;
- note += ")";
- CrashReporter::AppendAppNotesToCrashReport(note);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"),
- nsDependentCString(buf.buffer));
+ FixedBuffer crashReasonBuffer;
+#define PrintToBuffer(...) \
+ PR_sxprintf(StuffFixedBuffer, &crashReasonBuffer, __VA_ARGS__)
+
+ PrintToBuffer("NS_RUNTIMEABORT(");
+ if (aStr) {
+ PrintToBuffer("%s", aStr);
+ }
+ if (aExpr) {
+ PrintToBuffer(": '%s', ", aExpr);
}
+ PrintToBuffer(")");
+ if (aFile) {
+ PrintToBuffer(", file %s", aFile);
+ }
+ if (aFunction) {
+ PrintToBuffer(", function %s", aFunction);
+ }
+#undef PrintToBuffer
+
+ CrashReporter::AnnotateMozCrashReason(crashReasonBuffer.buffer);
#endif // MOZ_CRASHREPORTER
#if defined(DEBUG) && defined(_WIN32)
RealBreak();
#endif
#if defined(DEBUG)
nsTraceRefcnt::WalkTheStack(stderr);
#endif