aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-05-17 19:20:33 +0000
committerPedro Alves <palves@redhat.com>2009-05-17 19:20:33 +0000
commitb242c3c2373ba4e31c501571c8b16d26d8fd2067 (patch)
tree701867d15bd9ad5fac9af7ba2d1be395e5717188 /gdb/infrun.c
parent235f2b04aed3c632481f8db71a3ea880ad575098 (diff)
downloadgdb-b242c3c2373ba4e31c501571c8b16d26d8fd2067.zip
gdb-b242c3c2373ba4e31c501571c8b16d26d8fd2067.tar.gz
gdb-b242c3c2373ba4e31c501571c8b16d26d8fd2067.tar.bz2
gdb/
2009-05-17 Pedro Alves <pedro@codesourcery.com> * infrun.c (handle_inferior_event): When handling a TARGET_WAITKIND_FORKED, detach breakpoints from the fork child immediatelly. * linux-nat.c (linux_child_follow_fork): Only detach breakpoint from the child if vforking. * inf-ptrace.c (inf_ptrace_follow_fork): No need to detach breakpoints from the child here. gdb/testsuite/ 2009-05-17 Pedro Alves <pedro@codesourcery.com> * gdb.base/foll-fork.c: Include stdlib.h. Add markers for `gdb_get_line_number'. Call `callee' in both parent and child. * gdb.base/foll-fork.exp (catch_fork_child_follow): Use `gdb_get_line_number' instead of hardcoding line numbers. (catch_fork_unpatch_child): New procedure to test detaching breakpoints from child fork. (tcatch_fork_parent_follow): Use `gdb_get_line_number' instead of hardcoding line numbers. (do_fork_tests): Run `catch_fork_unpatch_child'.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index dbaf02b..99873b1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2418,6 +2418,27 @@ handle_inferior_event (struct execution_control_state *ecs)
reinit_frame_cache ();
}
+ /* Immediately detach breakpoints from the child before there's
+ any chance of letting the user delete breakpoints from the
+ breakpoint lists. If we don't do this early, it's easy to
+ leave left over traps in the child, vis: "break foo; catch
+ fork; c; <fork>; del; c; <child calls foo>". We only follow
+ the fork on the last `continue', and by that time the
+ breakpoint at "foo" is long gone from the breakpoint table.
+ If we vforked, then we don't need to unpatch here, since both
+ parent and child are sharing the same memory pages; we'll
+ need to unpatch at follow/detach time instead to be certain
+ that new breakpoints added between catchpoint hit time and
+ vfork follow are detached. */
+ if (ecs->ws.kind != TARGET_WAITKIND_VFORKED)
+ {
+ int child_pid = ptid_get_pid (ecs->ws.value.related_pid);
+
+ /* This won't actually modify the breakpoint list, but will
+ physically remove the breakpoints from the child. */
+ detach_breakpoints (child_pid);
+ }
+
stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);