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
|
|
|
|
@@ -803,11 +803,23 @@ 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. */
|
|
|
|
+ lp = add_lwp (BUILD_LWP (GET_PID (inferior_ptid),
|
|
|
|
+ GET_PID (inferior_ptid)));
|
|
|
|
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? */
|
|
|
|
|