This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PING][PATCH PR gdb/18071] TLS variables can't be resolved on aarch64-linux-gnu
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Wei-min Pan <weimin dot pan at oracle dot com>
- Cc: "gdb-patches\@sourceware.org" <gdb-patches at sourceware dot org>
- Date: Tue, 16 Jan 2018 17:12:18 +0000
- Subject: Re: [PING][PATCH PR gdb/18071] TLS variables can't be resolved on aarch64-linux-gnu
- Authentication-results: sourceware.org; auth=none
- References: <1509636764-46111-1-git-send-email-weimin.pan@oracle.com> <6eadd01b-098c-ca82-b41a-4303f0f6aa0a@oracle.com>
Wei-min Pan <weimin.pan@oracle.com> writes:
>> Function info_address_command() handles the "info address" command and
>> calls lookup_minimal_symbol_and_objfile() to find sym's symbol entry in
>> mininal 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.
lookup_minimal_symbol_and_objfile is documented as "only checks the
linkage name" in minsyms.h,
/* Find the minimal symbol named NAME, and return both the minsym
struct and its objfile. This only checks the linkage name. */
struct bound_minimal_symbol lookup_minimal_symbol_and_objfile (const char *);
>>
>> The fix is to call lookup_minimal_symbol(), which already looks up entries
>> in both minsym's hash tables, to find names when traversing the object file
>> list in lookup_minimal_symbol_and_objfile().
so, it is incorrect to extend it to search demangled name. If I set a
breakpoint on lookup_minimal_symbol_and_objfile,
(gdb) info address K::another_thread_local
Breakpoint 1, lookup_minimal_symbol_and_objfile (name=0x621000136e40 "K::another_thread_local") at gdb/minsyms.c:1012
1012 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
(gdb) up
#1 0x0000000000af7690 in info_address_command (exp=0x604000023f5d "K::another_thread_local", from_tty=1)
at gdb/printcmd.c:1567
1567 msym = lookup_minimal_symbol_and_objfile (SYMBOL_LINKAGE_NAME (sym));
The problem to me is that why SYMBOL_LINKAGE_NAME (sym) is
"K::another_thread_local", which is a demangled one. The symbol's name
is set in dwarf2read.c:new_symbol_full,
/* Cache this symbol's name and the name's demangled form (if any). */
SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack);
linkagename = dwarf2_physname (name, die, cu);
SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
however, dwarf2_physname doesn't return the linkage name, so the
symbol's linkagename is set incorrectly. I think the right fix would be
call other function to get linkagename, maybe, dw2_linkage_name? I
don't know.
--
Yao (齐尧)