This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 08/08] multi-process support: fix follow-exec part 2


With the previous patches in place, we get a couple of regressions in
the follow exec support.  This patch fixes the regression.

The issue is that generic_mourn_inferior will get rid of the
current inferior, and there is nothing else readding it back, which
results in later failures to find the current inferior all over
the place.

Although this is mostly true:
  "/* We've followed the inferior through an exec.  Therefore, the
     inferior has essentially been killed & reborn. */"

... it isn't 100% true.  It is still the same inferior, but with
a diferent executable image.

The patch fixes the issue by inlining the needed bits from
generic_mourn_inferior in follow_exec, meaning, only the
breakpoint_init_inferior call, thus avoiding removing the
inferior from the inferior list.

While doing that, I added a new inf_context:inf_execd, instead of
reusing inf_exited.  Nothing else needs to be adjusted, as
breakpoint_init_inferior only checks if the context is inf_starting
or not.  I think this makes things clearer and more future proof.

-- 
Pedro Alves
2008-09-12  Pedro Alves  <pedro@codesourcery.com>

	* infrun.c (follow_exec): Don't do a generic mourn.  Instead
	inline the required bits.
	* breakpoint.h (enum inf_context): Add inf_execd.

---
 gdb/breakpoint.h |    3 ++-
 gdb/infrun.c     |    6 ++----
 2 files changed, 4 insertions(+), 5 deletions(-)

Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-09-12 15:53:45.000000000 +0100
+++ src/gdb/infrun.c	2008-09-12 16:10:29.000000000 +0100
@@ -331,7 +331,6 @@ follow_inferior_reset_breakpoints (void)
 static void
 follow_exec (ptid_t pid, char *execd_pathname)
 {
-  ptid_t saved_pid = pid;
   struct target_ops *tgt;
   struct thread_info *th = inferior_thread ();
 
@@ -370,9 +369,8 @@ follow_exec (ptid_t pid, char *execd_pat
      inferior has essentially been killed & reborn. */
 
   gdb_flush (gdb_stdout);
-  generic_mourn_inferior ();
-  /* Because mourn_inferior resets inferior_ptid. */
-  inferior_ptid = saved_pid;
+
+  breakpoint_init_inferior (inf_execd);
 
   if (gdb_sysroot && *gdb_sysroot)
     {
Index: src/gdb/breakpoint.h
===================================================================
--- src.orig/gdb/breakpoint.h	2008-09-12 16:05:23.000000000 +0100
+++ src/gdb/breakpoint.h	2008-09-12 16:05:39.000000000 +0100
@@ -663,7 +663,8 @@ enum inf_context
   {
     inf_starting,
     inf_running,
-    inf_exited
+    inf_exited,
+    inf_execd
   };
 
 /* The possible return values for breakpoint_here_p.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]