diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-18 17:42:27 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-18 17:42:27 +0000 |
commit | 5a8d4ce29f346d9fe2435d17c375e2ddb6fe6123 (patch) | |
tree | 99c554aab7548aac08323e96b97b261c2fe6e714 /base | |
parent | b8b2dbebdf0d28db0f162eadb2c3838ac7b8a088 (diff) | |
download | chromium_src-5a8d4ce29f346d9fe2435d17c375e2ddb6fe6123.zip chromium_src-5a8d4ce29f346d9fe2435d17c375e2ddb6fe6123.tar.gz chromium_src-5a8d4ce29f346d9fe2435d17c375e2ddb6fe6123.tar.bz2 |
Move DumpProcessWithoutCrash to base, so we can use it from net and content
BUG=none
R=mark@chromium.org
TBR=wez@chromium.org
Review URL: https://codereview.chromium.org/99523009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 2 | ||||
-rw-r--r-- | base/compiler_specific.h | 9 | ||||
-rw-r--r-- | base/debug/dump_without_crashing.cc | 32 | ||||
-rw-r--r-- | base/debug/dump_without_crashing.h | 27 | ||||
-rw-r--r-- | base/native_library.h | 8 |
5 files changed, 71 insertions, 7 deletions
diff --git a/base/base.gypi b/base/base.gypi index 11edab0..60ff4f2 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -137,6 +137,8 @@ 'debug/debugger.h', 'debug/debugger_posix.cc', 'debug/debugger_win.cc', + 'debug/dump_without_crashing.cc', + 'debug/dump_without_crashing.h', # This file depends on files from the 'allocator' target, # but this target does not depend on 'allocator' (see # allocator.gyp for details). diff --git a/base/compiler_specific.h b/base/compiler_specific.h index dc4b233..09b4e70 100644 --- a/base/compiler_specific.h +++ b/base/compiler_specific.h @@ -211,4 +211,13 @@ void __msan_unpoison(const void *p, unsigned long s); #define MSAN_UNPOISON(p, s) #endif // MEMORY_SANITIZER +// Macro useful for writing cross-platform function pointers. +#if !defined(CDECL) +#if defined(OS_WIN) +#define CDECL __cdecl +#else // defined(OS_WIN) +#define CDECL +#endif // defined(OS_WIN) +#endif // !defined(CDECL) + #endif // BASE_COMPILER_SPECIFIC_H_ diff --git a/base/debug/dump_without_crashing.cc b/base/debug/dump_without_crashing.cc new file mode 100644 index 0000000..47fd873 --- /dev/null +++ b/base/debug/dump_without_crashing.cc @@ -0,0 +1,32 @@ +// Copyright 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 "base/debug/dump_without_crashing.h" + +#include "base/logging.h" + +namespace { + +// Pointer to the function that's called by DumpWithoutCrashing() to dump the +// process's memory. +void (CDECL *dump_without_crashing_function_)() = NULL; + +} // namespace + +namespace base { + +namespace debug { + +void DumpWithoutCrashing() { + if (dump_without_crashing_function_) + (*dump_without_crashing_function_)(); +} + +void SetDumpWithoutCrashingFunction(void (CDECL *function)()) { + dump_without_crashing_function_ = function; +} + +} // namespace debug + +} // namespace base diff --git a/base/debug/dump_without_crashing.h b/base/debug/dump_without_crashing.h new file mode 100644 index 0000000..c46f446 --- /dev/null +++ b/base/debug/dump_without_crashing.h @@ -0,0 +1,27 @@ +// Copyright 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 BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_ +#define BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_ + +#include "base/base_export.h" +#include "base/compiler_specific.h" +#include "build/build_config.h" + +namespace base { + +namespace debug { + +// Handler to silently dump the current process without crashing. +BASE_EXPORT void DumpWithoutCrashing(); + +// Sets a function that'll be invoked to dump the current process when +// DumpWithoutCrashing() is called. +BASE_EXPORT void SetDumpWithoutCrashingFunction(void (CDECL *function)()); + +} // namespace debug + +} // namespace base + +#endif // BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_ diff --git a/base/native_library.h b/base/native_library.h index 891f35b..9353b1f 100644 --- a/base/native_library.h +++ b/base/native_library.h @@ -9,6 +9,7 @@ // a loadable module. #include "base/base_export.h" +#include "base/compiler_specific.h" #include "build/build_config.h" #if defined(OS_WIN) @@ -19,13 +20,6 @@ #include "base/strings/string16.h" -// Macro useful for writing cross-platform function pointers. -#if defined(OS_WIN) && !defined(CDECL) -#define CDECL __cdecl -#else -#define CDECL -#endif - namespace base { class FilePath; |