| 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 // Add a prefetch argument to prevent the crashpad process from |
| 91 // polluting the prefetch profile of the browser process. The prefetch |
| 92 // argument must be equal to switches::kPrefetchArgumentOther. |
| 93 // Unfortunately, crashpad cannot depend on any of the targets that |
| 94 // define this constant. |
| 95 arguments.push_back("/prefetch:8"); |
| 96 } |
| 87 } | 97 } |
| 88 | 98 |
| 89 // TODO(scottmg): See https://crashpad.chromium.org/bug/23. | 99 // TODO(scottmg): See https://crashpad.chromium.org/bug/23. |
| 90 arguments.push_back("--no-rate-limit"); | 100 arguments.push_back("--no-rate-limit"); |
| 91 | 101 |
| 92 result = g_crashpad_client.Get().StartHandler( | 102 result = g_crashpad_client.Get().StartHandler( |
| 93 exe_file, database_path, url, process_annotations, arguments, false); | 103 exe_file, database_path, url, process_annotations, arguments, false); |
| 94 | 104 |
| 95 // If we're the browser, push the pipe name into the environment so child | 105 // 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 | 106 // 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( | 275 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
| 266 void* start) { | 276 void* start) { |
| 267 ExceptionHandlerRecord* record = | 277 ExceptionHandlerRecord* record = |
| 268 reinterpret_cast<ExceptionHandlerRecord*>(start); | 278 reinterpret_cast<ExceptionHandlerRecord*>(start); |
| 269 | 279 |
| 270 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 280 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
| 271 } | 281 } |
| 272 #endif // ARCH_CPU_X86_64 | 282 #endif // ARCH_CPU_X86_64 |
| 273 | 283 |
| 274 } // extern "C" | 284 } // extern "C" |
| OLD | NEW |