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'.
This commit is contained in:
Pedro Alves
2009-05-17 19:20:33 +00:00
parent 235f2b04ae
commit b242c3c237
7 changed files with 126 additions and 18 deletions

View File

@@ -593,11 +593,15 @@ linux_child_follow_fork (struct target_ops *ops, int follow_child)
/* We're already attached to the parent, by default. */
/* Before detaching from the child, remove all breakpoints from
it. (This won't actually modify the breakpoint list, but will
physically remove the breakpoints from the child.) */
/* If we vforked this will remove the breakpoints from the parent
also, but they'll be reinserted below. */
detach_breakpoints (child_pid);
it. If we forked, then this has already been taken care of
by infrun.c. If we vforked however, any breakpoint inserted
in the parent is visible in the child, even those added while
stopped in a vfork catchpoint. This won't actually modify
the breakpoint list, but will physically remove the
breakpoints from the child. This will remove the breakpoints
from the parent also, but they'll be reinserted below. */
if (has_vforked)
detach_breakpoints (child_pid);
/* Detach new forked process? */
if (detach_fork)
@@ -701,10 +705,6 @@ linux_child_follow_fork (struct target_ops *ops, int follow_child)
breakpoint. */
last_tp->step_resume_breakpoint = NULL;
/* Needed to keep the breakpoint lists in sync. */
if (! has_vforked)
detach_breakpoints (child_pid);
/* Before detaching from the parent, remove all breakpoints from it. */
remove_breakpoints ();