From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 7234B3858C50 for ; Fri, 24 Mar 2023 08:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7234B3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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 A8FB11FE70; Fri, 24 Mar 2023 08:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679647222; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=S/B2y2ophVthIZcTBUUgTMI4oND7fSh44Iw1esJespc=; b=e9JNi1NEO70EgwMfo+j6NjJA+UZY6k1UqM6nqslqtZps5IoA5eeK28xryO5mTaDXL9Bsmq +x1UBuZaQYnURp5AANUklK4v5tbzqXk6Q9uBcvX+1x8rtTErUOufAN21vpSeOy55fXzEjT +3DSV6fECTV8F8KsnUjXPNNalzLCcdY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679647222; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=S/B2y2ophVthIZcTBUUgTMI4oND7fSh44Iw1esJespc=; b=SQDhaXv6ZNvi2dws/5EWVFeXbOYfM0KKyjnuCYfiQDVubMWT+Wpk/kgo4socOZ8QO3jYpS l2GapPJmsEojESAg== 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 90C0B133E5; Fri, 24 Mar 2023 08:40:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4C4hIvZhHWTOBAAAMHmgww (envelope-from ); Fri, 24 Mar 2023 08:40:22 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] [gdb/symtab] Fix line number of static const class member Date: Fri, 24 Mar 2023 09:40:20 +0100 Message-Id: <20230324084020.12883-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 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: Since commit 6d263fe46e0 ("Avoid bad breakpoints with --gc-sections"), there was a silent regression on openSUSE Leap 15.4 for test-case gdb.cp/m-static.exp, from: ... (gdb) info variable everywhere^M All variables matching regular expression "everywhere":^M ^M File /home/vries/tmp.local-remote-host-native/m-static.h:^M 8: const int gnu_obj_4::everywhere;^M (gdb) ... to: ... (gdb) info variable everywhere^M All variables matching regular expression "everywhere":^M ^M File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M 8: const int gnu_obj_4::everywhere;^M ^M File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M 8: const int gnu_obj_4::everywhere;^M (gdb) ... Another regression was found due to that commit, and it was fixed in commit 99d679e7b30 ("[gdb/symtab] Fix "file index out of range" complaint") by limiting the scope of the fix in the original commit. Fix this regression by yet further limiting the scope of that fix, making sure that this bit in dwarf_decode_lines is executed again for m-static1.cc: ... /* Make sure a symtab is created for every file, even files which contain only variables (i.e. no code with associated line numbers). */ ... Tested on x86_64-linux. PR symtab/30265 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30265 --- gdb/dwarf2/read.c | 3 +-- gdb/testsuite/gdb.cp/m-static.exp | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index c9208a097bf..c910be875a3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7610,8 +7610,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, then there won't be any interesting code in the CU, but a check later on (in lnp_state_machine::check_line_address) will fail to properly exclude an entry that was removed via --gc-sections. */ - if (have_code) - dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); + dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping && have_code); } /* Process DW_TAG_compile_unit or DW_TAG_partial_unit. */ diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp index 37d3289a751..a78baa9e895 100644 --- a/gdb/testsuite/gdb.cp/m-static.exp +++ b/gdb/testsuite/gdb.cp/m-static.exp @@ -185,8 +185,10 @@ gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo if { $non_dwarf } { setup_xfail *-*-* } gdb_test "info variable everywhere" \ [multi_line \ + {All variables matching regular expression "everywhere":} \ + "" \ "File (.*/)?m-static\[.\]h:" \ - "$decimal:\tconst int gnu_obj_4::everywhere;.*"] + "$decimal:\tconst int gnu_obj_4::everywhere;"] # Perhaps at some point test4 should also include a test for a static # const int that was initialized in the header file. But I'm not sure base-commit: 1985d8cb7048bcfce60b59cfe219d3b09bda6373 -- 2.35.3