From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UDg3E312j2dRSRYAWB0awg (envelope-from ) for ; Tue, 21 Jan 2025 05:27:09 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=1yRwbkuV; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iX7wRsbS; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=1yRwbkuV; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iX7wRsbS; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4A6581E100; Tue, 21 Jan 2025 05:27:09 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AE0F71E08E for ; Tue, 21 Jan 2025 05:27:08 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31FEE3857001 for ; Tue, 21 Jan 2025 10:27:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31FEE3857001 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=1yRwbkuV; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iX7wRsbS; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=1yRwbkuV; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iX7wRsbS Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 7602C3857340 for ; Tue, 21 Jan 2025 10:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7602C3857340 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 7602C3857340 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=1737455196; cv=none; b=e+UCHhmxDxr+X+k8mbfaC1WLGHVp0t2AHDXC2AYuG+u6VnAtVaPwTzeM1MTTItiDgjwnKfBlr+72V7hFU+0RwAF13C1iO7XkC6hcuPQu4HnXTxH2RoIiTWHbH8jI4rrLSKK+1i8zEC9713DeUpLTBd7YfliG0twlc6Cbr+Sfn6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737455196; c=relaxed/simple; bh=3JXOM2Xkgw1OHW/D19GiCKoHwVLCK3psNOfwB4lt+zg=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=Y0Kp1Bt14MndFiE6Lblol5zKeVBIy8RtmD7Dzld+yQmIQOPJzxbnlbzfGpvIWYTaeF125N6gtcoCWT+zjqwxJioE3MHo3p+AZuhkE3h4W6GrCvmCIsvJJnlc+D5s1BNcoYuHc7E8OO3x0174VbQOQZtc8VL+b0iW8xpigwfzcXQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7602C3857340 Received: from imap1.dmz-prg2.suse.org (unknown [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 5F22021188 for ; Tue, 21 Jan 2025 10:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737455195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+gFsersmHXcocxtFCNztc/i35pfiO6+gvY6/Wn7v1nM=; b=1yRwbkuV/B5AsaMGaV2hd0T8tSHKReSTQHaXCwsulTI2umPsNGwOXRzwfjwlvxma/j7M49 Pnn40gSmgkgoi8wYDg37SM/PNvtcaEyBGlSoDGAQcl8Gh3gfSCf109ksyPwtL9zH6k4kMJ Y9c5CYm5Ab1kQDdUGG+Br+dgp5snvLY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737455195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+gFsersmHXcocxtFCNztc/i35pfiO6+gvY6/Wn7v1nM=; b=iX7wRsbS/rp/iVbn1P/ZgU1ZMI3ngUJeI1J8MmoMQxZG7kZVx3MrY7qNrgZwN+FAgletGI kUbV+kDwpKBe6mAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737455195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+gFsersmHXcocxtFCNztc/i35pfiO6+gvY6/Wn7v1nM=; b=1yRwbkuV/B5AsaMGaV2hd0T8tSHKReSTQHaXCwsulTI2umPsNGwOXRzwfjwlvxma/j7M49 Pnn40gSmgkgoi8wYDg37SM/PNvtcaEyBGlSoDGAQcl8Gh3gfSCf109ksyPwtL9zH6k4kMJ Y9c5CYm5Ab1kQDdUGG+Br+dgp5snvLY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737455195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+gFsersmHXcocxtFCNztc/i35pfiO6+gvY6/Wn7v1nM=; b=iX7wRsbS/rp/iVbn1P/ZgU1ZMI3ngUJeI1J8MmoMQxZG7kZVx3MrY7qNrgZwN+FAgletGI kUbV+kDwpKBe6mAQ== 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 48C3B13963 for ; Tue, 21 Jan 2025 10:26:35 +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 TfqpD1t2j2fQZAAAD6G6ig (envelope-from ) for ; Tue, 21 Jan 2025 10:26:35 +0000 Message-ID: Date: Tue, 21 Jan 2025 11:26:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/11] [gdb/macros] Handle 64-bit dwarf in gdb.base/fission-macro.exp From: Tom de Vries To: gdb-patches@sourceware.org References: <20240521154415.9543-1-tdevries@suse.de> <20240521154415.9543-2-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20240521154415.9543-2-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 5/21/24 17:44, Tom de Vries wrote: > When enabling 64-bit dwarf in the test-case gdb.base/fission-macro.exp, we run > into: > ... > (gdb) break -qualified main^M > DW_MACRO_define_strx pointing outside of .debug_str.dwo section \ > [in module fission-macro-5-640.dwo]^M > (gdb) FAIL: gdb.base/fission-macro.exp: dwarf_version=5: dwarf_bits=64: \ > gdb_breakpoint: set breakpoint at main > ... > > A dwarf-5 .debug_str_offsets section starts with a header consisting of: > - an initial length (4 bytes for 32-bit and 12 bytes for 64-bit), > - a 2 byte version string, and > - 2 bytes padding > so in total 8 bytes for 32-bit and 16 bytes for 64-bit. > > This offset is calculated here in dwarf_decode_macros: > ... > str_offsets_base = cu->header.addr_size; > ... > and in both cases this evaluates to 8. > > So in the 64-bit case, we interpret the last 8 bytes of the header as an offset. > > Fix this by computing str_offsets_base correctly for dwarf-5, for both the > 32-bit and 64-bit case. > I've combined this patch and "Handle v4 dwarf in gdb.base/fission-macro.exp", in other words 02/11 and 06/11 and resubmitted as https://sourceware.org/pipermail/gdb-patches/2025-January/214901.html . I've also changed the code to use "cu->header.version" instead of "cu->per_cu->version ()". ( See also https://sourceware.org/pipermail/gdb-patches/2025-January/214886.html ). Thanks, - Tom > Tested on x86_64-linux. > > Tested test-case using a current gcc trunk build, and gcc 14. > --- > gdb/dwarf2/read.c | 11 ++++++++++- > gdb/testsuite/gdb.base/fission-macro.exp | 2 +- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index e8416905163..4884553000a 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -21232,7 +21232,16 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, > str_offsets_section = &cu->dwo_unit->dwo_file > ->sections.str_offsets; > str_section = &cu->dwo_unit->dwo_file->sections.str; > - str_offsets_base = cu->header.addr_size; > + if (cu->per_cu->version () <= 4) > + str_offsets_base = cu->header.addr_size; > + else > + { > + bfd *abfd = str_offsets_section->get_bfd_owner (); > + unsigned int bytes_read = 0; > + read_initial_length (abfd, str_offsets_section->buffer, &bytes_read, false); > + const bool is_dwarf64 = bytes_read != 4; > + str_offsets_base = is_dwarf64 ? 16 : 8; > + } > } > else > { > diff --git a/gdb/testsuite/gdb.base/fission-macro.exp b/gdb/testsuite/gdb.base/fission-macro.exp > index 705e3dd0c4b..4eb9c0efe21 100644 > --- a/gdb/testsuite/gdb.base/fission-macro.exp > +++ b/gdb/testsuite/gdb.base/fission-macro.exp > @@ -67,7 +67,7 @@ proc do_tests { dwarf_version dwarf_bits strict_dwarf } { > } > > foreach_with_prefix dwarf_version {5} { > - foreach_with_prefix dwarf_bits {32} { > + foreach_with_prefix dwarf_bits {32 64} { > foreach_with_prefix strict_dwarf {0 1} { > do_tests $dwarf_version $dwarf_bits $strict_dwarf > }