OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
scottmg
2017/01/06 18:29:04
2017 :)
Sigurður Ásgeirsson
2017/01/06 20:59:10
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_ | |
6 #define COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_ | |
7 | |
8 #include "base/command_line.h" | |
9 #include "base/files/file_path.h" | |
10 #include "base/macros.h" | |
11 #include "base/win/scoped_handle.h" | |
12 #include "base/win/startup_information.h" | |
13 | |
14 #include <windows.h> | |
scottmg
2017/01/06 18:29:04
This goes before " includes.
Sigurður Ásgeirsson
2017/01/06 20:59:10
Done.
| |
15 | |
16 namespace crash_reporter { | |
17 | |
18 // This class is a last-ditch crash handler for the Crashpad handler process. | |
19 // It prepares and stores a command line, ready for dispatching when | |
20 // an exception occurs. Everything needed to call CreateProcess is pre-allocated | |
21 // to minimize the odds of re-faulting due to e.g. tripping over the same issue | |
22 // that caused the initial crash. | |
23 // This is still very much best-effort, as doing anything at all inside a | |
24 // process that's crashed is always going to be iffy^2. | |
25 // Only one instance of this class can exist at a time. | |
scottmg
2017/01/06 18:29:04
"Only one instance" should be confirmed somewhere
Sigurður Ásgeirsson
2017/01/06 20:59:10
Ah, that's redundant. Initially I had wanted to ma
| |
26 class FallbackCrashHandlerLauncher { | |
27 public: | |
28 FallbackCrashHandlerLauncher(); | |
29 ~FallbackCrashHandlerLauncher(); | |
30 | |
31 // Initialize | |
32 bool Initialize(const base::CommandLine& program, | |
33 const base::FilePath& crashpad_database); | |
34 | |
35 // Launch the pre-computed command line for the fallback error handler. | |
36 // The expectation is that this function will never return, as the fallback | |
37 // error handler should terminate it with the exception code as the process | |
38 // exit code. The return value from this function is therefore academic in | |
39 // the normal case. | |
40 // However, for completeness, this function returns one of: | |
41 // - The error from CreateProcess if it fails to launch the fallback handler. | |
42 // - The error from waiting on the fallback crash handler process if it | |
43 // fails to wait for that process to exit. | |
44 // - The exit code from the fallback crash handler process. | |
45 // - The error encountered in retrieving the crash handler process' exit code. | |
46 DWORD LaunchAndWaitForHandler(EXCEPTION_POINTERS* pointers); | |
47 | |
48 private: | |
49 // A copy of the actual exception pointers made at time of exception. | |
50 EXCEPTION_POINTERS exception_pointers_; | |
51 | |
52 // The precomputed startup info and command line for launching the fallback | |
53 // handler. | |
54 base::win::StartupInformation startup_info_; | |
55 // Stores the pre-cooked command line, with an allottment of zeros at the back | |
scottmg
2017/01/06 18:29:04
allotment
Sigurður Ásgeirsson
2017/01/06 20:59:10
Done.
| |
56 // sufficient for writing in the thread id, just before launch. | |
57 std::vector<wchar_t> cmd_line_; | |
58 | |
59 // An inheritable handle to our own process, the raw handle is necessary | |
60 // for pre-computing the startup info. | |
61 base::win::ScopedHandle self_process_handle_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(FallbackCrashHandlerLauncher); | |
64 }; | |
65 | |
66 } // namespace crash_reporter | |
67 | |
68 #endif // COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_ | |
OLD | NEW |