Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Frank Schaefer <frank.schafer@setuza.cz>
To: gdb@sources.redhat.com
Subject: Re: Problems debugging forked processes
Date: Sun, 21 Apr 2002 22:47:00 -0000	[thread overview]
Message-ID: <1019454426.310.1.camel@ADMIN> (raw)
In-Reply-To: <20020419121038.A24030@nevyn.them.org>

On Fri, 2002-04-19 at 18:10, Daniel Jacobowitz wrote:
> On Fri, Apr 19, 2002 at 09:45:49AM +0200, Frank Schaefer wrote:
> > Hi there,
> > 
> > I've written a network daemon and client. The daemon forks to serve a
> > client request.
> > Everything runs fine outside of the debugger, but I want to trace the
> > code at least once, before I release it.
> > 
> > Here goes my problem:
> > # gdb daemon
> > GNU gdb 5.0
> > Copyright 2000 Free Software Foundation, Inc.
> > GDB is free software, covered by the GNU General Public License, and you
> > are
> > welcome to change it and/or distribute copies of it under certain
> > conditions.
> > Type "show copying" to see the conditions.
> > There is absolutely no warranty for GDB.  Type "show warranty" for
> > details.
> > This GDB was configured as "i686-pc-linux-gnu"...
> > (gdb) b 13
> > Breakpoint 1 at 0x8048899: file daemon.c, line 13.
> > (gdb) show follow-fork-mode
> > Debugger response to a program call of fork or vfork is "parent".
> > (gdb) set follow-fork-mode child
> > (gdb) show follow-fork-mode
> > Debugger response to a program call of fork or vfork is "child".
> 
> This variable doesn't actually affect GNU/Linux.  Yeah, I know, I know. 
> We need a documentation patch to address this; please file a PR
> (http://sources.redhat.com/gdb/, Bugs).
> 
> > If I use the attach method from a second instance of gdb ( there's the
> > sleep() above for ), the child process exits on exceptions ( mostly
> > segmentation fault and sometimes invalid operation ) on different
> > (random???) lines in the code. This happens everytime in the fixup()
> > from ld.linux.so.
> 
> Because the breakpoints which were inserted when the application forked
> turn into traps.  There's no clear solution to this without actually
> implementing fork-following - which should not be hard, but no one has
> stepped up to do it.

O.K.,

I had a look at sources.redhat.com.
Maybe I'll have a look at the GDB-code too. Just now I don't have the
time. The fork related stuff should be in inftarg.c, fork-child.c and
infptrace.c for GNU/Linux right?

For now I use this workaround.

RetVal = fork();
if( RetVal ) printf( "%d\n", RetVal ); else sleep( 10 );
... further code

I start the daemon outside of gdb, and attach the child to a gdb session
after the PID is printed, having the first breakpoint somewhere in the
"further code". That's not very nice but at least it works for me.

Regards and thanks for the hints
Frank


      parent reply	other threads:[~2002-04-22  5:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-19  0:45 Frank Schaefer
2002-04-19  9:10 ` Daniel Jacobowitz
2002-04-20 22:14   ` Eli Zaretskii
2002-04-20 22:18     ` Andrew Cagney
2002-04-20 22:21     ` Daniel Jacobowitz
2002-04-21 22:47   ` Frank Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1019454426.310.1.camel@ADMIN \
    --to=frank.schafer@setuza.cz \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox