| 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/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/files/file_util.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "components/crash/content/app/crash_reporter_client.h" | 17 #include "components/crash/content/app/crash_reporter_client.h" |
| 17 #include "components/crash/content/app/crash_switches.h" | 18 #include "components/crash/content/app/crash_switches.h" |
| 18 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 19 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
| 19 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 20 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 46 (*annotations)["plat"] = std::string("Win32"); | 47 (*annotations)["plat"] = std::string("Win32"); |
| 47 #elif defined(ARCH_CPU_X86_64) | 48 #elif defined(ARCH_CPU_X86_64) |
| 48 (*annotations)["plat"] = std::string("Win64"); | 49 (*annotations)["plat"] = std::string("Win64"); |
| 49 #endif | 50 #endif |
| 50 } | 51 } |
| 51 | 52 |
| 52 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 53 base::FilePath PlatformCrashpadInitialization(bool initial_client, |
| 53 bool browser_process, | 54 bool browser_process, |
| 54 bool embedded_handler) { | 55 bool embedded_handler) { |
| 55 base::FilePath database_path; // Only valid in the browser process. | 56 base::FilePath database_path; // Only valid in the browser process. |
| 57 base::FilePath metrics_path; // Only valid in the browser process. |
| 56 bool result = false; | 58 bool result = false; |
| 57 | 59 |
| 58 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; | 60 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; |
| 59 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; | 61 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; |
| 60 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 62 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 61 if (initial_client) { | 63 if (initial_client) { |
| 62 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 64 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
| 63 | 65 |
| 64 base::string16 database_path_str; | 66 base::string16 database_path_str; |
| 65 if (crash_reporter_client->GetCrashDumpLocation(&database_path_str)) | 67 if (crash_reporter_client->GetCrashDumpLocation(&database_path_str)) |
| 66 database_path = base::FilePath(database_path_str); | 68 database_path = base::FilePath(database_path_str); |
| 67 | 69 |
| 70 base::string16 metrics_path_str; |
| 71 if (crash_reporter_client->GetCrashMetricsLocation(&metrics_path_str)) { |
| 72 metrics_path = base::FilePath(metrics_path_str); |
| 73 CHECK(base::CreateDirectoryAndGetError(metrics_path, nullptr)); |
| 74 } |
| 75 |
| 68 std::map<std::string, std::string> process_annotations; | 76 std::map<std::string, std::string> process_annotations; |
| 69 GetPlatformCrashpadAnnotations(&process_annotations); | 77 GetPlatformCrashpadAnnotations(&process_annotations); |
| 70 | 78 |
| 71 #if defined(GOOGLE_CHROME_BUILD) | 79 #if defined(GOOGLE_CHROME_BUILD) |
| 72 std::string url = "https://clients2.google.com/cr/report"; | 80 std::string url = "https://clients2.google.com/cr/report"; |
| 73 #else | 81 #else |
| 74 std::string url; | 82 std::string url; |
| 75 #endif | 83 #endif |
| 76 | 84 |
| 77 // Allow the crash server to be overridden for testing. If the variable | 85 // Allow the crash server to be overridden for testing. If the variable |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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 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 |
| 111 result = g_crashpad_client.Get().StartHandler( | 119 result = g_crashpad_client.Get().StartHandler( |
| 112 exe_file, database_path, url, process_annotations, arguments, false); | 120 exe_file, database_path, metrics_path, url, process_annotations, |
| 121 arguments, false); |
| 113 | 122 |
| 114 // If we're the browser, push the pipe name into the environment so child | 123 // If we're the browser, push the pipe name into the environment so child |
| 115 // processes can connect to it. If we inherited another crashpad_handler's | 124 // processes can connect to it. If we inherited another crashpad_handler's |
| 116 // pipe name, we'll overwrite it here. | 125 // pipe name, we'll overwrite it here. |
| 117 env->SetVar(kPipeNameVar, | 126 env->SetVar(kPipeNameVar, |
| 118 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); | 127 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); |
| 119 } else { | 128 } else { |
| 120 std::string pipe_name_utf8; | 129 std::string pipe_name_utf8; |
| 121 result = env->GetVar(kPipeNameVar, &pipe_name_utf8); | 130 result = env->GetVar(kPipeNameVar, &pipe_name_utf8); |
| 122 if (result) { | 131 if (result) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 292 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
| 284 void* start) { | 293 void* start) { |
| 285 ExceptionHandlerRecord* record = | 294 ExceptionHandlerRecord* record = |
| 286 reinterpret_cast<ExceptionHandlerRecord*>(start); | 295 reinterpret_cast<ExceptionHandlerRecord*>(start); |
| 287 | 296 |
| 288 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 297 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
| 289 } | 298 } |
| 290 #endif // ARCH_CPU_X86_64 | 299 #endif // ARCH_CPU_X86_64 |
| 291 | 300 |
| 292 } // extern "C" | 301 } // extern "C" |
| OLD | NEW |