summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/base.gypi5
-rw-r--r--base/debug/debugger.cc10
-rw-r--r--base/debug/debugger.h8
-rw-r--r--base/debug/debugger_posix.cc2
-rw-r--r--base/debug/debugger_win.cc3
-rw-r--r--base/debug_util.cc7
-rw-r--r--base/debug_util.h36
-rw-r--r--base/mac/os_crash_dumps.cc (renamed from base/debug_util_mac.cc)22
-rw-r--r--base/mac/os_crash_dumps.h20
-rw-r--r--base/process_util_unittest.cc1
-rw-r--r--base/test/test_suite.cc4
11 files changed, 58 insertions, 60 deletions
diff --git a/base/base.gypi b/base/base.gypi
index e7ebe0d..bbb25fc 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -51,9 +51,6 @@
'cpu.h',
'debug_on_start.cc',
'debug_on_start.h',
- 'debug_util.cc',
- 'debug_util.h',
- 'debug_util_mac.cc',
'debug/debugger.cc',
'debug/debugger.h',
'debug/debugger_posix.cc',
@@ -117,6 +114,8 @@
'mac_util.h',
'mac_util.mm',
'mac/cocoa_protocols.h',
+ 'mac/os_crash_dumps.cc',
+ 'mac/os_crash_dumps.h',
'mac/scoped_aedesc.h',
'mac/scoped_cftyperef.h',
'mac/scoped_nsautorelease_pool.h',
diff --git a/base/debug/debugger.cc b/base/debug/debugger.cc
index fb23524..8674f1f 100644
--- a/base/debug/debugger.cc
+++ b/base/debug/debugger.cc
@@ -9,6 +9,8 @@
namespace base {
namespace debug {
+static bool is_debug_ui_suppressed = false;
+
bool WaitForDebugger(int wait_seconds, bool silent) {
for (int i = 0; i < wait_seconds * 10; ++i) {
if (BeingDebugged()) {
@@ -21,5 +23,13 @@ bool WaitForDebugger(int wait_seconds, bool silent) {
return false;
}
+void SetSuppressDebugUI(bool suppress) {
+ is_debug_ui_suppressed = suppress;
+}
+
+bool IsDebugUISuppressed() {
+ return is_debug_ui_suppressed;
+}
+
} // namespace debug
} // namespace base
diff --git a/base/debug/debugger.h b/base/debug/debugger.h
index 008d77d..77bde0d 100644
--- a/base/debug/debugger.h
+++ b/base/debug/debugger.h
@@ -33,6 +33,14 @@ bool BeingDebugged();
// Break into the debugger, assumes a debugger is present.
void BreakDebugger();
+// Used in test code, this controls whether showing dialogs and breaking into
+// the debugger is suppressed for debug errors, even in debug mode (normally
+// release mode doesn't do this stuff -- this is controlled separately).
+// Normally UI is not suppressed. This is normally used when running automated
+// tests where we want a crash rather than a dialog or a debugger.
+void SetSuppressDebugUI(bool suppress);
+bool IsDebugUISuppressed();
+
} // namespace debug
} // namespace base
diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc
index ffa4670d..b865e65 100644
--- a/base/debug/debugger_posix.cc
+++ b/base/debug/debugger_posix.cc
@@ -137,7 +137,7 @@ bool BeingDebugged() {
#elif defined(OS_FREEBSD)
-bool DebugUtil::BeingDebugged() {
+bool BeingDebugged() {
// TODO(benl): can we determine this under FreeBSD?
NOTIMPLEMENTED();
return false;
diff --git a/base/debug/debugger_win.cc b/base/debug/debugger_win.cc
index d1d47cd..3323b61 100644
--- a/base/debug/debugger_win.cc
+++ b/base/debug/debugger_win.cc
@@ -8,7 +8,6 @@
#include <dbghelp.h>
#include "base/basictypes.h"
-#include "base/debug_util.h"
#include "base/logging.h"
namespace base {
@@ -103,7 +102,7 @@ bool BeingDebugged() {
}
void BreakDebugger() {
- if (DebugUtil::AreDialogsSuppressed())
+ if (IsDebugUISuppressed())
_exit(1);
__debugbreak();
}
diff --git a/base/debug_util.cc b/base/debug_util.cc
deleted file mode 100644
index 4773de3..0000000
--- a/base/debug_util.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/debug_util.h"
-
-bool DebugUtil::suppress_dialogs_ = false;
diff --git a/base/debug_util.h b/base/debug_util.h
deleted file mode 100644
index a643ccf..0000000
--- a/base/debug_util.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_DEBUG_UTIL_H_
-#define BASE_DEBUG_UTIL_H_
-#pragma once
-
-#include "build/build_config.h"
-
-class DebugUtil {
- public:
-#if defined(OS_MACOSX)
- // On Mac OS X, it can take a really long time for the OS crash handler to
- // process a Chrome crash when debugging symbols are available. This
- // translates into a long wait until the process actually dies. This call
- // disables Apple Crash Reporter entirely.
- static void DisableOSCrashDumps();
-#endif // defined(OS_MACOSX)
-
- // This should be used only in test code.
- static void SuppressDialogs() {
- suppress_dialogs_ = true;
- }
-
- static bool AreDialogsSuppressed() {
- return suppress_dialogs_;
- }
-
- private:
- // If true, avoid displaying any dialogs that could cause problems
- // in non-interactive environments.
- static bool suppress_dialogs_;
-};
-
-#endif // BASE_DEBUG_UTIL_H_
diff --git a/base/debug_util_mac.cc b/base/mac/os_crash_dumps.cc
index a4eed66..e82fd73 100644
--- a/base/debug_util_mac.cc
+++ b/base/mac/os_crash_dumps.cc
@@ -1,23 +1,29 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/debug_util.h"
+#include "base/mac/os_crash_dumps.h"
#include <signal.h>
#include <unistd.h>
#include "base/basictypes.h"
-static void ExitSignalHandler(int sig) {
+namespace base {
+namespace mac {
+
+namespace {
+
+void ExitSignalHandler(int sig) {
// A call to exit() can call atexit() handlers. If we SIGSEGV due
// to a corrupt heap, and if we have an atexit handler that
// allocates or frees memory, we are in trouble if we do not _exit.
_exit(128 + sig);
}
-// static
-void DebugUtil::DisableOSCrashDumps() {
+} // namespace
+
+void DisableOSCrashDumps() {
// These are the POSIX signals corresponding to the Mach exceptions that
// Apple Crash Reporter handles. See ux_exception() in xnu's
// bsd/uxkern/ux_exception.c and machine_exception() in xnu's
@@ -31,7 +37,9 @@ void DebugUtil::DisableOSCrashDumps() {
};
// For all these signals, just wire things up so we exit immediately.
- for (size_t i = 0; i < arraysize(signals_to_intercept); ++i) {
+ for (size_t i = 0; i < arraysize(signals_to_intercept); ++i)
signal(signals_to_intercept[i], ExitSignalHandler);
- }
}
+
+} // namespace mac
+} // namespace base
diff --git a/base/mac/os_crash_dumps.h b/base/mac/os_crash_dumps.h
new file mode 100644
index 0000000..9758575
--- /dev/null
+++ b/base/mac/os_crash_dumps.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_MAC_OS_CRASH_DUMPS_H_
+#define BASE_MAC_OS_CRASH_DUMPS_H_
+
+namespace base {
+namespace mac {
+
+// On Mac OS X, it can take a really long time for the OS crash handler to
+// process a Chrome crash when debugging symbols are available. This
+// translates into a long wait until the process actually dies. This call
+// disables Apple Crash Reporter entirely.
+void DisableOSCrashDumps();
+
+} // namespace mac
+} // namespace base
+
+#endif // BASE_MAC_OS_CRASH_DUMPS_H_
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index fd05c23..672e396 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -7,7 +7,6 @@
#include <limits>
#include "base/command_line.h"
-#include "base/debug_util.h"
#include "base/eintr_wrapper.h"
#include "base/file_path.h"
#include "base/logging.h"
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 7d25a60..2cfaa4b 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -9,8 +9,6 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug_on_start.h"
-#include "base/debug_util.h"
-#include "base/debug/debugger.h"
#include "base/debug/debugger.h"
#include "base/file_path.h"
#include "base/i18n/icu_util.h"
@@ -196,7 +194,7 @@ void TestSuite::Initialize() {
if (!base::debug::BeingDebugged() &&
!CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) {
SuppressErrorDialogs();
- DebugUtil::SuppressDialogs();
+ base::debug::SetSuppressDebugUI(true);
logging::SetLogAssertHandler(UnitTestAssertHandler);
}