summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 03:37:27 +0000
committermseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 03:37:27 +0000
commitfe69aa149a0f3f024e76ebd44b3ac450d9e39288 (patch)
tree33e75e557c0b74c5240d5e9d59dddac22f37bb08
parentfa8daeb6036e44f07f7c62b18cff112c3c4bff21 (diff)
downloadchromium_src-fe69aa149a0f3f024e76ebd44b3ac450d9e39288.zip
chromium_src-fe69aa149a0f3f024e76ebd44b3ac450d9e39288.tar.gz
chromium_src-fe69aa149a0f3f024e76ebd44b3ac450d9e39288.tar.bz2
Split DumpWithoutCrashing() into a separate file
This will allow nacl_helper to link against breakpad_linux.cc (which calls SetDumpWithoutCrashingFunction()) without pulling in the rest of logging_chrome.cc, which depends on logging code generated for all IPC messages which we don't want to pull into nacl_helper. BUG=https://code.google.com/p/nativeclient/issues/detail?id=2096 TEST=build Review URL: https://chromiumcodereview.appspot.com/12090096 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180057 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad_linux.cc1
-rw-r--r--chrome/app/breakpad_mac.mm1
-rw-r--r--chrome/browser/metrics/thread_watcher.cc1
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/dump_without_crashing.cc50
-rw-r--r--chrome/common/dump_without_crashing.h23
-rw-r--r--chrome/common/logging_chrome.cc33
-rw-r--r--chrome/common/logging_chrome.h9
8 files changed, 80 insertions, 40 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 0643993..b2b5b0d 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -41,6 +41,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info_posix.h"
+#include "chrome/common/dump_without_crashing.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h"
#include "content/public/common/content_descriptors.h"
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm
index 063da35..03198bb 100644
--- a/chrome/app/breakpad_mac.mm
+++ b/chrome/app/breakpad_mac.mm
@@ -28,6 +28,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/crash_keys.h"
+#include "chrome/common/dump_without_crashing.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/installer/util/google_update_settings.h"
diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc
index 8b75c3f..069e033 100644
--- a/chrome/browser/metrics/thread_watcher.cc
+++ b/chrome/browser/metrics/thread_watcher.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/dump_without_crashing.h"
#include "chrome/common/logging_chrome.h"
#if defined(OS_WIN)
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 955ea52..2df901f 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -131,6 +131,8 @@
'common/custom_handlers/protocol_handler.cc',
'common/custom_handlers/protocol_handler.h',
'common/descriptors_android.h',
+ 'common/dump_without_crashing.cc',
+ 'common/dump_without_crashing.h',
'common/extensions/api/commands/commands_handler.cc',
'common/extensions/api/commands/commands_handler.h',
'common/extensions/api/extension_action/browser_action_handler.cc',
diff --git a/chrome/common/dump_without_crashing.cc b/chrome/common/dump_without_crashing.cc
new file mode 100644
index 0000000..8c692e4
--- /dev/null
+++ b/chrome/common/dump_without_crashing.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 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 "build/build_config.h"
+
+#include "chrome/common/dump_without_crashing.h"
+
+#include "chrome/common/chrome_constants.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
+namespace {
+
+#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
+// Pointer to the function that's called by DumpWithoutCrashing() to dump the
+// process's memory.
+void (*dump_without_crashing_function_)() = NULL;
+#endif
+
+} // namespace
+
+namespace logging {
+
+void DumpWithoutCrashing() {
+#if defined(OS_WIN)
+ // Get the breakpad pointer from chrome.exe
+ typedef void (__cdecl *DumpProcessFunction)();
+ DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
+ ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName),
+ "DumpProcess"));
+ if (DumpProcess)
+ DumpProcess();
+#elif defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
+ if (dump_without_crashing_function_)
+ (*dump_without_crashing_function_)();
+#else
+ NOTIMPLEMENTED();
+#endif
+}
+
+#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
+void SetDumpWithoutCrashingFunction(void (*function)()) {
+ dump_without_crashing_function_ = function;
+}
+#endif
+
+} // namespace logging
diff --git a/chrome/common/dump_without_crashing.h b/chrome/common/dump_without_crashing.h
new file mode 100644
index 0000000..fdf6e07
--- /dev/null
+++ b/chrome/common/dump_without_crashing.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2013 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 CHROME_COMMON_DUMP_WITHOUT_CRASHING_H_
+#define CHROME_COMMON_DUMP_WITHOUT_CRASHING_H_
+
+#include "build/build_config.h"
+
+namespace logging {
+
+// Handler to silently dump the current process without crashing.
+void DumpWithoutCrashing();
+
+#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
+// Sets a function that'll be invoked to dump the current process when
+// DumpWithoutCrashing() is called.
+void SetDumpWithoutCrashingFunction(void (*function)());
+#endif
+
+} // namespace logging
+
+#endif // CHROME_COMMON_DUMP_WITHOUT_CRASHING_H_
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index f738c3f..3b2e579 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -47,6 +47,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/dump_without_crashing.h"
#include "chrome/common/env_vars.h"
#include "ipc/ipc_logging.h"
@@ -78,12 +79,6 @@ const GUID kChromeTraceProviderName = {
{ 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } };
#endif
-#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
-// Pointer to the function that's called by DumpWithoutCrashing() to dump the
-// process's memory.
-void (*dump_without_crashing_function_)() = NULL;
-#endif
-
// Assertion handler for logging errors that occur when dialogs are
// silenced. To record a new error, pass the log string associated
// with that error in the str parameter.
@@ -97,13 +92,7 @@ void SilentRuntimeReportHandler(const std::string& str) {
// Handler to silently dump the current process when there is an assert in
// chrome.
void DumpProcessAssertHandler(const std::string& str) {
- // Get the breakpad pointer from chrome.exe
- typedef void (__cdecl *DumpProcessFunction)();
- DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
- ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName),
- "DumpProcess"));
- if (DumpProcess)
- DumpProcess();
+ logging::DumpWithoutCrashing();
}
#endif // OS_WIN
MSVC_ENABLE_OPTIMIZE();
@@ -443,24 +432,6 @@ size_t GetFatalAssertions(AssertionList* assertions) {
return assertion_count;
}
-void DumpWithoutCrashing() {
-#if defined(OS_WIN)
- std::string str;
- DumpProcessAssertHandler(str);
-#elif defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
- if (dump_without_crashing_function_)
- (*dump_without_crashing_function_)();
-#else
- NOTIMPLEMENTED();
-#endif
-}
-
-#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
-void SetDumpWithoutCrashingFunction(void (*function)()) {
- dump_without_crashing_function_ = function;
-}
-#endif
-
FilePath GenerateTimestampedName(const FilePath& base_path,
base::Time timestamp) {
base::Time::Exploded time_deets;
diff --git a/chrome/common/logging_chrome.h b/chrome/common/logging_chrome.h
index a0d2d0d..dee2533 100644
--- a/chrome/common/logging_chrome.h
+++ b/chrome/common/logging_chrome.h
@@ -62,15 +62,6 @@ typedef std::vector<std::wstring> AssertionList;
// the program writing the log has terminated.
size_t GetFatalAssertions(AssertionList* assertions);
-// Handler to silently dump the current process without crashing.
-void DumpWithoutCrashing();
-
-#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX)
-// Sets a function that'll be invoked to dump the current process when
-// DumpWithoutCrashing() is called.
-void SetDumpWithoutCrashingFunction(void (*function)());
-#endif
-
// Inserts timestamp before file extension in the format
// "_yymmdd-hhmmss".
FilePath GenerateTimestampedName(const FilePath& base_path,