Commit f0e90cf9 authored by wfh@chromium.org's avatar wfh@chromium.org

Set dump_without_crashing_function_ in chrome.dll with value of exported...

Set dump_without_crashing_function_ in chrome.dll with value of exported chrome!DumpProcessWithoutCrash.

BUG=391974
TEST=chrome://crashdump and verify crash dump appears and tab does not crash
TBR=darin@chromium.org

Review URL: https://codereview.chromium.org/371073003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284448 0039d316-1c4b-4281-b951-d872f2087c98
parent 48728ff5
...@@ -14,6 +14,9 @@ namespace base { ...@@ -14,6 +14,9 @@ namespace base {
namespace debug { namespace debug {
// Handler to silently dump the current process without crashing. // Handler to silently dump the current process without crashing.
// Before calling this function, call SetDumpWithoutCrashingFunction to pass a
// function pointer, typically chrome!DumpProcessWithoutCrash. See example code
// in chrome_main.cc that does this for chrome.dll.
BASE_EXPORT void DumpWithoutCrashing(); BASE_EXPORT void DumpWithoutCrashing();
// Sets a function that'll be invoked to dump the current process when // Sets a function that'll be invoked to dump the current process when
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#include "content/public/app/content_main.h" #include "content/public/app/content_main.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/debug/dump_without_crashing.h"
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "chrome/common/chrome_constants.h"
#define DLLEXPORT __declspec(dllexport) #define DLLEXPORT __declspec(dllexport)
...@@ -38,6 +40,15 @@ int ChromeMain(int argc, const char** argv) { ...@@ -38,6 +40,15 @@ int ChromeMain(int argc, const char** argv) {
base::win::SetAbortBehaviorForCrashReporting(); base::win::SetAbortBehaviorForCrashReporting();
params.instance = instance; params.instance = instance;
params.sandbox_info = sandbox_info; params.sandbox_info = sandbox_info;
// SetDumpWithoutCrashingFunction must be passed the DumpProcess function
// from the EXE and not from the DLL in order for DumpWithoutCrashing to
// function correctly.
typedef void (__cdecl *DumpProcessFunction)();
DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName),
"DumpProcessWithoutCrash"));
base::debug::SetDumpWithoutCrashingFunction(DumpProcess);
#else #else
params.argc = argc; params.argc = argc;
params.argv = argv; params.argv = argv;
......
...@@ -668,6 +668,7 @@ const size_t kNumberOfChromeHostURLs = arraysize(kChromeHostURLs); ...@@ -668,6 +668,7 @@ const size_t kNumberOfChromeHostURLs = arraysize(kChromeHostURLs);
const char* const kChromeDebugURLs[] = { const char* const kChromeDebugURLs[] = {
content::kChromeUICrashURL, content::kChromeUICrashURL,
content::kChromeUIDumpURL,
content::kChromeUIKillURL, content::kChromeUIKillURL,
content::kChromeUIHangURL, content::kChromeUIHangURL,
content::kChromeUIShorthangURL, content::kChromeUIShorthangURL,
......
...@@ -573,6 +573,10 @@ void InitCrashReporter(const std::string& process_type_switch) { ...@@ -573,6 +573,10 @@ void InitCrashReporter(const std::string& process_type_switch) {
google_breakpad::ExceptionHandler::HANDLER_NONE, google_breakpad::ExceptionHandler::HANDLER_NONE,
dump_type, pipe_name.c_str(), custom_info); dump_type, pipe_name.c_str(), custom_info);
// Set the DumpWithoutCrashingFunction for this instance of base.lib. Other
// executable images linked with base should set this again for
// DumpWithoutCrashing to function correctly.
// See chrome_main.cc for example.
base::debug::SetDumpWithoutCrashingFunction(&DumpProcessWithoutCrash); base::debug::SetDumpWithoutCrashingFunction(&DumpProcessWithoutCrash);
if (g_breakpad->IsOutOfProcess()) { if (g_breakpad->IsOutOfProcess()) {
......
...@@ -174,6 +174,7 @@ bool IsRendererDebugURL(const GURL& url) { ...@@ -174,6 +174,7 @@ bool IsRendererDebugURL(const GURL& url) {
return true; return true;
return url == GURL(kChromeUICrashURL) || return url == GURL(kChromeUICrashURL) ||
url == GURL(kChromeUIDumpURL) ||
url == GURL(kChromeUIKillURL) || url == GURL(kChromeUIKillURL) ||
url == GURL(kChromeUIHangURL) || url == GURL(kChromeUIHangURL) ||
url == GURL(kChromeUIShorthangURL); url == GURL(kChromeUIShorthangURL);
......
...@@ -33,6 +33,7 @@ const char kChromeUITracingHost[] = "tracing"; ...@@ -33,6 +33,7 @@ const char kChromeUITracingHost[] = "tracing";
const char kChromeUIWebRTCInternalsHost[] = "webrtc-internals"; const char kChromeUIWebRTCInternalsHost[] = "webrtc-internals";
const char kChromeUICrashURL[] = "chrome://crash"; const char kChromeUICrashURL[] = "chrome://crash";
const char kChromeUIDumpURL[] = "chrome://crashdump";
const char kChromeUIGpuCleanURL[] = "chrome://gpuclean"; const char kChromeUIGpuCleanURL[] = "chrome://gpuclean";
const char kChromeUIGpuCrashURL[] = "chrome://gpucrash"; const char kChromeUIGpuCrashURL[] = "chrome://gpucrash";
const char kChromeUIGpuHangURL[] = "chrome://gpuhang"; const char kChromeUIGpuHangURL[] = "chrome://gpuhang";
......
...@@ -42,6 +42,7 @@ CONTENT_EXPORT extern const char kChromeUIWebRTCInternalsHost[]; ...@@ -42,6 +42,7 @@ CONTENT_EXPORT extern const char kChromeUIWebRTCInternalsHost[];
// Full about URLs (including schemes). // Full about URLs (including schemes).
CONTENT_EXPORT extern const char kChromeUICrashURL[]; CONTENT_EXPORT extern const char kChromeUICrashURL[];
CONTENT_EXPORT extern const char kChromeUIDumpURL[];
CONTENT_EXPORT extern const char kChromeUIGpuCleanURL[]; CONTENT_EXPORT extern const char kChromeUIGpuCleanURL[];
CONTENT_EXPORT extern const char kChromeUIGpuCrashURL[]; CONTENT_EXPORT extern const char kChromeUIGpuCrashURL[];
CONTENT_EXPORT extern const char kChromeUIGpuHangURL[]; CONTENT_EXPORT extern const char kChromeUIGpuHangURL[];
......
...@@ -289,6 +289,12 @@ static void MaybeHandleDebugURL(const GURL& url) { ...@@ -289,6 +289,12 @@ static void MaybeHandleDebugURL(const GURL& url) {
return; return;
if (url == GURL(kChromeUICrashURL)) { if (url == GURL(kChromeUICrashURL)) {
CrashIntentionally(); CrashIntentionally();
} else if (url == GURL(kChromeUIDumpURL)) {
// This URL will only correctly create a crash dump file if content is
// hosted in a process that has correctly called
// base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation
// of base::debug::DumpWithoutCrashing for more details.
base::debug::DumpWithoutCrashing();
} else if (url == GURL(kChromeUIKillURL)) { } else if (url == GURL(kChromeUIKillURL)) {
base::KillProcess(base::GetCurrentProcessHandle(), 1, false); base::KillProcess(base::GetCurrentProcessHandle(), 1, false);
} else if (url == GURL(kChromeUIHangURL)) { } else if (url == GURL(kChromeUIHangURL)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment