From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yUgAMGQu5mkOniwAWB0awg (envelope-from ) for ; Mon, 20 Apr 2026 09:47:16 -0400 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=MHkYhtB/; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=AgQmFHNB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=MHkYhtB/; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=AgQmFHNB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B89C41E0BA; Mon, 20 Apr 2026 09:47:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 311661E0B1 for ; Mon, 20 Apr 2026 09:47:15 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 481DB4D108DD for ; Mon, 20 Apr 2026 13:47:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 481DB4D108DD 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=MHkYhtB/; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=AgQmFHNB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=MHkYhtB/; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=AgQmFHNB Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id CDF224B358A2 for ; Mon, 20 Apr 2026 13:46:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDF224B358A2 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 CDF224B358A2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776692781; cv=none; b=ADVooCagtIHEHCbykaA34qsyb5MJO03S1USAVMPA7nJ2efC5B0P3nhGO07XLRcEsHpiw9I5gZ8FLIziXMlxw5EJR/uv1m2/S3/MibTYoPPjiBHAwdSUnp6oBochjDyNBV0aOUK7o4rB57t3aKlApYdFw9+kz8Y4lSQj4Ih0kwTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776692781; c=relaxed/simple; bh=X2NLru1gb0vcSkQtX/uskazDLXyS3tjAaybWr9/rUlA=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=pNO1oNm/0dsZnb7/dyWaYkfd1/jn0pb2PlfuagSCffW5tgKXKgIpejo54ILudEGhRht7BrUbxSxe+FTpOUjVL33CEpuOC8b9oN8mFUGZepITJPDll2/xAVHlfjUrhPnjd+5Iqn90aHii/To7s9y6VqvpiCX+uTDecTv5VE1Wdtk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDF224B358A2 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 4FC596A7DF for ; Mon, 20 Apr 2026 13:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776692769; 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=OI6e47oAWJ2z5x/ZfigGSzX0bDLQfkBaujEyjMQYWUU=; b=MHkYhtB/Rxa+xG+wGs5XzZk2v1dSVL7pnjpFBSvf/gY4vqrKVRhtT8jkSOz87FsFj8SaFN m0SG2nBAY6YTJYMh2VlBJMBh5F3e6BIQR18GZVOXiw0uFQauZzPi39CTY6NcwRFx8SKD8X US18FodcbIJQw1ZPrpILogP1tzS0D4E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776692769; 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=OI6e47oAWJ2z5x/ZfigGSzX0bDLQfkBaujEyjMQYWUU=; b=AgQmFHNBsoM5TzMEnxoRvBk+GVSOA73hatFJoN64lTmpqt4o+nJmEIQrh4nt4d7zk1bT+s teWGHenDp6ByFyDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776692769; 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=OI6e47oAWJ2z5x/ZfigGSzX0bDLQfkBaujEyjMQYWUU=; b=MHkYhtB/Rxa+xG+wGs5XzZk2v1dSVL7pnjpFBSvf/gY4vqrKVRhtT8jkSOz87FsFj8SaFN m0SG2nBAY6YTJYMh2VlBJMBh5F3e6BIQR18GZVOXiw0uFQauZzPi39CTY6NcwRFx8SKD8X US18FodcbIJQw1ZPrpILogP1tzS0D4E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776692769; 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=OI6e47oAWJ2z5x/ZfigGSzX0bDLQfkBaujEyjMQYWUU=; b=AgQmFHNBsoM5TzMEnxoRvBk+GVSOA73hatFJoN64lTmpqt4o+nJmEIQrh4nt4d7zk1bT+s teWGHenDp6ByFyDA== 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 38C29593B1 for ; Mon, 20 Apr 2026 13:46:09 +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 eByqDCEu5mnzQAAAD6G6ig (envelope-from ) for ; Mon, 20 Apr 2026 13:46:09 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 4/5] [gdb/symtab] Add lnp_state_machine::m_stmt_at_last_address Date: Mon, 20 Apr 2026 15:46:07 +0200 Message-ID: <20260420134608.2537059-5-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260420134608.2537059-1-tdevries@suse.de> References: <20260420134608.2537059-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,step-and-next-inline.cc:url]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,imap1.dmz-prg2.suse.org:helo]; 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-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 Consider lnp_state_machine::stmt_at_address: ... /* Set to true when a previous line at the same address (using m_last_address) had LEF_IS_STMT set in m_flags. This is reset to false when a line entry at a new address (m_address different to m_last_address) is processed. */ bool m_stmt_at_address = false; ... set at the end of lnp_state_machine::record_line: ... /* Track whether we have seen any IS_STMT true at m_address in case we have multiple line table entries all at m_address. */ if (m_last_address != m_address) m_stmt_at_address = false; m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0; ... Now consider this line number information: ... File name Line number Starting address View Stmt step-and-next-inline.cc 40 0x10000714 step-and-next-inline.cc 42 0x1000071c x step-and-next-inline.cc 43 0x1000071c 1 x step-and-next-inline.cc 43 0x1000071c 2 step-and-next-inline.cc 52 0x1000071c 3 step-and-next-inline.cc 52 0x10000720 step-and-next-inline.cc 38 0x10000728 x ... If we calculate the values of m_stmt_at_address: ... entry m_address m_last_address m_stmt m_stmt_at_address ---------------------------------------------------------------------- 40/0x10000714 0x10000714 - 0 0 42/0x1000071c 0x1000071c 0x10000714 1 0 43/0x1000071c/1 0x1000071c 0x1000071c 1 1 43/0x1000071c/2 0x1000071c 0x1000071c 0 1 52/0x1000071c/3 0x1000071c 0x1000071c 0 1 52/0x10000720 0x10000720 0x1000071c 0 1 38/0x10000728 0x10000728 0x10000720 1 0 ... we observe a skew of one entry between m_stmt and m_stmt_at_address. Looking at entry 52/0x10000720, the value of m_stmt_at_address == 1 is in contradiction with the documentation: A value of 1 implies that there is a previous entry at the same address, and there isn't. This was not a problem for the initial use, which only happened if m_last_address == m_address: ... bool ignore_this_line = ((file_changed && !end_sequence && m_last_address == m_address && ((m_flags & LEF_IS_STMT) == 0) && m_stmt_at_address) || (!end_sequence && m_line == 0)); ... But recent commit 8efed40efd6 ("gdb: fix-up truncated inline function block ranges") introduced a use for the opposite case: ... if (m_address != m_last_address && m_stmt_at_address && m_cu->producer_is_gcc () && (m_flags & LEF_IS_STMT) == 0) dwarf_find_and_extend_inline_block_range (m_cu, m_last_address, m_address, m_line); ... While that use is correct, using it in a context where the value contradicts the documentation is problematic. Fix this by moving the calculation of m_stmt_at_address to the start of record_line, removing the skew, and creating a much easier to understand concept: ... entry m_address m_last_address m_stmt m_stmt_at_address ---------------------------------------------------------------------- 40/0x10000714 0x10000714 - 0 0 42/0x1000071c 0x1000071c 0x10000714 1 1 43/0x1000071c/1 0x1000071c 0x1000071c 1 1 43/0x1000071c/2 0x1000071c 0x1000071c 0 1 52/0x1000071c/3 0x1000071c 0x1000071c 0 1 52/0x10000720 0x10000720 0x1000071c 0 0 38/0x10000728 0x10000728 0x10000720 1 1 ... and introducing an m_stmt_at_last_address (similar to m_last_address and m_last_line in the sense that they represent the value of a state variable when processing the previous entry). Tested on x86_64-linux. --- gdb/dwarf2/line-program.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c index d821de14e76..c8aaeb15ece 100644 --- a/gdb/dwarf2/line-program.c +++ b/gdb/dwarf2/line-program.c @@ -185,10 +185,11 @@ class lnp_state_machine unrelocated_addr m_last_address; unsigned int m_last_line = 0; - /* Set to true when a previous line at the same address (using - m_last_address) had LEF_IS_STMT set in m_flags. This is reset to false - when a line entry at a new address (m_address different to - m_last_address) is processed. */ + /* The m_stmt_at_address value of the last line entry. */ + bool m_stmt_at_last_address = false; + + /* Set to true when this or an earlier entry at the same address has + LEF_IS_STMT set in m_flags. */ bool m_stmt_at_address = false; /* When true, record the lines we decode. */ @@ -430,6 +431,12 @@ dwarf_find_and_extend_inline_block_range (dwarf2_cu *cu, void lnp_state_machine::record_line (bool end_sequence) { + /* Track whether we have seen any IS_STMT true at m_address in case we + have multiple line table entries all at m_address. */ + if (m_last_address != m_address) + m_stmt_at_address = false; + m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0; + if (dwarf_line_debug) { gdb_printf (gdb_stdlog, @@ -446,7 +453,7 @@ lnp_state_machine::record_line (bool end_sequence) } if (m_address != m_last_address - && m_stmt_at_address + && m_stmt_at_last_address && m_cu->producer_is_gcc () && (m_flags & LEF_IS_STMT) == 0) dwarf_find_and_extend_inline_block_range (m_cu, m_last_address, @@ -501,14 +508,9 @@ lnp_state_machine::record_line (bool end_sequence) } } - /* Track whether we have seen any IS_STMT true at m_address in case we - have multiple line table entries all at m_address. */ - if (m_last_address != m_address) - m_stmt_at_address = false; - m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0; - m_last_address = m_address; m_last_line = m_line; + m_stmt_at_last_address = m_stmt_at_address; } lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch) -- 2.51.0