gdb/gdbserver: 2006-10-08 Jan Kratochvil * gdbreplay.c (remote_open, main): Remove "host:port" argument support as obsoleted by "fd" using socat(1). * remote-utils.c (remote_open): Likewise. * server.c (gdbserver_usage): Likewise. gdb/doc: 2006-10-08 Jan Kratochvil * gdb.texinfo (Using the gdbserver program): Remove "host:port". diff -u -rup gdb-fds-plus/doc/gdb.texinfo gdb/doc/gdb.texinfo --- gdb-fds-plus/doc/gdb.texinfo 2006-10-08 20:27:51.000000000 +0200 +++ gdb/doc/gdb.texinfo 2006-10-08 20:30:51.000000000 +0200 @@ -12567,9 +12567,8 @@ target> gdbserver @var{comm} @var{progra @end smallexample @var{comm} is either a device name (to use a serial line) or file descriptions -numbers or a TCP hostname and portnumber. For example, to debug Emacs with the -argument @samp{foo.txt} and communicate with @value{GDBN} over the serial port -@file{/dev/com1}: +numbers. For example, to debug Emacs with the argument @samp{foo.txt} and +communicate with @value{GDBN} over the serial port @file{/dev/com1}: @smallexample target> gdbserver /dev/com1 emacs foo.txt @@ -12603,13 +12602,6 @@ a port number that conflicts with anothe message and exits.} You must use the same port number with the host @value{GDBN} @code{target remote} command. -On IPv4 networks you may also run @code{gdbserver} directly, without the -@code{socat} helper there (equivalent command to the example above): - -@smallexample -target> gdbserver :2345 emacs foo.txt -@end smallexample - On some targets, @code{gdbserver} can also attach to running programs. This is accomplished via the @code{--attach} argument. The syntax is: diff -u -rup gdb-fds-plus/gdbserver/gdbreplay.c gdb/gdbserver/gdbreplay.c --- gdb-fds-plus/gdbserver/gdbreplay.c 2006-10-08 20:27:51.000000000 +0200 +++ gdb/gdbserver/gdbreplay.c 2006-10-08 20:30:01.000000000 +0200 @@ -129,80 +129,16 @@ remote_open (char *name) } else if (!strchr (name, ':')) { - fprintf (stderr, "%s: Must specify tcp connection as host:addr" - " or use fd\n", name); + fprintf (stderr, "%s: Must specify connection as fd\n", name); fflush (stderr); exit (1); } else { - int remote_desc; -#ifdef USE_WIN32API - static int winsock_initialized; -#endif - char *port_str; - int port; - struct sockaddr_in sockaddr; - socklen_t tmp; - int tmp_desc; - - port_str = strchr (name, ':'); - - port = atoi (port_str + 1); - -#ifdef USE_WIN32API - if (!winsock_initialized) - { - WSADATA wsad; - - WSAStartup (MAKEWORD (1, 0), &wsad); - winsock_initialized = 1; - } -#endif - - tmp_desc = socket (PF_INET, SOCK_STREAM, 0); - if (tmp_desc < 0) - perror_with_name ("Can't open socket"); - - /* Allow rapid reuse of this port. */ - tmp = 1; - setsockopt (tmp_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, - sizeof (tmp)); - - sockaddr.sin_family = PF_INET; - sockaddr.sin_port = htons (port); - sockaddr.sin_addr.s_addr = INADDR_ANY; - - if (bind (tmp_desc, (struct sockaddr *) &sockaddr, sizeof (sockaddr)) - || listen (tmp_desc, 1)) - perror_with_name ("Can't bind address"); - - tmp = sizeof (sockaddr); - remote_desc = accept (tmp_desc, (struct sockaddr *) &sockaddr, &tmp); - if (remote_desc == -1) - perror_with_name ("Accept failed"); - - /* Enable TCP keep alive process. */ - tmp = 1; - setsockopt (tmp_desc, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp, sizeof (tmp)); - - /* Tell TCP not to delay small packets. This greatly speeds up - interactive response. */ - tmp = 1; - setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY, - (char *) &tmp, sizeof (tmp)); - - close (tmp_desc); /* No longer need this */ - -#ifndef USE_WIN32API - close (tmp_desc); /* No longer need this */ - - signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbreplay simply - exits when the remote side dies. */ -#else - closesocket (tmp_desc); /* No longer need this */ -#endif - remote_desc_in = remote_desc_out = remote_desc; + fprintf (stderr, "%s: tcp host:port no longer supported," + " see the help for fd"); + fflush (stderr); + exit (1); } #if defined(F_SETFL) && defined (FASYNC) @@ -357,8 +293,7 @@ main (int argc, char *argv[]) { fprintf (stderr, "Usage: gdbreplay { | fd}\n" "\n" - "Use host:port to listen for a TCP connection, or\n" - "fd (such as fd34) for networking over file descriptors:\n" + "Use fd (such as fd34) for networking over file descriptors:\n" " " "socat EXEC:'gdbserver fd34 PROG',fdin=3,fdout=4 TCP6-LISTEN:5000\n"); fflush (stderr); diff -u -rup gdb-fds-plus/gdbserver/remote-utils.c gdb/gdbserver/remote-utils.c --- gdb-fds-plus/gdbserver/remote-utils.c 2006-10-08 20:27:51.000000000 +0200 +++ gdb/gdbserver/remote-utils.c 2006-10-08 20:30:01.000000000 +0200 @@ -106,139 +106,11 @@ remote_open (char *name) } else if (!strchr (name, ':')) { - int remote_desc; - -#ifdef USE_WIN32API - error ("Only : or fd supported on this platform."); -#else - remote_desc = open (name, O_RDWR); - if (remote_desc < 0) - perror_with_name ("Could not open remote device"); - -#ifdef HAVE_TERMIOS - { - struct termios termios; - tcgetattr (remote_desc, &termios); - - termios.c_iflag = 0; - termios.c_oflag = 0; - termios.c_lflag = 0; - termios.c_cflag &= ~(CSIZE | PARENB); - termios.c_cflag |= CLOCAL | CS8; - termios.c_cc[VMIN] = 1; - termios.c_cc[VTIME] = 0; - - tcsetattr (remote_desc, TCSANOW, &termios); - } -#endif - -#ifdef HAVE_TERMIO - { - struct termio termio; - ioctl (remote_desc, TCGETA, &termio); - - termio.c_iflag = 0; - termio.c_oflag = 0; - termio.c_lflag = 0; - termio.c_cflag &= ~(CSIZE | PARENB); - termio.c_cflag |= CLOCAL | CS8; - termio.c_cc[VMIN] = 1; - termio.c_cc[VTIME] = 0; - - ioctl (remote_desc, TCSETA, &termio); - } -#endif - -#ifdef HAVE_SGTTY - { - struct sgttyb sg; - - ioctl (remote_desc, TIOCGETP, &sg); - sg.sg_flags = RAW; - ioctl (remote_desc, TIOCSETP, &sg); - } -#endif - - fprintf (stderr, "Remote debugging using %s\n", name); - remote_desc_in = remote_desc_out = remote_desc; -#endif /* USE_WIN32API */ + error ("Only fd supported on this platform."); } else { - int remote_desc; - -#ifdef USE_WIN32API - static int winsock_initialized; -#endif - char *port_str; - int port; - struct sockaddr_in sockaddr; - socklen_t tmp; - int tmp_desc; - - port_str = strchr (name, ':'); - - port = atoi (port_str + 1); - -#ifdef USE_WIN32API - if (!winsock_initialized) - { - WSADATA wsad; - - WSAStartup (MAKEWORD (1, 0), &wsad); - winsock_initialized = 1; - } -#endif - - tmp_desc = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); - if (tmp_desc < 0) - perror_with_name ("Can't open socket"); - - /* Allow rapid reuse of this port. */ - tmp = 1; - setsockopt (tmp_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, - sizeof (tmp)); - - sockaddr.sin_family = PF_INET; - sockaddr.sin_port = htons (port); - sockaddr.sin_addr.s_addr = INADDR_ANY; - - if (bind (tmp_desc, (struct sockaddr *) &sockaddr, sizeof (sockaddr)) - || listen (tmp_desc, 1)) - perror_with_name ("Can't bind address"); - - fprintf (stderr, "Listening on port %d\n", port); - fflush (stderr); - - tmp = sizeof (sockaddr); - remote_desc = accept (tmp_desc, (struct sockaddr *) &sockaddr, &tmp); - if (remote_desc == -1) - perror_with_name ("Accept failed"); - - /* Enable TCP keep alive process. */ - tmp = 1; - setsockopt (tmp_desc, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp, sizeof (tmp)); - - /* Tell TCP not to delay small packets. This greatly speeds up - interactive response. */ - tmp = 1; - setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY, - (char *) &tmp, sizeof (tmp)); - - -#ifndef USE_WIN32API - close (tmp_desc); /* No longer need this */ - - signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver simply - exits when the remote side dies. */ -#else - closesocket (tmp_desc); /* No longer need this */ -#endif - - /* Convert IP address to string. */ - fprintf (stderr, "Remote debugging from host %s\n", - inet_ntoa (sockaddr.sin_addr)); - remote_desc_in = remote_desc_out = remote_desc; + error ("tcp host:port no longer supported, see the help for fd"); } #if defined(F_SETFL) && defined (FASYNC) diff -u -rup gdb-fds-plus/gdbserver/server.c gdb/gdbserver/server.c --- gdb-fds-plus/gdbserver/server.c 2006-10-08 20:27:51.000000000 +0200 +++ gdb/gdbserver/server.c 2006-10-08 20:30:01.000000000 +0200 @@ -436,7 +436,6 @@ gdbserver_usage (void) "\tgdbserver COMM --attach PID\n" "\n" "COMM may either be a tty device (for serial debugging), or\n" - "HOST:PORT to listen for a TCP connection, or\n" "fd (such as fd34) for networking over file descriptors:\n" " " "socat EXEC:'gdbserver fd34 PROG',fdin=3,fdout=4 TCP6-LISTEN:5000\n");