summaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-01-19 16:58:16 +0000
committerPedro Alves <palves@redhat.com>2016-01-19 17:46:01 +0000
commit9df40db33e6bf8501ecfe947f89fc568897cd6fc (patch)
treedff81d118c9bf58d4b99f0586f765f989c08129d /gdb/infrun.c
parent1982996d39292574f6d3586dfaaaf829e0782001 (diff)
downloadbinutils-gdb-users/palves/fork-bugs.tar.gz
Fix PR 19461: strange "info thread" behavior in non-stopusers/palves/fork-bugs
If you have "set follow-fork child" set, then if you do "info threads" right after a fork, and before the child reports any other event to GDB core, you'll see: (gdb) info threads Id Target Id Frame * 1.1 Thread 0x7ffff7fc1740 (LWP 31875) "fork-plus-threa" (running) 2.1 process 31879 "fork-plus-threa" Selected thread is running. (gdb) The "Selected thread is running." bit is a bogus error. That was GDB trying to fetch the current frame of thread 2.1, because the external runnning state is "stopped", and then throwing an error because the thread is actually running. This actually affects all-stop + schedule-multiple as well. The problem here is that on a fork event, GDB doesn't update the external parent/child running states. New comprehensive test included. The "kill inferior 1" / "kill inferior 2" bits also trip on PR gdb/19494 (hang killing unfollowed fork children), which was fixed by the previous patch. gdb/ChangeLog: 2016-01-19 Pedro Alves <palves@redhat.com> PR threads/19461 * infrun.c (handle_inferior_event_1) <fork/vfork>: Update parent/child running states. gdb/testsuite/ChangeLog: 2016-01-19 Pedro Alves <palves@redhat.com> PR threads/19461 * gdb.base/fork-running-state.c: New file. * gdb.base/fork-running-state.exp: New file.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 33981d27bb6..15210c9e3e1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5198,6 +5198,17 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
parent = ecs->ptid;
child = ecs->ws.value.related_pid;
+ /* At this point, the parent is marked running, and the
+ child is marked stopped. */
+
+ /* If not resuming the parent, mark it stopped. */
+ if (follow_child && !detach_fork && !non_stop && !sched_multi)
+ set_running (parent, 0);
+
+ /* If resuming the child, mark it running. */
+ if (follow_child || (!detach_fork && (non_stop || sched_multi)))
+ set_running (child, 1);
+
/* In non-stop mode, also resume the other branch. */
if (!detach_fork && (non_stop
|| (sched_multi && target_is_non_stop_p ())))