From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SajGGlA31mkBWA0AWB0awg (envelope-from ) for ; Wed, 08 Apr 2026 07:09:04 -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=ofYZnbFl; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=9jsK2NZX; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jkbKaFe6; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=P9MrKmeM; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3DCA91E0C3; Wed, 08 Apr 2026 07:09:04 -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 D00241E04F for ; Wed, 08 Apr 2026 07:09:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 36FFA4BA2E2E for ; Wed, 8 Apr 2026 11:09:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36FFA4BA2E2E 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=ofYZnbFl; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=9jsK2NZX; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jkbKaFe6; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=P9MrKmeM 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 0945E4BA2E0F for ; Wed, 8 Apr 2026 11:08:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0945E4BA2E0F 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 0945E4BA2E0F 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=1775646509; cv=none; b=OCDHjv88tC+2cs/I5ZHh7dasUgWshgpM20uQhSZLtFMS8G1B6E5CLEe1fs8eGu0AURLxbhSrr0+USsMrWJolKB9CDB0ftQuls3o3eEwJNlwtYLfG2idug19X2nz5zG9EvvsQd+V0JOVUyVOdWAN6cTOxuTA7MsfWCofABn9k/88= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775646509; c=relaxed/simple; bh=XS1oP37qnd6SRTBPMYwSly3gDtb/j7Q365n1xlK6mnI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=C52WsRxa7EoayMmWeR0tW3tkSSIVoRxboJ7xM336107kuafw5VKogVlgbFZbgd68yEyGmnNoA7zMMqh6S+/Jio6sy3BXMegxb7HBiEYPAskjPGSYQ8IF65h6QX5C5Cwj7V64p+QNO08+sPyYI7XQZKFdgpeaC3vs6p2/khcvyv4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0945E4BA2E0F 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-out1.suse.de (Postfix) with ESMTPS id F0FBF4E980 for ; Wed, 8 Apr 2026 11:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1775646508; 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=TSDNfcMRw/7TTC8KKVDvahEOh4sS/xlLxvHpme1cJK8=; b=ofYZnbFlAKBFymEcIgxTLpnuINYci0ursgxUV8sh3Fm6r33cKskejayhRcbHDFKhNxvO+F brtufiOU1umGxurtWDyyPCXkWSpFRcxO2npvdLMZXqzTWtrC/qb3E5sAtwc3MPxiDlB8rV A8bdda7sm4uLY3lhWDqiPZiEnb13Jyw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1775646508; 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=TSDNfcMRw/7TTC8KKVDvahEOh4sS/xlLxvHpme1cJK8=; b=9jsK2NZXtGVS4R2GuoNT9Y808lKWWCLBrMeFng40hzY6SQFbgjJoGtPWn46ZaKLa3HKEqx u/SnhjgDk89p8dAQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jkbKaFe6; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=P9MrKmeM DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1775646507; 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=TSDNfcMRw/7TTC8KKVDvahEOh4sS/xlLxvHpme1cJK8=; b=jkbKaFe6++Ypc+xjAeJAV4zgnnZbwSB+VwQXLD0CZIAkEurU9izXgKd6yDrx9XVyb1FPXD cL0xFBdZfnhJ7V1gb7bHBuec0aGYKldPPaX2LL7o0ON3e/M4EuHklPRspKshaMjowpLsby EMbPyhT4KGfssTsgvHBjQqzBEGKBzKc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1775646507; 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=TSDNfcMRw/7TTC8KKVDvahEOh4sS/xlLxvHpme1cJK8=; b=P9MrKmeMSBijFFDPA6nMqtuSTL7jq62Ia10IBTkjLFrsIGcGRTjEbYjJt+CkM5V5flFmgj 8pPFInP71v+rJ/Bg== 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 DBF3D4A0B5 for ; Wed, 8 Apr 2026 11:08:27 +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 qCKINCs31mmyFwAAD6G6ig (envelope-from ) for ; Wed, 08 Apr 2026 11:08:27 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [RFC 2/2] [gdb/symtab] Don't expand type units for breakpoints Date: Wed, 8 Apr 2026 13:08:27 +0200 Message-ID: <20260408110827.2249311-3-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260408110827.2249311-1-tdevries@suse.de> References: <20260408110827.2249311-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)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; 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]; 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)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim, suse.de:mid, sourceware.org:url] X-Rspamd-Queue-Id: F0FBF4E980 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 a cc1plus exec compiled with GCC and LTO [1]. If we try to set a breakpoint on do_rpo_vn: ... $ gdb -q -batch cc1plus \ -ex "b do_rpo_vn" Breakpoint 1 at 0xfd75f0: do_rpo_vn. (2 locations) ... we expand 435 units: ... $ gdb -q -batch cc1plus \ -ex "b do_rpo_vn" \ -ex "maint print statistics" \ | grep "Number of read units" Number of read units: 435 ... [ When compiling with LTO, GCC generates debug info in two phases: - in the early phase, it generates a unit for each source file, containing the types in the source file. Let's call these type-only units. - in the late phase, it generates a so-called artificial unit for each optimized code blob. The artificial unit doesn't contains types, but imports them from the type-only units. The cc1plus exec contains 1150 units, 128 of which are artificials units: ... $ readelf -wi --dwarf-depth=1 cc1plus | grep -c "Compilation Unit @" 1150 $ readelf -wi --dwarf-depth=1 cc1plus | grep -c "" 128 ... ] Most of the expanded units are type-only units, which have no relevant information when we're looking for function symbols. They're merely expanded because the artificial units import them. So the question is: can we skip expanding the type-only units when looking for function symbols? This patch contains a naive implementation of that approach, in process_queue. Using it, we expand just 7 artificial units: ... $ gdb -q -batch cc1plus \ -ex "b do_rpo_vn" \ -ex "maint print statistics" \ | grep "Number of read units" Number of read units: 7 ... But there's a problem with this implementation, which we can illustrate using DWZ: ... $ cat test.c struct s { int x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; }; struct s var1; int main (void) { return 0; } $ gcc -g test.c; rm -f ab.dwz; cp a.out b.out; dwz -m ab.dwz a.out b.out $ gdb -q -batch a.out -ex "b main" -ex "ptype struct s" Breakpoint 1 at 0x40111a: file test.c, line 6. No struct type named s. ... First, we use DWZ to move struct s to a partial unit. Then in the GDB session the following happens: - setting a breakpoint on main expands the test.c CU - the test.c CU has an import of the partial CU, but the partial CU is not expanded, because it contains only types - printing struct s attempts to expand test.c CU, finds that it's already expanded, and the partial CU containing struct s remains unexpanded. - gdb tries to find struct s in the expanded CUs, and struct s is not found. RFC: what is the best way to fix this problem? I wondered about expanding function compunit_symtab_set_p et al with a domain_search_flags parameter, giving us a way to express that a CU is expanded for SEARCH_FUNCTION_DOMAIN, but not for other domains. But there may be a better way to achieve this. [ FWIW, I've tested this on x86_64-linux, and ran into a number of FAILs: ... 9 gdb.cp/cpexprs-debug-types.exp: 1 gdb.dlang/circular.exp: 2 gdb.dwarf2/ada-cold-name.exp: 4 gdb.dwarf2/ada-linkage-name.exp: 14 gdb.dwarf2/dw2-bad-abstract-origin.exp: 1 gdb.dwarf2/dw2-inline-bt.exp: 1 gdb.dwarf2/dw2-prologue-end-2.exp: 1 gdb.dwarf2/dw2-ranges-psym.exp: 7 gdb.dwarf2/dw2-step-between-different-inline-functions.exp: 6 gdb.dwarf2/dw2-step-between-inline-func-blocks.exp: 60 gdb.dwarf2/dw2-unexpected-entry-pc.exp: 1 gdb.dwarf2/inlined_subroutine-inheritance.exp: 1 gdb.dwarf2/struct-decl.exp: ... ] Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33922 --- gdb/dwarf2/read.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index afd0b60006e..475dc03f0b0 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1945,7 +1945,8 @@ dwarf2_base_index_functions::search_one compunit_symtab *symtab = dw2_instantiate_symtab (per_cu, per_objfile, false, domain); - gdb_assert (symtab != nullptr); + if (symtab == nullptr) + return true; if (listener != nullptr) { @@ -3908,6 +3909,15 @@ process_queue (dwarf2_per_objfile *per_objfile, domain_search_flags domain) gdb_assert (!per_objfile->compunit_symtab_set_p (per_cu)); + bool skip = (domain == SEARCH_FUNCTION_DOMAIN + && !per_cu->addresses_seen); + if (skip) + { + cu->queued = false; + per_objfile->queue->pop (); + continue; + } + namespace chr = std::chrono; unsigned int debug_print_threshold; -- 2.51.0