From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54802 invoked by alias); 6 Mar 2018 01:21:18 -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 54788 invoked by uid 89); 6 Mar 2018 01:21:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,SPF_PASS,T_FILL_THIS_FORM_SHORT,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Receiving, H*u:6.1, H*UA:6.1 X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Mar 2018 01:21:16 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w261LCEt110887 for ; Tue, 6 Mar 2018 01:21:14 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2ghe5xgk3h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Mar 2018 01:21:13 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w261JjA7014176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 6 Mar 2018 01:19:46 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w261Jj23020880 for ; Tue, 6 Mar 2018 01:19:45 GMT Received: from [10.132.97.56] (/10.132.97.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 17:19:45 -0800 Subject: Re: [PING 5][PATCH PR gdb/18071] TLS variables can't be resolved on aarch64-linux-gnu From: Weimin Pan To: "gdb-patches@sourceware.org" References: <1509636764-46111-1-git-send-email-weimin.pan@oracle.com> <515b875f-8240-b7e0-f5cc-4a26efb64b89@oracle.com> <64a638db-13e1-e692-f775-9afc19677a2a@oracle.com> <2fb1c016-778c-516b-56bd-b658e942bd6b@oracle.com> Message-ID: Date: Tue, 06 Mar 2018 01:21:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <2fb1c016-778c-516b-56bd-b658e942bd6b@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060014 X-SW-Source: 2018-03/txt/msg00128.txt.bz2 On 2/5/2018 5:21 PM, Weimin Pan wrote: > On 1/23/2018 5:11 PM, Weimin Pan wrote: >> While this problem shows up in aarch64, the fix is actually >> in gdb core. Pedro, would you please review the patch when >> you get a chance? >> >> Thanks. >> >> On 1/11/2018 4:32 PM, Wei-min Pan wrote: >>> >>> On 11/15/2017 5:51 PM, Wei-min Pan wrote: >>>> >>>> On 11/2/2017 8:32 AM, 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 >>>>> 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)); >>>> >>> >> >