aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-02-27 17:21:35 +0000
committerDaniel Jacobowitz <drow@false.org>2007-02-27 17:21:35 +0000
commit6f8486daac90adbf742dde9b81775651b5b6e624 (patch)
tree03b51d8fed5c00d4d116869c76ec4e99f6a7a0c5 /gdb
parentc499ed39b6662c1fdf22d65f6049df2603f85880 (diff)
downloadgdb-6f8486daac90adbf742dde9b81775651b5b6e624.zip
gdb-6f8486daac90adbf742dde9b81775651b5b6e624.tar.gz
gdb-6f8486daac90adbf742dde9b81775651b5b6e624.tar.bz2
from Mat Hostetter <mat@lcs.mit.edu>
* remote-utils.c (remote_open): Print out the assigned port number.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/ChangeLog4
-rw-r--r--gdb/gdbserver/remote-utils.c11
2 files changed, 15 insertions, 0 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index b2dd45c..1900371 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -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.
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 6a9a176..b9a0733 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -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);