Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFC] solib-svr4.c: Never attempt to place breakpoints on _start, __start, or main
Date: Sat, 18 Sep 2010 14:13:00 -0000	[thread overview]
Message-ID: <20100917164015.69011490@mesquite.lan> (raw)
In-Reply-To: <201009170810.o8H8AITW028258@glazunov.sibelius.xs4all.nl>

On Fri, 17 Sep 2010 10:10:18 +0200 (CEST)
Mark Kettenis <mark.kettenis@xs4all.nl> wrote:

> > Comments?  (I.e. does anyone know of a platform or a situation where
> > the code that I'm deleting is still needed?)
> 
> Sorry, but I think that code is still useful.  Over the years I've
> seen various cases where setting the breakpoint in the proper place
> failed: the magic ld.so breakpoint function was renamed, somebody
> stripped ld.so, GDB misinterpreted the debug information in ld.so.
> The code you're removing makes sure (or at least attempts too make
> sure) that you have a valid list of shared libraries as soon as you
> hit main().

Okay.

> Obviously it is pointless to keep removing and reinserting these
> breakpoints.  Perhaps they should be disabled as soon as one of them
> has been hit?

That sounds like a good idea.  It's not sufficient though for
debugging scenarios in which one attaches to a program that's
already gone past start or main.  Perhaps we should skip the
attempt to place a breakpoint on _start, __start, and main
when attaching?

> Also, I think it is pointless to insert these if the program you're
> debugging isn't using the dynamic linker.  I'm a little bit suprised
> that the solib-svr4.c code is used at all when debugging the Linux
> kernel.  Does the same thing happen for static binaries?

Yes, the same thing happens for static binaries.  Here's
"maint info breakpoints" when run on a static hello world program:

(gdb) maint info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004003f8 in main at hello.c:6 inf 1
        breakpoint already hit 1 time
-2      shlib events   keep y   0x000000000043a200 <_dl_debug_state> inf 1
-4      exception master keep n   0x0000000000469960 <_Unwind_DebugHook> inf 1

We don't have a breakpoint on _start, __start, or main, but that's
because _dl_debug_state was found first.  (The code searches for that
symbol and others like it first...)

If I edit the binary and change _dl_debug_state to _dl_rebug_state, I
can get a breakpoint set on _start:

(gdb) maint info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004003f8 in main at hello.c:6 inf 1
        breakpoint already hit 1 time
-2      shlib events   keep y   0x00000000004002e0 <_start> inf 1
        breakpoint already hit 1 time
-4      exception master keep n   0x0000000000469960 <_Unwind_DebugHook> inf 1

Kevin


  reply	other threads:[~2010-09-17 23:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-17  2:13 Kevin Buettner
2010-09-17  8:10 ` Daniel Jacobowitz
2010-09-17 12:29 ` Mark Kettenis
2010-09-18 14:13   ` Kevin Buettner [this message]
2010-09-18 16:03     ` Mark Kettenis

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=20100917164015.69011490@mesquite.lan \
    --to=kevinb@redhat.com \
    --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