From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Ax5+Gg2PUWFxOwAAWB0awg (envelope-from ) for ; Mon, 27 Sep 2021 05:29:49 -0400 Received: by simark.ca (Postfix, from userid 112) id 5B9121EE25; Mon, 27 Sep 2021 05:29:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F31441EDDB for ; Mon, 27 Sep 2021 05:29:47 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1322F385840F for ; Mon, 27 Sep 2021 09:29:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1322F385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632734987; bh=lfR3i58NsKjuaakLAg4z7XvLfcRUL+XfEhFtARZPkZs=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cwLz0HWdVuWJuWxXnBxibKUGSJ4y4W3SevM8ILplhI3aaSWn5noITm3dL7kvqvwkL T2XjuForKnwp392qcOahtd670wqtFivvTCpPGieshb32K0bM8CvWkGpQ+mbyMIILRy KFEOzX/g144fT8ncfdacDDQyu0fjRma1ke13M724= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id D5B843858C27 for ; Mon, 27 Sep 2021 09:29:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5B843858C27 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 16060200BF; Mon, 27 Sep 2021 09:29:28 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D1A4313A5C; Mon, 27 Sep 2021 09:29:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wwdXMPeOUWGdcgAAMHmgww (envelope-from ); Mon, 27 Sep 2021 09:29:27 +0000 Subject: Re: [PATCH][gdb/build] Fix build with g++-4.8 To: Simon Marchi , gdb-patches@sourceware.org References: <20210926091521.GA31054@delia> <4c635f63-2e4d-559e-0d8d-85e77524201e@polymtl.ca> Message-ID: <95dadb7a-10fe-9373-a076-26cef9c48777@suse.de> Date: Mon, 27 Sep 2021 11:29:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <4c635f63-2e4d-559e-0d8d-85e77524201e@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 9/26/21 9:33 PM, Simon Marchi wrote: >> [ I considered just removing the initialization, with the idea that access >> should be guarded by has_pc_info, but I ran into one failure in the testsuite, >> for gdb.base/check-psymtab.exp due to add_partial_symbol using lowpc without >> checking has_pc_info. ] > > Does that mean you've found a bug in add_partial_symbol? Good question, I'm not sure. Basically, we're processing this DIE: ... <1><134>: Abbrev Number: 5 (DW_TAG_subprogram) <135> DW_AT_name : foo <139> DW_AT_decl_file : 1 <13a> DW_AT_decl_line : 19 <13b> DW_AT_prototyped : 1 <13b> DW_AT_type : <0x12d> <13f> DW_AT_inline : 3 (declared as inline and inlined) ... which indeed does not have low_pc/high_pc or ranges, so has_pc_info remains false, and lowpc remains set to the initialization value of 0, end we end up with foo at addresss 0: ... (gdb) maint print psymbols^M ... Global partial symbols:^M `main', function, 0x4004a7^M Static partial symbols:^M `int', type, 0x0^M `foo', function, 0x0^M ... There actually is an entry: ... <2><115>: Abbrev Number: 3 (DW_TAG_inlined_subroutine) <116> DW_AT_abstract_origin: <0x134> <11a> DW_AT_low_pc : 0x4004ab <122> DW_AT_high_pc : 0x5 <12a> DW_AT_call_file : 1 <12b> DW_AT_call_line : 27 ... with low_pc/high_pc, but that one is ignored because of being a child of DW_TAG_subprogram main rather than a top-level DIE. So, does foo having address 0 cause problems? I suspect not. It's inlined into main, so the address range is covered there. Then, is it a bug to access pdi->low_pc without has_pc_info == true? If so, it's fixed by doing: ... case DW_TAG_subprogram: - addr = ... pdi->lowpc ... ; + if (pdi->has_pc_info) + addr = ... pdi->lowpc ... ; ... with as only effect that the initialization could be removed. I think addressing this in a more consistent way is to add accessor functions that can assert when used incorrectly, and perhaps adding an enum { none, high_low, high_low_non_contiguous, range_offset } to more precisely encode what kind of information we have. Thanks, - Tom