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 07/08] multi-process support: fix follow-exec part 1


With the previous patches in place, we get a couple of regressions in
the follow exec support.  This patch and the next fix them.

handle_inferior_event was calling into follow_exec with whatever
previous thread was selected previously, instead of the thread
that really got the exec event.

We were already going through a bit of a contortion
to swap inferior_ptid while calling bpstat_stop_status.  Switching
threads before cleans that up.

At this point, this is just a cleanup.  It turns into a bug fix
when you have multi-process with follow-exec support, because in
that case, inferior_ptid could be pointing at the wrong process...

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

	* infrun.c (handle_inferior_event): In the follow exec case,
	context-switch before doing anything else.

---
 gdb/infrun.c |   31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-09-12 15:15:16.000000000 +0100
+++ src/gdb/infrun.c	2008-09-12 15:53:45.000000000 +0100
@@ -2089,32 +2089,23 @@ handle_inferior_event (struct execution_
 	savestring (ecs->ws.value.execd_pathname,
 		    strlen (ecs->ws.value.execd_pathname));
 
-      /* This causes the eventpoints and symbol table to be reset.  Must
-         do this now, before trying to determine whether to stop. */
-      follow_exec (inferior_ptid, pending_follow.execd_pathname);
-      xfree (pending_follow.execd_pathname);
-
-      stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
-
-      {
-	/* The breakpoints module may need to touch the inferior's
-	   memory.  Switch to the (stopped) event ptid
-	   momentarily.  */
-	ptid_t saved_inferior_ptid = inferior_ptid;
-	inferior_ptid = ecs->ptid;
-
-	ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
-
-	ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
-	inferior_ptid = saved_inferior_ptid;
-      }
-
       if (!ptid_equal (ecs->ptid, inferior_ptid))
 	{
 	  context_switch (ecs->ptid);
 	  reinit_frame_cache ();
 	}
 
+      stop_pc = read_pc ();
+
+      /* This causes the eventpoints and symbol table to be reset.
+         Must do this now, before trying to determine whether to
+         stop.  */
+      follow_exec (inferior_ptid, pending_follow.execd_pathname);
+      xfree (pending_follow.execd_pathname);
+
+      ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
+      ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
+
       /* If no catchpoint triggered for this, then keep going.  */
       if (ecs->random_signal)
 	{

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