Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1126)

Side by Side Diff: chrome/browser/hang_monitor/hang_crash_dump_win.cc

Issue 2088133002: Switch chrome_elf exception handling from breakpad to crashpad. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" 5 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/common/chrome_constants.h" 8 #include "chrome/common/chrome_constants.h"
9 #include "content/public/common/result_codes.h" 9 #include "content/public/common/result_codes.h"
10 10
11 namespace { 11 namespace {
12 12
13 // How long do we wait for the terminated thread or process to die (in ms) 13 // How long do we wait for the terminated thread or process to die (in ms)
14 static const int kTerminateTimeoutMS = 2000; 14 static const int kTerminateTimeoutMS = 2000;
15 15
16 // How long do we wait for the crash to be generated (in ms). 16 // How long do we wait for the crash to be generated (in ms).
17 static const int kGenerateDumpTimeoutMS = 10000; 17 static const int kGenerateDumpTimeoutMS = 10000;
18 18
19 } // namespace 19 } // namespace
20 20
21 void CrashDumpAndTerminateHungChildProcess(HANDLE hprocess) { 21 void CrashDumpAndTerminateHungChildProcess(HANDLE hprocess) {
22 // Before terminating the process we try collecting a dump. Which 22 // Before terminating the process we try collecting a dump. Which
23 // a transient thread in the child process will do for us. 23 // a transient thread in the child process will do for us.
24 typedef HANDLE (__cdecl *DumpFunction)(HANDLE); 24 typedef HANDLE (__cdecl *DumpFunction)(HANDLE);
25 static DumpFunction request_dump = NULL; 25 static DumpFunction request_dump = NULL;
26 if (!request_dump) { 26 if (!request_dump) {
27 request_dump = reinterpret_cast<DumpFunction>(GetProcAddress( 27 request_dump = reinterpret_cast<DumpFunction>(GetProcAddress(
28 GetModuleHandle(chrome::kBrowserProcessExecutableName), 28 GetModuleHandle(chrome::kChromeElfDllName),
29 "InjectDumpProcessWithoutCrash")); 29 "InjectDumpProcessWithoutCrash"));
30 DCHECK(request_dump) << "Failed loading DumpProcessWithoutCrash: error " << 30 DCHECK(request_dump) << "Failed loading DumpProcessWithoutCrash: error " <<
31 GetLastError(); 31 GetLastError();
32 } 32 }
33 33
34 if (request_dump) { 34 if (request_dump) {
35 HANDLE remote_thread = request_dump(hprocess); 35 HANDLE remote_thread = request_dump(hprocess);
36 DCHECK(remote_thread) << "Failed creating remote thread: error " << 36 DCHECK(remote_thread) << "Failed creating remote thread: error " <<
37 GetLastError(); 37 GetLastError();
38 if (remote_thread) { 38 if (remote_thread) {
39 WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS); 39 WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS);
40 CloseHandle(remote_thread); 40 CloseHandle(remote_thread);
41 } 41 }
42 } 42 }
43 43
44 TerminateProcess(hprocess, content::RESULT_CODE_HUNG); 44 TerminateProcess(hprocess, content::RESULT_CODE_HUNG);
45 WaitForSingleObject(hprocess, kTerminateTimeoutMS); 45 WaitForSingleObject(hprocess, kTerminateTimeoutMS);
46 } 46 }
47 47
48 void CrashDumpForHangDebugging(HANDLE hprocess) { 48 void CrashDumpForHangDebugging(HANDLE hprocess) {
49 if (hprocess == GetCurrentProcess()) { 49 if (hprocess == GetCurrentProcess()) {
50 typedef void (__cdecl *DumpFunction)(); 50 typedef void (__cdecl *DumpFunction)();
51 DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress( 51 DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress(
52 GetModuleHandle(chrome::kBrowserProcessExecutableName), 52 GetModuleHandle(chrome::kChromeElfDllName),
53 "DumpProcessWithoutCrash")); 53 "DumpProcessWithoutCrash"));
54 DCHECK(request_dump) << "Failed loading DumpProcessWithoutCrash: error " << 54 DCHECK(request_dump) << "Failed loading DumpProcessWithoutCrash: error " <<
55 GetLastError(); 55 GetLastError();
56 if (request_dump) 56 if (request_dump)
57 request_dump(); 57 request_dump();
58 } else { 58 } else {
59 typedef HANDLE (__cdecl *DumpFunction)(HANDLE); 59 typedef HANDLE (__cdecl *DumpFunction)(HANDLE);
60 DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress( 60 DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress(
61 GetModuleHandle(chrome::kBrowserProcessExecutableName), 61 GetModuleHandle(chrome::kChromeElfDllName),
62 "InjectDumpForHangDebugging")); 62 "InjectDumpForHangDebugging"));
63 DCHECK(request_dump) << "Failed loading InjectDumpForHangDebugging: error " 63 DCHECK(request_dump) << "Failed loading InjectDumpForHangDebugging: error "
64 << GetLastError(); 64 << GetLastError();
65 if (request_dump) { 65 if (request_dump) {
66 HANDLE remote_thread = request_dump(hprocess); 66 HANDLE remote_thread = request_dump(hprocess);
67 DCHECK(remote_thread) << "Failed creating remote thread: error " << 67 DCHECK(remote_thread) << "Failed creating remote thread: error " <<
68 GetLastError(); 68 GetLastError();
69 if (remote_thread) { 69 if (remote_thread) {
70 WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS); 70 WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS);
71 CloseHandle(remote_thread); 71 CloseHandle(remote_thread);
72 } 72 }
73 } 73 }
74 } 74 }
75 } 75 }
OLDNEW
« no previous file with comments | « chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698