public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Lacage <mathieu.lacage@gmail.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: impossible to resolve symbols in same binary loaded twice with 	dlmopen
Date: Sun, 25 Jul 2010 12:25:00 -0000	[thread overview]
Message-ID: <AANLkTimZ1TQqbEVrkaFYwp-Hn0RzRFppgXn3CU6yUHd8@mail.gmail.com> (raw)
In-Reply-To: <m31vayaqqb.fsf@fleche.redhat.com>

On Tue, Jul 20, 2010 at 9:38 PM, Tom Tromey <tromey@redhat.com> wrote:

> 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.

http://sourceware.org/bugzilla/show_bug.cgi?id=11839

> 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:

ahhh. Good point. It works nicely for _static_ variables, but not for
global variables (which I never use).

> 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.

(gdb) b main
Breakpoint 1 at 0x400602: file test.c, line 14.
(gdb) r
Starting program: /home/mathieu/code/elf-loader/t
Breakpoint 1, main (argc=1, argv=0x7fffffffe128) at test.c:14
14	  void *a = dlmopen (LM_ID_NEWLM, "./libtest.so", RTLD_LAZY);
(gdb) n
15	  void *b = dlmopen (LM_ID_NEWLM, "./libtest.so", RTLD_LAZY);
(gdb)
17	  call (a, "foo");
(gdb) info sharedlibrary
From                To                  Syms Read   Shared Object Library
0x00007ffff7de8a50  0x00007ffff7df824f  Yes         ./ldso
0x00007ffff7be6ad0  0x00007ffff7be6cef  Yes         ./libvdl.so
0x00000037fa81e860  0x00000037fa9262fc  Yes (*)     /lib64/libc.so.6
0x00007ffff79e52e4  0x00007ffff79e52fa  Yes         ././libtest.so
0x00007ffff77e42e4  0x00007ffff77e42fa  Yes         ././libtest.so
(*): Shared library is missing debugging information.
(gdb) b foo
Breakpoint 2 at 0x7ffff79e52e8: file libtest.c, line 5. (2 locations)
(gdb) c
Continuing.
Breakpoint 2, foo () at libtest.c:5
5	  return 0;
(gdb) p &g_global
$4 = (int *) 0x7ffff7be543c
(gdb) p &g_static
$5 = (int *) 0x7ffff7be5438
(gdb) c
Continuing.
Breakpoint 2, foo () at libtest.c:5
5	  return 0;
(gdb) p &g_global
$6 = (int *) 0x7ffff7be543c
(gdb) p &g_static
$7 = (int *) 0x7ffff79e4438
(gdb)


> 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 :-)

Indeed. Shall I file a bug ? Maybe you can also give me a hint on
where I can fix it ? It might be a nice change from writing the
thesis.

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

I don't have commit rights, and, really, it's better for you if I don't :)

Mathieu
-- 
Mathieu Lacage <mathieu.lacage@gmail.com>

  reply	other threads:[~2010-07-25 12:25 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
2010-07-25 12:25       ` Mathieu Lacage [this message]
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=AANLkTimZ1TQqbEVrkaFYwp-Hn0RzRFppgXn3CU6yUHd8@mail.gmail.com \
    --to=mathieu.lacage@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).