b242c3c237
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'.
40 lines
555 B
C
40 lines
555 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
|
|
#ifdef PROTOTYPES
|
|
void callee (int i)
|
|
#else
|
|
void callee (i)
|
|
int i;
|
|
#endif
|
|
{
|
|
printf("callee: %d\n", i);
|
|
}
|
|
|
|
#ifdef PROTOTYPES
|
|
int main (void)
|
|
#else
|
|
main ()
|
|
#endif
|
|
{
|
|
int pid;
|
|
int v = 5;
|
|
|
|
pid = fork ();
|
|
if (pid == 0) /* set breakpoint here */
|
|
{
|
|
v++;
|
|
/* printf ("I'm the child!\n"); */
|
|
callee (getpid ());
|
|
}
|
|
else
|
|
{
|
|
v--;
|
|
/* printf ("I'm the proud parent of child #%d!\n", pid); */
|
|
callee (getpid ());
|
|
}
|
|
|
|
exit (0); /* at exit */
|
|
}
|