Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: components/nacl/browser/nacl_process_host.cc

Issue 102073008: Allow multiple NaCl modules to be debugged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | content/browser/browser_child_process_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/browser/nacl_process_host.cc
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index 1f9487433643ed16b57135028835c77569061b29..e6e8ef450177a7df62ee5ecad6db1c6c26430689 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -667,26 +667,33 @@ void NaClProcessHost::SendMessageToRenderer(
}
// TCP port we chose for NaCl debug stub. It can be any other number.
-static const int kDebugStubPort = 4014;
+static const int kInitialDebugStubPort = 4014;
#if defined(OS_POSIX)
net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
net::SocketDescriptor s = net::kInvalidSocket;
- // We allocate currently unused TCP port for debug stub tests. The port
- // number is passed to the test via debug stub port listener.
- if (nacl_browser->HasGdbDebugStubPortListener()) {
- int port;
+ // We always try to allocate the default port first. If this fails, we then
+ // allocate any available port.
+ // On success, if the test system has register a handler
+ // (GdbDebugStubPortListener), we fire a notification.
+ int port = kInitialDebugStubPort;
+ s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port);
+ if (s == net::kInvalidSocket) {
s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port);
- if (s != net::kInvalidSocket) {
+ }
+ if (s != net::kInvalidSocket) {
+ if (nacl_browser->HasGdbDebugStubPortListener()) {
nacl_browser->FireGdbDebugStubPortOpened(port);
}
- } else {
- s = net::TCPListenSocket::CreateAndBind("127.0.0.1", kDebugStubPort);
}
+ // 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;
+ } else {
+ LOG(WARNING) << "debug stub on port " << port;
}
if (listen(s, 1)) {
LOG(ERROR) << "listen() failed on debug stub socket";
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | content/browser/browser_child_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698