From: "Metzger, Markus T via Gdb-patches" <gdb-patches@sourceware.org>
To: Pedro Alves <pedro@palves.net>, Tom Tromey <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v4] gdb, gdbserver: support dlmopen()
Date: Fri, 8 Apr 2022 12:40:34 +0000 [thread overview]
Message-ID: <DM8PR11MB574981C13AA9F4AE8FE4AE31DEE99@DM8PR11MB5749.namprd11.prod.outlook.com> (raw)
In-Reply-To: <DM8PR11MB57491140E600CFA2FB7C7837DE1E9@DM8PR11MB5749.namprd11.prod.outlook.com>
Hello,
>I extended my test case by adding a dependent DSO that gets loaded
>automatically when I dlmopen() the test DSO. When breaking inside the test
>DSO, I change a variable inside the dependent DSO from GDB. This should
>affect the current namespace but not others. And, since the variable is not
>located in the current DSO, GDB would need to traverse that namespace
>to find the correct instance.
>
>This appears to be working [1] as long as I stay on the ELF symbol level.
>GDB has separate objfile and separate so_list objects for each instance
>of a DSO inside a separate namespace.
>
>When I compile the test with clang, however, which does not add a declaration
>for the variable inside the test DSO, GDB reads the DWARF of the dependent
>DSO, which contains the variable. It does that several times for different
>instances.
>When looking up the name, GDB uses different objfile objects and finds different
>symbol objects, yet it ends up accessing the same target virtual address.
I eventually found the root cause of this. When looking up the symbol, GDB
finds the correct symbol in the correct objfile in the correct linker namespace.
Instead of taking the value directly from the symbol, though, get_symbol_address()
iterates over all objfiles again and looks for a matching minimal symbol. This time,
however, it does not use iterate_over_objfiles_in_search_order() so it does not
take linker namespaces into account and it may hence find a different instance
of that symbol in a different objfile in a different linker namespace.
This was introduced in
4b610737f02 Handle copy relocations
The commit message says that this is to handle copies inside the main program.
Wouldn't it suffice to look inside the main objfile in that case, rather than inside
each objfile? This would also be a lot faster.
Alternatively, it would need to use iterate_over_objfiles_in_search_order(). That
would be still slow, however, assuming we don't run into issues with recursive calls.
Could copy relocations be handled when processing a shared library's symbols so
get_symbol_address() and get_msymbol_address() can just return the address
stored inside the respective symbol object?
I counted 123 other places that iterate over objfiles in a flat list. I hope they don't
try to lookup symbols...
Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2022-04-08 12:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 14:28 Markus Metzger via Gdb-patches
2022-01-21 11:42 ` Metzger, Markus T via Gdb-patches
2022-03-01 19:10 ` Tom Tromey
2022-03-09 12:23 ` Metzger, Markus T via Gdb-patches
2022-03-03 18:32 ` Pedro Alves
2022-03-09 12:24 ` Metzger, Markus T via Gdb-patches
2022-03-09 14:15 ` Pedro Alves
2022-03-29 16:13 ` Metzger, Markus T via Gdb-patches
2022-04-08 12:40 ` Metzger, Markus T via Gdb-patches [this message]
2022-05-25 17:12 ` Kevin Buettner via Gdb-patches
2022-05-31 9:29 ` Metzger, Markus T via Gdb-patches
2022-05-31 18:44 ` Ben Woodard via Gdb-patches
2022-05-24 18:40 Ben Woodard via Gdb-patches
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=DM8PR11MB574981C13AA9F4AE8FE4AE31DEE99@DM8PR11MB5749.namprd11.prod.outlook.com \
--to=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=pedro@palves.net \
--cc=tom@tromey.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