From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] IPv6 support for gdbserver
Date: Sun, 08 Oct 2006 19:03:00 -0000 [thread overview]
Message-ID: <20061008190239.GA29584@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <20060930152757.GA27372@host0.dyn.jankratochvil.net>
[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]
Hi,
patch for the IPv6 support according to the Daniel Jacobowitz's recommendation:
http://sourceware.org/ml/gdb-patches/2006-09/msg00194.html
I am primarily interested if the mainline is going to use this "tcp6:" syntax.
gdb(1) client: As before - "tcp6:" prefix support, "tcp:" extended by IPv6.
gdbserver(1)/gdbreplay(1): Syntax "fd<in><out>" - like:
socat EXEC:'gdbserver fd34 emacs foo.txt',fdin=3,fdout=4 'TCP-LISTEN:2345'
The first patch "gdb-cvs-IPv6-fds-plus.patch" adds both features listed above.
The second patch "gdb-cvs-IPv6-hostport-minus.patch" removes the obsoleted
"host:port" syntax from gdbserver(1)/gdbreplay(1).
Regards,
Jan
On Sat, 30 Sep 2006 17:27:57 +0200, Jan Kratochvil wrote:
> On Wed, 27 Sep 2006 21:06:11 +0200, Daniel Jacobowitz wrote:
> > On Wed, Sep 27, 2006 at 08:55:47PM +0200, Jan Kratochvil wrote:
> > > On Wed, 27 Sep 2006 20:20:38 +0200, Daniel Jacobowitz wrote:
> > > ...
> > > > focused on the environment you're working in (Red Hat Linux).
> > > ...
> > > > I suspect that this would break GDB builds on a number of targets
>
> This version detects getaddrinfo(3)/getnameinfo(3)/AF_INET6;
> tested only by hand, not on a real system missing IPv6.
>
> ...
> > The advantage of providing just an fd interface is that you can leave
> > writing complicated networking code
>
> This patch extends the gdbserver part for IPv6.
>
>
> Regards,
> Jan
[-- Attachment #2: gdb-cvs-IPv6-fds-plus.patch --]
[-- Type: text/plain, Size: 31706 bytes --]
gdb:
2006-10-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* ser-tcp.c (net_open): Support IPv6 "tcp6:"&co. notation.
* configure.ac: Check for IPv6 getaddrinfo, getnameinfo and AF_INET6.
* configure, config.in: Regenerate.
gdb/gdbserver:
2006-10-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbreplay.c (remote_open, main): Support "fd<in><out>" fds argument.
(remote_desc_in, remote_desc_out, remote_close, remote_open, expect,
play): Replace `remote_desc' by `remote_desc_in' and `remote_desc_out'.
* remote-utils.c (remote_desc_in, remote_desc_out, remote_close,
remote_open, putpkt_binary, input_interrupt, readchar, getpkt):
Replace `remote_desc' by `remote_desc_in' and `remote_desc_out'.
* server.c (gdbserver_usage): Descripe "fd<in><out>" fds argument.
gdb/doc:
2006-10-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Connecting to a remote target): Describe IPv6
"tcp6:"&co. notation.
(Using the gdbserver program): Describe "fd<in><out>" comm notation.
diff -u -p -r1.84 config.in
--- gdb/config.in 8 Aug 2006 20:32:15 -0000 1.84
+++ gdb/config.in 8 Oct 2006 15:37:00 -0000
@@ -67,6 +67,10 @@
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
+/* Define to 1 if you have the declaration of `AF_INET6', and to 0 if you
+ don't. */
+#undef HAVE_DECL_AF_INET6
+
/* Define to 1 if you have the declaration of `free', and to 0 if you don't.
*/
#undef HAVE_DECL_FREE
@@ -113,9 +117,15 @@
/* Define if <sys/procfs.h> has fpregset_t. */
#undef HAVE_FPREGSET_T
+/* Define to 1 if you have the `getaddrinfo' function. */
+#undef HAVE_GETADDRINFO
+
/* Define to 1 if you have the `getgid' function. */
#undef HAVE_GETGID
+/* Define to 1 if you have the `getnameinfo' function. */
+#undef HAVE_GETNAMEINFO
+
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
diff -u -p -r1.213 configure
--- gdb/configure 8 Aug 2006 20:32:15 -0000 1.213
+++ gdb/configure 8 Oct 2006 15:37:03 -0000
@@ -17453,6 +17453,285 @@ fi
done
+for ac_func in getaddrinfo
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in getnameinfo
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+echo "$as_me:$LINENO: checking whether AF_INET6 is declared" >&5
+echo $ECHO_N "checking whether AF_INET6 is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_AF_INET6+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/socket.h>
+
+
+int
+main ()
+{
+#ifndef AF_INET6
+ char *p = (char *) AF_INET6;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_AF_INET6=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_AF_INET6=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_AF_INET6" >&5
+echo "${ECHO_T}$ac_cv_have_decl_AF_INET6" >&6
+if test $ac_cv_have_decl_AF_INET6 = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_AF_INET6 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_AF_INET6 0
+_ACEOF
+
+
+fi
+
+
+
# Check the return and argument types of ptrace. No canned test for
# this, so roll our own.
gdb_ptrace_headers='
@@ -22335,7 +22614,7 @@ ac_x_header_dirs='
/usr/openwin/share/include'
if test "$ac_x_includes" = no; then
- # Guess where to find include files, by looking for Intrinsic.h.
+ # Guess where to find include files, by looking for Xlib.h.
# First, try using that file with no special directory specified.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -22343,7 +22622,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <X11/Intrinsic.h>
+#include <X11/Xlib.h>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
@@ -22370,7 +22649,7 @@ else
sed 's/^/| /' conftest.$ac_ext >&5
for ac_dir in $ac_x_header_dirs; do
- if test -r "$ac_dir/X11/Intrinsic.h"; then
+ if test -r "$ac_dir/X11/Xlib.h"; then
ac_x_includes=$ac_dir
break
fi
@@ -22384,18 +22663,18 @@ if test "$ac_x_libraries" = no; then
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS=$LIBS
- LIBS="-lXt $LIBS"
+ LIBS="-lX11 $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <X11/Intrinsic.h>
+#include <X11/Xlib.h>
int
main ()
{
-XtMalloc (0)
+XrmInitialize ()
;
return 0;
}
diff -u -p -r1.34 configure.ac
--- gdb/configure.ac 8 Aug 2006 20:26:23 -0000 1.34
+++ gdb/configure.ac 8 Oct 2006 15:37:03 -0000
@@ -446,6 +446,12 @@ AC_CHECK_FUNCS(socketpair)
AC_CHECK_FUNCS(syscall)
AC_CHECK_FUNCS(ttrace)
AC_CHECK_FUNCS(wborder)
+AC_CHECK_FUNCS(getaddrinfo)
+AC_CHECK_FUNCS(getnameinfo)
+AC_CHECK_DECLS(AF_INET6, [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
# Check the return and argument types of ptrace. No canned test for
# this, so roll our own.
diff -u -p -r1.26 ser-tcp.c
--- gdb/ser-tcp.c 10 Feb 2006 22:01:43 -0000 1.26
+++ gdb/ser-tcp.c 8 Oct 2006 15:37:04 -0000
@@ -68,67 +68,142 @@ void _initialize_ser_tcp (void);
int
net_open (struct serial *scb, const char *name)
{
- char *port_str, hostname[100];
- int n, port, tmp;
- int use_udp;
- struct hostent *hostent;
- struct sockaddr_in sockaddr;
+ char *name_base;
+ char *port_str;
+ int n, tmp;
#ifdef USE_WIN32API
u_long ioarg;
#else
int ioarg;
#endif
-
- use_udp = 0;
- if (strncmp (name, "udp:", 4) == 0)
+ struct prefix
+ {
+ const char *string;
+ int family;
+ int socktype;
+ };
+ const struct prefix prefixes[] =
{
- use_udp = 1;
- name = name + 4;
+ { "udp:", AF_UNSPEC, SOCK_DGRAM },
+ { "tcp:", AF_UNSPEC, SOCK_STREAM },
+ { "udp4:", AF_INET, SOCK_DGRAM },
+ { "tcp4:", AF_INET, SOCK_STREAM },
+/* We do not support `AF_INET6' without getaddrinfo(3). */
+#if defined (HAVE_GETADDRINFO) && HAVE_DECL_AF_INET6
+ { "udp6:", AF_INET6, SOCK_DGRAM },
+ { "tcp6:", AF_INET6, SOCK_STREAM },
+#endif /* defined (HAVE_GETADDRINFO) && HAVE_DECL_AF_INET6 */
+ };
+ const struct prefix *prefix;
+#ifdef HAVE_GETADDRINFO
+ struct addrinfo hints;
+ struct addrinfo *addrinfo_base, *addrinfo = NULL;
+#else /* !HAVE_GETADDRINFO */
+ struct hostent *hostent;
+ struct sockaddr_in sockaddr;
+#endif /* !HAVE_GETADDRINFO */
+ /* Error by default. */
+ int retval = -1;
+
+ name_base = xstrdup (name);
+ name = name_base;
+#ifdef HAVE_GETADDRINFO
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_flags = AI_ADDRCONFIG;
+#endif /* HAVE_GETADDRINFO */
+ for (prefix = prefixes; prefix < prefixes + ARRAY_SIZE (prefixes); prefix++)
+ if (strncmp (name, prefix->string, strlen (prefix->string)) == 0)
+ {
+ name += strlen (prefix->string);
+#ifdef HAVE_GETADDRINFO
+ hints.ai_family = prefix->family;
+ hints.ai_socktype = prefix->socktype;
+#endif /* HAVE_GETADDRINFO */
+ break;
+ }
+ if (prefix >= prefixes + ARRAY_SIZE (prefixes))
+ prefix = NULL;
+ if ((prefix == NULL || prefix->family != AF_INET)
+ && name[0] == '[' && (port_str = strchr (name, ']')))
+ {
+ name++;
+ *port_str++ = 0;
+ }
+ else
+ port_str = strchr (name, ':');
+ /* It may happen with IPv6 for like "[::1]". */
+ if (port_str == NULL || *port_str != ':')
+ error (_("net_open: No colon in host name!"));
+ *port_str++ = 0;
+
+ /* Default hostname for `node == NULL' is localhost
+ as we did not specify `hints.ai_flags & AI_PASSIVE'. */
+ if (name[0] == 0)
+ name = NULL;
+
+#ifdef HAVE_GETADDRINFO
+ n = getaddrinfo (name, port_str, &hints, &addrinfo_base);
+ if (n != 0)
+ {
+ fprintf_unfiltered (gdb_stderr, "%s:%s: cannot resolve name: %s\n",
+ (name != NULL ? name : "<local>"),
+ port_str, gai_strerror (n));
+ errno = ENOENT;
+ free (name_base);
+ return -1;
}
- else if (strncmp (name, "tcp:", 4) == 0)
- name = name + 4;
-
- port_str = strchr (name, ':');
-
- if (!port_str)
- error (_("net_open: No colon in host name!")); /* Shouldn't ever happen */
-
- tmp = min (port_str - name, (int) sizeof hostname - 1);
- strncpy (hostname, name, tmp); /* Don't want colon */
- hostname[tmp] = '\000'; /* Tie off host name */
- port = atoi (port_str + 1);
- /* default hostname is localhost */
- if (!hostname[0])
- strcpy (hostname, "localhost");
+ /* Still used for `port_str' above. */
+ free (name_base);
- hostent = gethostbyname (hostname);
- if (!hostent)
+ for (addrinfo = addrinfo_base; addrinfo != NULL; addrinfo = addrinfo->ai_next)
+ {
+ scb->fd = socket (addrinfo->ai_family, addrinfo->ai_socktype,
+ addrinfo->ai_protocol);
+ if (scb->fd >= 0)
+ break;
+ }
+ if (addrinfo == NULL)
{
- fprintf_unfiltered (gdb_stderr, "%s: unknown host\n", hostname);
+ freeaddrinfo (addrinfo_base);
+ return -1;
+ }
+#else /* !HAVE_GETADDRINFO */
+ hostent = gethostbyname ((name != NULL ? name : "localhost"));
+ if (hostent == NULL)
+ {
+ fprintf_unfiltered (gdb_stderr, "%s: unknown host\n", name);
errno = ENOENT;
+ free (name_base);
return -1;
}
- if (use_udp)
- scb->fd = socket (PF_INET, SOCK_DGRAM, 0);
- else
- scb->fd = socket (PF_INET, SOCK_STREAM, 0);
+ sockaddr.sin_family = PF_INET;
+ sockaddr.sin_port = htons (atoi (port_str));
+ memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
+ sizeof (struct in_addr));
+ /* Still used for `port_str' above. */
+ free (name_base);
+
+ scb->fd = socket (sockaddr.sin_family,
+ (prefix != NULL ? prefix->socktype : SOCK_STREAM),
+ 0);
if (scb->fd < 0)
return -1;
-
- sockaddr.sin_family = PF_INET;
- sockaddr.sin_port = htons (port);
- memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
- sizeof (struct in_addr));
+#endif /* !HAVE_GETADDRINFO */
/* set socket nonblocking */
ioarg = 1;
ioctl (scb->fd, FIONBIO, &ioarg);
/* Use Non-blocking connect. connect() will return 0 if connected already. */
+#ifdef HAVE_GETADDRINFO
+ n = connect (scb->fd, addrinfo->ai_addr, addrinfo->ai_addrlen);
+#else /* !HAVE_GETADDRINFO */
n = connect (scb->fd, (struct sockaddr *) &sockaddr, sizeof (sockaddr));
+#endif /* !HAVE_GETADDRINFO */
if (n < 0
#ifdef USE_WIN32API
@@ -143,8 +218,7 @@ net_open (struct serial *scb, const char
#ifdef USE_WIN32API
errno = WSAGetLastError();
#endif
- net_close (scb);
- return -1;
+ goto cleanup_scb;
}
if (n)
@@ -165,8 +239,7 @@ net_open (struct serial *scb, const char
if (deprecated_ui_loop_hook (0))
{
errno = EINTR;
- net_close (scb);
- return -1;
+ goto cleanup_scb;
}
}
@@ -192,8 +265,7 @@ net_open (struct serial *scb, const char
{
if (polls > TIMEOUT * POLL_INTERVAL)
errno = ETIMEDOUT;
- net_close (scb);
- return -1;
+ goto cleanup_scb;
}
}
@@ -211,8 +283,7 @@ net_open (struct serial *scb, const char
{
if (err)
errno = err;
- net_close (scb);
- return -1;
+ goto cleanup_scb;
}
}
@@ -220,7 +291,7 @@ net_open (struct serial *scb, const char
ioarg = 0;
ioctl (scb->fd, FIONBIO, &ioarg);
- if (use_udp == 0)
+ if (prefix == NULL || prefix->socktype == SOCK_STREAM)
{
/* Disable Nagle algorithm. Needed in some cases. */
tmp = 1;
@@ -234,7 +305,16 @@ net_open (struct serial *scb, const char
signal (SIGPIPE, SIG_IGN);
#endif
- return 0;
+ retval = 0;
+ goto cleanup_addrinfo_base;
+
+cleanup_scb:
+ net_close (scb);
+cleanup_addrinfo_base:
+#ifdef HAVE_GETADDRINFO
+ freeaddrinfo (addrinfo_base);
+#endif /* HAVE_GETADDRINFO */
+ return retval;
}
void
diff -u -p -r1.355 gdb.texinfo
--- gdb/doc/gdb.texinfo 21 Sep 2006 14:01:12 -0000 1.355
+++ gdb/doc/gdb.texinfo 8 Oct 2006 15:37:13 -0000
@@ -12404,8 +12404,10 @@ If you're using a serial line, you may w
(@pxref{Remote configuration, set remotebaud}) before the
@code{target} command.
-@item target remote @code{@var{host}:@var{port}}
+@item target remote @code{@var{host}:@var{port}}
@itemx target remote @code{tcp:@var{host}:@var{port}}
+@itemx target remote @code{tcp4:@var{host}:@var{port}}
+@itemx target remote @code{tcp6:@var{host}:@var{port}}
@cindex @acronym{TCP} port, @code{target remote}
Debug using a @acronym{TCP} connection to @var{port} on @var{host}.
The @var{host} may be either a host name or a numeric @acronym{IP}
@@ -12414,6 +12416,9 @@ the target machine itself, if it is dire
it might be a terminal server which in turn has a serial line to the
target.
+@code{tcp6:} prefix forces IPv6 network connection while @code{tcp4:} forces
+IPv4, both on the reliable stream TCP connection.
+
For example, to connect to port 2828 on a terminal server named
@code{manyfarms}:
@@ -12434,10 +12439,15 @@ target remote :1234
Note that the colon is still required here.
@item target remote @code{udp:@var{host}:@var{port}}
+@itemx target remote @code{udp6:@var{host}:@var{port}}
+@itemx target remote @code{udp4:@var{host}:@var{port}}
@cindex @acronym{UDP} port, @code{target remote}
Debug using @acronym{UDP} packets to @var{port} on @var{host}. For example, to
connect to @acronym{UDP} port 2828 on a terminal server named @code{manyfarms}:
+@code{udp6:} prefix forces IPv6 network connection while @code{udp4:} forces
+IPv4, both on the unreliable datagram UDP connection.
+
@smallexample
target remote udp:manyfarms:2828
@end smallexample
@@ -12556,9 +12566,9 @@ syntax is:
target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ]
@end smallexample
-@var{comm} is either a device name (to use a serial line) 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
+@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}:
@smallexample
@@ -12571,20 +12581,34 @@ with it.
To use a TCP connection instead of a serial line:
@smallexample
-target> gdbserver host:2345 emacs foo.txt
+target> socat EXEC:'gdbserver fd34 emacs foo.txt',fdin=3,fdout=4 'TCP-LISTEN:2345'
@end smallexample
-The only difference from the previous example is the first argument,
-specifying that you are communicating with the host @value{GDBN} via
-TCP. The @samp{host:2345} argument means that @code{gdbserver} is to
-expect a TCP connection from machine @samp{host} to local TCP port 2345.
-(Currently, the @samp{host} part is ignored.) You can choose any number
-you want for the port number as long as it does not conflict with any
-TCP ports already in use on the target system (for example, @code{23} is
-reserved for @code{telnet}).@footnote{If you choose a port number that
-conflicts with another service, @code{gdbserver} prints an error message
-and exits.} You must use the same port number with the host @value{GDBN}
-@code{target remote} command.
+This example still debugs the same program just in this case it is specifying
+that you are communicating with the host @value{GDBN} via TCP.
+The @code{gdbserver} specific part @code{fd34} directs @code{gdbserver} to use
+already preopened file descriptor 3 for @value{GDBN} remote serial protocol
+input and file descriptor 4 for the protocol output. As the format is
+@code{fd<character><character>} you cannot specify file descriptors numbers
+above 9. Do not use the file descriptors 0, 1 or 2 as the @value{GDBN}
+protocol communication could get corrupted by the inferior program's stdio.
+
+Please check external @code{socat} program documentation for other available
+network options (such as using @code{TCP6-LISTEN} for IPv6 networks).
+
+You can choose any port number you want (@code{2345} here) as long as it does
+not conflict with any TCP ports already in use on the target system (for
+example, @code{23} is reserved for @code{telnet}).@footnote{If you choose
+a port number that conflicts with another service, @code{socat} prints an error
+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 -p -r1.12 gdbreplay.c
--- gdb/gdbserver/gdbreplay.c 23 Jul 2006 03:52:15 -0000 1.12
+++ gdb/gdbserver/gdbreplay.c 8 Oct 2006 15:37:13 -0000
@@ -61,7 +61,7 @@ typedef int socklen_t;
/* Sort of a hack... */
#define EOL (EOF - 1)
-static int remote_desc;
+static int remote_desc_in, remote_desc_out;
/* Print the system error message for errno, and also mention STRING
as the file name for which the error was encountered.
@@ -103,9 +103,13 @@ static void
remote_close (void)
{
#ifdef USE_WIN32API
- closesocket (remote_desc);
+ closesocket (remote_desc_in);
+ if (remote_desc_in != remote_desc_out)
+ closesocket (remote_desc_out);
#else
- close (remote_desc);
+ close (remote_desc_in);
+ if (remote_desc_in != remote_desc_out)
+ close (remote_desc_out);
#endif
}
@@ -115,14 +119,24 @@ remote_close (void)
static void
remote_open (char *name)
{
- if (!strchr (name, ':'))
+ /* "fd01" for STDIO, "fd23" for socat(1) "fdin=2,fdout=3". */
+ if (name[0] == 'f' && name[1] == 'd'
+ && isdigit (name[2]) && isdigit (name[3])
+ && name[4] == 0)
{
- fprintf (stderr, "%s: Must specify tcp connection as host:addr\n", name);
+ remote_desc_in = name[2] - '0';
+ remote_desc_out = name[3] - '0';
+ }
+ else if (!strchr (name, ':'))
+ {
+ fprintf (stderr, "%s: Must specify tcp connection as host:addr"
+ " or use fd<in><out>\n", name);
fflush (stderr);
exit (1);
}
else
{
+ int remote_desc;
#ifdef USE_WIN32API
static int winsock_initialized;
#endif
@@ -188,10 +202,13 @@ remote_open (char *name)
#else
closesocket (tmp_desc); /* No longer need this */
#endif
+ remote_desc_in = remote_desc_out = remote_desc;
}
#if defined(F_SETFL) && defined (FASYNC)
- fcntl (remote_desc, F_SETFL, FASYNC);
+ fcntl (remote_desc_in, F_SETFL, FASYNC);
+ if (remote_desc_in != remote_desc_out)
+ fcntl (remote_desc_out, F_SETFL, FASYNC);
#endif
fprintf (stderr, "Replay logfile using %s\n", name);
@@ -299,7 +316,7 @@ expect (FILE *fp)
{
break;
}
- read (remote_desc, &fromgdb, 1);
+ read (remote_desc_in, &fromgdb, 1);
}
while (fromlog == fromgdb);
if (fromlog != EOL)
@@ -326,7 +343,7 @@ play (FILE *fp)
while ((fromlog = logchar (fp)) != EOL)
{
ch = fromlog;
- write (remote_desc, &ch, 1);
+ write (remote_desc_out, &ch, 1);
}
}
@@ -338,7 +355,12 @@ main (int argc, char *argv[])
if (argc < 3)
{
- fprintf (stderr, "Usage: gdbreplay <logfile> <host:port>\n");
+ fprintf (stderr, "Usage: gdbreplay <logfile> {<host:port> | fd<in><out>}\n"
+ "\n"
+ "Use host:port to listen for a TCP connection, or\n"
+ "fd<in><out> (such as fd34) for networking over file descriptors:\n"
+ " "
+ "socat EXEC:'gdbserver fd34 PROG',fdin=3,fdout=4 TCP6-LISTEN:5000\n");
fflush (stderr);
exit (1);
}
diff -u -p -r1.32 remote-utils.c
--- gdb/gdbserver/remote-utils.c 21 Sep 2006 16:09:54 -0000 1.32
+++ gdb/gdbserver/remote-utils.c 8 Oct 2006 15:37:13 -0000
@@ -52,6 +52,7 @@
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
+#include <ctype.h>
#if USE_WIN32API
#include <winsock.h>
@@ -79,7 +80,7 @@ int all_symbols_looked_up;
int remote_debug = 0;
struct ui_file *gdb_stdlog;
-static int remote_desc;
+static int remote_desc_in, remote_desc_out;
/* FIXME headerize? */
extern int using_threads;
@@ -95,10 +96,20 @@ remote_open (char *name)
int save_fcntl_flags;
#endif
- if (!strchr (name, ':'))
+ /* "fd01" for STDIO, "fd23" for socat(1) "fdin=2,fdout=3". */
+ if (name[0] == 'f' && name[1] == 'd'
+ && isdigit (name[2]) && isdigit (name[3])
+ && name[4] == 0)
{
+ remote_desc_in = name[2] - '0';
+ remote_desc_out = name[3] - '0';
+ }
+ else if (!strchr (name, ':'))
+ {
+ int remote_desc;
+
#ifdef USE_WIN32API
- error ("Only <host>:<port> is supported on this platform.");
+ error ("Only <host>:<port> or fd<in><out> supported on this platform.");
#else
remote_desc = open (name, O_RDWR);
if (remote_desc < 0)
@@ -149,10 +160,13 @@ remote_open (char *name)
#endif
fprintf (stderr, "Remote debugging using %s\n", name);
+ remote_desc_in = remote_desc_out = remote_desc;
#endif /* USE_WIN32API */
}
else
{
+ int remote_desc;
+
#ifdef USE_WIN32API
static int winsock_initialized;
#endif
@@ -224,13 +238,21 @@ remote_open (char *name)
/* 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;
}
#if defined(F_SETFL) && defined (FASYNC)
- save_fcntl_flags = fcntl (remote_desc, F_GETFL, 0);
- fcntl (remote_desc, F_SETFL, save_fcntl_flags | FASYNC);
+ save_fcntl_flags = fcntl (remote_desc_in, F_GETFL, 0);
+ fcntl (remote_desc_in, F_SETFL, save_fcntl_flags | FASYNC);
+ if (remote_desc_in != remote_desc_out)
+ {
+ save_fcntl_flags = fcntl (remote_desc_out, F_GETFL, 0);
+ fcntl (remote_desc_out, F_SETFL, save_fcntl_flags | FASYNC);
+ }
#if defined (F_SETOWN)
- fcntl (remote_desc, F_SETOWN, getpid ());
+ fcntl (remote_desc_in, F_SETOWN, getpid ());
+ if (remote_desc_in != remote_desc_out)
+ fcntl (remote_desc_out, F_SETOWN, getpid ());
#endif
#endif
disable_async_io ();
@@ -240,9 +262,13 @@ void
remote_close (void)
{
#ifdef USE_WIN32API
- closesocket (remote_desc);
+ closesocket (remote_desc_in);
+ if (remote_desc_in != remote_desc_out)
+ closesocket (remote_desc_out);
#else
- close (remote_desc);
+ close (remote_desc_in);
+ if (remote_desc_in != remote_desc_out)
+ close (remote_desc_out);
#endif
}
@@ -486,7 +512,7 @@ putpkt_binary (char *buf, int cnt)
{
int cc;
- if (send (remote_desc, buf2, p - buf2, 0) != p - buf2)
+ if (send (remote_desc_out, buf2, p - buf2, 0) != p - buf2)
{
perror ("putpkt(write)");
return -1;
@@ -497,7 +523,7 @@ putpkt_binary (char *buf, int cnt)
fprintf (stderr, "putpkt (\"%s\"); [looking for ack]\n", buf2);
fflush (stderr);
}
- cc = recv (remote_desc, buf3, 1, 0);
+ cc = recv (remote_desc_in, buf3, 1, 0);
if (remote_debug)
{
fprintf (stderr, "[received '%c' (0x%x)]\n", buf3[0], buf3[0]);
@@ -552,13 +578,13 @@ input_interrupt (int unused)
be a problem under NetBSD 1.4 and 1.5. */
FD_ZERO (&readset);
- FD_SET (remote_desc, &readset);
- if (select (remote_desc + 1, &readset, 0, 0, &immediate) > 0)
+ FD_SET (remote_desc_in, &readset);
+ if (select (remote_desc_in + 1, &readset, 0, 0, &immediate) > 0)
{
int cc;
char c = 0;
- cc = recv (remote_desc, &c, 1, 0);
+ cc = recv (remote_desc_in, &c, 1, 0);
if (cc != 1 || c != '\003')
{
@@ -639,7 +665,7 @@ readchar (void)
if (bufcnt-- > 0)
return *bufp++;
- bufcnt = recv (remote_desc, buf, sizeof (buf), 0);
+ bufcnt = recv (remote_desc_in, buf, sizeof (buf), 0);
if (bufcnt <= 0)
{
@@ -706,7 +732,7 @@ getpkt (char *buf)
fprintf (stderr, "Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
(c1 << 4) + c2, csum, buf);
- send (remote_desc, "-", 1, 0);
+ send (remote_desc_out, "-", 1, 0);
}
if (remote_debug)
@@ -715,7 +741,7 @@ getpkt (char *buf)
fflush (stderr);
}
- send (remote_desc, "+", 1, 0);
+ send (remote_desc_out, "+", 1, 0);
if (remote_debug)
{
diff -u -p -r1.39 server.c
--- gdb/gdbserver/server.c 8 Aug 2006 16:03:29 -0000 1.39
+++ gdb/gdbserver/server.c 8 Oct 2006 15:37:14 -0000
@@ -435,8 +435,11 @@ gdbserver_usage (void)
printf ("Usage:\tgdbserver COMM PROG [ARGS ...]\n"
"\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.\n");
+ "COMM may either be a tty device (for serial debugging), or\n"
+ "HOST:PORT to listen for a TCP connection, or\n"
+ "fd<in><out> (such as fd34) for networking over file descriptors:\n"
+ " "
+ "socat EXEC:'gdbserver fd34 PROG',fdin=3,fdout=4 TCP6-LISTEN:5000\n");
}
int
[-- Attachment #3: gdb-cvs-IPv6-hostport-minus.patch --]
[-- Type: text/plain, Size: 9359 bytes --]
gdb/gdbserver:
2006-10-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbreplay.c (remote_open, main): Remove "host:port" argument support
as obsoleted by "fd<in><out>" using socat(1).
* remote-utils.c (remote_open): Likewise.
* server.c (gdbserver_usage): Likewise.
gdb/doc:
2006-10-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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<in><out>\n", name);
+ fprintf (stderr, "%s: Must specify connection as fd<in><out>\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<in><out>");
+ fflush (stderr);
+ exit (1);
}
#if defined(F_SETFL) && defined (FASYNC)
@@ -357,8 +293,7 @@ main (int argc, char *argv[])
{
fprintf (stderr, "Usage: gdbreplay <logfile> {<host:port> | fd<in><out>}\n"
"\n"
- "Use host:port to listen for a TCP connection, or\n"
- "fd<in><out> (such as fd34) for networking over file descriptors:\n"
+ "Use fd<in><out> (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 <host>:<port> or fd<in><out> 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<in><out> 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<in><out>");
}
#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<in><out> (such as fd34) for networking over file descriptors:\n"
" "
"socat EXEC:'gdbserver fd34 PROG',fdin=3,fdout=4 TCP6-LISTEN:5000\n");
next prev parent reply other threads:[~2006-10-08 19:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-27 16:33 Jan Kratochvil
2006-09-27 18:20 ` Daniel Jacobowitz
2006-09-27 18:56 ` Jan Kratochvil
2006-09-27 19:06 ` Daniel Jacobowitz
2006-09-30 15:28 ` Jan Kratochvil
2006-10-08 19:03 ` Jan Kratochvil [this message]
2006-10-09 4:33 ` Eli Zaretskii
2006-10-09 14:17 ` Jan Kratochvil
2006-10-09 19:01 ` Daniel Jacobowitz
2006-10-09 19:36 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061008190239.GA29584@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox