This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fork debugging : back to parent.


Daniel Jacobowitz <drow@false.org> writes:

> On Mon, Aug 07, 2006 at 11:47:03PM +0200, Richard wrote:
>> set follow-fork-mode to both is not supported:
>
> Sorry, try turning off detach-on-fork.  See "help set".
>
>> Sorry, if I'm missing something obvious. How owuld I browse "recent
>> features" in CVS?
>
> Take a look at the NEWS file.
>
> -- 
> Daniel Jacobowitz
> CodeSourcery
>

I think I answered my own question:

By setting follow to parent and detach to off, one can use info fork in
the parent thread in order to switch to the child thread.

If follow is set to child and detach is off, then there is no fork info
in the child for some reason so you cant switch back to the parent. Is
this a bug?

(1) follow parent and then switch to the child fork - we end up at our
childs breakpoint "pit_t par=" etc...
,----
| >set follow parent
| >set detach off
| >c
| Continuing.
| % date
| Breakpoint 3, main () at forkcmd.c:31
| 31                      if ((pid = waitpid(pid, &status, 0)) < 0)
| >info fork
|   1 process 11319 at 0xffffe410, <__kernel_vsyscall>
| * 0 process 11308 (main process) at 0x80487e6, file forkcmd.c, line 31
| >fork 1
| Reading in symbols for ../sysdeps/i386/elf/start.S...done.
| Switching to process 11319
| #0  __kernel_vsyscall ()
| >c
| Continuing.
| 
| Breakpoint 2, main () at forkcmd.c:23
| 23               pid_t par = getppid();
| >
`----

(2) try to follow child to a break and switch back to parent fork : not possible.

,----
| >set follow child
| >run
| The program being debugged has been started already.
| Start it from the beginning? (y or n) y
| Starting program: etc
| Reading symbols from system-supplied DSO at 0xffffe000...done.
| Reading symbols from /lib/tls/i686/cmov/libc.so.6...done.
| Reading symbols from /lib/ld-linux.so.2...done.
| 
| Breakpoint 1, main () at forkcmd.c:11
| 11              printf("%% ");  /* print prompt (printf requires %% to print %) */
| >c
| Continuing.
| % date
| [New process 11385]
| 
| Program received signal SIGINT, Interrupt.
| __kernel_vsyscall ()
| >c
| Continuing.
| c
| 
| Program received signal SIGINT, Interrupt.
| __kernel_vsyscall ()
| >info fork
| * 2 process 11385 at 0xffffe410, <__kernel_vsyscall>
`----

Am I misunderstandong something? Thanks for any help.




-- 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]