2007-10-13 18:40:40 +00:00
|
|
|
[base]
|
|
|
|
|
|
|
|
2007-10-13 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
|
|
|
|
* linux-nat.c (iterate_over_lwps): Fixed missing LWP initialization for
|
|
|
|
current INFERIOR_PTID.
|
|
|
|
|
|
|
|
2007-10-13 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
|
|
|
|
* gdb.base/follow-child.exp, gdb.base/follow-child.c: New files.
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
Index: gdb-6.6/gdb/doc/observer.texi
|
2006-07-11 06:33:02 +00:00
|
|
|
===================================================================
|
2007-01-21 01:53:01 +00:00
|
|
|
--- gdb-6.6.orig/gdb/doc/observer.texi
|
|
|
|
+++ gdb-6.6/gdb/doc/observer.texi
|
2006-07-11 06:33:02 +00:00
|
|
|
@@ -119,6 +119,10 @@ when @value{GDBN} calls this observer, t
|
|
|
|
haven't been loaded yet.
|
2005-01-19 23:29:48 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
+@deftypefun void mourn_inferior (struct target_ops *@var{target})
|
|
|
|
+@value{GDBN} has just detached from an inferior.
|
|
|
|
+@end deftypefun
|
|
|
|
+
|
|
|
|
@deftypefun void solib_unloaded (struct so_list *@var{solib})
|
2006-07-11 06:33:02 +00:00
|
|
|
The shared library specified by @var{solib} has been unloaded.
|
2005-01-19 23:29:48 +00:00
|
|
|
@end deftypefun
|
2007-01-21 01:53:01 +00:00
|
|
|
Index: gdb-6.6/gdb/linux-nat.c
|
2006-07-11 06:33:02 +00:00
|
|
|
===================================================================
|
2007-01-21 01:53:01 +00:00
|
|
|
--- gdb-6.6.orig/gdb/linux-nat.c
|
|
|
|
+++ gdb-6.6/gdb/linux-nat.c
|
2007-10-13 18:40:40 +00:00
|
|
|
@@ -803,11 +803,26 @@ iterate_over_lwps (int (*callback) (stru
|
2005-01-18 16:37:00 +00:00
|
|
|
{
|
|
|
|
struct lwp_info *lp, *lpnext;
|
|
|
|
|
|
|
|
- for (lp = lwp_list; lp; lp = lpnext)
|
|
|
|
+ if (lwp_list != NULL)
|
|
|
|
{
|
|
|
|
- lpnext = lp->next;
|
|
|
|
+ for (lp = lwp_list; lp; lp = lpnext)
|
|
|
|
+ {
|
|
|
|
+ lpnext = lp->next;
|
|
|
|
+ if ((*callback) (lp, data))
|
|
|
|
+ return lp;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /* We are calling iterate_over_lwps for a non-threaded program.
|
|
|
|
+ Initialize the lwp list to the inferior's ptid. */
|
2007-10-13 18:40:40 +00:00
|
|
|
+ gdb_assert (!is_lwp (inferior_ptid));
|
|
|
|
+
|
|
|
|
+ inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid),
|
|
|
|
+ GET_PID (inferior_ptid));
|
|
|
|
+ lp = add_lwp (inferior_ptid);
|
2005-01-18 16:37:00 +00:00
|
|
|
if ((*callback) (lp, data))
|
|
|
|
- return lp;
|
|
|
|
+ return lp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2006-07-11 06:33:02 +00:00
|
|
|
@@ -3262,6 +3274,18 @@ linux_nat_add_target (struct target_ops
|
|
|
|
thread_db_init (t);
|
2005-01-18 16:37:00 +00:00
|
|
|
}
|
|
|
|
|
2005-01-19 23:29:48 +00:00
|
|
|
+/* Observer function for a mourn inferior event. This is needed
|
2005-01-18 16:37:00 +00:00
|
|
|
+ because if iterate_over_lwps is called for a non-threaded program
|
|
|
|
+ to handle watchpoints, the lwp list gets initialized but there is
|
2005-01-19 23:29:48 +00:00
|
|
|
+ no corresponding clean-up when the inferior is detached. In
|
|
|
|
+ a threaded program, the observer is simply redundant as the
|
|
|
|
+ same clean-up gets done in linux_nat_mourn_inferior. */
|
2005-01-18 16:37:00 +00:00
|
|
|
+static void
|
2005-01-19 23:29:48 +00:00
|
|
|
+linux_nat_mourn_inferior_observer (struct target_ops *objfile)
|
2005-01-18 16:37:00 +00:00
|
|
|
+{
|
|
|
|
+ init_lwp_list ();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void
|
|
|
|
_initialize_linux_nat (void)
|
|
|
|
{
|
2006-07-11 06:33:02 +00:00
|
|
|
@@ -3276,6 +3300,8 @@ Specify any of the following keywords fo
|
2005-01-18 16:37:00 +00:00
|
|
|
status -- list a different bunch of random process info.\n\
|
2006-07-11 06:33:02 +00:00
|
|
|
all -- list all available /proc info."));
|
2005-01-19 23:29:48 +00:00
|
|
|
|
2006-07-11 06:33:02 +00:00
|
|
|
+ observer_attach_mourn_inferior (linux_nat_mourn_inferior_observer);
|
|
|
|
+
|
|
|
|
/* Save the original signal mask. */
|
|
|
|
sigprocmask (SIG_SETMASK, NULL, &normal_mask);
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
Index: gdb-6.6/gdb/target.c
|
2006-07-11 06:33:02 +00:00
|
|
|
===================================================================
|
2007-01-21 01:53:01 +00:00
|
|
|
--- gdb-6.6.orig/gdb/target.c
|
|
|
|
+++ gdb-6.6/gdb/target.c
|
|
|
|
@@ -40,6 +40,7 @@
|
2005-01-19 23:29:48 +00:00
|
|
|
#include "gdb_assert.h"
|
|
|
|
#include "gdbcore.h"
|
2007-01-21 01:53:01 +00:00
|
|
|
#include "exceptions.h"
|
2005-01-19 23:29:48 +00:00
|
|
|
+#include "observer.h"
|
|
|
|
|
|
|
|
static void target_info (char *, int);
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
@@ -276,6 +277,13 @@ target_load (char *arg, int from_tty)
|
2005-01-19 23:29:48 +00:00
|
|
|
(*current_target.to_load) (arg, from_tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
|
|
|
+target_mourn_inferior (void)
|
|
|
|
+{
|
|
|
|
+ (*current_target.to_mourn_inferior) ();
|
|
|
|
+ observer_notify_mourn_inferior (¤t_target);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int
|
|
|
|
nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,
|
|
|
|
struct target_ops *t)
|
2007-01-21 01:53:01 +00:00
|
|
|
Index: gdb-6.6/gdb/target.h
|
2006-07-11 06:33:02 +00:00
|
|
|
===================================================================
|
2007-01-21 01:53:01 +00:00
|
|
|
--- gdb-6.6.orig/gdb/target.h
|
|
|
|
+++ gdb-6.6/gdb/target.h
|
|
|
|
@@ -891,8 +891,7 @@ int target_follow_fork (int follow_child
|
2005-01-19 23:29:48 +00:00
|
|
|
|
|
|
|
/* The inferior process has died. Do what is right. */
|
|
|
|
|
|
|
|
-#define target_mourn_inferior() \
|
|
|
|
- (*current_target.to_mourn_inferior) ()
|
|
|
|
+extern void target_mourn_inferior (void);
|
|
|
|
|
|
|
|
/* Does target have enough data to do a run or attach command? */
|
|
|
|
|
2007-10-13 18:40:40 +00:00
|
|
|
diff -u -u -X /home/jkratoch/.diffi.list -rup gdb-6.6-orig/gdb/testsuite/gdb.base/follow-child.c gdb-6.6/gdb/testsuite/gdb.base/follow-child.c
|
|
|
|
--- gdb-6.6-orig/gdb/testsuite/gdb.base/follow-child.c 2007-10-13 19:24:58.000000000 +0200
|
|
|
|
+++ gdb-6.6/gdb/testsuite/gdb.base/follow-child.c 2007-10-13 19:11:08.000000000 +0200
|
|
|
|
@@ -0,0 +1,29 @@
|
|
|
|
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
+
|
|
|
|
+ Copyright 2007 Free Software Foundation, Inc.
|
|
|
|
+
|
|
|
|
+ This program is free software; you can redistribute it and/or modify
|
|
|
|
+ it under the terms of the GNU General Public License as published by
|
|
|
|
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ (at your option) any later version.
|
|
|
|
+
|
|
|
|
+ This program 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 General Public License for more details.
|
|
|
|
+
|
|
|
|
+ You should have received a copy of the GNU General Public License
|
|
|
|
+ along with this program; if not, write to the Free Software
|
|
|
|
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
+
|
|
|
|
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
|
+ bug-gdb@prep.ai.mit.edu */
|
|
|
|
+
|
|
|
|
+#include <unistd.h>
|
|
|
|
+
|
|
|
|
+int main()
|
|
|
|
+{
|
|
|
|
+ fork ();
|
|
|
|
+ sleep (60);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
diff -u -u -X /home/jkratoch/.diffi.list -rup gdb-6.6-orig/gdb/testsuite/gdb.base/follow-child.exp gdb-6.6/gdb/testsuite/gdb.base/follow-child.exp
|
|
|
|
--- gdb-6.6-orig/gdb/testsuite/gdb.base/follow-child.exp 2007-10-13 19:24:58.000000000 +0200
|
|
|
|
+++ gdb-6.6/gdb/testsuite/gdb.base/follow-child.exp 2007-10-13 19:24:21.000000000 +0200
|
|
|
|
@@ -0,0 +1,55 @@
|
|
|
|
+# Copyright 2007 Free Software Foundation, Inc.
|
|
|
|
+
|
|
|
|
+# This program is free software; you can redistribute it and/or modify
|
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
|
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+# (at your option) any later version.
|
|
|
|
+#
|
|
|
|
+# This program 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 General Public License for more details.
|
|
|
|
+#
|
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
|
+# along with this program; if not, write to the Free Software
|
|
|
|
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
+
|
|
|
|
+if $tracelevel then {
|
|
|
|
+ strace $tracelevel
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+set prms_id 0
|
|
|
|
+set bug_id 0
|
|
|
|
+
|
|
|
|
+set testfile follow-child
|
|
|
|
+set srcfile ${testfile}.c
|
|
|
|
+set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
|
|
|
+ untested "Couldn't compile test program"
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# Get things started.
|
|
|
|
+
|
|
|
|
+gdb_exit
|
|
|
|
+gdb_start
|
|
|
|
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
+gdb_load ${binfile}
|
|
|
|
+
|
|
|
|
+# For C programs, "start" should stop in main().
|
|
|
|
+
|
|
|
|
+gdb_test "set follow-fork-mode child" ""
|
|
|
|
+set test "started"
|
|
|
|
+# GDB_RUN_CMD already checks for `Starting program:'.
|
|
|
|
+gdb_run_cmd
|
|
|
|
+sleep 5
|
|
|
|
+send_gdb "\003"
|
|
|
|
+set test "break"
|
|
|
|
+gdb_test_multiple "" $test {
|
|
|
|
+ -re "Program received signal SIGINT.*$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "\\\[New process \[0-9\]+\\\]" {
|
|
|
|
+ fail $test
|
|
|
|
+ }
|
|
|
|
+}
|