* [PATCH2 PR gdb/18071] aarch64: "info addr" command can't resolve TLS variables
@ 2018-03-26 22:20 Weimin Pan
2018-03-27 3:31 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Weimin Pan @ 2018-03-26 22:20 UTC (permalink / raw)
To: gdb-patches
Running the test case with upstream gdb shows two failures:
(1) Receiving different error messages when printing TLS variable before
program runs - because the ARM compiler does not emit dwarf attribute
DW_AT_location for TLS, the result is expected and the baseline may
need to be changed for aarch64.
(2) Using "info address" command on C++ static TLS object resulted in
"symbol unresolved" error - below is a snippet from the test case:
class K {
public:
static __thread int another_thread_local;
};
__thread int K::another_thread_local;
(gdb) info address K::another_thread_local
Symbol "K::another_thread_local" is unresolved.
This patch contains fix for (2).
Function info_address_command() handles the "info address" command and
calls lookup_minimal_symbol_and_objfile() to find sym's symbol entry in
minimal symbol table if SYMBOL_COMPUTED_OPS (sym) is false. Problem is
that function lookup_minimal_symbol_and_objfile() only looked up an
objfile's minsym ordinary hash table, not its demangled hash table, which
was the reason why the C++ name was not found.
The fix is to replace the lookup_minimal_symbol_and_objfile() call with
the lookup_bound_minimal_symbol() call, which looks up entries in both
minsym's hash tables, via lookup_minimal_symbol(), to find symbol entry
that's associated with the demangled name.
Tested in both aarch64-linux-gnu and amd64-linux-gnu. No regressions.
---
gdb/ChangeLog | 8 ++++++++
gdb/printcmd.c | 2 +-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fe4ae9f..5faa37b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2018-03-22 Weimin Pan <weimin.pan@oracle.com>
+
+ PR gdb/18071:
+ * printcmd.c (info_address_command): Replace
+ lookup_minimal_symbol_and_objfile call with
+ lookup_bound_minimal_symbol call to find symbol entry
+ of a demangled name.
+
2018-03-19 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index dd81d8f..06038cd 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1564,7 +1564,7 @@ info_address_command (const char *exp, int from_tty)
{
struct bound_minimal_symbol msym;
- msym = lookup_minimal_symbol_and_objfile (SYMBOL_LINKAGE_NAME (sym));
+ msym = lookup_bound_minimal_symbol (SYMBOL_LINKAGE_NAME (sym));
if (msym.minsym == NULL)
printf_filtered ("unresolved");
else
--
1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH2 PR gdb/18071] aarch64: "info addr" command can't resolve TLS variables
2018-03-26 22:20 [PATCH2 PR gdb/18071] aarch64: "info addr" command can't resolve TLS variables Weimin Pan
@ 2018-03-27 3:31 ` Simon Marchi
2018-03-27 19:56 ` Weimin Pan
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2018-03-27 3:31 UTC (permalink / raw)
To: Weimin Pan; +Cc: gdb-patches
On 2018-03-26 17:54, Weimin Pan wrote:
> Running the test case with upstream gdb shows two failures:
>
> (1) Receiving different error messages when printing TLS variable
> before
> program runs - because the ARM compiler does not emit dwarf
> attribute
> DW_AT_location for TLS, the result is expected and the baseline may
> need to be changed for aarch64.
>
> (2) Using "info address" command on C++ static TLS object resulted in
> "symbol unresolved" error - below is a snippet from the test case:
>
> class K {
> public:
> static __thread int another_thread_local;
> };
>
> __thread int K::another_thread_local;
>
> (gdb) info address K::another_thread_local
> Symbol "K::another_thread_local" is unresolved.
>
> This patch contains fix for (2).
>
> Function info_address_command() handles the "info address" command and
> calls lookup_minimal_symbol_and_objfile() to find sym's symbol entry in
> minimal symbol table if SYMBOL_COMPUTED_OPS (sym) is false. Problem is
> that function lookup_minimal_symbol_and_objfile() only looked up an
> objfile's minsym ordinary hash table, not its demangled hash table,
> which
> was the reason why the C++ name was not found.
>
> The fix is to replace the lookup_minimal_symbol_and_objfile() call with
> the lookup_bound_minimal_symbol() call, which looks up entries in both
> minsym's hash tables, via lookup_minimal_symbol(), to find symbol entry
> that's associated with the demangled name.
Hi Weimin,
I don't know if it was clear, but I pushed this patch already:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bce02d8884d6baa72c537d0d7c59f924cb290799
Removing lookup_minimal_symbol_and_objfile and replacing it with
lookup_bound_minimal_symbol should be done as a separate patch (with a
relevant title that describes the change). Can you do that? There are
just a few callers of lookup_minimal_symbol_and_objfile that will need
to be updated.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH2 PR gdb/18071] aarch64: "info addr" command can't resolve TLS variables
2018-03-27 3:31 ` Simon Marchi
@ 2018-03-27 19:56 ` Weimin Pan
0 siblings, 0 replies; 3+ messages in thread
From: Weimin Pan @ 2018-03-27 19:56 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On 3/26/2018 8:31 PM, Simon Marchi wrote:
> On 2018-03-26 17:54, Weimin Pan wrote:
>> Running the test case with upstream gdb shows two failures:
>>
>> (1) Receiving different error messages when printing TLS variable before
>> Â Â Â program runs - because the ARM compiler does not emit dwarf
>> attribute
>> Â Â Â DW_AT_location for TLS, the result is expected and the baseline may
>> Â Â Â need to be changed for aarch64.
>>
>> (2) Using "info address" command on C++ static TLS object resulted in
>> Â Â Â "symbol unresolved" error - below is a snippet from the test case:
>>
>> class K {
>> Â public:
>> Â static __thread int another_thread_local;
>> };
>>
>> __thread int K::another_thread_local;
>>
>> (gdb) info address K::another_thread_local
>> Symbol "K::another_thread_local" is unresolved.
>>
>> This patch contains fix for (2).
>>
>> Function info_address_command() handles the "info address" command and
>> calls lookup_minimal_symbol_and_objfile() to find sym's symbol entry in
>> minimal symbol table if SYMBOL_COMPUTED_OPS (sym) is false. Problem is
>> that function lookup_minimal_symbol_and_objfile() only looked up an
>> objfile's minsym ordinary hash table, not its demangled hash table,
>> which
>> was the reason why the C++ name was not found.
>>
>> The fix is to replace the lookup_minimal_symbol_and_objfile() call with
>> the lookup_bound_minimal_symbol() call, which looks up entries in both
>> minsym's hash tables, via lookup_minimal_symbol(), to find symbol entry
>> that's associated with the demangled name.
>
> Hi Weimin,
>
> I don't know if it was clear, but I pushed this patch already:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bce02d8884d6baa72c537d0d7c59f924cb290799
>
>
> Removing lookup_minimal_symbol_and_objfile and replacing it with
> lookup_bound_minimal_symbol should be done as a separate patch (with a
> relevant title that describes the change). Can you do that? There
> are just a few callers of lookup_minimal_symbol_and_objfile that will
> need to be updated.
>
Hi Simon,
Yes, I will do another patch get rid of all
lookup_minimal_symbol_and_objfile calls.
Weimin
> Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-27 19:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 22:20 [PATCH2 PR gdb/18071] aarch64: "info addr" command can't resolve TLS variables Weimin Pan
2018-03-27 3:31 ` Simon Marchi
2018-03-27 19:56 ` Weimin Pan
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).