This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Improve handling of fork/exec events in threaded programs
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Sun, 10 Sep 2006 12:20:23 -0400
- Subject: [commit] Improve handling of fork/exec events in threaded programs
handle_inferior_event is mighty complicated...
This PR was caused by missing context switches. One thread would exit.
Then we'd receive a fork event for a different thread, but never get to
context_switch - so inferior_ptid would still point at the previous,
exited thread. This caused all sorts of interesting errors, e.g. when
we tried to find that thread's registers.
Tested on x86_64-pc-linux-gnu, and committed.
--
Daniel Jacobowitz
CodeSourcery
2006-08-30 Daniel Jacobowitz <dan@codesourcery.com>
PR threads/2149
* infrun.c (handle_inferior_event): Context switch after fork
and exec events.
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.214
diff -u -p -r1.214 infrun.c
--- infrun.c 19 Aug 2006 03:19:00 -0000 1.214
+++ infrun.c 30 Aug 2006 18:13:51 -0000
@@ -1411,6 +1411,12 @@ handle_inferior_event (struct execution_
pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid);
pending_follow.fork_event.child_pid = ecs->ws.value.related_pid;
+ if (!ptid_equal (ecs->ptid, inferior_ptid))
+ {
+ context_switch (ecs);
+ flush_cached_frames ();
+ }
+
stop_pc = read_pc ();
stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid, 0);
@@ -1469,6 +1475,12 @@ handle_inferior_event (struct execution_
ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
inferior_ptid = ecs->saved_inferior_ptid;
+ if (!ptid_equal (ecs->ptid, inferior_ptid))
+ {
+ context_switch (ecs);
+ flush_cached_frames ();
+ }
+
/* If no catchpoint triggered for this, then keep going. */
if (ecs->random_signal)
{