From patchwork Tue Jan 21 10:18:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 105179 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 805283857000 for ; Tue, 21 Jan 2025 10:19:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 805283857000 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=KenVKO9T; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Lxn2IS/+; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=KenVKO9T; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Lxn2IS/+ X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id CAAFF3857340 for ; Tue, 21 Jan 2025 10:18:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAAFF3857340 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 CAAFF3857340 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737454719; cv=none; b=tmhnsyWFzUbJXPKGbdk+o8/F+Q++f9jL6+2cTzu7UDo5n7sJqSNp13ESyMWU7uuDUsRkoY7OJWrBYBRNeEzHIOlMNUihw9/TdlO3F/tz1kPO25/T6Ee2+a0Fa2dxl1wZr0ihoO0AYI+ZRwgZ0B3NxJz3fODjmH1OLpUb03eg4xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737454719; c=relaxed/simple; bh=TMVQVq4hTGh+yCGqIGzQwjfDXfPLOTHYVspTb0Kbs/k=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=UrsQRwkA+2njE8Q/1wzdAyIobjYRZ8lOEF6oqg0x+3NPMzOSCln6jlcSAX+WLX4cW0p4HnUuLI++24Dq1GEWlL0jKqqXl7wgW6bYx9cxCdSW0cgv6IJzIzHMt57jRW2qlfYtAkrd5hz7aOMw3NnPWa9iISKW5PvNhfEFrqE02nM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAAFF3857340 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-out2.suse.de (Postfix) with ESMTPS id B243C1F794 for ; Tue, 21 Jan 2025 10:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737454718; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=t1dEa6uqJHJS2ZwpagdC1kA3vLwC0js9VZ/lpLJKhuY=; b=KenVKO9TZZzVmHhE6T57pfwdkYuo6HkGB7QAe6G+TRUHMnYKmBHJa3rowosf+E3iF5QAeZ riIRE7g9sDv7EnjUeQQLIMxwF+L7FgeYuix9CwHxMyOz27xJcdUrP7BCJyYMiR6tbPGg7H xYy1dx+/+CvbFJwgP3EuNGCKaVZrDbo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737454718; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=t1dEa6uqJHJS2ZwpagdC1kA3vLwC0js9VZ/lpLJKhuY=; b=Lxn2IS/++TiFy0GJABF00RuyI21PI4i063ZG57Z0ezZXaC4TusN4INJYkocnFjtto9kGxv 5ZblI1jX8LlozUBA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737454718; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=t1dEa6uqJHJS2ZwpagdC1kA3vLwC0js9VZ/lpLJKhuY=; b=KenVKO9TZZzVmHhE6T57pfwdkYuo6HkGB7QAe6G+TRUHMnYKmBHJa3rowosf+E3iF5QAeZ riIRE7g9sDv7EnjUeQQLIMxwF+L7FgeYuix9CwHxMyOz27xJcdUrP7BCJyYMiR6tbPGg7H xYy1dx+/+CvbFJwgP3EuNGCKaVZrDbo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737454718; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=t1dEa6uqJHJS2ZwpagdC1kA3vLwC0js9VZ/lpLJKhuY=; b=Lxn2IS/++TiFy0GJABF00RuyI21PI4i063ZG57Z0ezZXaC4TusN4INJYkocnFjtto9kGxv 5ZblI1jX8LlozUBA== 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 91EFA13963 for ; Tue, 21 Jan 2025 10:18:38 +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 9kZMIn50j2dwTgAAD6G6ig (envelope-from ) for ; Tue, 21 Jan 2025 10:18:38 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/symtab] Fix gdb.base/fission-macro.exp with unix/-m32 Date: Tue, 21 Jan 2025 11:18:55 +0100 Message-ID: <20250121101855.14719-1-tdevries@suse.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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 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~patchwork=sourceware.org@sourceware.org When running test-case gdb.base/fission-macro.exp on openSUSE Tumbleweed (using gcc 14) with target board unix/-m32, I get: ... (gdb) info macro FIRST^M Defined at /data/vries/gdb/src/gdb/testsuite/gdb.base/fission-macro.c:0^M -DFIRST=1^M (gdb) FAIL: $exp: \ dwarf_version=5: dwarf_bits=32: strict_dwarf=0: info macro FIRST ... instead of the expected: ... (gdb) info macro FIRST^M Defined at /data/vries/gdb/src/gdb/testsuite/gdb.base/fission-macro.c:18^M (gdb) PASS: $exp: \ dwarf_version=5: dwarf_bits=32: strict_dwarf=0: info macro FIRST ... 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; ... which is wrong for both dwarf-5 (and also happens to be wrong for dwarf-4). Fix this by computing str_offsets_base correctly for dwarf-5, for both the 32-bit and 64-bit case. Likewise, fix this for dwarf-4, using str_offsets_base 0. We can only test this with gcc-15, because gcc 14 and earlier don't have the fix for PR debug/115066. Tested on x86_64-linux. Tested test-case using a current gcc trunk build, and gcc 14. PR symtab/31897 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31897 --- gdb/dwarf2/read.c | 12 +++++++++++- gdb/testsuite/gdb.base/fission-macro.exp | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) base-commit: 24f46f126f4df6d727967f4489c66bc0921b1d6e diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4503977d62b..9e3d13c9875 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20832,7 +20832,17 @@ 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->header.version <= 4) + str_offsets_base = 0; + 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..9e5d5c0a0d5 100644 --- a/gdb/testsuite/gdb.base/fission-macro.exp +++ b/gdb/testsuite/gdb.base/fission-macro.exp @@ -66,8 +66,12 @@ proc do_tests { dwarf_version dwarf_bits strict_dwarf } { gdb_test "info macro FOURTH" "#define FOURTH 4" } -foreach_with_prefix dwarf_version {5} { - foreach_with_prefix dwarf_bits {32} { +foreach_with_prefix dwarf_version {4 5} { + if { $dwarf_version == 4 && [gcc_major_version] < 15 } { + # Gcc does not contain fix for PR debug/115066. + continue + } + foreach_with_prefix dwarf_bits {32 64} { foreach_with_prefix strict_dwarf {0 1} { do_tests $dwarf_version $dwarf_bits $strict_dwarf }