Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 void GetPlatformCrashpadAnnotations( | 28 void GetPlatformCrashpadAnnotations( |
| 29 std::map<std::string, std::string>* annotations) { | 29 std::map<std::string, std::string>* annotations) { |
| 30 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 30 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
| 31 wchar_t exe_file[MAX_PATH] = {}; | 31 wchar_t exe_file[MAX_PATH] = {}; |
| 32 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); | 32 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); |
| 33 base::string16 product_name, version, special_build, channel_name; | 33 base::string16 product_name, version, special_build, channel_name; |
| 34 crash_reporter_client->GetProductNameAndVersion( | 34 crash_reporter_client->GetProductNameAndVersion( |
| 35 exe_file, &product_name, &version, &special_build, &channel_name); | 35 exe_file, &product_name, &version, &special_build, &channel_name); |
| 36 (*annotations)["prod"] = base::UTF16ToUTF8(product_name); | 36 (*annotations)["prod"] = base::UTF16ToUTF8(product_name); |
| 37 (*annotations)["ver"] = base::UTF16ToUTF8(version); | 37 (*annotations)["ver"] = base::UTF16ToUTF8(version); |
| 38 (*annotations)["channel"] = base::UTF16ToUTF8(channel_name); | 38 #if defined(GOOGLE_CHROME_BUILD) |
| 39 // Empty means stable. | |
| 40 const bool allow_empty_channel = true; | |
| 41 #else | |
| 42 const bool allow_empty_channel = false; | |
| 43 #endif | |
| 44 if (allow_empty_channel || !channel_name.empty()) | |
| 45 (*annotations)["channel"] = base::UTF16ToUTF8(channel_name); | |
| 39 if (!special_build.empty()) | 46 if (!special_build.empty()) |
| 40 (*annotations)["special"] = base::UTF16ToUTF8(special_build); | 47 (*annotations)["special"] = base::UTF16ToUTF8(special_build); |
| 41 #if defined(ARCH_CPU_X86) | 48 #if defined(ARCH_CPU_X86) |
| 42 (*annotations)["plat"] = std::string("Win32"); | 49 (*annotations)["plat"] = std::string("Win32"); |
| 43 #elif defined(ARCH_CPU_X86_64) | 50 #elif defined(ARCH_CPU_X86_64) |
| 44 (*annotations)["plat"] = std::string("Win64"); | 51 (*annotations)["plat"] = std::string("Win64"); |
| 45 #endif | 52 #endif |
| 46 } | 53 } |
| 47 | 54 |
| 48 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 55 base::FilePath PlatformCrashpadInitialization(bool initial_client, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 if (crash_reporter_client->GetShouldDumpLargerDumps()) { | 96 if (crash_reporter_client->GetShouldDumpLargerDumps()) { |
| 90 const uint32_t kIndirectMemoryLimit = 4 * 1024 * 1024; | 97 const uint32_t kIndirectMemoryLimit = 4 * 1024 * 1024; |
| 91 crashpad::CrashpadInfo::GetCrashpadInfo() | 98 crashpad::CrashpadInfo::GetCrashpadInfo() |
| 92 ->set_gather_indirectly_referenced_memory( | 99 ->set_gather_indirectly_referenced_memory( |
| 93 crashpad::TriState::kEnabled, kIndirectMemoryLimit); | 100 crashpad::TriState::kEnabled, kIndirectMemoryLimit); |
| 94 } | 101 } |
| 95 | 102 |
| 96 // If the handler is embedded in the binary (e.g. chrome, setup), we | 103 // If the handler is embedded in the binary (e.g. chrome, setup), we |
| 97 // reinvoke it with --type=crashpad-handler. Otherwise, we use the | 104 // reinvoke it with --type=crashpad-handler. Otherwise, we use the |
| 98 // standalone crashpad_handler.exe (for tests, etc.). | 105 // standalone crashpad_handler.exe (for tests, etc.). |
| 99 std::vector<std::string> arguments; | 106 std::vector<std::string> start_arguments; |
| 100 if (embedded_handler) { | 107 if (embedded_handler) { |
| 101 arguments.push_back(std::string("--type=") + switches::kCrashpadHandler); | 108 start_arguments.push_back(std::string("--type=") + |
| 109 switches::kCrashpadHandler); | |
| 102 // The prefetch argument added here has to be documented in | 110 // The prefetch argument added here has to be documented in |
| 103 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant | 111 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant |
| 104 // can't be used here because crashpad can't depend on Chrome. | 112 // can't be used here because crashpad can't depend on Chrome. |
| 105 arguments.push_back("/prefetch:7"); | 113 start_arguments.push_back("/prefetch:7"); |
| 106 } else { | 114 } else { |
| 107 base::FilePath exe_dir = exe_file.DirName(); | 115 base::FilePath exe_dir = exe_file.DirName(); |
| 108 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); | 116 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); |
| 109 } | 117 } |
| 110 | 118 |
| 119 std::vector<std::string> arguments(start_arguments); | |
| 120 | |
| 121 if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) { | |
| 122 arguments.push_back("--monitor-self"); | |
| 123 for (const std::string& start_argument : start_arguments) { | |
| 124 arguments.push_back(std::string("--monitor-self-argument=") + | |
| 125 start_argument); | |
| 126 } | |
| 127 } | |
| 128 | |
| 129 // Set up --monitor-self-annotation even in the absence of --monitor-self so | |
| 130 // that minidumps produced by generate_dump will contain these annotations. | |
|
scottmg
2017/04/10 17:09:31
A little questionable here since there's no genera
Mark Mentovai
2017/04/10 17:19:02
scottmg wrote:
scottmg
2017/04/10 18:05:45
Huh! I didn't remember porting it. For some reason
| |
| 131 arguments.push_back(std::string("--monitor-self-annotation=ptype=") + | |
| 132 switches::kCrashpadHandler); | |
| 133 | |
| 111 GetCrashpadClient().StartHandler(exe_file, database_path, metrics_path, url, | 134 GetCrashpadClient().StartHandler(exe_file, database_path, metrics_path, url, |
| 112 process_annotations, arguments, false, | 135 process_annotations, arguments, false, |
| 113 false); | 136 false); |
| 114 | 137 |
| 115 // If we're the browser, push the pipe name into the environment so child | 138 // If we're the browser, push the pipe name into the environment so child |
| 116 // processes can connect to it. If we inherited another crashpad_handler's | 139 // processes can connect to it. If we inherited another crashpad_handler's |
| 117 // pipe name, we'll overwrite it here. | 140 // pipe name, we'll overwrite it here. |
| 118 env->SetVar(kPipeNameVar, | 141 env->SetVar(kPipeNameVar, |
| 119 base::UTF16ToUTF8(GetCrashpadClient().GetHandlerIPCPipe())); | 142 base::UTF16ToUTF8(GetCrashpadClient().GetHandlerIPCPipe())); |
| 120 } else { | 143 } else { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 355 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
| 333 void* start) { | 356 void* start) { |
| 334 ExceptionHandlerRecord* record = | 357 ExceptionHandlerRecord* record = |
| 335 reinterpret_cast<ExceptionHandlerRecord*>(start); | 358 reinterpret_cast<ExceptionHandlerRecord*>(start); |
| 336 | 359 |
| 337 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 360 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
| 338 } | 361 } |
| 339 #endif // ARCH_CPU_X86_64 | 362 #endif // ARCH_CPU_X86_64 |
| 340 | 363 |
| 341 } // extern "C" | 364 } // extern "C" |
| OLD | NEW |