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 g_crashpad_client.Get().StartHandler( | 121 if (!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, false); | 123 arguments, false, true)) { |
124 // This means that CreateThread() failed, so this process is very messed | |
125 // up. This should be effectively unreachable. Note that if this is | |
126 // converted to non-fatal, calls to BlockUntilHandlerStarted() will have | |
robertshield
2016/12/15 20:06:30
nit: consider updating the comment about "if this
scottmg
2016/12/16 17:16:51
Done.
| |
127 // to be amended. | |
128 LOG(FATAL) << "synchronous part of handler startup failed"; | |
129 } | |
124 | 130 |
125 // If we're the browser, push the pipe name into the environment so child | 131 // If we're the browser, push the pipe name into the environment so child |
126 // processes can connect to it. If we inherited another crashpad_handler's | 132 // processes can connect to it. If we inherited another crashpad_handler's |
127 // pipe name, we'll overwrite it here. | 133 // pipe name, we'll overwrite it here. |
128 env->SetVar(kPipeNameVar, | 134 env->SetVar(kPipeNameVar, |
129 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); | 135 base::UTF16ToUTF8(g_crashpad_client.Get().GetHandlerIPCPipe())); |
130 } else { | 136 } else { |
131 std::string pipe_name_utf8; | 137 std::string pipe_name_utf8; |
132 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { | 138 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { |
133 g_crashpad_client.Get().SetHandlerIPCPipe( | 139 g_crashpad_client.Get().SetHandlerIPCPipe( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 VLOG(1) << "dumped for hang debugging"; | 207 VLOG(1) << "dumped for hang debugging"; |
202 return 0; | 208 return 0; |
203 } | 209 } |
204 | 210 |
205 MSVC_POP_WARNING() | 211 MSVC_POP_WARNING() |
206 MSVC_ENABLE_OPTIMIZE() | 212 MSVC_ENABLE_OPTIMIZE() |
207 | 213 |
208 } // namespace | 214 } // namespace |
209 | 215 |
210 } // namespace internal | 216 } // 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 | |
211 } // namespace crash_reporter | 227 } // namespace crash_reporter |
212 | 228 |
213 extern "C" { | 229 extern "C" { |
214 | 230 |
215 // Crashes the process after generating a dump for the provided exception. Note | 231 // Crashes the process after generating a dump for the provided exception. Note |
216 // that the crash reporter should be initialized before calling this function | 232 // that the crash reporter should be initialized before calling this function |
217 // for it to do anything. | 233 // for it to do anything. |
218 // NOTE: This function is used by SyzyASAN to invoke a crash. If you change the | 234 // NOTE: This function is used by SyzyASAN to invoke a crash. If you change the |
219 // the name or signature of this function you will break SyzyASAN instrumented | 235 // the name or signature of this function you will break SyzyASAN instrumented |
220 // releases of Chrome. Please contact syzygy-team@chromium.org before doing so! | 236 // 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... | |
343 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 359 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
344 void* start) { | 360 void* start) { |
345 ExceptionHandlerRecord* record = | 361 ExceptionHandlerRecord* record = |
346 reinterpret_cast<ExceptionHandlerRecord*>(start); | 362 reinterpret_cast<ExceptionHandlerRecord*>(start); |
347 | 363 |
348 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 364 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
349 } | 365 } |
350 #endif // ARCH_CPU_X86_64 | 366 #endif // ARCH_CPU_X86_64 |
351 | 367 |
352 } // extern "C" | 368 } // extern "C" |
OLD | NEW |