From 50a62388359d7e577532f4d9df8bac35f36013ce Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Oct 01 2006 19:21:15 +0000 Subject: - No longer disassemble invalid i386 opcodes of movQ/movA (BZ 172034). - Simplify the IPv6 patch for gdbserver (BZ 198365). - Suggest fixing your target architecture for gdbserver(1) (BZ 190810). - Fix dereferencing registers for 32bit inferiors on 64bit hosts (BZ 181390). - Fix `gcore' command for 32bit inferiors on 64bit hosts. --- diff --git a/gdb-6.5-bz181390-memory-address-width.patch b/gdb-6.5-bz181390-memory-address-width.patch new file mode 100644 index 0000000..b955af0 --- /dev/null +++ b/gdb-6.5-bz181390-memory-address-width.patch @@ -0,0 +1,100 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=181390 + + +2006-09-28 Jan Kratochvil + + * gdb/utils.c (paddress): Disable cutting of the printed addresses + to the target's address bit size; user wants to see everything. + * gdb/value.c (value_as_address_core): Original `value_as_address'. + (value_as_address): New `value_as_address' wrapper - cut memory address + to the target's address bit size, bugreport by John Reiser. + + +Index: gdb-6.5/gdb/utils.c +=================================================================== +RCS file: /cvs/src/src/gdb/utils.c,v +retrieving revision 1.169 +diff -u -p -r1.169 utils.c +--- gdb-6.5.orig/gdb/utils.c 21 Sep 2006 13:50:51 -0000 1.169 ++++ gdb-6.5/gdb/utils.c 28 Sep 2006 17:06:03 -0000 +@@ -2596,6 +2596,14 @@ paddr_nz (CORE_ADDR addr) + const char * + paddress (CORE_ADDR addr) + { ++ /* Do not cut the address as the user should see all the information ++ available. Otherwise 64-bit gdb debugging 32-bit inferior would ++ report for `x/x 0xffffffffffffce70' error ++ `Cannot access memory at 0xffffce70' while the error occured just ++ because of the higher order bits 0xffffffff00000000 there. ++ This specific error no longer occurs as the address is now cut ++ during execution by `value_as_address'. */ ++#if 0 + /* Truncate address to the size of a target address, avoiding shifts + larger or equal than the width of a CORE_ADDR. The local + variable ADDR_BIT stops the compiler reporting a shift overflow +@@ -2609,6 +2617,8 @@ paddress (CORE_ADDR addr) + + if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) + addr &= ((CORE_ADDR) 1 << addr_bit) - 1; ++#endif ++ + return hex_string (addr); + } + +Index: gdb-6.5/gdb/value.c +=================================================================== +RCS file: /cvs/src/src/gdb/value.c,v +retrieving revision 1.36 +diff -u -p -r1.36 value.c +--- gdb-6.5.orig/gdb/value.c 31 Mar 2006 10:36:18 -0000 1.36 ++++ gdb-6.5/gdb/value.c 28 Sep 2006 17:06:03 -0000 +@@ -950,11 +950,10 @@ value_as_double (struct value *val) + error (_("Invalid floating value found in program.")); + return foo; + } +-/* Extract a value as a C pointer. Does not deallocate the value. +- Note that val's type may not actually be a pointer; value_as_long +- handles all the cases. */ +-CORE_ADDR +-value_as_address (struct value *val) ++ ++/* See `value_as_address' below - core of value to C pointer extraction. */ ++static CORE_ADDR ++value_as_address_core (struct value *val) + { + /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure + whether we want this to be true eventually. */ +@@ -1054,6 +1053,33 @@ value_as_address (struct value *val) + return unpack_long (value_type (val), value_contents (val)); + #endif + } ++ ++/* Extract a value as a C pointer. Does not deallocate the value. ++ Note that val's type may not actually be a pointer; value_as_long ++ handles all the cases. */ ++CORE_ADDR ++value_as_address (struct value *val) ++{ ++ CORE_ADDR addr; ++ ++ addr = value_as_address_core (val); ++ ++ /* Truncate address to the size of a target address, avoiding shifts ++ larger or equal than the width of a CORE_ADDR. The local ++ variable ADDR_BIT stops the compiler reporting a shift overflow ++ when it won't occur. */ ++ /* NOTE: This assumes that the significant address information is ++ kept in the least significant bits of ADDR - the upper bits were ++ either zero or sign extended. Should ADDRESS_TO_POINTER() or ++ some ADDRESS_TO_PRINTABLE() be used to do the conversion? */ ++ ++ int addr_bit = TARGET_ADDR_BIT; ++ ++ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) ++ addr &= ((CORE_ADDR) 1 << addr_bit) - 1; ++ ++ return addr; ++} + + /* Unpack raw data (copied from debugee, target byte order) at VALADDR + as a long, or as a double, assuming the raw data is described diff --git a/gdb-6.5-bz190810-gdbserver-arch-advice.patch b/gdb-6.5-bz190810-gdbserver-arch-advice.patch new file mode 100644 index 0000000..7e97f25 --- /dev/null +++ b/gdb-6.5-bz190810-gdbserver-arch-advice.patch @@ -0,0 +1,41 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=190810 + + +2006-09-26 Jan Kratochvil + + * remote.c (remote_wait): Suggestion on crash due to nonmatching target. + (remote_async_wait): Likewise. + + +--- gdb-6.5/gdb/remote.c.orig 2006-10-01 08:01:17.000000000 -0400 ++++ gdb-6.5/gdb/remote.c 2006-10-01 08:03:18.000000000 -0400 +@@ -2789,8 +2789,13 @@ + reg->regnum, regs); + } + ++ /* It may also occur on amd64 which defaults to 32-bit i386 ++ target. gdbserver(1) is not aware of the `set architecture' ++ name itself as it is not using libbfd. */ + if (*p++ != ';') +- error (_("Remote register badly formatted: %s\nhere: %s"), ++ error (_("Remote register badly formatted: %s\nhere: %s" ++ "\nTry to load the executable by `file' first," ++ "\nyou may also check `set/show architecture'."), + buf, p); + } + } +@@ -2983,8 +2988,13 @@ + regcache_raw_supply (current_regcache, reg->regnum, regs); + } + ++ /* It may also occur on amd64 which defaults to 32-bit i386 ++ target. gdbserver(1) is not aware of the `set architecture' ++ name itself as it is not using libbfd. */ + if (*p++ != ';') +- error (_("Remote register badly formatted: %s\nhere: %s"), ++ error (_("Remote register badly formatted: %s\nhere: %s" ++ "\nTry to load the executable by `file' first," ++ "\nyou may also check `set/show architecture'."), + buf, p); + } + } diff --git a/gdb-6.5-bz198365-IPv6.patch b/gdb-6.5-bz198365-IPv6.patch new file mode 100644 index 0000000..db7414a --- /dev/null +++ b/gdb-6.5-bz198365-IPv6.patch @@ -0,0 +1,1850 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=198365 + + +2006-09-30 Jan Kratochvil + + * ser-tcp.c (net_open): Support IPv6, "tcp6:"&co. notation. + * configure.ac: Check for IPv6 getaddrinfo, getnameinfo and AF_INET6. + * configure, config.in: Regenerate. + +2006-09-30 Jan Kratochvil + + * gdbreplay.c (remote_open): Support IPv6, "tcp6:"&co. notation. + * remote-utils.c (remote_open): Likewise. + * configure.ac: Check for IPv6 getaddrinfo, getnameinfo and AF_INET6. + * configure, config.in: Regenerate. + +2006-09-30 Jan Kratochvil + + * gdb.texinfo (Connecting to a remote target): Support IPv6, + "tcp6:"&co. notation. + (Using the gdbserver program): Likewise. + + +diff -u -rup gdb-6.5-orig/gdb/config.in gdb-6.5/gdb/config.in +--- gdb-6.5-orig/gdb/config.in 2005-07-03 18:05:11.000000000 +0200 ++++ gdb-6.5/gdb/config.in 2006-09-30 14:18:50.000000000 +0200 +@@ -72,6 +72,10 @@ + /* Define to 1 if you have the `dcgettext' function. */ + #undef HAVE_DCGETTEXT + ++/* 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 +@@ -118,12 +122,18 @@ + /* Define if 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 `getcwd' function. */ + #undef HAVE_GETCWD + + /* 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 -rup gdb-6.5-orig/gdb/configure gdb-6.5/gdb/configure +--- gdb-6.5-orig/gdb/configure 2006-09-30 13:21:47.000000000 +0200 ++++ gdb-6.5/gdb/configure 2006-09-30 14:25:10.000000000 +0200 +@@ -16593,6 +16593,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 declares $ac_func. ++ For example, HP-UX 11i 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 to if __STDC__ is defined, since ++ exists even on freestanding compilers. */ ++ ++#ifdef __STDC__ ++# include ++#else ++# include ++#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 declares $ac_func. ++ For example, HP-UX 11i 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 to if __STDC__ is defined, since ++ exists even on freestanding compilers. */ ++ ++#ifdef __STDC__ ++# include ++#else ++# include ++#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 ++#include ++ ++ ++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=' +@@ -21471,7 +21750,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. */ +@@ -21479,7 +21758,7 @@ _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ +-#include ++#include + _ACEOF + if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 +@@ -21506,7 +21785,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 +@@ -21520,18 +21799,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 ++#include + int + main () + { +-XtMalloc (0) ++XrmInitialize () + ; + return 0; + } +diff -u -rup gdb-6.5-orig/gdb/configure.ac gdb-6.5/gdb/configure.ac +--- gdb-6.5-orig/gdb/configure.ac 2006-09-30 13:21:48.000000000 +0200 ++++ gdb-6.5/gdb/configure.ac 2006-09-30 14:24:56.000000000 +0200 +@@ -473,6 +473,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 ++#include ++]) + + # Check the return and argument types of ptrace. No canned test for + # this, so roll our own. +diff -u -rup gdb-6.5-orig/gdb/doc/gdb.texinfo gdb-6.5/gdb/doc/gdb.texinfo +--- gdb-6.5-orig/gdb/doc/gdb.texinfo 2006-09-30 13:21:48.000000000 +0200 ++++ gdb-6.5/gdb/doc/gdb.texinfo 2006-09-30 13:34:32.000000000 +0200 +@@ -12358,8 +12358,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} +@@ -12368,6 +12370,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}: + +@@ -12388,10 +12393,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 +@@ -12532,14 +12542,30 @@ The only difference from the previous ex + 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 ++(The @samp{host} part is usually omitted as it defaults to listen from any ++host. You may use a local address as expected by the @code{bind} syscall.) ++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. + ++@item gdbserver @code{tcp:@var{host}:@var{port}} emacs foo.txt ++@itemx gdbserver @code{tcp6:@var{host}:@var{port}} emacs foo.txt ++@itemx gdbserver @code{tcp4:@var{host}:@var{port}} emacs foo.txt ++@itemx gdbserver @code{udp:@var{host}:@var{port}} emacs foo.txt ++@itemx gdbserver @code{udp6:@var{host}:@var{port}} emacs foo.txt ++@itemx gdbserver @code{udp4:@var{host}:@var{port}} emacs foo.txt ++ ++The @code{::} part can be also replaced by the optional @var{host} part as ++in the sample case of @code{tcp:@var{host}:@var{port}}. ++These all alternative syntaxes force either the reliable stream TCP protocol or ++the unreliable datagram UDP protocol appropriately. You may also force the use ++of IPv6 or IPv4 network connections; @code{tcp:} and @code{udp:} select the ++network version type according to the provided @var{host}. ++The connection type defaults to the @code{tcp:} prefix behavior. ++ + 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-6.5-orig/gdb/gdbserver/config.in gdb-6.5/gdb/gdbserver/config.in +--- gdb-6.5-orig/gdb/gdbserver/config.in 2006-03-15 17:13:28.000000000 +0100 ++++ gdb-6.5/gdb/gdbserver/config.in 2006-09-30 16:23:20.000000000 +0200 +@@ -1,5 +1,9 @@ + /* config.in. Generated from configure.ac by autoheader. */ + ++/* 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 `strerror', and to 0 if you + don't. */ + #undef HAVE_DECL_STRERROR +@@ -7,6 +11,12 @@ + /* Define if has elf_fpregset_t. */ + #undef HAVE_ELF_FPREGSET_T + ++/* Define to 1 if you have the `getaddrinfo' function. */ ++#undef HAVE_GETADDRINFO ++ ++/* Define to 1 if you have the `getnameinfo' function. */ ++#undef HAVE_GETNAMEINFO ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_INTTYPES_H + +diff -u -rup gdb-6.5-orig/gdb/gdbserver/configure gdb-6.5/gdb/gdbserver/configure +--- gdb-6.5-orig/gdb/gdbserver/configure 2006-03-15 17:13:28.000000000 +0100 ++++ gdb-6.5/gdb/gdbserver/configure 2006-09-30 16:23:19.000000000 +0200 +@@ -947,7 +947,7 @@ esac + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi +- cd "$ac_popdir" ++ cd $ac_popdir + done + fi + +@@ -1865,7 +1865,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -1923,7 +1924,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2039,7 +2041,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2093,7 +2096,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2138,7 +2142,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2182,7 +2187,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2708,7 +2714,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2879,7 +2886,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -2956,7 +2964,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3104,7 +3113,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3179,7 +3189,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3213,6 +3224,285 @@ fi + + . ${srcdir}/configure.srv + ++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 declares $ac_func. ++ For example, HP-UX 11i 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 to if __STDC__ is defined, since ++ exists even on freestanding compilers. */ ++ ++#ifdef __STDC__ ++# include ++#else ++# include ++#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 declares $ac_func. ++ For example, HP-UX 11i 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 to if __STDC__ is defined, since ++ exists even on freestanding compilers. */ ++ ++#ifdef __STDC__ ++# include ++#else ++# include ++#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 ++#include ++ ++ ++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 ++ ++ ++ + if test "${srv_linux_usrregs}" = "yes"; then + + cat >>confdefs.h <<\_ACEOF +@@ -3257,7 +3547,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3318,7 +3609,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3383,7 +3675,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3447,7 +3740,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3511,7 +3805,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3575,7 +3870,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -3654,7 +3950,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l + 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' ++ { 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=$? +@@ -3711,7 +4008,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l + 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' ++ { 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=$? +@@ -3776,7 +4074,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l + 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' ++ { 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=$? +@@ -3833,7 +4132,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c + 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' ++ { 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=$? +@@ -4686,6 +4986,11 @@ esac + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + ++ if test x"$ac_file" != x-; then ++ { echo "$as_me:$LINENO: creating $ac_file" >&5 ++echo "$as_me: creating $ac_file" >&6;} ++ rm -f "$ac_file" ++ fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ +@@ -4724,12 +5029,6 @@ echo "$as_me: error: cannot find input f + fi;; + esac + done` || { (exit 1); exit 1; } +- +- if test x"$ac_file" != x-; then +- { echo "$as_me:$LINENO: creating $ac_file" >&5 +-echo "$as_me: creating $ac_file" >&6;} +- rm -f "$ac_file" +- fi + _ACEOF + cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +diff -u -rup gdb-6.5-orig/gdb/gdbserver/configure.ac gdb-6.5/gdb/gdbserver/configure.ac +--- gdb-6.5-orig/gdb/gdbserver/configure.ac 2006-03-15 17:13:29.000000000 +0100 ++++ gdb-6.5/gdb/gdbserver/configure.ac 2006-09-30 16:23:06.000000000 +0200 +@@ -47,6 +47,12 @@ AC_CHECK_TYPES(socklen_t, [], [], + #include + ]) + . ${srcdir}/configure.srv ++AC_CHECK_FUNCS(getaddrinfo) ++AC_CHECK_FUNCS(getnameinfo) ++AC_CHECK_DECLS(AF_INET6, [], [], ++[#include ++#include ++]) + + if test "${srv_linux_usrregs}" = "yes"; then + AC_DEFINE(HAVE_LINUX_USRREGS, 1, +diff -u -rup gdb-6.5-orig/gdb/gdbserver/gdbreplay.c gdb-6.5/gdb/gdbserver/gdbreplay.c +--- gdb-6.5-orig/gdb/gdbserver/gdbreplay.c 2005-12-23 19:11:55.000000000 +0100 ++++ gdb-6.5/gdb/gdbserver/gdbreplay.c 2006-09-30 16:26:09.000000000 +0200 +@@ -99,6 +99,8 @@ remote_close (void) + static void + remote_open (char *name) + { ++ char *name_orig = name; ++ + if (!strchr (name, ':')) + { + fprintf (stderr, "%s: Must specify tcp connection as host:addr\n", name); +@@ -108,56 +110,232 @@ remote_open (char *name) + else + { + char *port_str; +- int port; +- struct sockaddr_in sockaddr; + socklen_t tmp; +- int tmp_desc; ++ int tmp_desc = -1; ++ struct prefix ++ { ++ const char *string; ++ int family; ++ int socktype; ++ }; ++ const struct prefix prefixes[] = ++ { ++ { "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; ++ int err; ++#else /* !HAVE_GETADDRINFO */ ++ struct sockaddr_in sockaddr; ++#endif /* !HAVE_GETADDRINFO */ ++#ifdef HAVE_GETNAMEINFO ++ char back_host[64], back_port[16]; ++#endif /* HAVE_GETNAMEINFO */ ++ char *name_base; ++ ++ name_base = strdup (name); ++ name = name_base; ++#ifdef HAVE_GETADDRINFO ++ memset (&hints, 0, sizeof (hints)); ++ hints.ai_family = AF_UNSPEC; ++ hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; ++#endif /* HAVE_GETADDRINFO */ ++ for (prefix = prefixes; ++ prefix < prefixes + sizeof (prefixes) / sizeof (*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 + sizeof (prefixes) / sizeof (*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 != ':') ++ { ++ fprintf (stderr, "net_open: No colon in host name!\n"); ++ fflush (stderr); ++ exit (1); ++ } ++ *port_str++ = 0; + +- port_str = strchr (name, ':'); ++ /* Default hostname for `node == NULL' is `INADDR_ANY'/`in6addr_any'. ++ as we did specify `hints.ai_flags & AI_PASSIVE'. */ ++ if (name[0] == 0) ++ name = NULL; ++ ++#ifdef HAVE_GETADDRINFO ++ err = getaddrinfo (name, port_str, &hints, &addrinfo_base); ++ if (err != 0) ++ { ++ /* `name_base' is used here for `port_str'. */ ++ fprintf (stderr, "%s:%s: cannot resolve name: %s\n", ++ name, port_str, gai_strerror (err)); ++ fflush (stderr); ++ exit (1); ++ } + +- port = atoi (port_str + 1); ++ for (addrinfo = addrinfo_base; ++ addrinfo != NULL; ++ addrinfo = addrinfo->ai_next) ++ { ++ tmp_desc = socket (addrinfo->ai_family, addrinfo->ai_socktype, ++ addrinfo->ai_protocol); ++ if (tmp_desc >= 0) ++ break; ++ } ++ if (addrinfo == NULL) ++ { ++ freeaddrinfo (addrinfo_base); ++ perror_with_name ("Can't open socket"); ++ } ++#else /* !HAVE_GETADDRINFO */ ++ sockaddr.sin_family = PF_INET; ++ sockaddr.sin_port = htons (atoi (port_str)); + +- tmp_desc = socket (PF_INET, SOCK_STREAM, 0); ++ if (name == NULL) ++ sockaddr.sin_addr.s_addr = INADDR_ANY; ++ else ++ { ++ struct hostent *hostent; ++ ++ hostent = gethostbyname (name); ++ if (hostent == NULL) ++ { ++ fprintf (stderr, "%s: unknown host\n", name); ++ free (name_base); ++ perror_with_name ("gethostbyname(3) resolving"); ++ } ++ ++ memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr, ++ sizeof (struct in_addr)); ++ } ++ ++ /* We assume matching `AF_*' and `PF_*'. */ ++ tmp_desc = socket (sockaddr.sin_family, ++ (prefix != NULL ? prefix->socktype : SOCK_STREAM), ++ 0); + if (tmp_desc < 0) +- perror_with_name ("Can't open socket"); ++ { ++ free (name_base); ++ perror_with_name ("Can't open socket"); ++ } ++#endif /* !HAVE_GETADDRINFO */ + + /* 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; +- ++#ifdef HAVE_GETADDRINFO ++ if (bind (tmp_desc, addrinfo->ai_addr, addrinfo->ai_addrlen) ++ || ((prefix == NULL || prefix->socktype != SOCK_DGRAM) ++ && listen (tmp_desc, 1))) ++#else /* !HAVE_GETADDRINFO */ + 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)); ++ || ((prefix == NULL || prefix->socktype != SOCK_DGRAM) ++ && listen (tmp_desc, 1))) ++#endif /* !HAVE_GETADDRINFO */ ++ { ++#ifdef HAVE_GETADDRINFO ++ freeaddrinfo (addrinfo_base); ++#endif /* HAVE_GETADDRINFO */ ++ free (name_base); ++ perror_with_name ("Can't bind address"); ++ } ++ ++#ifdef HAVE_GETNAMEINFO ++ if (0 == getnameinfo (addrinfo->ai_addr, addrinfo->ai_addrlen, ++ back_host, sizeof (back_host), ++ back_port, sizeof (back_port), ++ NI_NUMERICHOST | NI_NUMERICSERV)) ++ fprintf (stderr, "Listening on port %s (on host %s)\n", ++ back_port, back_host); ++ else ++#endif /* !HAVE_GETNAMEINFO */ ++ fprintf (stderr, "Listening on port %s (on host %s)\n", ++ port_str, (name != NULL ? name : "")); ++ fflush (stderr); + +- close (tmp_desc); /* No longer need this */ ++ /* Used for `port_str' above. */ ++ free (name_base); + +- signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbreplay simply +- exits when the remote side dies. */ ++ if (prefix != NULL && prefix->socktype == SOCK_DGRAM) ++ remote_desc = tmp_desc; ++ else ++ { ++ struct sockaddr_storage sockaddr; ++ socklen_t sockaddr_len = sizeof (sockaddr); ++ remote_desc = accept (tmp_desc, (struct sockaddr *) &sockaddr, &sockaddr_len); ++ if (remote_desc == -1) ++ { ++#ifdef HAVE_GETADDRINFO ++ freeaddrinfo (addrinfo_base); ++#endif /* HAVE_GETADDRINFO */ ++ 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. */ ++ if (prefix == NULL || prefix->socktype == SOCK_STREAM) ++ { ++ tmp = 1; ++ setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY, ++ (char *) &tmp, sizeof (tmp)); ++ } ++#ifdef HAVE_GETADDRINFO ++ freeaddrinfo (addrinfo_base); ++#endif /* HAVE_GETADDRINFO */ ++ ++ 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. */ ++ ++#ifdef HAVE_GETNAMEINFO ++ /* Convert IP address to string. */ ++ if (0 == getnameinfo ((struct sockaddr *) &sockaddr, sockaddr_len, ++ back_host, sizeof (back_host), ++ back_port, sizeof (back_port), ++ NI_NUMERICHOST | NI_NUMERICSERV)) ++ fprintf (stderr, "Remote debugging from host %s port %s\n", ++ back_host, back_port); ++ else ++#endif /* !HAVE_GETNAMEINFO */ ++ fprintf (stderr, "Remote debugging started\n"); ++ } ++ fflush (stderr); + } + + fcntl (remote_desc, F_SETFL, FASYNC); + +- fprintf (stderr, "Replay logfile using %s\n", name); ++ fprintf (stderr, "Replay logfile using %s\n", name_orig); + fflush (stderr); + } + +diff -u -rup gdb-6.5-orig/gdb/gdbserver/remote-utils.c gdb-6.5/gdb/gdbserver/remote-utils.c +--- gdb-6.5-orig/gdb/gdbserver/remote-utils.c 2006-03-03 15:48:55.000000000 +0100 ++++ gdb-6.5/gdb/gdbserver/remote-utils.c 2006-09-30 16:25:16.000000000 +0200 +@@ -124,57 +124,222 @@ remote_open (char *name) + else + { + char *port_str; +- int port; +- struct sockaddr_in sockaddr; + socklen_t tmp; +- int tmp_desc; ++ int tmp_desc = -1; ++ struct prefix ++ { ++ const char *string; ++ int family; ++ int socktype; ++ }; ++ const struct prefix prefixes[] = ++ { ++ { "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; ++ int err; ++#else /* !HAVE_GETADDRINFO */ ++ struct sockaddr_in sockaddr; ++#endif /* !HAVE_GETADDRINFO */ ++#ifdef HAVE_GETNAMEINFO ++ char back_host[64], back_port[16]; ++#endif /* HAVE_GETNAMEINFO */ ++ char *name_base; ++ ++ name_base = strdup (name); ++ name = name_base; ++#ifdef HAVE_GETADDRINFO ++ memset (&hints, 0, sizeof (hints)); ++ hints.ai_family = AF_UNSPEC; ++ hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; ++#endif /* HAVE_GETADDRINFO */ ++ for (prefix = prefixes; ++ prefix < prefixes + sizeof (prefixes) / sizeof (*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 + sizeof (prefixes) / sizeof (*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 `INADDR_ANY'/`in6addr_any'. ++ as we did specify `hints.ai_flags & AI_PASSIVE'. */ ++ if (name[0] == 0) ++ name = NULL; ++ ++#ifdef HAVE_GETADDRINFO ++ err = getaddrinfo (name, port_str, &hints, &addrinfo_base); ++ if (err != 0) ++ { ++ /* `name_base' is used here for `port_str'. */ ++ error ("%s:%s: cannot resolve name: %s\n", ++ name, port_str, gai_strerror (err)); ++ } ++ ++ for (addrinfo = addrinfo_base; ++ addrinfo != NULL; ++ addrinfo = addrinfo->ai_next) ++ { ++ tmp_desc = socket (addrinfo->ai_family, addrinfo->ai_socktype, ++ addrinfo->ai_protocol); ++ if (tmp_desc >= 0) ++ break; ++ } ++ if (addrinfo == NULL) ++ { ++ freeaddrinfo (addrinfo_base); ++ free (name_base); ++ perror_with_name ("Can't open socket"); ++ } ++#else /* !HAVE_GETADDRINFO */ ++ sockaddr.sin_family = PF_INET; ++ sockaddr.sin_port = htons (atoi (port_str)); + +- port_str = strchr (name, ':'); ++ if (name == NULL) ++ sockaddr.sin_addr.s_addr = INADDR_ANY; ++ else ++ { ++ struct hostent *hostent; + +- port = atoi (port_str + 1); ++ hostent = gethostbyname (name); ++ if (hostent == NULL) ++ { ++ fprintf (stderr, "%s: unknown host\n", name); ++ free (name_base); ++ perror_with_name ("gethostbyname(3) resolving"); ++ } + +- tmp_desc = socket (PF_INET, SOCK_STREAM, 0); ++ memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr, ++ sizeof (struct in_addr)); ++ } ++ ++ /* We assume matching `AF_*' and `PF_*'. */ ++ tmp_desc = socket (sockaddr.sin_family, ++ (prefix != NULL ? prefix->socktype : SOCK_STREAM), ++ 0); + if (tmp_desc < 0) +- perror_with_name ("Can't open socket"); ++ { ++ free (name_base); ++ perror_with_name ("Can't open socket"); ++ } ++#endif /* !HAVE_GETADDRINFO */ + + /* 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; +- ++#ifdef HAVE_GETADDRINFO ++ if (bind (tmp_desc, addrinfo->ai_addr, addrinfo->ai_addrlen) ++ || ((prefix == NULL || prefix->socktype != SOCK_DGRAM) ++ && listen (tmp_desc, 1))) ++#else /* !HAVE_GETADDRINFO */ + 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); +- +- 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)); ++ || ((prefix == NULL || prefix->socktype != SOCK_DGRAM) ++ && listen (tmp_desc, 1))) ++#endif /* !HAVE_GETADDRINFO */ ++ { ++#ifdef HAVE_GETADDRINFO ++ freeaddrinfo (addrinfo_base); ++#endif /* HAVE_GETADDRINFO */ ++ free (name_base); ++ perror_with_name ("Can't bind address"); ++ } + +- /* 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)); ++#ifdef HAVE_GETNAMEINFO ++ if (0 == getnameinfo (addrinfo->ai_addr, addrinfo->ai_addrlen, ++ back_host, sizeof (back_host), ++ back_port, sizeof (back_port), ++ NI_NUMERICHOST | NI_NUMERICSERV)) ++ fprintf (stderr, "Listening on port %s (on host %s)\n", ++ back_port, back_host); ++ else ++#endif /* !HAVE_GETNAMEINFO */ ++ fprintf (stderr, "Listening on port %s (on host %s)\n", ++ port_str, (name != NULL ? name : "")); ++ fflush (stderr); + +- close (tmp_desc); /* No longer need this */ ++ /* Used for `port_str' above. */ ++ free (name_base); + +- signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver simply +- exits when the remote side dies. */ ++ if (prefix != NULL && prefix->socktype == SOCK_DGRAM) ++ remote_desc = tmp_desc; ++ else ++ { ++ struct sockaddr_storage sockaddr; ++ socklen_t sockaddr_len = sizeof (sockaddr); ++ remote_desc = accept (tmp_desc, (struct sockaddr *) &sockaddr, &sockaddr_len); ++ if (remote_desc == -1) ++ { ++#ifdef HAVE_GETADDRINFO ++ freeaddrinfo (addrinfo_base); ++#endif /* HAVE_GETADDRINFO */ ++ perror_with_name ("Accept failed"); ++ } + +- /* Convert IP address to string. */ +- fprintf (stderr, "Remote debugging from host %s\n", +- inet_ntoa (sockaddr.sin_addr)); ++ /* 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. */ ++ if (prefix == NULL || prefix->socktype == SOCK_STREAM) ++ { ++ tmp = 1; ++ setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY, ++ (char *) &tmp, sizeof (tmp)); ++ } ++#ifdef HAVE_GETADDRINFO ++ freeaddrinfo (addrinfo_base); ++#endif /* HAVE_GETADDRINFO */ ++ ++ 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. */ ++ ++#ifdef HAVE_GETNAMEINFO ++ /* Convert IP address to string. */ ++ if (0 == getnameinfo ((struct sockaddr *) &sockaddr, sockaddr_len, ++ back_host, sizeof (back_host), ++ back_port, sizeof (back_port), ++ NI_NUMERICHOST | NI_NUMERICSERV)) ++ fprintf (stderr, "Remote debugging from host %s port %s\n", ++ back_host, back_port); ++ else ++#endif /* !HAVE_GETNAMEINFO */ ++ fprintf (stderr, "Remote debugging started\n"); ++ } ++ fflush (stderr); + } + + #if defined(F_SETFL) && defined (FASYNC) +diff -u -rup gdb-6.5-orig/gdb/ser-tcp.c gdb-6.5/gdb/ser-tcp.c +--- gdb-6.5-orig/gdb/ser-tcp.c 2006-02-10 23:01:43.000000000 +0100 ++++ gdb-6.5/gdb/ser-tcp.c 2006-09-30 15:53:48.000000000 +0200 +@@ -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 : ""), ++ 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 --git a/gdb-6.5-gcore-i386-on-amd64.patch b/gdb-6.5-gcore-i386-on-amd64.patch new file mode 100644 index 0000000..fab2fbc --- /dev/null +++ b/gdb-6.5-gcore-i386-on-amd64.patch @@ -0,0 +1,747 @@ +2006-10-01 Jan Kratochvil + Fujitsu + + * amd64-linux-nat.c: Support new linux_elfcore_write_prpsinfo, + linux_elfcore_write_prstatus, linux_elfcore_write_prfpreg. + (i386_linux_gregset32_reg_offset): New mapping for i386 on amd64. + * gcore.c (gcore_create_callback): Comment vdso Linux kernel bug. + * configure.ac: Check for , . + * configure, config.in: Regenerated. + * gdb_user32.h, gdb_procfs32.h: Define 32-bit core files even for + 64-bit gdb, provide fallbacks for and . + * linux-nat.c: Virtualize `elfcore_*' by (*`linux_elfcore_*'). + (linux_nat_do_thread_registers): Likewise. + (linux_nat_make_corefile_notes): Likewise. + * linux-nat.h: Likewise. + * Makefile.in: Dependencies updated. + + +Index: gdb-6.5/gdb/Makefile.in +=================================================================== +--- gdb-6.5.orig/gdb/Makefile.in 21 Sep 2006 14:00:53 -0000 1.844 ++++ gdb-6.5/gdb/Makefile.in 1 Oct 2006 16:22:42 -0000 +@@ -696,6 +696,7 @@ gdb_h = gdb.h + gdb_locale_h = gdb_locale.h + gdb_obstack_h = gdb_obstack.h $(obstack_h) + gdb_proc_service_h = gdb_proc_service.h $(gregset_h) ++gdb_procfs32_h = gdb_procfs32.h $(gdb_user32_h) + gdb_ptrace_h = gdb_ptrace.h + gdb_regex_h = gdb_regex.h $(xregex_h) + gdb_select_h = gdb_select.h +@@ -705,6 +706,7 @@ gdb_string_h = gdb_string.h + gdb_thread_db_h = gdb_thread_db.h + gdbthread_h = gdbthread.h $(breakpoint_h) $(frame_h) + gdbtypes_h = gdbtypes.h $(hashtab_h) ++gdb_user32_h = gdb_user32.h $(gdb_stdint_h) + gdb_vfork_h = gdb_vfork.h + gdb_wait_h = gdb_wait.h + glibc_tdep_h = glibc-tdep.h +@@ -1743,7 +1745,8 @@ amd64fbsd-tdep.o: amd64fbsd-tdep.c $(def + amd64-linux-nat.o: amd64-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ + $(regcache_h) $(linux_nat_h) $(gdb_assert_h) $(gdb_string_h) \ + $(gdb_proc_service_h) $(gregset_h) $(amd64_tdep_h) \ +- $(i386_linux_tdep_h) $(amd64_nat_h) $(target_h) ++ $(i386_linux_tdep_h) $(amd64_nat_h) $(target_h) \ ++ $(i387_tdep_h) $(elf_bfd_h) $(gdb_procfs32_h) + amd64-linux-tdep.o: amd64-linux-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \ + $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \ + $(solib_svr4_h) +Index: gdb-6.5/gdb/amd64-linux-nat.c +=================================================================== +--- gdb-6.5.orig/gdb/amd64-linux-nat.c 19 Aug 2006 15:15:18 -0000 1.13 ++++ gdb-6.5/gdb/amd64-linux-nat.c 1 Oct 2006 16:22:42 -0000 +@@ -52,6 +52,9 @@ + #include "amd64-tdep.h" + #include "i386-linux-tdep.h" + #include "amd64-nat.h" ++#include "i387-tdep.h" ++#include "bfd/elf-bfd.h" ++#include "gdb_procfs32.h" + + /* Mapping between the general-purpose registers in GNU/Linux x86-64 + `struct user' format and GDB's register cache layout. */ +@@ -86,6 +89,35 @@ static int amd64_linux_gregset64_reg_off + GNU/Linux i386 registers are all 32-bit, but since we're + little-endian we get away with that. */ + ++/* This info is not reusable from "i386-linux-nat.c" as gdb itself runs in ++ 64-bit mode and so ptrace(2) has 64-bit structure layout. ++ Just the corefile being generated has 32-bit layout so we need to do ++ a conversion specific to the i386-on-amd64 compatibility mode. */ ++static int i386_linux_gregset32_reg_offset[] = ++{ ++ 6 * 4, /* %eax */ ++ 1 * 4, /* %ecx */ ++ 2 * 4, /* %edx */ ++ 0 * 4, /* %ebx */ ++ 15 * 4, /* %esp */ ++ 5 * 4, /* %ebp */ ++ 3 * 4, /* %esi */ ++ 4 * 4, /* %edi */ ++ 12 * 4, /* %eip */ ++ 14 * 4, /* %eflags */ ++ 13 * 4, /* %cs */ ++ 16 * 4, /* %ss */ ++ 7 * 4, /* %ds */ ++ 8 * 4, /* %es */ ++ 9 * 4, /* %fs */ ++ 10 * 4, /* %gs */ ++ -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, ++ 11 * 4 /* "orig_eax" */ ++}; ++ + /* From on GNU/Linux i386. */ + static int amd64_linux_gregset32_reg_offset[] = + { +@@ -104,6 +136,94 @@ static int amd64_linux_gregset32_reg_off + }; + + ++/* This functions make ELF32 32-bit elfcore note sections ++ on amd64 environment. */ ++ ++static char * ++amd64_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, ++ const char *fname, const char *psargs) ++{ ++ if (gdbarch_ptr_bit(current_gdbarch) == 32) ++ { ++ int note_type; ++ char *note_name = "CORE"; ++ struct elf_prpsinfo32 data; ++ note_type = NT_PRPSINFO; ++ ++ memset (&data, 0, sizeof (data)); ++ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); ++ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, note_type, &data, sizeof (data)); ++ } ++ else ++ return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs); ++} ++ ++static void ++amd64_linux_set_registers (const gdb_byte *gregs, gdb_byte *buf) ++{ ++ int i; ++ /* Copy the i386 registers in the amd64 layout into i386 layout. */ ++ for (i = 0; i < I386_NUM_GREGS; i++) ++ memcpy(buf + i386_linux_gregset32_reg_offset[i], ++ gregs + amd64_linux_gregset32_reg_offset[i], 4); ++ for (i = I386_CS_REGNUM; i <= I386_GS_REGNUM; i++) ++ memcpy(buf + i386_linux_gregset32_reg_offset[i], ++ gregs + amd64_linux_gregset32_reg_offset[i], 4); ++} ++ ++static char * ++amd64_linux_elfcore_write_prstatus (bfd *abfd, char *buf, int *bufsiz, ++ long pid, int cursig, const void *gregs) ++{ ++ if (gdbarch_ptr_bit(current_gdbarch) == 32) ++ { ++ char *note_name = "CORE"; ++ struct elf_prstatus32 prstat; ++ memset (&prstat, 0, sizeof (prstat)); ++ prstat.pr_pid = pid; ++ prstat.pr_cursig = cursig; ++ amd64_linux_set_registers (gregs, (gdb_byte *) &prstat.pr_reg); ++ return elfcore_write_note (abfd, buf, bufsiz, note_name, ++ NT_PRSTATUS, &prstat, sizeof (prstat)); ++ } ++ else ++ return elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs); ++} ++ ++static char * ++amd64_elfcore_write_prxfpreg32 (bfd *abfd, char *buf, int *bufsiz) ++{ ++ char *note_name = "LINUX"; ++ elf_fpxregset32_t fpxregs32; ++ ++ i387_fill_fxsave (&fpxregs32, -1); ++ return elfcore_write_note(abfd, buf, bufsiz, ++ note_name, NT_PRXFPREG, &fpxregs32, ++ sizeof(fpxregs32)); ++} ++ ++static char * ++amd64_linux_elfcore_write_prfpreg (bfd *abfd, char *buf, ++ int *bufsiz, const void *fpregs, int size) ++{ ++ if (gdbarch_ptr_bit(current_gdbarch) == 32) ++ { ++ char *note_name = "CORE"; ++ elf_fpregset32_t fpregs32; ++ ++ i387_fill_fsave (&fpregs32, -1); ++ buf = elfcore_write_note(abfd, buf, bufsiz, note_name, ++ NT_FPREGSET, &fpregs32, sizeof(fpregs32)); ++ ++ return amd64_elfcore_write_prxfpreg32 (abfd, buf, bufsiz); ++ } ++ else ++ return elfcore_write_prfpreg (abfd, buf, bufsiz, fpregs, size); ++} ++ ++ + /* Transfering the general-purpose registers between GDB, inferiors + and core files. */ + +@@ -406,6 +526,11 @@ _initialize_amd64_linux_nat (void) + t->to_fetch_registers = amd64_linux_fetch_inferior_registers; + t->to_store_registers = amd64_linux_store_inferior_registers; + ++ /* This functions make elfcore note sections. */ ++ linux_elfcore_write_prpsinfo = amd64_linux_elfcore_write_prpsinfo; ++ linux_elfcore_write_prstatus = amd64_linux_elfcore_write_prstatus; ++ linux_elfcore_write_prfpreg = amd64_linux_elfcore_write_prfpreg; ++ + /* Register the target. */ + linux_nat_add_target (t); + } +Index: gdb-6.5/gdb/config.in +=================================================================== +--- gdb-6.5.orig/gdb/config.in 8 Aug 2006 20:32:15 -0000 1.84 ++++ gdb-6.5/gdb/config.in 1 Oct 2006 16:22:42 -0000 +@@ -373,6 +373,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_POLL_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_PROCFS32_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_PROCFS_H + +@@ -397,6 +400,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_TYPES_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_USER32_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_USER_H + +Index: gdb-6.5/gdb/configure +=================================================================== +--- gdb-6.5.orig/gdb/configure 2006-10-01 18:43:40.000000000 +0200 ++++ gdb-6.5/gdb/configure 2006-10-01 18:40:44.000000000 +0200 +@@ -11949,6 +11949,157 @@ + + + ++for ac_header in sys/user32.h sys/procfs32.h ++do ++as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` ++if eval "test \"\${$as_ac_Header+set}\" = set"; then ++ echo "$as_me:$LINENO: checking for $ac_header" >&5 ++echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 ++if eval "test \"\${$as_ac_Header+set}\" = set"; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++fi ++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 ++echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 ++else ++ # Is the header compilable? ++echo "$as_me:$LINENO: checking $ac_header usability" >&5 ++echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 ++cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++$ac_includes_default ++#include <$ac_header> ++_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_header_compiler=yes ++else ++ echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ac_header_compiler=no ++fi ++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ++echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 ++echo "${ECHO_T}$ac_header_compiler" >&6 ++ ++# Is the header present? ++echo "$as_me:$LINENO: checking $ac_header presence" >&5 ++echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 ++cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++#include <$ac_header> ++_ACEOF ++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 ++ (eval $ac_cpp conftest.$ac_ext) 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); } >/dev/null; then ++ if test -s conftest.err; then ++ ac_cpp_err=$ac_c_preproc_warn_flag ++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag ++ else ++ ac_cpp_err= ++ fi ++else ++ ac_cpp_err=yes ++fi ++if test -z "$ac_cpp_err"; then ++ ac_header_preproc=yes ++else ++ echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_header_preproc=no ++fi ++rm -f conftest.err conftest.$ac_ext ++echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 ++echo "${ECHO_T}$ac_header_preproc" >&6 ++ ++# So? What about this header? ++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in ++ yes:no: ) ++ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 ++echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} ++ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 ++echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ++ ac_header_preproc=yes ++ ;; ++ no:yes:* ) ++ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 ++echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} ++ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 ++echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} ++ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 ++echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} ++ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 ++echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} ++ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 ++echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ++ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 ++echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ++ ( ++ cat <<\_ASBOX ++## ------------------------------------------ ## ++## Report this to the AC_PACKAGE_NAME lists. ## ++## ------------------------------------------ ## ++_ASBOX ++ ) | ++ sed "s/^/$as_me: WARNING: /" >&2 ++ ;; ++esac ++echo "$as_me:$LINENO: checking for $ac_header" >&5 ++echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 ++if eval "test \"\${$as_ac_Header+set}\" = set"; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ eval "$as_ac_Header=\$ac_header_preproc" ++fi ++echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 ++echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 ++ ++fi ++if test `eval echo '${'$as_ac_Header'}'` = yes; then ++ cat >>confdefs.h <<_ACEOF ++#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 ++_ACEOF ++ ++fi ++ ++done ++ ++ ++ + for ac_header in sys/wait.h wait.h + do + as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +Index: gdb-6.5/gdb/configure.ac +=================================================================== +--- gdb-6.5.orig/gdb/configure.ac 8 Aug 2006 20:26:23 -0000 1.34 ++++ gdb-6.5/gdb/configure.ac 1 Oct 2006 16:22:43 -0000 +@@ -365,6 +365,7 @@ AC_CHECK_HEADERS(sys/user.h, [], [], + # include + #endif + ]) ++AC_CHECK_HEADERS(sys/user32.h sys/procfs32.h) + AC_CHECK_HEADERS(sys/wait.h wait.h) + AC_CHECK_HEADERS(termios.h termio.h sgtty.h) + AC_CHECK_HEADERS(unistd.h) +Index: gdb-6.5/gdb/gcore.c +=================================================================== +--- gdb-6.5.orig/gdb/gcore.c 17 Dec 2005 22:33:59 -0000 1.18 ++++ gdb-6.5/gdb/gcore.c 1 Oct 2006 16:22:43 -0000 +@@ -314,6 +314,11 @@ gcore_create_callback (CORE_ADDR vaddr, + asection *osec; + flagword flags = SEC_ALLOC | SEC_HAS_CONTENTS | SEC_LOAD; + ++ /* Some Linux kernel versions around 2.6.17 have for i386 inferiors running ++ in compatibility mode on amd64 kernel their VSYSCALL page (at 0xffffe000) ++ protected as RWX==000 by default and gdb fails to read the library header ++ upon loading the core. This is a Linux kernel bug being fixed. */ ++ + /* If the memory segment has no permissions set, ignore it, otherwise + when we later try to access it for read/write, we'll get an error + or jam the kernel. */ +Index: gdb-6.5/gdb/gdb_procfs32.h +=================================================================== +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ gdb-6.5/gdb/gdb_procfs32.h 1 Oct 2006 16:22:43 -0000 +@@ -0,0 +1,128 @@ ++#ifdef HAVE_SYS_PROCFS32_H ++#include ++#else ++ ++/* Copyright (C) 2006 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _SYS_PROCFS32_H ++#define _SYS_PROCFS32_H 1 ++ ++/* This is somewhat modelled after the file of the same name on SVR4 ++ systems. It provides a definition of the core file format for ELF ++ used on Linux. It doesn't have anything to do with the /proc file ++ system, even though Linux has one. ++ ++ Anyway, the whole purpose of this file is for GDB and GDB only. ++ Don't read too much into it. Don't use it for anything other than ++ GDB unless you know what you are doing. */ ++ ++#include ++#include ++#include ++#include "gdb_user32.h" ++ ++/* We define here only the symbols differing from their 64-bit variant. */ ++#include ++ ++__BEGIN_DECLS ++ ++/* Type for a general-purpose register. */ ++typedef unsigned int elf_greg32_t; ++ ++/* And the whole bunch of them. We could have used `struct ++ user_regs_struct' directly in the typedef, but tradition says that ++ the register set is an array, which does have some peculiar ++ semantics, so leave it that way. */ ++#define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t)) ++typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32]; ++ ++/* Register set for the floating-point registers. */ ++typedef struct user_fpregs32_struct elf_fpregset32_t; ++ ++/* Register set for the extended floating-point registers. Includes ++ the Pentium III SSE registers in addition to the classic ++ floating-point stuff. */ ++typedef struct user_fpxregs32_struct elf_fpxregset32_t; ++ ++ ++/* Definitions to generate Intel SVR4-like core files. These mostly ++ have the same names as the SVR4 types with "elf_" tacked on the ++ front to prevent clashes with Linux definitions, and the typedef ++ forms have been avoided. This is mostly like the SVR4 structure, ++ but more Linuxy, with things that Linux does not support and which ++ GDB doesn't really use excluded. */ ++ ++struct prstatus32_timeval ++ { ++ int tv_sec; ++ int tv_usec; ++ }; ++ ++struct elf_prstatus32 ++ { ++ struct elf_siginfo pr_info; /* Info associated with signal. */ ++ short int pr_cursig; /* Current signal. */ ++ unsigned int pr_sigpend; /* Set of pending signals. */ ++ unsigned int pr_sighold; /* Set of held signals. */ ++ __pid_t pr_pid; ++ __pid_t pr_ppid; ++ __pid_t pr_pgrp; ++ __pid_t pr_sid; ++ struct prstatus32_timeval pr_utime; /* User time. */ ++ struct prstatus32_timeval pr_stime; /* System time. */ ++ struct prstatus32_timeval pr_cutime; /* Cumulative user time. */ ++ struct prstatus32_timeval pr_cstime; /* Cumulative system time. */ ++ elf_gregset32_t pr_reg; /* GP registers. */ ++ int pr_fpvalid; /* True if math copro being used. */ ++ }; ++ ++ ++struct elf_prpsinfo32 ++ { ++ char pr_state; /* Numeric process state. */ ++ char pr_sname; /* Char for pr_state. */ ++ char pr_zomb; /* Zombie. */ ++ char pr_nice; /* Nice val. */ ++ unsigned int pr_flag; /* Flags. */ ++ unsigned short int pr_uid; ++ unsigned short int pr_gid; ++ int pr_pid, pr_ppid, pr_pgrp, pr_sid; ++ /* Lots missing */ ++ char pr_fname[16]; /* Filename of executable. */ ++ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ ++ }; ++ ++ ++/* The rest of this file provides the types for emulation of the ++ Solaris interfaces that should be implemented by ++ users of libthread_db. */ ++ ++/* Register sets. Linux has different names. */ ++typedef elf_gregset_t prgregset32_t; ++typedef elf_fpregset_t prfpregset32_t; ++ ++/* Process status and info. In the end we do provide typedefs for them. */ ++typedef struct elf_prstatus32 prstatus32_t; ++typedef struct elf_prpsinfo32 prpsinfo32_t; ++ ++__END_DECLS ++ ++#endif /* _SYS_PROCFS32_H */ ++ ++#endif /* HAVE_SYS_PROCFS32_H */ +Index: gdb-6.5/gdb/gdb_user32.h +=================================================================== +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ gdb-6.5/gdb/gdb_user32.h 1 Oct 2006 16:22:43 -0000 +@@ -0,0 +1,108 @@ ++#ifdef HAVE_SYS_USER32_H ++#include ++#else ++ ++#ifdef HAVE_STDINT_H ++#include ++typedef int32_t gdb_int32_t; ++typedef uint32_t gdb_uint32_t; ++#else ++typedef signed int gdb_uint32_t; ++typedef unsigned int gdb_uint32_t; ++#endif ++ ++/* Copyright (C) 2006 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _SYS_USER32_H ++#define _SYS_USER32_H 1 ++ ++/* These are the 32-bit x86 structures. */ ++ ++struct user_fpregs32_struct ++{ ++ int32_t cwd; ++ int32_t swd; ++ int32_t twd; ++ int32_t fip; ++ int32_t fcs; ++ int32_t foo; ++ int32_t fos; ++ int32_t st_space [20]; ++}; ++ ++struct user_fpxregs32_struct ++{ ++ unsigned short int cwd; ++ unsigned short int swd; ++ unsigned short int twd; ++ unsigned short int fop; ++ int32_t fip; ++ int32_t fcs; ++ int32_t foo; ++ int32_t fos; ++ int32_t mxcsr; ++ int32_t reserved; ++ int32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ ++ int32_t xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ ++ int32_t padding[56]; ++}; ++ ++struct user_regs32_struct ++{ ++ int32_t ebx; ++ int32_t ecx; ++ int32_t edx; ++ int32_t esi; ++ int32_t edi; ++ int32_t ebp; ++ int32_t eax; ++ int32_t xds; ++ int32_t xes; ++ int32_t xfs; ++ int32_t xgs; ++ int32_t orig_eax; ++ int32_t eip; ++ int32_t xcs; ++ int32_t eflags; ++ int32_t esp; ++ int32_t xss; ++}; ++ ++struct user32 ++{ ++ struct user_regs32_struct regs; ++ int u_fpvalid; ++ struct user_fpregs32_struct i387; ++ uint32_t u_tsize; ++ uint32_t u_dsize; ++ uint32_t u_ssize; ++ uint32_t start_code; ++ uint32_t start_stack; ++ int32_t signal; ++ int reserved; ++ struct user_regs32_struct* u_ar0; ++ struct user_fpregs32_struct* u_fpstate; ++ uint32_t magic; ++ char u_comm [32]; ++ int u_debugreg [8]; ++}; ++ ++#endif /* _SYS_USER32_H */ ++ ++#endif /* HAVE_SYS_USER32_H */ +Index: gdb-6.5/gdb/linux-nat.c +=================================================================== +--- gdb-6.5.orig/gdb/linux-nat.c 16 Sep 2006 09:48:12 -0000 1.50 ++++ gdb-6.5/gdb/linux-nat.c 1 Oct 2006 16:22:43 -0000 +@@ -99,6 +99,15 @@ static LONGEST (*super_xfer_partial) (st + const gdb_byte *, + ULONGEST, LONGEST); + ++/* This functions make elfcore note sections. ++ They may get overriden by code adjusting data for multi-target builds. */ ++char *(*linux_elfcore_write_prpsinfo) ++ (bfd *, char *, int *, const char *, const char *) = elfcore_write_prpsinfo; ++char *(*linux_elfcore_write_prstatus) ++ (bfd *, char *, int *, long, int, const void *) = elfcore_write_prstatus; ++char *(*linux_elfcore_write_prfpreg) ++ (bfd *, char *, int *, const void *, int) = elfcore_write_prfpreg; ++ + static int debug_linux_nat; + static void + show_debug_linux_nat (struct ui_file *file, int from_tty, +@@ -2562,11 +2571,11 @@ linux_nat_do_thread_registers (bfd *obfd + else + fill_gregset (&gregs, -1); + +- note_data = (char *) elfcore_write_prstatus (obfd, +- note_data, +- note_size, +- lwp, +- stop_signal, &gregs); ++ note_data = (char *) linux_elfcore_write_prstatus (obfd, ++ note_data, ++ note_size, ++ lwp, ++ stop_signal, &gregs); + + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", +@@ -2577,10 +2586,10 @@ linux_nat_do_thread_registers (bfd *obfd + else + fill_fpregset (&fpregs, -1); + +- note_data = (char *) elfcore_write_prfpreg (obfd, +- note_data, +- note_size, +- &fpregs, sizeof (fpregs)); ++ note_data = (char *) linux_elfcore_write_prfpreg (obfd, ++ note_data, ++ note_size, ++ &fpregs, sizeof (fpregs)); + + #ifdef FILL_FPXREGSET + if (core_regset_p +@@ -2675,9 +2684,9 @@ linux_nat_make_corefile_notes (bfd *obfd + strncat (psargs, get_inferior_args (), + sizeof (psargs) - strlen (psargs)); + } +- note_data = (char *) elfcore_write_prpsinfo (obfd, +- note_data, +- note_size, fname, psargs); ++ note_data = (char *) linux_elfcore_write_prpsinfo (obfd, note_data, ++ note_size, fname, ++ psargs); + } + + /* Dump information for threads. */ +Index: gdb-6.5/gdb/linux-nat.h +=================================================================== +--- gdb-6.5.orig/gdb/linux-nat.h 23 Jul 2006 21:21:01 -0000 1.12 ++++ gdb-6.5/gdb/linux-nat.h 1 Oct 2006 16:22:43 -0000 +@@ -96,3 +96,12 @@ void linux_nat_add_target (struct target + /* Update linux-nat internal state when changing from one fork + to another. */ + void linux_nat_switch_fork (ptid_t new_ptid); ++ ++/* This functions make elfcore note sections. ++ They may get overriden by code adjusting data for multi-target builds. */ ++extern char *(*linux_elfcore_write_prpsinfo) ++ (bfd *, char *, int *, const char *, const char *); ++extern char *(*linux_elfcore_write_prstatus) ++ (bfd *, char *, int *, long, int, const void *); ++extern char *(*linux_elfcore_write_prfpreg) ++ (bfd *, char *, int *, const void *, int); diff --git a/gdb.spec b/gdb.spec index e7803fb..c8aad7a 100644 --- a/gdb.spec +++ b/gdb.spec @@ -11,7 +11,7 @@ Name: gdb Version: 6.5 # The release always contains a leading reserved number, start it at 0. -Release: 10%{?dist} +Release: 11%{?dist} License: GPL Group: Development/Debuggers @@ -268,7 +268,20 @@ Patch195: gdb-6.5-tls-of-separate-debuginfo.patch Patch196: gdb-6.5-sharedlibrary-path.patch # Support IPv6 for gdbserver (BZ 198365). -Patch197: gdb-6.5-IPv6.patch +Patch197: gdb-6.5-bz198365-IPv6.patch + +# No longer disassemble invalid i386 opcodes of movQ/movA (BZ 172034). +Patch198: gdb-6.5-bz172034-disasm-i386-C6-C7.patch + +# Suggest fixing your target architecture for gdbserver(1) (BZ 190810). +# FIXME: It could be autodetected. +Patch199: gdb-6.5-bz190810-gdbserver-arch-advice.patch + +# Fix dereferencing registers for 32bit inferiors on 64bit hosts (BZ 181390). +Patch200: gdb-6.5-bz181390-memory-address-width.patch + +# Fix `gcore' command for 32bit inferiors on 64bit hosts. +Patch201: gdb-6.5-gcore-i386-on-amd64.patch BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext BuildRequires: flex bison sharutils @@ -378,6 +391,10 @@ and printing their data. %patch195 -p1 %patch196 -p1 %patch197 -p1 +%patch198 -p1 +%patch199 -p1 +%patch200 -p1 +%patch201 -p1 # Change the version that gets printed at GDB startup, so it is RedHat # specific. @@ -539,6 +556,13 @@ fi # don't include the files in include, they are part of binutils %changelog +* Sun Oct 1 2006 Jan Kratochvil - 6.5-11 +- No longer disassemble invalid i386 opcodes of movQ/movA (BZ 172034). +- Simplify the IPv6 patch for gdbserver (BZ 198365). +- Suggest fixing your target architecture for gdbserver(1) (BZ 190810). +- Fix dereferencing registers for 32bit inferiors on 64bit hosts (BZ 181390). +- Fix `gcore' command for 32bit inferiors on 64bit hosts. + * Wed Sep 27 2006 Jan Kratochvil - 6.5-10 - Support IPv6 for gdbserver (BZ 198365). - Temporarily disable testcase "chng-syms.exp" for a possible kernel Bug 207002.