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, |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 namespace crashpad { | 35 namespace crashpad { |
36 namespace test { | 36 namespace test { |
37 namespace { | 37 namespace { |
38 | 38 |
39 // Runs the ExceptionHandlerServer on a background thread. | 39 // Runs the ExceptionHandlerServer on a background thread. |
40 class RunServerThread : public Thread { | 40 class RunServerThread : public Thread { |
41 public: | 41 public: |
42 // Instantiates a thread which will invoke server->Run(delegate, pipe_name); | 42 // Instantiates a thread which will invoke server->Run(delegate, pipe_name); |
43 RunServerThread(ExceptionHandlerServer* server, | 43 RunServerThread(ExceptionHandlerServer* server, |
44 ExceptionHandlerServer::Delegate* delegate, | 44 ExceptionHandlerServer::Delegate* delegate) |
45 const std::string& pipe_name) | 45 : server_(server), delegate_(delegate) {} |
46 : server_(server), delegate_(delegate), pipe_name_(pipe_name) {} | |
47 ~RunServerThread() override {} | 46 ~RunServerThread() override {} |
48 | 47 |
49 private: | 48 private: |
50 // Thread: | 49 // Thread: |
51 void ThreadMain() override { server_->Run(delegate_, pipe_name_); } | 50 void ThreadMain() override { server_->Run(delegate_); } |
52 | 51 |
53 ExceptionHandlerServer* server_; | 52 ExceptionHandlerServer* server_; |
54 ExceptionHandlerServer::Delegate* delegate_; | 53 ExceptionHandlerServer::Delegate* delegate_; |
55 std::string pipe_name_; | |
56 | 54 |
57 DISALLOW_COPY_AND_ASSIGN(RunServerThread); | 55 DISALLOW_COPY_AND_ASSIGN(RunServerThread); |
58 }; | 56 }; |
59 | 57 |
60 // During destruction, ensures that the server is stopped and the background | 58 // During destruction, ensures that the server is stopped and the background |
61 // thread joined. | 59 // thread joined. |
62 class ScopedStopServerAndJoinThread { | 60 class ScopedStopServerAndJoinThread { |
63 public: | 61 public: |
64 ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread) | 62 ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread) |
65 : server_(server), thread_(thread) {} | 63 : server_(server), thread_(thread) {} |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 }; | 121 }; |
124 | 122 |
125 void TestCrashingChild(const base::string16& directory_modification) { | 123 void TestCrashingChild(const base::string16& directory_modification) { |
126 // Set up the registration server on a background thread. | 124 // Set up the registration server on a background thread. |
127 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" + | 125 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" + |
128 base::StringPrintf("%08x", GetCurrentProcessId()); | 126 base::StringPrintf("%08x", GetCurrentProcessId()); |
129 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr)); | 127 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr)); |
130 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr)); | 128 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr)); |
131 CrashingDelegate delegate(server_ready.get(), completed.get()); | 129 CrashingDelegate delegate(server_ready.get(), completed.get()); |
132 | 130 |
133 ExceptionHandlerServer exception_handler_server; | 131 ExceptionHandlerServer exception_handler_server(pipe_name); |
134 RunServerThread server_thread( | 132 RunServerThread server_thread(&exception_handler_server, &delegate); |
135 &exception_handler_server, &delegate, pipe_name); | |
136 server_thread.Start(); | 133 server_thread.Start(); |
137 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( | 134 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( |
138 &exception_handler_server, &server_thread); | 135 &exception_handler_server, &server_thread); |
139 | 136 |
140 WaitForSingleObject(server_ready.get(), INFINITE); | 137 WaitForSingleObject(server_ready.get(), INFINITE); |
141 | 138 |
142 // Spawn a child process, passing it the pipe name to connect to. | 139 // Spawn a child process, passing it the pipe name to connect to. |
143 base::FilePath test_executable = Paths::Executable(); | 140 base::FilePath test_executable = Paths::Executable(); |
144 std::wstring child_test_executable = | 141 std::wstring child_test_executable = |
145 test_executable.DirName() | 142 test_executable.DirName() |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 223 |
227 void TestDumpWithoutCrashingChild( | 224 void TestDumpWithoutCrashingChild( |
228 const base::string16& directory_modification) { | 225 const base::string16& directory_modification) { |
229 // Set up the registration server on a background thread. | 226 // Set up the registration server on a background thread. |
230 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" + | 227 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" + |
231 base::StringPrintf("%08x", GetCurrentProcessId()); | 228 base::StringPrintf("%08x", GetCurrentProcessId()); |
232 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr)); | 229 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr)); |
233 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr)); | 230 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr)); |
234 SimulateDelegate delegate(server_ready.get(), completed.get()); | 231 SimulateDelegate delegate(server_ready.get(), completed.get()); |
235 | 232 |
236 ExceptionHandlerServer exception_handler_server; | 233 ExceptionHandlerServer exception_handler_server(pipe_name); |
237 RunServerThread server_thread( | 234 RunServerThread server_thread(&exception_handler_server, &delegate); |
238 &exception_handler_server, &delegate, pipe_name); | |
239 server_thread.Start(); | 235 server_thread.Start(); |
240 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( | 236 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( |
241 &exception_handler_server, &server_thread); | 237 &exception_handler_server, &server_thread); |
242 | 238 |
243 WaitForSingleObject(server_ready.get(), INFINITE); | 239 WaitForSingleObject(server_ready.get(), INFINITE); |
244 | 240 |
245 // Spawn a child process, passing it the pipe name to connect to. | 241 // Spawn a child process, passing it the pipe name to connect to. |
246 base::FilePath test_executable = Paths::Executable(); | 242 base::FilePath test_executable = Paths::Executable(); |
247 std::wstring child_test_executable = | 243 std::wstring child_test_executable = |
248 test_executable.DirName() | 244 test_executable.DirName() |
(...skipping 25 matching lines...) Expand all Loading... |
274 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug")); | 270 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug")); |
275 #else | 271 #else |
276 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release")); | 272 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release")); |
277 #endif | 273 #endif |
278 } | 274 } |
279 #endif // ARCH_CPU_64_BITS | 275 #endif // ARCH_CPU_64_BITS |
280 | 276 |
281 } // namespace | 277 } // namespace |
282 } // namespace test | 278 } // namespace test |
283 } // namespace crashpad | 279 } // namespace crashpad |
OLD | NEW |