From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 144AE3858D33 for ; Fri, 29 Nov 2024 16:08:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 144AE3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 144AE3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732896516; cv=none; b=D3C/X4roX411kdVn+rbBvkYVzimHlVmW5jhhpocn/WQ8Ag/56oqy5VE/kPXnqje5NXO/YlxMyssZ1FiXmShHxNgU5q6fLOOyQgcSWZ2w08XWMvw0MQs/CWl9nxzxJxfvEPj2OB1tZLljow1KHrYn0DSKPbIQqUhhk5Ax/F+m/nc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732896516; c=relaxed/simple; bh=F4xmjtJMpFgDgHO9CLeB6kanTh6cR3JSm7U55aLpbTQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=kxuNKnOsG0Mr+etj1pv62dDX7t28etRSabKImGDghtLOYolrglrpzHDWcSydQRj/8R+gVUkp/IyhfWH+sTA/nxwR7WSQS4GAI4D2xnqIGyQBiIOmZiSmapCPa3MtFRNdXJ1vAB9dgmrmTJcegzNYHQS887OvgNFJO04MasQc/gA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 144AE3858D33 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=F8ZsnOGZ; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RFHBuBRD; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oUUeVUHb; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=N6A729kL Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1296721183 for ; Fri, 29 Nov 2024 16:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732896515; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ea9Se9Vv7lOK1lm1TUh8/01u+2Ey8XtfijW5m7e+9iA=; b=F8ZsnOGZhUmHlgK6PSHp2Mf8fhN2Ct1ZhONzoh+M2UBgdx0QF8Jmpdf2gVtd+TY6XYx2g0 dEV+bIppeIIetIJKwu9YT2NW3B3QukdceSCKvRGx03Yco/yIdVohgz/C0MjpsZ/+eUrpEe vhCt3Qu6Jpo+RtYMMderhXMHop3SRz8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732896515; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ea9Se9Vv7lOK1lm1TUh8/01u+2Ey8XtfijW5m7e+9iA=; b=RFHBuBRDwGmHVzqWFqB+hEwizuwsotrf34nfD3zWa96ZE6pgqcb4Y2jjlpY8NDit3SwmRJ VsVqOlxK4JM82tBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=oUUeVUHb; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=N6A729kL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732896514; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ea9Se9Vv7lOK1lm1TUh8/01u+2Ey8XtfijW5m7e+9iA=; b=oUUeVUHbZatTaRGhLrE4vgs+gIEYZ27CWYV1KYaNyQWY/kEyOzghs9HiSNQkBNf2yUTEqT 8num/sczSq5lN13dLrYzU1S1g6QfcXmVVdLQj29A2x0METC+8NYtolVHC2HLIcN+EEc4Md ST6VyPGOacAGcDI/WQI7Sj2+WubNo6o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732896514; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ea9Se9Vv7lOK1lm1TUh8/01u+2Ey8XtfijW5m7e+9iA=; b=N6A729kLdi+POlbq08j6jJrM11PTpAVz4IEDYS8eqFKI10TerXIxdPipiy/8p8DSTRrowW cIkmICumPNY+g2BQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ECF2713A7D for ; Fri, 29 Nov 2024 16:08:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WLuzOAHnSWcYVAAAD6G6ig (envelope-from ) for ; Fri, 29 Nov 2024 16:08:33 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/2] [gdb/symtab] Apply workaround for PR gas/31115 a bit more Date: Fri, 29 Nov 2024 17:09:38 +0100 Message-Id: <20241129160939.24045-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241129160939.24045-1-tdevries@suse.de> References: <20241129160939.24045-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1296721183 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: In commit 8a61ee551ce ("[gdb/symtab] Workaround PR gas/31115"), I applied a workaround for PR gas/31115 in read_func_scope, fixing test-case gdb.arch/pr25124.exp. Recently I noticed that the test-case is failing again. Fix this by factoring out the workaround into a new function fixup_low_high_pc and applying it in dwarf2_die_base_address. While we're at it, do the same in dwarf2_record_block_ranges. Tested on arm-linux with target boards unix/-marm and unix/-mthumb. --- gdb/dwarf2/read.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5a284be1f90..2890799b761 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9989,6 +9989,30 @@ check_ada_pragma_import (struct die_info *die, struct dwarf2_cu *cu) return true; } +/* Apply fixups to LOW_PC and HIGH_PC due to an incorrect DIE in CU. */ + +static void +fixup_low_high_pc (struct dwarf2_cu *cu, struct die_info *die, CORE_ADDR *low_pc, + CORE_ADDR *high_pc) +{ + if (die->tag != DW_TAG_subprogram) + return; + + dwarf2_per_objfile *per_objfile = cu->per_objfile; + struct objfile *objfile = per_objfile->objfile; + struct gdbarch *gdbarch = objfile->arch (); + + if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm + && producer_is_gas_ge_2_39 (cu)) + { + /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low_pc + attribute with the thumb bit set (PR gas/31115). Work around this. */ + *low_pc = gdbarch_addr_bits_remove (gdbarch, *low_pc); + if (high_pc != nullptr) + *high_pc = gdbarch_addr_bits_remove (gdbarch, *high_pc); + } +} + static void read_func_scope (struct die_info *die, struct dwarf2_cu *cu) { @@ -10068,15 +10092,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) lowpc = per_objfile->relocate (unrel_low); highpc = per_objfile->relocate (unrel_high); - - if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm - && producer_is_gas_ge_2_39 (cu)) - { - /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low_pc - attribute with the thumb bit set (PR gas/31115). Work around this. */ - lowpc = gdbarch_addr_bits_remove (gdbarch, lowpc); - highpc = gdbarch_addr_bits_remove (gdbarch, highpc); - } + fixup_low_high_pc (cu, die, &lowpc, &highpc); /* If we have any template arguments, then we must allocate a different sort of symbol. */ @@ -11336,7 +11352,11 @@ dwarf2_die_base_address (struct die_info *die, struct block *block, struct attribute *attr = dwarf2_attr (die, DW_AT_low_pc, cu); if (attr != nullptr) - return per_objfile->relocate (attr->as_address ()); + { + CORE_ADDR res = per_objfile->relocate (attr->as_address ()); + fixup_low_high_pc (cu, die, &res, nullptr); + return res; + } else if (block->ranges ().size () > 0) return block->ranges ()[0].start (); @@ -11443,6 +11463,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, CORE_ADDR low = per_objfile->relocate (unrel_low); CORE_ADDR high = per_objfile->relocate (unrel_high); + fixup_low_high_pc (cu, die, &low, &high); cu->get_builder ()->record_block_range (block, low, high - 1); } } -- 2.35.3