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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "components/crash/content/app/crash_reporter_client.h" | 18 #include "components/crash/content/app/crash_reporter_client.h" |
| 19 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" |
19 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 20 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
20 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 21 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
21 #include "third_party/crashpad/crashpad/client/simulate_crash_win.h" | 22 #include "third_party/crashpad/crashpad/client/simulate_crash_win.h" |
22 | 23 |
23 namespace crash_reporter { | 24 namespace crash_reporter { |
24 namespace internal { | 25 namespace internal { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 base::LazyInstance<crashpad::CrashpadClient>::Leaky g_crashpad_client = | 29 base::LazyInstance<crashpad::CrashpadClient>::Leaky g_crashpad_client = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 78 |
78 // In test binaries, use crashpad_handler directly. Otherwise, we launch | 79 // In test binaries, use crashpad_handler directly. Otherwise, we launch |
79 // chrome.exe with --type=crashpad-handler. | 80 // chrome.exe with --type=crashpad-handler. |
80 base::FilePath exe_file; | 81 base::FilePath exe_file; |
81 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); | 82 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); |
82 if (exe_file.BaseName().value() != FILE_PATH_LITERAL("chrome.exe")) { | 83 if (exe_file.BaseName().value() != FILE_PATH_LITERAL("chrome.exe")) { |
83 base::FilePath exe_dir = exe_file.DirName(); | 84 base::FilePath exe_dir = exe_file.DirName(); |
84 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); | 85 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); |
85 } else { | 86 } else { |
86 arguments.push_back("--type=crashpad-handler"); | 87 arguments.push_back("--type=crashpad-handler"); |
| 88 |
| 89 if (startup_metric_utils::GetPreReadOptions().use_prefetch_argument) { |
| 90 // The prefetch argument added here has to be documented in |
| 91 // chrome_switches.cc, below the kPrefetchArgument* constants. A |
| 92 // constant can't be used here because crashpad can't depend on Chrome. |
| 93 arguments.push_back("/prefetch:7"); |
| 94 } |
87 } | 95 } |
88 | 96 |
89 // TODO(scottmg): See https://crashpad.chromium.org/bug/23. | 97 // TODO(scottmg): See https://crashpad.chromium.org/bug/23. |
90 arguments.push_back("--no-rate-limit"); | 98 arguments.push_back("--no-rate-limit"); |
91 | 99 |
92 result = g_crashpad_client.Get().StartHandler( | 100 result = g_crashpad_client.Get().StartHandler( |
93 exe_file, database_path, url, process_annotations, arguments, false); | 101 exe_file, database_path, url, process_annotations, arguments, false); |
94 | 102 |
95 // If we're the browser, push the pipe name into the environment so child | 103 // If we're the browser, push the pipe name into the environment so child |
96 // processes can connect to it. If we inherited another crashpad_handler's | 104 // processes can connect to it. If we inherited another crashpad_handler's |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 273 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
266 void* start) { | 274 void* start) { |
267 ExceptionHandlerRecord* record = | 275 ExceptionHandlerRecord* record = |
268 reinterpret_cast<ExceptionHandlerRecord*>(start); | 276 reinterpret_cast<ExceptionHandlerRecord*>(start); |
269 | 277 |
270 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 278 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
271 } | 279 } |
272 #endif // ARCH_CPU_X86_64 | 280 #endif // ARCH_CPU_X86_64 |
273 | 281 |
274 } // extern "C" | 282 } // extern "C" |
OLD | NEW |