OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/crash/content/app/crashpad.h" | 5 #include "components/crash/content/app/crashpad.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/auto_reset.h" | 13 #include "base/auto_reset.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/debug/crash_logging.h" | 15 #include "base/debug/crash_logging.h" |
16 #include "base/debug/dump_without_crashing.h" | 16 #include "base/debug/dump_without_crashing.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
21 #include "base/strings/sys_string_conversions.h" | 21 #include "base/strings/sys_string_conversions.h" |
22 #include "base/strings/utf_string_conversions.h" | |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 #include "components/crash/content/app/crash_reporter_client.h" | 24 #include "components/crash/content/app/crash_reporter_client.h" |
24 #include "third_party/crashpad/crashpad/client/crash_report_database.h" | 25 #include "third_party/crashpad/crashpad/client/crash_report_database.h" |
25 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 26 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
26 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 27 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
27 #include "third_party/crashpad/crashpad/client/settings.h" | 28 #include "third_party/crashpad/crashpad/client/settings.h" |
28 #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" | 29 #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" |
29 #include "third_party/crashpad/crashpad/client/simulate_crash.h" | 30 #include "third_party/crashpad/crashpad/client/simulate_crash.h" |
30 | 31 |
31 #if defined(OS_POSIX) | 32 #if defined(OS_POSIX) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 // time to chew on symbols. | 137 // time to chew on symbols. |
137 if (!browser_process || is_debug_build) { | 138 if (!browser_process || is_debug_build) { |
138 crashpad_info->set_system_crash_reporter_forwarding( | 139 crashpad_info->set_system_crash_reporter_forwarding( |
139 crashpad::TriState::kDisabled); | 140 crashpad::TriState::kDisabled); |
140 } | 141 } |
141 #endif // OS_MACOSX | 142 #endif // OS_MACOSX |
142 | 143 |
143 g_simple_string_dictionary = new crashpad::SimpleStringDictionary(); | 144 g_simple_string_dictionary = new crashpad::SimpleStringDictionary(); |
144 crashpad_info->set_simple_annotations(g_simple_string_dictionary); | 145 crashpad_info->set_simple_annotations(g_simple_string_dictionary); |
145 | 146 |
147 #if !defined(OS_WIN) || !defined(COMPONENT_BUILD) | |
148 // chrome/common/child_process_logging_win.cc registers crash keys for | |
149 // chrome.dll. In a component build, that is sufficient as chrome.dll and | |
150 // chrome.exe share a copy of base (in base.dll). In a static build, the EXE | |
151 // must separately initialize the crash keys configuration as it has its own | |
152 // statically linked copy of base. | |
146 base::debug::SetCrashKeyReportingFunctions(SetCrashKeyValue, ClearCrashKey); | 153 base::debug::SetCrashKeyReportingFunctions(SetCrashKeyValue, ClearCrashKey); |
147 crash_reporter_client->RegisterCrashKeys(); | 154 crash_reporter_client->RegisterCrashKeys(); |
155 #endif | |
148 | 156 |
149 SetCrashKeyValue("ptype", browser_process ? base::StringPiece("browser") | 157 SetCrashKeyValue("ptype", browser_process ? base::StringPiece("browser") |
150 : base::StringPiece(process_type)); | 158 : base::StringPiece(process_type)); |
151 #if defined(OS_POSIX) | 159 #if defined(OS_POSIX) |
152 SetCrashKeyValue("pid", base::IntToString(getpid())); | 160 SetCrashKeyValue("pid", base::IntToString(getpid())); |
153 #elif defined(OS_WIN) | 161 #elif defined(OS_WIN) |
154 SetCrashKeyValue("pid", base::IntToString(::GetCurrentProcessId())); | 162 SetCrashKeyValue("pid", base::IntToString(::GetCurrentProcessId())); |
155 #endif | 163 #endif |
156 | 164 |
157 logging::SetLogMessageHandler(LogMessageHandler); | 165 logging::SetLogMessageHandler(LogMessageHandler); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 } | 235 } |
228 } | 236 } |
229 | 237 |
230 std::sort(uploaded_reports->begin(), uploaded_reports->end(), | 238 std::sort(uploaded_reports->begin(), uploaded_reports->end(), |
231 [](const UploadedReport& a, const UploadedReport& b) { | 239 [](const UploadedReport& a, const UploadedReport& b) { |
232 return a.creation_time >= b.creation_time; | 240 return a.creation_time >= b.creation_time; |
233 }); | 241 }); |
234 } | 242 } |
235 | 243 |
236 } // namespace crash_reporter | 244 } // namespace crash_reporter |
245 | |
246 #if defined(OS_WIN) | |
247 | |
248 extern "C" { | |
249 | |
250 // NOTE: This function is used by SyzyASAN to annotate crash reports. If you | |
251 // change the name or signature of this function you will break SyzyASAN | |
252 // instrumented releases of Chrome. Please contact syzygy-team@chromium.org | |
253 // before doing so! See also http://crbug.com/567781. | |
254 void __declspec(dllexport) __cdecl SetCrashKeyValueImpl(const wchar_t* key, | |
255 const wchar_t* value) { | |
scottmg
2015/12/10 01:11:29
These also happen to be functions that SyzyASAN re
| |
256 crash_reporter::SetCrashKeyValue(base::UTF16ToUTF8(key), | |
257 base::UTF16ToUTF8(value)); | |
258 } | |
259 | |
260 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { | |
261 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); | |
262 } | |
263 | |
264 } // extern "C" | |
265 | |
266 #endif // OS_WIN | |
OLD | NEW |