public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Mathieu Lacage <mathieu.lacage@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: impossible to resolve symbols in same binary loaded twice with 	dlmopen
Date: Tue, 20 Jul 2010 19:38:00 -0000	[thread overview]
Message-ID: <m31vayaqqb.fsf@fleche.redhat.com> (raw)
In-Reply-To: <AANLkTikX8KmJl6_gcsIEWfuJ5m3NS0LHvEZPVuS2iAJ4@mail.gmail.com>	(Mathieu Lacage's message of "Fri, 9 Jul 2010 13:36:47 +0200")

>>>>> "Mathieu" == Mathieu Lacage <mathieu.lacage@gmail.com> writes:

Tom> into it too much since I wasn't aware of anybody really using dlmopen.
Tom> If gdb cannot do this, please file a bug report.

Mathieu> I do not believe that gdb can do this and I could file a bug but it's
Mathieu> probably going to be hard to fix (beyond my own abilities).

Yeah, that is ok -- please file it anyway.

Tom> Once you have this patch, does it really work?  It seems like it would
Tom> work ok for some things, like backtraces, but not other things.  E.g.,
Tom> does symbol lookup work properly in the dlmopen case?  I would imagine
Tom> that it does or does not depending on the ordering of objfiles in gdb's
Tom> internal list.

Mathieu> If you use the libc loader and run the test program I attached to the
Mathieu> bug report, you will see that it's indeed impossible to put a
Mathieu> breakpoint or print the address of a function located in a binary
Mathieu> loaded with dlmopen [...]

Actually I am curious about failures even with your loader.

Can you set breakpoints on all instances of a function?  Does printing a
global variable defined in a dlmopen()d .so always work properly?  I
would guess that you could construct a case where it does not, something
like:

File x.c defines a function, file y.c defines a global.  Compile into a
shared library.  Have the main program dlmopen the library twice and
call the function in each one.  Then, step into each instance of the
function and print the address of the global.

The reason I think this will fail is that I am not sure that gdb will do
the symbol search properly.  I suspect it will always find the first
instance of the global, not the one in the current objfile.

Maybe I'm wrong about this, though :-)

Anyway, AFAICT, your patch won't break anything, and it is a step in the
right direction.  So, please check it in.

Tom

  parent reply	other threads:[~2010-07-20 19:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-07 18:49 Mathieu Lacage
2010-07-08 20:32 ` Tom Tromey
2010-07-09 11:37   ` Mathieu Lacage
2010-07-09 11:42     ` Mathieu Lacage
2010-07-20 19:38     ` Tom Tromey [this message]
2010-07-25 12:25       ` Mathieu Lacage
2011-01-20 14:51         ` Mathieu Lacage
2011-01-26 10:52           ` Thiago Jung Bauermann
2011-01-28 11:10             ` Tom Tromey
2011-01-29 10:32               ` Thiago Jung Bauermann
2011-01-31 17:50                 ` Tom Tromey
2010-07-08 15:59 Mathieu Lacage

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=m31vayaqqb.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mathieu.lacage@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).