| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 arguments.push_back(std::string("--type=") + switches::kCrashpadHandler); | 111 arguments.push_back(std::string("--type=") + switches::kCrashpadHandler); |
| 112 // The prefetch argument added here has to be documented in | 112 // The prefetch argument added here has to be documented in |
| 113 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant | 113 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant |
| 114 // 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. |
| 115 arguments.push_back("/prefetch:7"); | 115 arguments.push_back("/prefetch:7"); |
| 116 } else { | 116 } else { |
| 117 base::FilePath exe_dir = exe_file.DirName(); | 117 base::FilePath exe_dir = exe_file.DirName(); |
| 118 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); | 118 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); |
| 119 } | 119 } |
| 120 | 120 |
| 121 if (!g_crashpad_client.Get().StartHandler( | 121 g_crashpad_client.Get().StartHandler( |
| 122 exe_file, database_path, metrics_path, url, process_annotations, | 122 exe_file, database_path, metrics_path, url, process_annotations, |
| 123 arguments, false, true)) { | 123 arguments, false, false); |
| 124 // This means that CreateThread() failed, so this process is very messed | |
| 125 // up. This should be effectively unreachable. It is unlikely that there | |
| 126 // is any utility to ever making this non-fatal, however, if this is done, | |
| 127 // calls to BlockUntilHandlerStarted() will have to be amended. | |
| 128 LOG(FATAL) << "synchronous part of handler startup failed"; | |
| 129 } | |
| 130 | 124 |
| 131 // 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 |
| 132 // 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 |
| 133 // pipe name, we'll overwrite it here. | 127 // pipe name, we'll overwrite it here. |
| 134 env->SetVar(kPipeNameVar, | 128 env->SetVar(kPipeNameVar, |
| 135 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); | 129 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); |
| 136 } else { | 130 } else { |
| 137 std::string pipe_name_utf8; | 131 std::string pipe_name_utf8; |
| 138 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { | 132 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { |
| 139 g_crashpad_client.Get().SetHandlerIPCPipe( | 133 g_crashpad_client.Get().SetHandlerIPCPipe( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 VLOG(1) << "dumped for hang debugging"; | 201 VLOG(1) << "dumped for hang debugging"; |
| 208 return 0; | 202 return 0; |
| 209 } | 203 } |
| 210 | 204 |
| 211 MSVC_POP_WARNING() | 205 MSVC_POP_WARNING() |
| 212 MSVC_ENABLE_OPTIMIZE() | 206 MSVC_ENABLE_OPTIMIZE() |
| 213 | 207 |
| 214 } // namespace | 208 } // namespace |
| 215 | 209 |
| 216 } // namespace internal | 210 } // namespace internal |
| 217 | |
| 218 void BlockUntilHandlerStarted() { | |
| 219 // We know that the StartHandler() at least started asynchronous startup if | |
| 220 // we're here, as if it doesn't, we abort. | |
| 221 const unsigned int kTimeoutMS = 5000; | |
| 222 if (!internal::g_crashpad_client.Get().WaitForHandlerStart(kTimeoutMS)) { | |
| 223 LOG(ERROR) << "Crashpad handler failed to start, crash reporting disabled"; | |
| 224 } | |
| 225 } | |
| 226 | |
| 227 } // namespace crash_reporter | 211 } // namespace crash_reporter |
| 228 | 212 |
| 229 extern "C" { | 213 extern "C" { |
| 230 | 214 |
| 231 // Crashes the process after generating a dump for the provided exception. Note | 215 // Crashes the process after generating a dump for the provided exception. Note |
| 232 // that the crash reporter should be initialized before calling this function | 216 // that the crash reporter should be initialized before calling this function |
| 233 // for it to do anything. | 217 // for it to do anything. |
| 234 // NOTE: This function is used by SyzyASAN to invoke a crash. If you change the | 218 // NOTE: This function is used by SyzyASAN to invoke a crash. If you change the |
| 235 // the name or signature of this function you will break SyzyASAN instrumented | 219 // the name or signature of this function you will break SyzyASAN instrumented |
| 236 // releases of Chrome. Please contact syzygy-team@chromium.org before doing so! | 220 // releases of Chrome. Please contact syzygy-team@chromium.org before doing so! |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 343 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
| 360 void* start) { | 344 void* start) { |
| 361 ExceptionHandlerRecord* record = | 345 ExceptionHandlerRecord* record = |
| 362 reinterpret_cast<ExceptionHandlerRecord*>(start); | 346 reinterpret_cast<ExceptionHandlerRecord*>(start); |
| 363 | 347 |
| 364 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 348 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
| 365 } | 349 } |
| 366 #endif // ARCH_CPU_X86_64 | 350 #endif // ARCH_CPU_X86_64 |
| 367 | 351 |
| 368 } // extern "C" | 352 } // extern "C" |
| OLD | NEW |