OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "snapshot/win/exception_snapshot_win.h" | 15 #include "snapshot/win/exception_snapshot_win.h" |
16 | 16 |
17 #include <string> | 17 #include <string> |
18 | 18 |
19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "client/crashpad_client.h" | 21 #include "client/crashpad_client.h" |
22 #include "gtest/gtest.h" | 22 #include "gtest/gtest.h" |
23 #include "snapshot/win/process_snapshot_win.h" | 23 #include "snapshot/win/process_snapshot_win.h" |
24 #include "test/win/win_child_process.h" | 24 #include "test/win/win_child_process.h" |
25 #include "util/thread/thread.h" | 25 #include "util/thread/thread.h" |
26 #include "util/win/exception_handler_server.h" | 26 #include "util/win/exception_handler_server.h" |
27 #include "util/win/registration_protocol_win.h" | 27 #include "util/win/registration_protocol_win.h" |
28 #include "util/win/scoped_handle.h" | 28 #include "util/win/scoped_handle.h" |
| 29 #include "util/win/scoped_process_suspend.h" |
29 | 30 |
30 namespace crashpad { | 31 namespace crashpad { |
31 namespace test { | 32 namespace test { |
32 namespace { | 33 namespace { |
33 | 34 |
34 HANDLE DuplicateEvent(HANDLE process, HANDLE event) { | 35 HANDLE DuplicateEvent(HANDLE process, HANDLE event) { |
35 HANDLE handle; | 36 HANDLE handle; |
36 if (DuplicateHandle(GetCurrentProcess(), | 37 if (DuplicateHandle(GetCurrentProcess(), |
37 event, | 38 event, |
38 process, | 39 process, |
(...skipping 16 matching lines...) Expand all Loading... |
55 break_near_(nullptr) {} | 56 break_near_(nullptr) {} |
56 ~Delegate() override {} | 57 ~Delegate() override {} |
57 | 58 |
58 void set_break_near(void* break_near) { break_near_ = break_near; } | 59 void set_break_near(void* break_near) { break_near_ = break_near; } |
59 | 60 |
60 void ExceptionHandlerServerStarted() override { SetEvent(server_ready_); } | 61 void ExceptionHandlerServerStarted() override { SetEvent(server_ready_); } |
61 | 62 |
62 unsigned int ExceptionHandlerServerException( | 63 unsigned int ExceptionHandlerServerException( |
63 HANDLE process, | 64 HANDLE process, |
64 WinVMAddress exception_information_address) override { | 65 WinVMAddress exception_information_address) override { |
| 66 ScopedProcessSuspend suspend(process); |
65 ProcessSnapshotWin snapshot; | 67 ProcessSnapshotWin snapshot; |
66 snapshot.Initialize(process); | 68 snapshot.Initialize(process, ProcessSuspensionState::kSuspended); |
67 snapshot.InitializeException(exception_information_address); | 69 snapshot.InitializeException(exception_information_address); |
68 | 70 |
69 // Confirm the exception record was read correctly. | 71 // Confirm the exception record was read correctly. |
70 EXPECT_NE(snapshot.Exception()->ThreadID(), 0u); | 72 EXPECT_NE(snapshot.Exception()->ThreadID(), 0u); |
71 EXPECT_EQ(snapshot.Exception()->Exception(), EXCEPTION_BREAKPOINT); | 73 EXPECT_EQ(snapshot.Exception()->Exception(), EXCEPTION_BREAKPOINT); |
72 | 74 |
73 // Verify the exception happened at the expected location with a bit of | 75 // Verify the exception happened at the expected location with a bit of |
74 // slop space to allow for reading the current PC before the exception | 76 // slop space to allow for reading the current PC before the exception |
75 // happens. See CrashingChildProcess::Run(). | 77 // happens. See CrashingChildProcess::Run(). |
76 const uint64_t kAllowedOffset = 64; | 78 const uint64_t kAllowedOffset = 64; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 handle->read.get(), &break_near_address, sizeof(break_near_address)); | 205 handle->read.get(), &break_near_address, sizeof(break_near_address)); |
204 delegate.set_break_near(break_near_address); | 206 delegate.set_break_near(break_near_address); |
205 | 207 |
206 // Wait for the child to crash and the exception information to be validated. | 208 // Wait for the child to crash and the exception information to be validated. |
207 WaitForSingleObject(completed.get(), INFINITE); | 209 WaitForSingleObject(completed.get(), INFINITE); |
208 } | 210 } |
209 | 211 |
210 } // namespace | 212 } // namespace |
211 } // namespace test | 213 } // namespace test |
212 } // namespace crashpad | 214 } // namespace crashpad |
OLD | NEW |