From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EUzFLnVlqGmERxQAWB0awg (envelope-from ) for ; Wed, 04 Mar 2026 12:01:41 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=labware.com header.i=@labware.com header.a=rsa-sha256 header.s=mimecast20220511 header.b=gmsJe703; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BA4D61E0DD; Wed, 04 Mar 2026 12:01:41 -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 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 ABB7A1E09A for ; Wed, 04 Mar 2026 12:01:39 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 433464B9DB58 for ; Wed, 4 Mar 2026 17:01:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 433464B9DB58 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=labware.com header.i=@labware.com header.a=rsa-sha256 header.s=mimecast20220511 header.b=gmsJe703 Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.133.114]) by sourceware.org (Postfix) with ESMTP id A81844BA2E14 for ; Wed, 4 Mar 2026 17:00:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A81844BA2E14 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=labware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=labware.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A81844BA2E14 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772643609; cv=none; b=FjSE+hkS9Fha3WQe5zO4KtX+OYlnhUOgfnBnoFa06/lFPb06hq6X5uEMOqhHo7ZmF+qHb6onJOsVtOrHtLHaP7e56/N3rBkQf9vImiVZO7EyK1mado+hDl/MKZalujbkDcpDB6OkbYDFmhWoHU2jf6GSlyLjlcJOxVBBbeuVps4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772643609; c=relaxed/simple; bh=XZ3cCCllm5K/iMdHwyVtwr7yumtipALBaVAyX4lvDYA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Im/xtnhkVVpj5dqZSI8mRK0lYKol945rfu6UZrGSNypiswgA1OKoTHCn1lgSbJBzgd6YOZRVZHDnNqWO7DT63JhCh875suYPTw+LsYHOfQex9M98wm9OiGkMdOP0T99eUzUcbBNHSAb2D+cExRHbfals2zVYBhAsD/icWBcd860= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A81844BA2E14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labware.com; s=mimecast20220511; t=1772643609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EwrDR8S2ulrWjM0Ir9VvA5edcwOTT5CdkqYXPYz/WEQ=; b=gmsJe703VcNmE9KJ6a/tniPfLukBOPx18HY4R7fVfu2dMUi1bh68Kstwj4GYla0yaRwNTp r6qMLyxThf7eNWS1raH0AAjaq/LnnwPdxY7/ahi3kJPOvV1BJeEln7mRs4G3d0sC16x3FV 0ZS+fvTsGkb3HfYUY8KHyxTB7G3IBZ4= Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11020101.outbound.protection.outlook.com [52.101.56.101]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-czCIvzTROLexakiU9GAibQ-1; Wed, 04 Mar 2026 12:00:08 -0500 X-MC-Unique: czCIvzTROLexakiU9GAibQ-1 X-Mimecast-MFC-AGG-ID: czCIvzTROLexakiU9GAibQ_1772643608 Received: from SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) by IA3PR17MB7264.namprd17.prod.outlook.com (2603:10b6:208:51c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.22; Wed, 4 Mar 2026 17:00:06 +0000 Received: from SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e]) by SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e%3]) with mapi id 15.20.9654.022; Wed, 4 Mar 2026 17:00:06 +0000 From: Jan Vrany To: gdb-patches@sourceware.org CC: Jan Vrany Subject: [PATCH v2 3/7] gdb: simplify find_compunit_symtab_for_pc_sect Date: Wed, 4 Mar 2026 16:59:10 +0000 Message-ID: <20260304165914.3209106-4-jan.vrany@labware.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260304165914.3209106-1-jan.vrany@labware.com> References: <20260304165914.3209106-1-jan.vrany@labware.com> X-ClientProxiedBy: LO4P123CA0475.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::12) To SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR17MB5365:EE_|IA3PR17MB7264:EE_ X-MS-Office365-Filtering-Correlation-Id: c1eb2c5e-703f-476a-f658-08de7a0f7c5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014 X-Microsoft-Antispam-Message-Info: Ir2GGdwE6MmucKO8NKgIXl08ufj9cA1jpXdy6U3fC6hrzHC5rKqZmiQxc/DWg67wzEp6Bd08xW0MkibDz7QEtkPunC0K9TW8e3xAwtj4IJrEpxOn2Kej+xrykZkkSt4ttKjt2KgF70D3ZYkGyPcNpKjdpQdQ1FoE4dgkH6Wp7Aq8l1ZhOh/ZDz0r4Mh8Q7ikbL8NI4zcRspayfi8zAybWs8PECPE7jOIqiofl6tfFBcHWnSNmjG25h090qN0SEvFXjVwvYSpCF4Qc2ZpyW/UKDGdHsBXpiGkD85/kOYfwsXxqAbrpXMa4caKBIhKsC5D0HvCR0a/2ju/HaZJib7HlBmF9+Et0iWxb6GnhtizsmiQ8eEjC67/U3ND8/Z2Moyu1SIrFrPUcxesKf7tO7wrvHT4VnD313fpUqtbv0TDj/nxtYA1N/TnvBLp5SIPNjAph6008FYJM/tmOOoRUsIe1iL++jJ3xNit6OQZpUoUM/g7b6icoKX0tq5JTvfRxy0n7Ps4Vv1pzQeHBROXiy2bZSOY35B5MrM7pbSnClXE3WrzLEtw+whxYlTQQwo88nxFxIV2exakiKEtwdJrC6Tebj36AtNT7pv7LAeuA1iFU9Nl+rH93f9ViA0HaGuxNgK7ZW0LGoJH0vAqq4uNaKiLVZuaTYcBtUnL1P5hDRJoWjhjCRrjQiRs6GyZcWamhqtVKO6UYVcVh51p49ZYLxD7kGHOEqCGwcrPejuTzQv/XWo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR17MB5365.namprd17.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ZnxlLpaYh8j6eYbz2PhGxHlKJ4BdhB9aOFAd3JaTdDDs4GgnjNWbeVCf/cYr?= =?us-ascii?Q?GoscjN0qaILPN9SNA5ALl3oBxmTH47/ZmLErLNRiXRRErSJFR0XWpdfgBffl?= =?us-ascii?Q?kqTZNdQcqMmPOd/rZP0LTuMCzHa4ic87xjgE1mBCuEoi0ntx/ujC9ooAK4tu?= =?us-ascii?Q?i9gJMPZc0qe2bnypEHPWPcIcZkkpOrgi25Vzc+6P87LmAx2VEad2rLX4H2D8?= =?us-ascii?Q?JLhM4GR2ezHq43NppSHH6XLb8eD8dBtN5VnJn5V2NMyGfC1vV2EBkayBXCoF?= =?us-ascii?Q?2xMzPCpjjpLLahhC/0+8rY7t1VulhXw8wvSPMIN+Sew5i54iZfKyF87z4xk9?= =?us-ascii?Q?JIIcIlTuPmuR+i8T7R+hKPYWpBeX1v4qvEX9aknggXbhJuiITEJcxInoqtwn?= =?us-ascii?Q?yLwUFsVbLx830I8w5vK391BnGHbcnip0/K0SDsYVX8Kb6rpIQqpEDo7tQCgx?= =?us-ascii?Q?Zy9Umj9gV0VdzXpP95JkZdzLDRE7s9TWe/OvH8d0OC85kIasODp5mNjDUy9R?= =?us-ascii?Q?0zJSKRFks3QrvpR/kFYn0urvqweI0GPOoexRhCniMOsaNE8Nj2rMK/mHo0KD?= =?us-ascii?Q?mkVwcNFv6RoNu+r1i1k8dVt1xT156T+yuNUsqgimmBXPkQcF7Iz2fCxMHwzv?= =?us-ascii?Q?OrubF9xIIQSet/OEDH/iwLKX8skwdJ85fXIECtQpdt9GlPqf51LwQBNA2wGC?= =?us-ascii?Q?59TrNrmV7uPqEKIhM7E3oo7rp2O4n+5zMZLXU/LcGGTjgHwBR8zzjkbYE8jW?= =?us-ascii?Q?/W787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?= =?us-ascii?Q?l6npzsb0prTvbSwOmUSpWn3QF039Zk+oBD6wdV+IDK9BxovUGrXkkkIASWKv?= =?us-ascii?Q?1HYqpbOUcw=3D=3D?= X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1eb2c5e-703f-476a-f658-08de7a0f7c5b X-MS-Exchange-CrossTenant-AuthSource: SA1PR17MB5365.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2026 17:00:06.3842 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UCc7tAx/0fDxnOxYDixmraKJGlAgrR65vqmt6YmvWNFn6PaZdnatmvv0yBMTaxZxnASOHkUxeiiuvXdy1IuOXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR17MB7264 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 015rF-ws2SZFziy9vQSoEEQs_bPgSEGIQz5zXa1ZzCE_1772643608 X-Mimecast-Originator: labware.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252 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 This commit simplifies find_compunit_symtab_for_pc_sect by removing the code that walks over all (currently expanded) CUs and delegating to quick_symbol_functions::find_pc_sect_compunit_symtab instead. With this commit on Linux x86_64 I see no regression. With -readnow there are some regressions, mainly caused by slightly different order of expanding CUs. Since there's a proposal to remove -readnow support, I have not fixed nor investigated failing tests in depth. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D33829 --- gdb/dwarf2/read.c | 8 ----- gdb/symtab.c | 91 ----------------------------------------------- 2 files changed, 99 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f7f39d75c16..7c6f54449ba 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2156,17 +2156,9 @@ dwarf2_base_index_functions::find_pc_sect_compunit_s= ymtab if (data =3D=3D nullptr) return nullptr; =20 - if (warn_if_readin && per_objfile->symtab_set_p (data)) - warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"= ), -=09 paddress (objfile->arch (), pc)); - compunit_symtab *result =3D find_pc_sect_compunit_symtab_includes (dw2_instantiate_symtab (data, per_objfile, false), pc); =20 - if (warn_if_readin && result =3D=3D nullptr) - warning (_("(Error: pc %s in address map, but not in symtab.)"), -=09 paddress (objfile->arch (), pc)); - return result; } =20 diff --git a/gdb/symtab.c b/gdb/symtab.c index cd3bf876551..4eea86319f8 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2742,9 +2742,6 @@ iterate_over_symbols (const struct block *block, struct compunit_symtab * find_compunit_symtab_for_pc_sect (CORE_ADDR pc, struct obj_section *sectio= n) { - struct compunit_symtab *best_cust =3D NULL; - CORE_ADDR best_cust_range =3D 0; - /* If we know that this is not a text address, return failure. This is necessary because we loop based on the block's high and low code addresses, which do not include the data ranges, and because @@ -2755,94 +2752,6 @@ find_compunit_symtab_for_pc_sect (CORE_ADDR pc, stru= ct obj_section *section) if (msymbol.minsym && msymbol.minsym->data_p ()) return NULL; =20 - /* Search all symtabs for the one whose file contains our address, and w= hich - is the smallest of all the ones containing the address. This is desi= gned - to deal with a case like symtab a is at 0x1000-0x2000 and 0x3000-0x40= 00 - and symtab b is at 0x2000-0x3000. So the GLOBAL_BLOCK for a is from - 0x1000-0x4000, but for address 0x2345 we want to return symtab b. - - This happens for native ecoff format, where code from included files - gets its own symtab. The symtab for the included file should have - been read in already via the dependency mechanism. - It might be swifter to create several symtabs with the same name - like xcoff does (I'm not sure). - - It also happens for objfiles that have their functions reordered. - For these, the symtab we are looking for is not necessarily read in. = */ - - for (objfile &obj_file : current_program_space->objfiles ()) - { - for (compunit_symtab &cust : obj_file.compunits ()) -=09{ -=09 const struct blockvector *bv =3D cust.blockvector (); -=09 const struct block *global_block =3D bv->global_block (); -=09 CORE_ADDR start =3D global_block->start (); -=09 CORE_ADDR end =3D global_block->end (); -=09 bool in_range_p =3D start <=3D pc && pc < end; -=09 if (!in_range_p) -=09 continue; - -=09 if (bv->map () !=3D nullptr) -=09 { -=09 if (bv->map ()->find (pc) =3D=3D nullptr) -=09=09continue; - -=09 return &cust; -=09 } - -=09 CORE_ADDR range =3D end - start; -=09 if (best_cust !=3D nullptr -=09 && range >=3D best_cust_range) -=09 /* Cust doesn't have a smaller range than best_cust, skip it. */ -=09 continue; - -=09 /* For an objfile that has its functions reordered, -=09 find_pc_psymtab will find the proper partial symbol table -=09 and we simply return its corresponding symtab. */ -=09 /* In order to better support objfiles that contain both -=09 stabs and coff debugging info, we continue on if a psymtab -=09 can't be found. */ -=09 struct compunit_symtab *result -=09 =3D obj_file.find_pc_sect_compunit_symtab (msymbol, pc, -=09=09=09=09=09=09 section, 0); -=09 if (result !=3D nullptr) -=09 return result; - -=09 if (section !=3D 0) -=09 { -=09 struct symbol *found_sym =3D nullptr; - -=09 for (int b_index =3D GLOBAL_BLOCK; -=09=09 b_index <=3D STATIC_BLOCK && found_sym =3D=3D nullptr; -=09=09 ++b_index) -=09=09{ -=09=09 const struct block *b =3D bv->block (b_index); -=09=09 for (struct symbol *sym : block_iterator_range (b)) -=09=09 { -=09=09 if (matching_obj_sections (sym->obj_section (&obj_file), -=09=09=09=09=09=09 section)) -=09=09=09{ -=09=09=09 found_sym =3D sym; -=09=09=09 break; -=09=09=09} -=09=09 } -=09=09} -=09 if (found_sym =3D=3D nullptr) -=09=09continue;=09=09/* No symbol in this symtab matches -=09=09=09=09=09 section. */ -=09 } - -=09 /* Cust is best found so far, save it. */ -=09 best_cust =3D &cust; -=09 best_cust_range =3D range; -=09} - } - - if (best_cust !=3D NULL) - return best_cust; - - /* Not found in symtabs, search the "quick" symtabs (e.g. psymtabs). */ - for (objfile &objf : current_program_space->objfiles ()) { struct compunit_symtab *result --=20 2.51.0