| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #elif defined(ARCH_CPU_X86_64) | 51 #elif defined(ARCH_CPU_X86_64) |
| 52 (*annotations)["plat"] = std::string("Win64"); | 52 (*annotations)["plat"] = std::string("Win64"); |
| 53 #endif | 53 #endif |
| 54 } | 54 } |
| 55 | 55 |
| 56 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 56 base::FilePath PlatformCrashpadInitialization(bool initial_client, |
| 57 bool browser_process, | 57 bool browser_process, |
| 58 bool embedded_handler) { | 58 bool embedded_handler) { |
| 59 base::FilePath database_path; // Only valid in the browser process. | 59 base::FilePath database_path; // Only valid in the browser process. |
| 60 base::FilePath metrics_path; // Only valid in the browser process. | 60 base::FilePath metrics_path; // Only valid in the browser process. |
| 61 bool result = false; | |
| 62 | 61 |
| 63 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; | 62 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; |
| 64 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; | 63 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; |
| 65 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 64 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 66 if (initial_client) { | 65 if (initial_client) { |
| 67 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 66 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
| 68 | 67 |
| 69 base::string16 database_path_str; | 68 base::string16 database_path_str; |
| 70 if (crash_reporter_client->GetCrashDumpLocation(&database_path_str)) | 69 if (crash_reporter_client->GetCrashDumpLocation(&database_path_str)) |
| 71 database_path = base::FilePath(database_path_str); | 70 database_path = base::FilePath(database_path_str); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 arguments.push_back(std::string("--type=") + switches::kCrashpadHandler); | 111 arguments.push_back(std::string("--type=") + switches::kCrashpadHandler); |
| 113 // The prefetch argument added here has to be documented in | 112 // The prefetch argument added here has to be documented in |
| 114 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant | 113 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant |
| 115 // can't be used here because crashpad can't depend on Chrome. | 114 // can't be used here because crashpad can't depend on Chrome. |
| 116 arguments.push_back("/prefetch:7"); | 115 arguments.push_back("/prefetch:7"); |
| 117 } else { | 116 } else { |
| 118 base::FilePath exe_dir = exe_file.DirName(); | 117 base::FilePath exe_dir = exe_file.DirName(); |
| 119 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); | 118 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); |
| 120 } | 119 } |
| 121 | 120 |
| 122 result = g_crashpad_client.Get().StartHandler( | 121 g_crashpad_client.Get().StartHandler( |
| 123 exe_file, database_path, metrics_path, url, process_annotations, | 122 exe_file, database_path, metrics_path, url, process_annotations, |
| 124 arguments, false); | 123 arguments, false, false); |
| 125 | 124 |
| 126 // If we're the browser, push the pipe name into the environment so child | 125 // If we're the browser, push the pipe name into the environment so child |
| 127 // processes can connect to it. If we inherited another crashpad_handler's | 126 // processes can connect to it. If we inherited another crashpad_handler's |
| 128 // pipe name, we'll overwrite it here. | 127 // pipe name, we'll overwrite it here. |
| 129 env->SetVar(kPipeNameVar, | 128 env->SetVar(kPipeNameVar, |
| 130 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); | 129 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); |
| 131 } else { | 130 } else { |
| 132 std::string pipe_name_utf8; | 131 std::string pipe_name_utf8; |
| 133 result = env->GetVar(kPipeNameVar, &pipe_name_utf8); | 132 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { |
| 134 if (result) { | 133 g_crashpad_client.Get().SetHandlerIPCPipe( |
| 135 result = g_crashpad_client.Get().SetHandlerIPCPipe( | |
| 136 base::UTF8ToUTF16(pipe_name_utf8)); | 134 base::UTF8ToUTF16(pipe_name_utf8)); |
| 137 } | 135 } |
| 138 } | 136 } |
| 139 | 137 |
| 140 if (result) { | |
| 141 result = g_crashpad_client.Get().UseHandler(); | |
| 142 } | |
| 143 return database_path; | 138 return database_path; |
| 144 } | 139 } |
| 145 | 140 |
| 146 // TODO(scottmg): http://crbug.com/546288 These exported functions are for | 141 // TODO(scottmg): http://crbug.com/546288 These exported functions are for |
| 147 // compatibility with how Breakpad worked, but it seems like there's no need to | 142 // compatibility with how Breakpad worked, but it seems like there's no need to |
| 148 // do the CreateRemoteThread() dance with a minor extension of the Crashpad API | 143 // do the CreateRemoteThread() dance with a minor extension of the Crashpad API |
| 149 // (to just pass the pid we want a dump for). We should add that and then modify | 144 // (to just pass the pid we want a dump for). We should add that and then modify |
| 150 // hang_crash_dump_win.cc to work in a more direct manner. | 145 // hang_crash_dump_win.cc to work in a more direct manner. |
| 151 | 146 |
| 152 // Used for dumping a process state when there is no crash. | 147 // Used for dumping a process state when there is no crash. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 304 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
| 310 void* start) { | 305 void* start) { |
| 311 ExceptionHandlerRecord* record = | 306 ExceptionHandlerRecord* record = |
| 312 reinterpret_cast<ExceptionHandlerRecord*>(start); | 307 reinterpret_cast<ExceptionHandlerRecord*>(start); |
| 313 | 308 |
| 314 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 309 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
| 315 } | 310 } |
| 316 #endif // ARCH_CPU_X86_64 | 311 #endif // ARCH_CPU_X86_64 |
| 317 | 312 |
| 318 } // extern "C" | 313 } // extern "C" |
| OLD | NEW |