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

Side by Side Diff: chrome_elf/breakpad.cc

Issue 154653002: Breakpad coverage for chrome_elf start up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More breakpad, less base Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This module contains the necessary code to register the Breakpad exception
6 // handler. This implementation is based on Chrome crash reporting code.
7
8 #include "chrome_elf/breakpad.h"
9
10 #include <string>
11
12 #include "base/macros.h"
13 #include "version.h" // NOLINT
14
15 google_breakpad::ExceptionHandler* g_elf_breakpad;
16
17 namespace {
18
19 const wchar_t kBreakpadProductName[] = L"ChromeElf";
20 const wchar_t kBreakpadVersionEntry[] = L"ver";
21 const wchar_t kBreakpadVersionDefault[] = L"0.1.0.0";
22 const wchar_t kBreakpadProdEntry[] = L"prod";
23 const wchar_t kBreakpadPlatformEntry[] = L"plat";
24 const wchar_t kBreakpadPlatformWin32[] = L"Win32";
25
26 // TODO(caitkp): figure out what these should be. Current pipe works with local
27 // instance of crash_service.exe.
28 // The protocol for connecting to the out-of-process Breakpad crash
29 // reporter is different for x86-32 and x86-64: the message sizes
30 // are different because the message struct contains a pointer. As
31 // a result, there are two different named pipes to connect to. The
32 // 64-bit one is distinguished with an "-x64" suffix.
33 #if defined(_WIN64)
34 const wchar_t kGoogleUpdatePipeName[] =
35 L"\\\\.\\pipe\\ChromeCrashServices";
36 //L"\\\\.\\pipe\\GoogleCrashServices\\S-1-5-18-x64";
37 #else
38 const wchar_t kGoogleUpdatePipeName[] =
39 L"\\\\.\\pipe\\ChromeCrashServices";
40 //L"\\\\.\\pipe\\GoogleCrashServices\\S-1-5-18";
41 #endif
42
43 google_breakpad::CustomClientInfo* GetCustomInfo() {
44 static google_breakpad::CustomInfoEntry ver_entry(
45 kBreakpadVersionEntry, TEXT(CHROME_VERSION_STRING));
46 static google_breakpad::CustomInfoEntry prod_entry(
47 kBreakpadProdEntry, kBreakpadProductName);
48 static google_breakpad::CustomInfoEntry plat_entry(
49 kBreakpadPlatformEntry, kBreakpadPlatformWin32);
50 static google_breakpad::CustomInfoEntry entries[] = {
51 ver_entry, prod_entry, plat_entry };
52 static google_breakpad::CustomClientInfo custom_info = {
53 entries, arraysize(entries) };
54 return &custom_info;
55 }
56
57 } // namespace
58
59 int GenerateCrashDump(EXCEPTION_POINTERS* exinfo) {
60 DWORD code = exinfo->ExceptionRecord->ExceptionCode;
61 if (code == EXCEPTION_BREAKPOINT || code == EXCEPTION_SINGLE_STEP)
62 return EXCEPTION_CONTINUE_SEARCH;
63
64 if (g_elf_breakpad != NULL)
65 g_elf_breakpad->WriteMinidumpForException(exinfo);
66 return EXCEPTION_CONTINUE_SEARCH;
67 }
68
69 void InitializeCrashReporting() {
70 // Disable the message box for assertions.
71 _CrtSetReportMode(_CRT_ASSERT, 0);
72
73 // Get the alternate dump directory. We use the temp path.
robertshield 2014/02/07 20:03:08 are crashes uploaded from the temp path as well?
Cait (Slow) 2014/02/10 18:13:20 I am not sure...it seems that the temp path is whe
74 // N.B. We don't use base::GetTempDir() here to avoid running more code then
75 // necessary before crashes can be properly reported.
76 wchar_t temp_directory[MAX_PATH + 1] = { 0 };
robertshield 2014/02/07 20:03:08 = {}
Cait (Slow) 2014/02/10 18:13:20 Done.
77 DWORD length = GetTempPath(MAX_PATH, temp_directory);
78 if (length == 0)
79 return;
80
81 // Minidump with stacks, PEB, TEBs and unloaded module list.
82 MINIDUMP_TYPE dump_type = static_cast<MINIDUMP_TYPE>(
83 MiniDumpWithProcessThreadData | // Get PEB and TEB.
84 MiniDumpWithUnloadedModules | // Get unloaded modules when available.
85 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack.
86
87 g_elf_breakpad = new google_breakpad::ExceptionHandler(
88 temp_directory,
89 NULL,
90 NULL,
91 NULL,
92 google_breakpad::ExceptionHandler::HANDLER_ALL,
93 dump_type,
94 kGoogleUpdatePipeName,
95 GetCustomInfo());
96
97 if (g_elf_breakpad->IsOutOfProcess()) {
98 // Tells breakpad to handle breakpoint and single step exceptions.
99 g_elf_breakpad->set_handle_debug_exceptions(true);
100 }
101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698