diff options
author | bradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 02:57:27 +0000 |
---|---|---|
committer | bradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 02:57:27 +0000 |
commit | 5307d7201503bd1a4738ea9b2dbc3cb884b78d42 (patch) | |
tree | 6607555c824f67971706d106b3fbc330d41094d5 /components | |
parent | 75fea56d1f18880a4640220d287b1b86b4bdd1e6 (diff) | |
download | chromium_src-5307d7201503bd1a4738ea9b2dbc3cb884b78d42.zip chromium_src-5307d7201503bd1a4738ea9b2dbc3cb884b78d42.tar.gz chromium_src-5307d7201503bd1a4738ea9b2dbc3cb884b78d42.tar.bz2 |
Update the task manager with the debug stub port chosen by nacl.
On mac/linux the debug stub port is allocated chrome side and provided to
Native Client. On Windows (where socket handles cannot be passed between
processes), the debug port must be allocated by the nacl process (which can
only happen when the outer sandbox is disable).
Propagate the debug port selected by the nacl side to the task manager to make
it available to the user and debugging extensions.
Depends on this nacl side change:
https://codereview.chromium.org/206493005
BUG=328714
TEST=None
R=mseaborn@chromium.org,jschuh@chromium.org
Review URL: https://codereview.chromium.org/198083006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/nacl/browser/nacl_process_host.cc | 27 | ||||
-rw-r--r-- | components/nacl/browser/nacl_process_host.h | 10 | ||||
-rw-r--r-- | components/nacl/common/nacl_messages.h | 5 | ||||
-rw-r--r-- | components/nacl/loader/nacl_listener.cc | 6 |
4 files changed, 41 insertions, 7 deletions
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc index 6ef4986..5919766 100644 --- a/components/nacl/browser/nacl_process_host.cc +++ b/components/nacl/browser/nacl_process_host.cc @@ -654,6 +654,8 @@ bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER_DELAY_REPLY( NaClProcessMsg_AttachDebugExceptionHandler, OnAttachDebugExceptionHandler) + IPC_MESSAGE_HANDLER(NaClProcessHostMsg_DebugStubPortSelected, + OnDebugStubPortSelected) #endif IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated, OnPpapiChannelsCreated) @@ -755,12 +757,20 @@ void NaClProcessHost::SendMessageToRenderer( } } +void NaClProcessHost::SetDebugStubPort(uint16_t port) { + NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); + if (nacl_browser->HasGdbDebugStubPortListener()) { + nacl_browser->FireGdbDebugStubPortOpened(port); + } + // Set debug stub port on the process object. + process_->SetNaClDebugStubPort(port); +} + +#if defined(OS_POSIX) // TCP port we chose for NaCl debug stub. It can be any other number. static const int kInitialDebugStubPort = 4014; -#if defined(OS_POSIX) net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { - NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); net::SocketDescriptor s = net::kInvalidSocket; // We always try to allocate the default port first. If this fails, we then // allocate any available port. @@ -772,12 +782,8 @@ net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); } if (s != net::kInvalidSocket) { - if (nacl_browser->HasGdbDebugStubPortListener()) { - nacl_browser->FireGdbDebugStubPortOpened(port); - } + SetDebugStubPort(port); } - // Set debug stub port on the process object. - process_->SetNaClDebugStubPort(port); if (s == net::kInvalidSocket) { LOG(ERROR) << "failed to open socket for debug stub"; return net::kInvalidSocket; @@ -794,6 +800,13 @@ net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { } #endif +#if defined(OS_WIN) +void NaClProcessHost::OnDebugStubPortSelected(uint16_t debug_stub_port) { + CHECK(!uses_nonsfi_mode_); + SetDebugStubPort(debug_stub_port); +} +#endif + bool NaClProcessHost::StartNaClExecution() { NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); diff --git a/components/nacl/browser/nacl_process_host.h b/components/nacl/browser/nacl_process_host.h index 37af81a..634e5b8 100644 --- a/components/nacl/browser/nacl_process_host.h +++ b/components/nacl/browser/nacl_process_host.h @@ -106,12 +106,22 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate { bool LaunchNaClGdb(); + // Mark the process as using a particular GDB debug stub port and notify + // listeners. + void SetDebugStubPort(uint16_t port); + #if defined(OS_POSIX) // Create bound TCP socket in the browser process so that the NaCl GDB debug // stub can use it to accept incoming connections even when the Chrome sandbox // is enabled. net::SocketDescriptor GetDebugStubSocketHandle(); #endif + +#if defined(OS_WIN) + // Called when the debug stub port has been selected. + void OnDebugStubPortSelected(uint16_t debug_stub_port); +#endif + bool LaunchSelLdr(); // BrowserChildProcessHostDelegate implementation: diff --git a/components/nacl/common/nacl_messages.h b/components/nacl/common/nacl_messages.h index 2b1fbba..bb58f9e 100644 --- a/components/nacl/common/nacl_messages.h +++ b/components/nacl/common/nacl_messages.h @@ -66,6 +66,11 @@ IPC_MESSAGE_CONTROL0(NaClProcessMsg_StopBroker) IPC_SYNC_MESSAGE_CONTROL1_1(NaClProcessMsg_AttachDebugExceptionHandler, std::string, /* Internal process info */ bool /* Result */) + +// Notify the browser process that the NaCl process has bound the given +// TCP port number to use for the GDB debug stub. +IPC_MESSAGE_CONTROL1(NaClProcessHostMsg_DebugStubPortSelected, + uint16_t /* debug_stub_port */) #endif // Used by the NaCl process to query a database in the browser. The database diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc index e7b8f4c..f527191 100644 --- a/components/nacl/loader/nacl_listener.cc +++ b/components/nacl/loader/nacl_listener.cc @@ -109,6 +109,10 @@ int AttachDebugExceptionHandler(const void* info, size_t info_size) { return result; } +void DebugStubPortSelectedHandler(uint16_t port) { + g_listener->Send(new NaClProcessHostMsg_DebugStubPortSelected(port)); +} + #endif // Creates the PPAPI IPC channel between the NaCl IRT and the host @@ -464,6 +468,8 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { #if defined(OS_WIN) args->broker_duplicate_handle_func = BrokerDuplicateHandle; args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; + args->debug_stub_server_port_selected_handler_func = + DebugStubPortSelectedHandler; #endif #if defined(OS_LINUX) args->prereserved_sandbox_size = prereserved_sandbox_size_; |