Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: Allow a wrapper when starting programs
Date: Sat, 09 Feb 2008 16:53:00 -0000	[thread overview]
Message-ID: <20080209165328.GA3161@caradoc.them.org> (raw)
In-Reply-To: <uhcgiqe0f.fsf@gnu.org>

On Sat, Feb 09, 2008 at 06:40:48PM +0200, Eli Zaretskii wrote:
> Maybe, but it's better not to create an impression that this is
> supported universally.  To make the burden easier, we could say
> something like "this is supported by only some platforms".
> 
> > Every native (non-remote) target uses fork-child, except for DJGPP,
> > Cygwin, mingw32, and QNX NTO.
> 
> DJGPP is not important enough to care, but Cygwin is, and so are (to a
> lesser extent, I think) MinGW and NTO.

Yeah.  Listing them is probably best.

> > > > +                             The wrapper will run until its first
> > > > +debug trap before @value{GDBN} takes control.
> > > > +
> > > > +On Unix systems, a debug trap (@code{SIGTRAP}) is generated at the
> > > > +@code{execve} system call.  This allows any program which uses
> > > > +@code{execve} to start another program to be used as a wrapper.
> > > 
> > > This is not detailed enough to be useful to anyone but a GDB hacker
> > > who also happened to read the respective portions of the code in
> > > fork-child.c.  In any case, it left me wondering what is this all
> > > about, and why I, as a GDB user, should care about SIGTRAPs.
> > > 
> > > IOW, if this is important for the user to know, we should explain the
> > > issue in terms understandable by a GDB user.
> > 
> > This is where I get stuck.  I did the best I could, but the effect of
> > waiting for an extra trap is hard to describe except in terms of
> > signals or examples.  I don't know what else to add.
> 
> Try me: if you explain why all this is needed, I might find a way to
> describe that in the manual.  For starters, why do we need to wait for
> an extra trap?

Sure.  We're waiting for an extra trap for the same reason we
currently wait for two (on most systems; sometimes varies).  We
normally fork and then execute a command like this one:

  sh -c 'exec your-program'

The first trap is generated when gdb execs sh.  At this point we know
where the child is, but it's at the wrong place.  The loaded binary is
sh, not your-program, so we can't set breakpoints in your-program.

With a wrapper, we run:

  sh -c 'exec wrapper your-program'

So after two traps, the loaded program is wrapper.  If we gave
control to the user or tried to insert breakpoints at your-program's
symbols, things would go wrong.  We have to wait until the loaded
program is finally your-program.

There's no portable way to check what the loaded program is, and
even if there were it wouldn't help enough; wrapper and your-program
might be the same binary (a corner case, I admit).

-- 
Daniel Jacobowitz
CodeSourcery


  reply	other threads:[~2008-02-09 16:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08 18:57 Daniel Jacobowitz
2008-02-09  8:48 ` Eli Zaretskii
2008-02-09 15:48   ` Daniel Jacobowitz
2008-02-09 16:41     ` Eli Zaretskii
2008-02-09 16:53       ` Daniel Jacobowitz [this message]
2008-02-09 19:20         ` Doug Evans
2008-02-10  1:15           ` Daniel Jacobowitz
2008-02-11 16:14         ` Daniel Jacobowitz
2008-02-11 19:45           ` Daniel Jacobowitz
2008-02-11 20:30           ` Eli Zaretskii
2008-03-10 23:14             ` Daniel Jacobowitz
2008-02-12 19:46 ` Joel Brobecker

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=20080209165328.GA3161@caradoc.them.org \
    --to=drow@false.org \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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