summaryrefslogtreecommitdiffstats
path: root/chrome/nacl
diff options
context:
space:
mode:
authormseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 02:48:04 +0000
committermseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 02:48:04 +0000
commitf50e9b22e51619f22d33bef0a591f6c4a50559aa (patch)
tree68013f65e2e33e5c77063dfdec57ff7a25a9428a /chrome/nacl
parent2b81497786a9177f66feff85b50e11a61832a651 (diff)
downloadchromium_src-f50e9b22e51619f22d33bef0a591f6c4a50559aa.zip
chromium_src-f50e9b22e51619f22d33bef0a591f6c4a50559aa.tar.gz
chromium_src-f50e9b22e51619f22d33bef0a591f6c4a50559aa.tar.bz2
NaCl: Split the debug exception handler thread into a separate file
This is in preparation for changing nacl_process_host.cc to reuse this code instead of having its own copy in DebugContext. This needs to go into chrome/common rather than chrome/nacl so that nacl_process_host.cc can #include it under the checkdeps rules. This changes the code to use PostTask() instead of PostDelayedTask(). BUG=http://code.google.com/p/nativeclient/issues/detail?id=2618 TEST=run_inbrowser_exception_test in nacl_integration Review URL: http://codereview.chromium.org/10211007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r--chrome/nacl/nacl_broker_listener.cc70
1 files changed, 4 insertions, 66 deletions
diff --git a/chrome/nacl/nacl_broker_listener.cc b/chrome/nacl/nacl_broker_listener.cc
index 8d13600..086f2a6 100644
--- a/chrome/nacl/nacl_broker_listener.cc
+++ b/chrome/nacl/nacl_broker_listener.cc
@@ -11,13 +11,12 @@
#include "base/message_loop_proxy.h"
#include "base/path_service.h"
#include "base/process_util.h"
-#include "base/threading/platform_thread.h"
#include "chrome/common/nacl_cmd_line.h"
+#include "chrome/common/nacl_debug_exception_handler_win.h"
#include "chrome/common/nacl_messages.h"
#include "content/common/sandbox_policy.h"
#include "content/public/common/content_switches.h"
#include "ipc/ipc_switches.h"
-#include "native_client/src/trusted/service_runtime/win/debug_exception_handler.h"
namespace {
@@ -25,62 +24,6 @@ void SendReply(IPC::Channel* channel, int32 pid) {
channel->Send(new NaClProcessMsg_DebugExceptionHandlerLaunched(pid));
}
-class DebugExceptionHandler : public base::PlatformThread::Delegate {
- public:
- DebugExceptionHandler(base::MessageLoopProxy* message_loop,
- IPC::Channel* channel, int32 pid)
- : message_loop_(message_loop), channel_(channel), pid_(pid) {
- }
-
- virtual void ThreadMain() OVERRIDE {
- // In the Windows API, the set of processes being debugged is
- // thread-local, so we have to attach to the process (using
- // DebugActiveProcess()) on the same thread on which
- // NaClDebugLoop() receives debug events for the process.
- BOOL attached = false;
- base::ProcessHandle process_handle = base::kNullProcessHandle;
- if (!base::OpenProcessHandleWithAccess(
- pid_,
- base::kProcessAccessQueryInformation |
- base::kProcessAccessSuspendResume |
- base::kProcessAccessTerminate |
- base::kProcessAccessVMOperation |
- base::kProcessAccessVMRead |
- base::kProcessAccessVMWrite |
- base::kProcessAccessWaitForTermination,
- &process_handle)) {
- LOG(ERROR) << "Failed to get process handle";
- } else {
- attached = DebugActiveProcess(pid_);
- if (!attached) {
- LOG(ERROR) << "Failed to connect to the process";
- }
- }
- // At the moment we do not say in the reply whether attaching as a
- // debugger succeeded. In the future, when we attach on demand
- // when an exception handler is first registered, we can make the
- // NaCl syscall indicate whether attaching succeeded.
- message_loop_->PostDelayedTask(FROM_HERE,
- base::Bind(SendReply, channel_, pid_), base::TimeDelta());
-
- if (attached) {
- DWORD exit_code;
- NaClDebugLoop(process_handle, &exit_code);
- }
- if (process_handle != base::kNullProcessHandle) {
- base::CloseProcessHandle(process_handle);
- }
- delete this;
- }
-
- private:
- base::MessageLoopProxy* message_loop_;
- IPC::Channel* channel_;
- int32 pid_;
-
- DISALLOW_COPY_AND_ASSIGN(DebugExceptionHandler);
-};
-
} // namespace
NaClBrokerListener::NaClBrokerListener()
@@ -156,14 +99,9 @@ void NaClBrokerListener::OnLaunchLoaderThroughBroker(
}
void NaClBrokerListener::OnLaunchDebugExceptionHandler(int32 pid) {
- // The new PlatformThread will take ownership of the
- // DebugExceptionHandler object, which will delete itself on exit.
- DebugExceptionHandler* handler = new DebugExceptionHandler(
- base::MessageLoopProxy::current(), channel_.get(), pid);
- if (!base::PlatformThread::CreateNonJoinable(0, handler)) {
- SendReply(channel_.get(), pid);
- delete handler;
- }
+ base::Closure reply_sender(base::Bind(SendReply, channel_.get(), pid));
+ NaClStartDebugExceptionHandlerThread(pid, base::MessageLoopProxy::current(),
+ reply_sender);
}
void NaClBrokerListener::OnStopBroker() {