From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OQW6F6V5pWkQoRAAWB0awg (envelope-from ) for ; Mon, 02 Mar 2026 06:51:01 -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=bNqkXs9F; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=rl76qka4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bNqkXs9F; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=rl76qka4; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 588161E0DD; Mon, 02 Mar 2026 06:51:01 -0500 (EST) 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,WEIRD_PORT 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 384611E089 for ; Mon, 02 Mar 2026 06:51:00 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id DFC134BA23EF for ; Mon, 2 Mar 2026 11:50:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFC134BA23EF 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=bNqkXs9F; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=rl76qka4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bNqkXs9F; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=rl76qka4 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 3D5134BA900B for ; Mon, 2 Mar 2026 11:49:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D5134BA900B 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 3D5134BA900B 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=1772452144; cv=none; b=o/7PLX494gB+SIgdnnx6hsLeb/ow/cKicurabByAWs4h+qn6v/KSwAuloej0TG1/V6TESLFlo7FLfWn111xFGq1YvcTWtN6brc3e35apRlhLY4yrbdp1la2U4jsZAVPxGUq9aT61hpI5nCsrDpIy3ouulABWGd0dtFHmfbfrdfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772452144; c=relaxed/simple; bh=w/jrJILkMNxyW7RdoOww2BTEvwl1PO9OQeiRdRpKlb4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=jnRY1oNUCf3Oo4Yf1ZVILSAuabx8DSlQSi3Hyi2ufk8HZOC3nOI734LXBODlpQXMpENa6AG2iVERX+CNlk0MXmn67uOSFw9Af7haFAfN0S6LQGjELyPhc7PXLFiVGKBCt+kV1qNjm0hmh4PSwtQxqiQX5uwpQch94MGarVfGDCk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D5134BA900B 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-out2.suse.de (Postfix) with ESMTPS id 82E185BD2B for ; Mon, 2 Mar 2026 11:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1772452130; 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=mDFTob6pnngQwMlcUqmi3ICiwfGSTtFEGVZYWGxQ6hU=; b=bNqkXs9FK1Hj63D+24kVrHbPpUqmH1Tir+SgseBKtQie2EYkHitzCraQ1Ge4au8D8EAEyy u1FwHnKIkWSr9kUUZwmbBTpUu7ahVI2MrFCGNGltFaHZFisim5awaDDd4KpZdBHLCaLStN DFPC1+HDFINWqcmi3qm0TPpWPC6qvrk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1772452130; 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=mDFTob6pnngQwMlcUqmi3ICiwfGSTtFEGVZYWGxQ6hU=; b=rl76qka460STwWZBk3cs//+3b/7/yz8/lj0rx3JAPTGymblalPFDj5/jYpWvePDtKKC4tA lNQkjab6zmTp/4AA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bNqkXs9F; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=rl76qka4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1772452130; 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=mDFTob6pnngQwMlcUqmi3ICiwfGSTtFEGVZYWGxQ6hU=; b=bNqkXs9FK1Hj63D+24kVrHbPpUqmH1Tir+SgseBKtQie2EYkHitzCraQ1Ge4au8D8EAEyy u1FwHnKIkWSr9kUUZwmbBTpUu7ahVI2MrFCGNGltFaHZFisim5awaDDd4KpZdBHLCaLStN DFPC1+HDFINWqcmi3qm0TPpWPC6qvrk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1772452130; 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=mDFTob6pnngQwMlcUqmi3ICiwfGSTtFEGVZYWGxQ6hU=; b=rl76qka460STwWZBk3cs//+3b/7/yz8/lj0rx3JAPTGymblalPFDj5/jYpWvePDtKKC4tA lNQkjab6zmTp/4AA== 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 6EC913EA6C for ; Mon, 2 Mar 2026 11:48:50 +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 ICvSGSJ5pWlEDQAAD6G6ig (envelope-from ) for ; Mon, 02 Mar 2026 11:48:50 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 3/3] [gdb/symtab] Tweak fix-up of truncated inline function block ranges Date: Mon, 2 Mar 2026 12:48:49 +0100 Message-ID: <20260302114849.1797017-4-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260302114849.1797017-1-tdevries@suse.de> References: <20260302114849.1797017-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 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)[]; 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)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; 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)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, entry:email, step-and-next-inline.cc:url, suse.de:dkim, suse.de:mid] X-Rspamd-Queue-Id: 82E185BD2B 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 test-case gdb.cp/step-and-next-inline.exp on ppc64le-linux. The corresponding source file step-and-next-inline.cc contains functions tree_check and get_alias_set: ... 35 #define TREE_TYPE(NODE) (*tree_check (NODE, 0)) 36 37 inline tree * 38 tree_check (tree *t, int i) 39 { 40 if (t->x != i) 41 abort(); 42 tree *x = t; 43 return x; 44 } ... 48 int __attribute__((noinline, noclone)) 49 get_alias_set (tree *t) 50 { 51 if (t != NULL 52 && TREE_TYPE (t).z != 1 53 && TREE_TYPE (t).z != 2 54 && TREE_TYPE (t).z != 3) 55 return 0; 56 return 1; 57 } ... as well as a trivial function main calling get_alias_set. Say we step into the first call to tree_check, and then step to the return at line 43: ... (gdb) s tree_check (i=0, t=0x10020030 ) at step-and-next-inline.cc:40 40 if (t->x != i) (gdb) s 43 return x; (gdb) ... At that point, we have pc 0x1000071c: ... (gdb) p $pc $1 = (void (*)(void)) 0x1000071c (gdb) ... and the backtrace looks like this: ... (gdb) bt #0 tree_check (i=, t=) at step-and-next-inline.cc:43 #1 get_alias_set (t=t@entry=0x10020030 ) at step-and-next-inline.cc:52 #2 0x0000000010000560 in main () at step-and-next-inline.cc:64 (gdb) ... which shows all 3 functions. This seems trivial, but it's not. All three calls to tree_check are inlined, and the first call is represented by: ... <2><877>: Abbrev Number: 40 (DW_TAG_inlined_subroutine) <878> DW_AT_abstract_origin: <0x967> <87c> DW_AT_entry_pc : 0x10000710 <884> DW_AT_GNU_entry_view: 0 <885> DW_AT_ranges : 0xc <88a> DW_AT_call_line : 52 ... with DW_AT_ranges referring to: ... Contents of the .debug_rnglists section: Offset Begin End 0000000c 0000000010000710 (base address) 00000015 0000000010000710 000000001000071c 00000018 000000001000077c 000000001000077c (start == end) 0000001b 0000000010000788 0000000010000790 0000001f ... The range at offset 0x15 is [0x10000710, 0x1000071c), so address 0x1000071c does not fall in the range, and consequently the debug info does not consider 0x1000071c part of the inlined tree_check. However, since commit 8efed40efd6 ("gdb: fix-up truncated inline function block ranges"), gdb contains a fix in lnp_state_machine::record_line: ... 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); ... that looks at the corresponding line number information: ... File name Line number Starting address View Stmt 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 ... and extends the range of the inlined tree_check to include [0x1000071c, 0x10000720). [ Please read the commit message of aforementioned commit to understand why the fix is correct. ] Let's look in more detail at how the call to dwarf_find_and_extend_inline_block_range is activated for the fix. It's activated for the last entry (52/0x10000720), with: - m_last_address == 0x1000071c, - m_address == 0x10000720, and - m_line == 52 (matching the DW_AT_call_line). It's easy to see that for the last entry, (m_flags & LEF_IS_STMT) == 0 holds, because it doesn't have an x in the "Stmt" column. I found it less obvious that m_stmt_at_address also holds. [ The documentation clarifies that this is related to m_last_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; ... To get maximum clarity, I checked the value for each entry: ... address m_stmt_at_address --------------------------------- before false 42/0x1000071c false->true 43/0x1000071c/1 true 43/0x1000071c/2 true 52/0x1000071c/3 true 52/0x10000720 true->false ... Again it's easy to relate the transitions for particular entries to the "Stmt" column. The tricky bit is that the transition takes place at the end of lnp_state_machine::record_line, so while processing entry 52/0x10000720, we sample m_stmt_at_address while it's still true. ] Likewise, the fix works for the second inlined call. But not for the third. The debug info has the same problem, but the fix is not applied. The corresponding line info looks slightly different: ... File name Line number Starting address View Stmt step-and-next-inline.cc 42 0x1000074c x step-and-next-inline.cc 43 0x1000074c 1 x step-and-next-inline.cc 43 0x1000074c 2 step-and-next-inline.cc 54 0x1000074c 3 step-and-next-inline.cc 55 0x10000750 ... In this case, dwarf_find_and_extend_inline_block_range gets called with: - m_last_address == 0x1000074c, - m_address == 0x10000750, and - m_line == 55, but since line 55 doesn't match DW_AT_call_line 54: ... <2><918>: Abbrev Number: 44 (DW_TAG_inlined_subroutine) <919> DW_AT_abstract_origin: <0x967> <91d> DW_AT_entry_pc : 0x10000740 <925> DW_AT_GNU_entry_view: 0 <926> DW_AT_low_pc : 0x10000740 <92e> DW_AT_high_pc : 0xc <937> DW_AT_call_line : 54 ... the fix is not applied. I'm proposing the following simple tweak, to handle the third inlined call as well: instead of using m_line, use m_last_line. Tested on x86_64-linux and ppc64le-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33930 --- gdb/dwarf2/line-program.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c index b9d93bb7b0e..5aa97ea3714 100644 --- a/gdb/dwarf2/line-program.c +++ b/gdb/dwarf2/line-program.c @@ -445,12 +445,25 @@ lnp_state_machine::record_line (bool end_sequence) (end_sequence ? "\t(end sequence)" : "")); } + /* Activate dwarf_find_and_extend_inline_block_range for line number info: + + Line number Starting address View Stmt + 42 0x1000074c x + 43 0x1000074c 1 x + 43 0x1000074c 2 + 54 0x1000074c 3 + 55 0x10000750 + + at entry 55/0x10000750 with: + - m_last_address == 0x1000074c + - m_address == 0x10000750 + - m_last_line == 54. */ 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); + m_address, m_last_line); file_entry *fe = current_file (); -- 2.51.0