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

Unified Diff: src/trusted/debug_stub/nacl_debug.cc

Issue 206493005: Provide chrome the option of learning the debug stub port chosen by nacl. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: review fixes Created 6 years, 9 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 | « src/public/chrome_main.h ('k') | src/trusted/debug_stub/transport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/debug_stub/nacl_debug.cc
diff --git a/src/trusted/debug_stub/nacl_debug.cc b/src/trusted/debug_stub/nacl_debug.cc
index 057d4bb6b622193a8f63aa0a82a341e817efbbd3..86bb64428549275ca0a9168b9ab5591998227a6b 100644
--- a/src/trusted/debug_stub/nacl_debug.cc
+++ b/src/trusted/debug_stub/nacl_debug.cc
@@ -47,16 +47,20 @@ static SocketBinding *g_socket_binding = NULL;
int NaClDebugBindSocket() {
if (g_socket_binding == NULL) {
NaClDebugStubInit();
- const char *addr = "127.0.0.1:4014";
- g_socket_binding = SocketBinding::Bind(addr);
+ // Try port 4014 first for compatibility.
+ g_socket_binding = SocketBinding::Bind("127.0.0.1:4014");
+ // If port 4014 is not available, try any port.
if (g_socket_binding == NULL) {
- NaClLog(LOG_ERROR, "NaClStubThread: Failed to bind TCP port '%s'\n",
- addr);
+ g_socket_binding = SocketBinding::Bind("127.0.0.1:0");
+ }
+ if (g_socket_binding == NULL) {
+ NaClLog(LOG_ERROR,
+ "NaClDebugStubBindSocket: Failed to bind any TCP port\n");
return 0;
}
NaClLog(LOG_WARNING,
- "nacl_debug(%d) : Connect GDB with 'target remote %s'.\n",
- __LINE__, addr);
+ "nacl_debug(%d) : Connect GDB with 'target remote :%d\n",
+ __LINE__, g_socket_binding->GetBoundPort());
}
return 1;
}
@@ -69,9 +73,6 @@ void NaClDebugSetBoundSocket(NaClSocketHandle bound_socket) {
void WINAPI NaClStubThread(void *thread_arg) {
UNREFERENCED_PARAMETER(thread_arg);
- if (!NaClDebugBindSocket()) {
- return;
- }
while (1) {
// Wait for a connection.
nacl::scoped_ptr<ITransport> trans(g_socket_binding->AcceptConnection());
@@ -124,6 +125,11 @@ int NaClDebugInit(struct NaClApp *nap) {
CHECK(g_target != NULL);
g_target->Init();
+ if (!NaClDebugBindSocket()) {
+ return 0;
+ }
+ nap->debug_stub_port = g_socket_binding->GetBoundPort();
+
NaClThread *thread = new NaClThread;
CHECK(thread != NULL);
« no previous file with comments | « src/public/chrome_main.h ('k') | src/trusted/debug_stub/transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698