Success: Was Re: Linking problems with gdb-7.2
On Mon, 2011-03-21 at 22:53 +0100, Samuel Thibault wrote:
> Svante Signell, le Mon 21 Mar 2011 22:28:54 +0100, a écrit :
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x0804846c in main () at test.c:1
> > 1 int main(void){ *(int*)0=0;}
> >
> > Only quitting talks about bogus threads:
> > (gdb) quit
> > A debugging session is active.
> >
> > Inferior 1 [bogus thread id 0] will be killed.
> >
> > Any more examples to try?
>
> Uh, no, that should be it, thanks!
Attaching the patch for review.
The problem with linking was due to that prune_threads() was only
locally defined, thank you Samuel.
I had to change the configure script in gdb-7.2/gdb adding the test for
libhurduser and libmachuser directly since this file was created with
autoconf 2.64, and the recent one was 2.67. I even tried downgrading to
2.64 and creating a new configure from configure.ac but it did not
generate a successful build. The need to explicitly link the lib*user
libraries is probably due to the recent ---as-needed linker changes. Was
this needed before?
The solution was to cut-and-paste the parts regarding lib{hurd,mach}user
from the generated configure into the old configure script. Otherwise
the following two rules are easily added in gdb/configure.ac:
# Needed to link properly for GNU/Hurd
AC_SEARCH_LIBS(mach_port_destroy, machuser)
AC_SEARCH_LIBS(proc_getmsgport, hurduser)
--- gdb-7.2/gdb/gnu-nat.c 2011-03-22 07:30:32.000000000 +0100
+++ gdb-7.2.patched/gdb/gnu-nat.c 2011-03-20 17:55:58.000000000 +0100
@@ -75,6 +75,8 @@
#include "exc_request_U.h"
#include "msg_U.h"
+extern void prune_threads (void);
+
static process_t proc_server = MACH_PORT_NULL;
/* If we've sent a proc_wait_request to the proc server, the pid of the
@@ -1578,8 +1580,8 @@
if (--inf->pending_execs == 0)
/* We're done! */
{
+ prune_threads (); /* Get rid of the old shell threads */
#if 0 /* do we need this? */
- prune_threads (1); /* Get rid of the old shell threads */
renumber_threads (0); /* Give our threads reasonable names. */
#endif
}
@@ -2137,6 +2139,10 @@
inf_steal_exc_ports (inf);
else
inf_restore_exc_ports (inf);
+
+#if 0
+ prune_threads ();
+#endif
}
--- gdb-7.2/gdb/thread.c.orig 2010-08-06 21:51:49.000000000 +0200
+++ gdb-7.2/gdb/thread.c 2011-03-21 17:08:05.000000000 +0100
@@ -61,7 +61,7 @@
static void info_threads_command (char *, int);
static void thread_apply_command (char *, int);
static void restore_current_thread (ptid_t);
-static void prune_threads (void);
+void prune_threads (void);
/* Frontend view of the thread state. Possible extensions: stepping,
finishing, until(ling),... */
@@ -518,7 +518,7 @@
return 1;
}
-static void
+void
prune_threads (void)
{
struct thread_info *tp, *next;
--- gdb-7.2/gdb/configure.orig 2010-08-19 00:55:56.000000000 +0200
+++ gdb-7.2/gdb/configure 2011-03-21 20:13:27.000000000 +0100
@@ -9173,6 +9173,118 @@
fi
+# Needed to link properly for GNU/Hurd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing mach_po
+rt_destroy" >&5
+$as_echo_n "checking for library containing mach_port_destroy... " >&6; }
+if test "${ac_cv_search_mach_port_destroy+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mach_port_destroy ();
+int
+main ()
+{
+return mach_port_destroy ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' machuser; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_mach_port_destroy=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if test "${ac_cv_search_mach_port_destroy+set}" = set; then :
+ break
+fi
+done
+if test "${ac_cv_search_mach_port_destroy+set}" = set; then :
+
+else
+ ac_cv_search_mach_port_destroy=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_mach_port_destroy" >&5
+$as_echo "$ac_cv_search_mach_port_destroy" >&6; }
+ac_res=$ac_cv_search_mach_port_destroy
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing proc_getmsgport" >&5
+$as_echo_n "checking for library containing proc_getmsgport... " >&6; }
+if test "${ac_cv_search_proc_getmsgport+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char proc_getmsgport ();
+int
+main ()
+{
+return proc_getmsgport ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' hurduser; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_proc_getmsgport=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if test "${ac_cv_search_proc_getmsgport+set}" = set; then :
+ break
+fi
+done
+if test "${ac_cv_search_proc_getmsgport+set}" = set; then :
+
+else
+ ac_cv_search_proc_getmsgport=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_proc_getmsgport" >&5
+$as_echo "$ac_cv_search_proc_getmsgport" >&6; }
+ac_res=$ac_cv_search_proc_getmsgport
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
# Link in zlib if we can. This allows us to read compressed debug sections.
--- gdb-7.2/gdb/configure.ac.orig 2010-08-19 00:55:57.000000000 +0200
+++ gdb-7.2/gdb/configure.ac 2011-03-21 19:02:58.000000000 +0100
@@ -425,6 +425,10 @@
# Some systems (e.g. Solaris) have `socketpair' in libsocket.
AC_SEARCH_LIBS(socketpair, socket)
+# Needed to link properly for GNU/Hurd
+AC_SEARCH_LIBS(mach_port_destroy, machuser)
+AC_SEARCH_LIBS(proc_getmsgport, hurduser)
+
# Link in zlib if we can. This allows us to read compressed debug sections.
AM_ZLIB
Reply to: