Index: inf-ptrace.c =================================================================== RCS file: /cvs/src/src/gdb/inf-ptrace.c,v retrieving revision 1.32 diff -u -p -r1.32 inf-ptrace.c --- inf-ptrace.c 24 Jan 2006 22:34:34 -0000 1.32 +++ inf-ptrace.c 15 Jun 2006 19:49:24 -0000 @@ -166,8 +166,10 @@ inf_ptrace_mourn_inferior (void) /* Wait just one more time to collect the inferior's exit status. Do not check whether this succeeds though, since we may be dealing with a process that we attached to. Such a process will - only report its exit status to its original parent. */ - waitpid (ptid_get_pid (inferior_ptid), &status, 0); + only report its exit status to its original parent. + WNOHANG is required as on follow_exec() (due to TARGET_WAITKIND_EXECD) + resulted from waitpid(2) and it called us by target_mourn_inferior(). */ + waitpid (ptid_get_pid (inferior_ptid), &status, WNOHANG); unpush_target (ptrace_ops_hack); generic_mourn_inferior (); Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.210 diff -u -p -r1.210 infrun.c --- infrun.c 30 Mar 2006 16:37:13 -0000 1.210 +++ infrun.c 15 Jun 2006 19:49:31 -0000 @@ -47,6 +47,7 @@ #include "language.h" #include "solib.h" #include "main.h" +#include "objfiles.h" #include "gdb_assert.h" #include "mi/mi-common.h" @@ -109,10 +110,10 @@ int sync_execution = 0; static ptid_t previous_inferior_ptid; /* This is true for configurations that may follow through execl() and - similar functions. At present this is only true for HP-UX native. */ + similar functions. */ #ifndef MAY_FOLLOW_EXEC -#define MAY_FOLLOW_EXEC (0) +#define MAY_FOLLOW_EXEC (1) #endif static int may_follow_exec = MAY_FOLLOW_EXEC; @@ -382,6 +383,7 @@ follow_exec (int pid, char *execd_pathna { int saved_pid = pid; struct target_ops *tgt; + struct objfile *objfile, *objfile_temp; if (!may_follow_exec) return; @@ -427,6 +429,19 @@ follow_exec (int pid, char *execd_pathna error (_("Could find run target to save before following exec")); gdb_flush (gdb_stdout); + + /* As symbol_file_add_main()->thread_db_new_objfile()->check_for_thread_db() + * would fine already loaded libpthread.so while the threading structures + * would not be yet initialized for this early inferior. + * Call before target_mourn_inferior() as it will breakpoint_re_set(). */ + clear_solib (); + /* Do not: symbol_file_clear()->clear_symtab_users()->breakpoint_re_set(). */ + ALL_OBJFILES_SAFE (objfile, objfile_temp) + { + free_objfile (objfile); + } + symfile_objfile = NULL; + target_mourn_inferior (); inferior_ptid = pid_to_ptid (saved_pid); /* Because mourn_inferior resets inferior_ptid. */ Index: linux-thread-db.c =================================================================== RCS file: /cvs/src/src/gdb/linux-thread-db.c,v retrieving revision 1.16 diff -u -p -r1.16 linux-thread-db.c --- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16 +++ linux-thread-db.c 15 Jun 2006 19:49:33 -0000 @@ -945,6 +945,10 @@ thread_db_wait (ptid_t ptid, struct targ if (ourstatus->kind == TARGET_WAITKIND_EXITED) return pid_to_ptid (-1); + /* Threading structures got reset. Return as nonthreaded. */ + if (ourstatus->kind == TARGET_WAITKIND_EXECD) + return pid_to_ptid (GET_PID (ptid)); + if (ourstatus->kind == TARGET_WAITKIND_STOPPED && ourstatus->value.sig == TARGET_SIGNAL_TRAP) /* Check for a thread event. */ @@ -1111,6 +1115,9 @@ thread_db_mourn_inferior (void) the inferior, so that we don't try to uninsert them. */ remove_thread_event_breakpoints (); + /* Destroy thread info; it's no longer valid. */ + init_thread_list (); + /* Detach thread_db target ops. */ unpush_target (&thread_db_ops); using_thread_db = 0; Index: testsuite/gdb.base/foll-exec.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/foll-exec.exp,v retrieving revision 1.2 diff -u -p -r1.2 foll-exec.exp --- testsuite/gdb.base/foll-exec.exp 6 Mar 2001 08:21:50 -0000 1.2 +++ testsuite/gdb.base/foll-exec.exp 15 Jun 2006 19:49:34 -0000 @@ -45,12 +45,6 @@ if { [gdb_compile "${srcdir}/${subdir}/ } -# Until "catch exec" is implemented on other targets... -# -if ![istarget "hppa*-hp-hpux*"] then { - continue -} - proc zap_session {} { global gdb_prompt global binfile @@ -212,7 +206,9 @@ proc do_exec_tests {} { setup_xfail hppa2.0w-hp-hpux* CLLbs16760 send_gdb "continue\n" gdb_expect { - -re ".*Executing new program:.*${testfile2}.*Catchpoint .*(exec\'d .*${testfile2}).*in .START..*$gdb_prompt $"\ + # It is OS dependent and no symbols may be found, GNU/Linux has "_start" + # while HP-UX has " in .START..*$gdb_prompt" etc. + -re ".*Executing new program:.*${testfile2}.*Catchpoint .*(exec\'d .*${testfile2}).*in .*$gdb_prompt $"\ {pass "hit catch exec"} -re "$gdb_prompt $" {fail "hit catch exec"} timeout {fail "(timeout) hit catch exec"}