OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/nacl/common/nacl_debug_exception_handler_win.h" | 5 #include "components/nacl/common/nacl_debug_exception_handler_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "base/win/scoped_handle.h" | 9 #include "base/win/scoped_handle.h" |
10 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler.
h" | 10 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler.
h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 message_loop_(message_loop), | 23 message_loop_(message_loop), |
24 on_connected_(on_connected) {} | 24 on_connected_(on_connected) {} |
25 | 25 |
26 virtual void ThreadMain() override { | 26 virtual void ThreadMain() override { |
27 // In the Windows API, the set of processes being debugged is | 27 // In the Windows API, the set of processes being debugged is |
28 // thread-local, so we have to attach to the process (using | 28 // thread-local, so we have to attach to the process (using |
29 // DebugActiveProcess()) on the same thread on which | 29 // DebugActiveProcess()) on the same thread on which |
30 // NaClDebugExceptionHandlerRun() receives debug events for the | 30 // NaClDebugExceptionHandlerRun() receives debug events for the |
31 // process. | 31 // process. |
32 bool attached = false; | 32 bool attached = false; |
33 int pid = nacl_process_.pid(); | 33 int pid = nacl_process_.Pid(); |
34 if (nacl_process_.IsValid()) { | 34 if (nacl_process_.IsValid()) { |
35 DCHECK(pid); | 35 DCHECK(pid); |
36 if (!DebugActiveProcess(pid)) { | 36 if (!DebugActiveProcess(pid)) { |
37 LOG(ERROR) << "Failed to connect to the process"; | 37 LOG(ERROR) << "Failed to connect to the process"; |
38 } else { | 38 } else { |
39 attached = true; | 39 attached = true; |
40 } | 40 } |
41 } else { | 41 } else { |
42 LOG(ERROR) << "Invalid process handle"; | 42 LOG(ERROR) << "Invalid process handle"; |
43 } | 43 } |
(...skipping 26 matching lines...) Expand all Loading... |
70 const base::Callback<void(bool)>& on_connected) { | 70 const base::Callback<void(bool)>& on_connected) { |
71 // The new PlatformThread will take ownership of the | 71 // The new PlatformThread will take ownership of the |
72 // DebugExceptionHandler object, which will delete itself on exit. | 72 // DebugExceptionHandler object, which will delete itself on exit. |
73 DebugExceptionHandler* handler = new DebugExceptionHandler( | 73 DebugExceptionHandler* handler = new DebugExceptionHandler( |
74 nacl_process.Pass(), startup_info, message_loop, on_connected); | 74 nacl_process.Pass(), startup_info, message_loop, on_connected); |
75 if (!base::PlatformThread::CreateNonJoinable(0, handler)) { | 75 if (!base::PlatformThread::CreateNonJoinable(0, handler)) { |
76 on_connected.Run(false); | 76 on_connected.Run(false); |
77 delete handler; | 77 delete handler; |
78 } | 78 } |
79 } | 79 } |
OLD | NEW |