from Mat Hostetter <mat@lcs.mit.edu>
authorDaniel Jacobowitz <drow@false.org>
Tue, 27 Feb 2007 17:21:35 +0000 (17:21 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 27 Feb 2007 17:21:35 +0000 (17:21 +0000)
* remote-utils.c (remote_open): Print out the assigned port number.

gdb/gdbserver/ChangeLog
gdb/gdbserver/remote-utils.c

index b2dd45c12aa1622c17b37698feec1ea9c07fd6d8..19003715e257428c7bb3d75c28cc679a0d3b284e 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-26  Mat Hostetter  <mat@lcs.mit.edu>
+
+       * remote-utils.c (remote_open): Print out the assigned port number.
+
 2007-02-26  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * remote-utils.c (monitor_output): New function.
index 6a9a176c07e308e9ceb1bc6f8845a68cfad4adb1..b9a0733067b173778d17f9b64848e6d563ef0461 100644 (file)
@@ -209,6 +209,17 @@ remote_open (char *name)
          || listen (tmp_desc, 1))
        perror_with_name ("Can't bind address");
 
+      /* If port is zero, a random port will be selected, and the
+        fprintf below needs to know what port was selected.  */
+      if (port == 0)
+       {
+         socklen_t len = sizeof (sockaddr);
+         if (getsockname (tmp_desc, (struct sockaddr *) &sockaddr, &len) < 0
+             || len < sizeof (sockaddr))
+           perror_with_name ("Can't determine port");
+         port = ntohs (sockaddr.sin_port);
+       }
+
       fprintf (stderr, "Listening on port %d\n", port);
       fflush (stderr);
 
This page took 0.029473 seconds and 4 git commands to generate.