From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101267 invoked by alias); 3 Nov 2017 00:54:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 100693 invoked by uid 89); 3 Nov 2017 00:54:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,RP_MATCHES_RCVD,SPF_PASS,T_FILL_THIS_FORM_SHORT,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=pan, Pan, Receiving X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 00:54:19 +0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA30sHlM026399 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 3 Nov 2017 00:54:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA30sHHg018417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 3 Nov 2017 00:54:17 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vA30sHTh019887 for ; Fri, 3 Nov 2017 00:54:17 GMT Received: from wmpan.us.oracle.com (/10.147.27.127) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Nov 2017 17:54:17 -0700 From: Weimin Pan To: gdb-patches@sourceware.org Subject: [PATCH PR gdb/18071] TLS variables can't be resolved on aarch64-linux-gnu Date: Fri, 03 Nov 2017 00:54:00 -0000 Message-Id: <1509669516-47946-1-git-send-email-weimin.pan@oracle.com> X-SW-Source: 2017-11/txt/msg00055.txt.bz2 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 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. 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(). Tested in both aarch64-linux-gnu and amd64-linux-gnu. No regressions. --- gdb/ChangeLog | 5 +++++ gdb/minsyms.c | 17 +++-------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4b292e0..2f630bc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-11-01 Weimin Pan + + * minsyms.c (lookup_minimal_symbol_and_objfile): Use + lookup_minimal_symbol() to find symbol entry. + 2017-10-27 Keith Seitz * breakpoint.c (print_breakpoint_location): Use the symbol saved diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 37edbd8..4edd8b1 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -881,23 +881,12 @@ lookup_minimal_symbol_and_objfile (const char *name) { struct bound_minimal_symbol result; struct objfile *objfile; - unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; ALL_OBJFILES (objfile) { - struct minimal_symbol *msym; - - for (msym = objfile->per_bfd->msymbol_hash[hash]; - msym != NULL; - msym = msym->hash_next) - { - if (strcmp (MSYMBOL_LINKAGE_NAME (msym), name) == 0) - { - result.minsym = msym; - result.objfile = objfile; - return result; - } - } + result = lookup_minimal_symbol (name, NULL, objfile); + if (result.minsym != NULL) + return result; } memset (&result, 0, sizeof (result)); -- 1.7.1