OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This module contains the necessary code to register the Breakpad exception | 5 // This module contains the necessary code to register the Breakpad exception |
6 // handler. This implementation is based on Chrome's crash reporting code. | 6 // handler. This implementation is based on Chrome's crash reporting code. |
7 | 7 |
8 #include "chrome_elf/breakpad.h" | 8 #include "chrome_elf/breakpad.h" |
9 | 9 |
10 #include <sddl.h> | 10 #include <sddl.h> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (code == EXCEPTION_BREAKPOINT || code == EXCEPTION_SINGLE_STEP) | 95 if (code == EXCEPTION_BREAKPOINT || code == EXCEPTION_SINGLE_STEP) |
96 return EXCEPTION_CONTINUE_SEARCH; | 96 return EXCEPTION_CONTINUE_SEARCH; |
97 | 97 |
98 if (g_elf_breakpad != NULL) | 98 if (g_elf_breakpad != NULL) |
99 g_elf_breakpad->WriteMinidumpForException(exinfo); | 99 g_elf_breakpad->WriteMinidumpForException(exinfo); |
100 return EXCEPTION_CONTINUE_SEARCH; | 100 return EXCEPTION_CONTINUE_SEARCH; |
101 } | 101 } |
102 | 102 |
103 void InitializeCrashReporting() { | 103 void InitializeCrashReporting() { |
104 wchar_t exe_path[MAX_PATH] = {}; | 104 wchar_t exe_path[MAX_PATH] = {}; |
105 if(!::GetModuleFileName(NULL, exe_path, arraysize(exe_path))) | 105 if (!::GetModuleFileName(NULL, exe_path, arraysize(exe_path))) |
106 return; | 106 return; |
107 | 107 |
108 // Disable the message box for assertions. | 108 // Disable the message box for assertions. |
109 _CrtSetReportMode(_CRT_ASSERT, 0); | 109 _CrtSetReportMode(_CRT_ASSERT, 0); |
110 | 110 |
111 // Get the alternate dump directory. We use the temp path. | 111 // Get the alternate dump directory. We use the temp path. |
112 // N.B. We don't use base::GetTempDir() here to avoid running more code then | 112 // N.B. We don't use base::GetTempDir() here to avoid running more code then |
113 // necessary before crashes can be properly reported. | 113 // necessary before crashes can be properly reported. |
114 wchar_t temp_directory[MAX_PATH + 1] = {}; | 114 wchar_t temp_directory[MAX_PATH + 1] = {}; |
115 DWORD length = GetTempPath(MAX_PATH, temp_directory); | 115 DWORD length = GetTempPath(MAX_PATH, temp_directory); |
116 if (length == 0) | 116 if (length == 0) |
117 return; | 117 return; |
118 | 118 |
119 // Minidump with stacks, PEB, TEBs and unloaded module list. | 119 // Minidump with stacks, PEB, TEBs and unloaded module list. |
120 MINIDUMP_TYPE dump_type = static_cast<MINIDUMP_TYPE>( | 120 MINIDUMP_TYPE dump_type = static_cast<MINIDUMP_TYPE>( |
121 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 121 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
122 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | 122 MiniDumpWithUnloadedModules | // Get unloaded modules when available. |
123 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by | 123 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by |
124 // stack. | 124 // stack. |
125 | 125 |
126 // Convert #define to a variable so that we can use if() rather than | 126 #if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD) |
127 // #if below and so at least compile-test the Chrome code in | 127 bool is_official_chrome_build = true; |
128 // Chromium builds. | |
129 #if defined(GOOGLE_CHROME_BUILD) | |
130 bool is_chrome_build = true; | |
131 #else | 128 #else |
132 bool is_chrome_build = false; | 129 bool is_official_chrome_build = false; |
133 #endif | 130 #endif |
134 | 131 |
135 base::string16 pipe_name; | 132 base::string16 pipe_name; |
136 | 133 |
137 bool enabled_by_policy = false; | 134 bool enabled_by_policy = false; |
138 bool use_policy = ReportingIsEnforcedByPolicy(&enabled_by_policy); | 135 bool use_policy = ReportingIsEnforcedByPolicy(&enabled_by_policy); |
139 | 136 |
140 if (!use_policy && IsHeadless()) { | 137 if (!use_policy && IsHeadless()) { |
141 pipe_name = kChromePipeName; | 138 pipe_name = kChromePipeName; |
142 } else if (use_policy ? enabled_by_policy : | 139 } else if (use_policy ? |
143 (is_chrome_build && AreUsageStatsEnabled(exe_path))) { | 140 enabled_by_policy : |
| 141 (is_official_chrome_build && AreUsageStatsEnabled(exe_path))) { |
144 // Build the pipe name. It can be one of: | 142 // Build the pipe name. It can be one of: |
145 // 32-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18 | 143 // 32-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18 |
146 // 32-bit user: \\.\pipe\GoogleCrashServices\<user SID> | 144 // 32-bit user: \\.\pipe\GoogleCrashServices\<user SID> |
147 // 64-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18-x64 | 145 // 64-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18-x64 |
148 // 64-bit user: \\.\pipe\GoogleCrashServices\<user SID>-x64 | 146 // 64-bit user: \\.\pipe\GoogleCrashServices\<user SID>-x64 |
149 base::string16 user_sid = IsSystemInstall(exe_path) ? kSystemPrincipalSid : | 147 base::string16 user_sid = IsSystemInstall(exe_path) ? kSystemPrincipalSid : |
150 GetUserSidString(); | 148 GetUserSidString(); |
151 if (user_sid.empty()) | 149 if (user_sid.empty()) |
152 return; | 150 return; |
153 | 151 |
(...skipping 17 matching lines...) Expand all Loading... |
171 google_breakpad::ExceptionHandler::HANDLER_ALL, | 169 google_breakpad::ExceptionHandler::HANDLER_ALL, |
172 dump_type, | 170 dump_type, |
173 pipe_name.c_str(), | 171 pipe_name.c_str(), |
174 GetCustomInfo()); | 172 GetCustomInfo()); |
175 | 173 |
176 if (g_elf_breakpad->IsOutOfProcess()) { | 174 if (g_elf_breakpad->IsOutOfProcess()) { |
177 // Tells breakpad to handle breakpoint and single step exceptions. | 175 // Tells breakpad to handle breakpoint and single step exceptions. |
178 g_elf_breakpad->set_handle_debug_exceptions(true); | 176 g_elf_breakpad->set_handle_debug_exceptions(true); |
179 } | 177 } |
180 } | 178 } |
OLD | NEW |