summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 04:30:14 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 04:30:14 +0000
commit54823b0f1ec8d65bf64423a64f727bbc8eb023a1 (patch)
treed8cabd5ef2f1413201b930520b923985db5caf25 /base
parent538ddce9c0e36665f2d34b6f7a731407afbcb554 (diff)
downloadchromium_src-54823b0f1ec8d65bf64423a64f727bbc8eb023a1.zip
chromium_src-54823b0f1ec8d65bf64423a64f727bbc8eb023a1.tar.gz
chromium_src-54823b0f1ec8d65bf64423a64f727bbc8eb023a1.tar.bz2
In release mode, trigger a SIGABRT rather than a SIGTRAP for fatal log errors, i.e. CHECK(false). Also enable tests to make sure we assert/crash as expected.
BUG=none TEST=Chrome in release mode generates crash dumps when CHECK() fails. See UI tests: AssertionTest.*:CheckFalseTest.*:RendererCrashTest.* Review URL: http://codereview.chromium.org/830003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/debug_util_posix.cc38
1 files changed, 28 insertions, 10 deletions
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index 0cccd9e..110cb20 100644
--- a/base/debug_util_posix.cc
+++ b/base/debug_util_posix.cc
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "build/build_config.h"
#include "base/debug_util.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/types.h>
@@ -17,13 +17,13 @@
#include <cxxabi.h>
#endif
-#include <iostream>
-#include <string>
-
#if defined(OS_MACOSX)
#include <AvailabilityMacros.h>
#endif
+#include <iostream>
+#include <string>
+
#include "base/basictypes.h"
#include "base/compat_execinfo.h"
#include "base/eintr_wrapper.h"
@@ -172,7 +172,7 @@ bool DebugUtil::BeingDebugged() {
size_t info_size = sizeof(info);
int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0);
- DCHECK(sysctl_result == 0);
+ DCHECK_EQ(sysctl_result, 0);
if (sysctl_result != 0) {
is_set = true;
being_debugged = false;
@@ -229,15 +229,33 @@ bool DebugUtil::BeingDebugged() {
return false;
}
+#endif // defined(OS_FREEBSD)
+
+// We want to break into the debugger in Debug mode, and cause a crash dump in
+// Release mode. Breakpad behaves as follows:
+//
+// +-------+-----------------+-----------------+
+// | OS | Dump on SIGTRAP | Dump on SIGABRT |
+// +-------+-----------------+-----------------+
+// | Linux | N | Y |
+// | Mac | Y | N |
+// +-------+-----------------+-----------------+
+//
+// Thus we do the following:
+// Linux: Debug mode, send SIGTRAP; Release mode, send SIGABRT.
+// Mac: Always send SIGTRAP.
+
+#if defined(NDEBUG) && !defined(OS_MACOSX)
+#define DEBUG_BREAK() abort()
+#elif defined(ARCH_CPU_ARM_FAMILY)
+#define DEBUG_BREAK() asm("bkpt 0")
+#else
+#define DEBUG_BREAK() asm("int3")
#endif
// static
void DebugUtil::BreakDebugger() {
-#if defined(ARCH_CPU_ARM_FAMILY)
- asm("bkpt 0");
-#else
- asm("int3");
-#endif
+ DEBUG_BREAK();
}
StackTrace::StackTrace() {