OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | |
scottmg
2015/04/24 04:55:06
2015
| |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #include "client/crashpad_client.h" | |
16 | |
17 #include <Windows.h> | |
scottmg
2015/04/24 04:55:06
lower 'W'
cpu_(ooo_6.6-7.5)
2015/04/29 01:34:17
Acknowledged.
| |
18 | |
19 namespace { | |
20 // Time to wait for the handler to create a dump. This is tricky to figure out. | |
21 const DWORD kMillisecondsUntilTerminate = 5000; | |
22 | |
23 // These two handles to events are leaked. | |
24 HANDLE g_signal_exception = nullptr; | |
25 HANDLE g_wait_termination = nullptr; | |
26 | |
27 LONG WINAPI UnhandledExceptionHandler(EXCEPTION_POINTERS* exception_pointers) { | |
28 // TODO (cpu): Here write |exception_pointers| to g_crashpad_info. | |
29 SignalObjectAndWait(g_signal_exception, | |
Mark Mentovai
2015/04/28 17:53:05
I would prefer if the return value were checked, s
| |
30 g_wait_termination, | |
31 kMillisecondsUntilTerminate, | |
32 FALSE); | |
33 // We don't want to generate more exceptions, so we take the fast route. | |
34 TerminateProcess(GetCurrentProcess(), 0); | |
Mark Mentovai
2015/04/28 17:53:05
0’s probably not the best exit code to use.
| |
35 return 0L; | |
36 } | |
37 | |
38 } // namespace | |
39 | |
40 namespace crashpad { | |
41 | |
42 CrashpadClient::CrashpadClient() { | |
43 } | |
44 | |
45 CrashpadClient::~CrashpadClient() { | |
46 } | |
47 | |
48 bool CrashpadClient::StartHandler( | |
49 const base::FilePath& handler, | |
50 const base::FilePath& database, | |
51 const std::string& url, | |
52 const std::map<std::string, std::string>& annotations, | |
53 const std::vector<std::string>& arguments) { | |
54 // Unclear if we need to implement this on Windows. We expect that in most | |
55 // cases SetHandler() is used exclusively. | |
Mark Mentovai
2015/04/28 17:53:05
This method can still be used to provide the refer
cpu_(ooo_6.6-7.5)
2015/04/29 01:34:17
Probably my misunderstanding. I'll update the comm
| |
56 return false; | |
57 } | |
58 | |
59 bool SetHandler(const std::string& ipc_port) { | |
60 // TODO (cpu): Contact the handler and obtain g_signal_exception and | |
61 // g_wait_termination. | |
62 return false; | |
63 } | |
64 | |
65 bool CrashpadClient::UseHandler() { | |
66 if (!g_signal_exception) | |
67 return false; | |
68 if (!g_wait_termination) | |
69 return false; | |
70 // In theory we could store the previous handler but it is not clear what | |
71 // use we have for it. | |
72 SetUnhandledExceptionFilter(&UnhandledExceptionHandler); | |
73 return true; | |
74 } | |
75 | |
76 } // namespace crashpad | |
OLD | NEW |