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