From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Zu+VH19goGn3OgsAWB0awg (envelope-from ) for ; Thu, 26 Feb 2026 10:01:51 -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=Ks8iz0n0; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 697251E0DD; Thu, 26 Feb 2026 10:01:51 -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 3A1591E089 for ; Thu, 26 Feb 2026 10:01:50 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D12954B9DB75 for ; Thu, 26 Feb 2026 15:01:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D12954B9DB75 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=Ks8iz0n0 Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.129.114]) by sourceware.org (Postfix) with ESMTP id C87DA4B9DB4B for ; Thu, 26 Feb 2026 15:00:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C87DA4B9DB4B 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 C87DA4B9DB4B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772118051; cv=none; b=qg0aAta+JwPwO5nplCtcdQUHcJU8EgiDaCLFtAj4SaLXxMYWW5gmt8t2sZK+ZIpzMorpUcjV3qgC/J1XYCQ71lw05F/iPYYpIZU05rY8d1WhpGAwDN24NLKUqaSXBNfS2xCrE5P/YoxGjHX9JrMEyq2H667U4MFJC0hygxu08WE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772118051; c=relaxed/simple; bh=sIzvRnHNPV5z1IKbPVtwj1REBf2kTVxIaTKj1QFcsoI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t/WXkdInNz03PjVyw5qASWXPklTLzSUt8CdSOPHUJcXF5VfKwOtJyqzgIpR6SwsalIFzeVxH4KXlotutTqPOvx7InPg5q7kXJzbqNp1heguh9p3uo2eHb6zA5ShQQa+2pqXi7rQvoPsx4CtiPrs8fj8ONf+j1sJNplNM5mjsIqY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C87DA4B9DB4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labware.com; s=mimecast20220511; t=1772118048; 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=SSVaPj51+uaqH/msuJ9VQEwksGY2ZH0JUzGnqei+ALE=; b=Ks8iz0n06L5krynae15Tw0Zm+PvgLNAZT0qiH3wd5T7OuR+cTVHuLISb4KdDZtGbTwyPTH O59wBhdtoF8s4ToOrR5jygEGJToF/4bm/CYfuJ4gVxpJjwfCw7SRwBqLBvtffghS7XEDop w4m8h8P6NuUjXRW9r6m1fA5F+edyo68= Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11022123.outbound.protection.outlook.com [40.93.195.123]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-389-Fy9mrFFLOr2AuNLpnwv8PA-1; Thu, 26 Feb 2026 10:00:45 -0500 X-MC-Unique: Fy9mrFFLOr2AuNLpnwv8PA-1 X-Mimecast-MFC-AGG-ID: Fy9mrFFLOr2AuNLpnwv8PA_1772118045 Received: from SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) by PH0PR17MB4455.namprd17.prod.outlook.com (2603:10b6:510:16::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.14; Thu, 26 Feb 2026 15:00:41 +0000 Received: from SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e]) by SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e%4]) with mapi id 15.20.9654.014; Thu, 26 Feb 2026 15:00:41 +0000 From: =?iso-8859-15?Q?Jan_Vran=FD?= To: "tom@tromey.com" CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH 3/7] gdb: simplify find_compunit_symtab_for_pc_sect Thread-Topic: [PATCH 3/7] gdb: simplify find_compunit_symtab_for_pc_sect Thread-Index: AQHcodGnZL84pNhu+UO8LK+zGuytZbWKcfiggAqrvAA= Date: Thu, 26 Feb 2026 15:00:41 +0000 Message-ID: <853bd327acf343d776a5f8513a7d67c828dcb674.camel@labware.com> References: <20260219185638.360694-1-jan.vrany@labware.com> <20260219185638.360694-4-jan.vrany@labware.com> <87ecmg4i39.fsf@tromey.com> In-Reply-To: <87ecmg4i39.fsf@tromey.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR17MB5365:EE_|PH0PR17MB4455:EE_ x-ms-office365-filtering-correlation-id: 1ae09ee5-baa1-455d-95cd-08de7547cf5c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|376014|38070700021 x-microsoft-antispam-message-info: yK9EXYwF7SjtNQyEfmk+h2wjJnCNwrHgl2behTpQl7+ltwUlzi8KVxLPtP9YkSQd2ahNHdJfWp+Waj4Ler13tEty0igl5DwJp7uyVkiGHJB6OAtiwXPfYRqqopPZVUbJ3/uA41REyU36DKtPb1a2UFt6oFw1pxp5VlJLfrlpw1oNVq+uoFntGXqup07e/tZ5IOkEHxGyN1+YBP14cujRG4pVV8QAybfzwUubR/Cf1SBxWM5FRFWCAqahdR3wq30L6Mghri72LRlzZca7J3MbKEfPzej9EIgG9w2kaDSVh5RyWVcGI2u4of5rpY1mwidO9presBum0Y0nTMj0/kWwr+GpSTY9ADEoUXcF3SudtMhe6cESwKnWpDAJvfv9Wjlo+w7Sq/ScY5OzepoXIQ/gUzU5rbOjSdhnQCJK/J4Zvk4/Oah+Nc2mn2nESn8E/ToaqbXE9s+GxXgk4MrSjumeQv0VZvWLzMJiA/jzr97WSAt9umPUK6I/1fqg98igkxpdFoQsRMIW9wviWrHvyTCo4YJ/VpHj6gcsdZuO69KVeeVoPtMGz+lPfcd+ZwvlpZ74YZSP2g9fY58M5ss5ub8/sc+IjokUzSUDxKmoHUPpojIlIVhNRhNOi9PvHNm5bXzws5K4q0uqhY/ATHZHSTz6K9nP/NX217Dsv90etPyFqEv187Vl4u+BKdqQiYagwFzmR1NHxfm/CbsKMEIvFBa73oelgMjA8b9/u7NBv6S6Diij+eDUVTadWVhxRArXVebuvtmYhbPIy4JawNhBZMP2o81kjqKzezjf0m7JjbGVuD8= 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)(38070700021); DIR:OUT; SFP:1102 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-15?Q?CrMRcWWFD40qjEu7LDbHyck+vAY7olu5lTjOsyqBHCohhZnTxB8+NZhHS?= =?iso-8859-15?Q?TNw1gyDcNyTd7wGQ3Eq2oblwNaiGl4knDfd/DjtmmPC/2f0SKomyIKgzd?= =?iso-8859-15?Q?xjm3pziG3jsoFZ5nX+gofFj4vZTdhTp/bk16RwBeaCrT3oerx1hFHOol+?= =?iso-8859-15?Q?us/5Mezmn0V/v7J9mAAPxUlcy6QahTGFy7msX5pl1bpDPDewnmMSNi094?= =?iso-8859-15?Q?jdvf8FRmVXX6c0SZd0xIhlzc+AVfKPB6lnpO8taOz6uJqvYZ6nYVoWtZe?= =?iso-8859-15?Q?Kfmm/QY9Yqu3kCEjksuNRi+LIVYRtVXD0XpTlkg2yySmjVvJlLktLhIbR?= =?iso-8859-15?Q?VLBjkGAQiHZg7EThguhcUqGTQH3cIfUpBWO3q1Q22tknKuYsjiXYdIdpZ?= =?iso-8859-15?Q?nLshK8L6pIcoxuk7CiZG+k9AxsfZmKQpqxzHpJqnImcSfHS3a1DIHLSFG?= =?iso-8859-15?Q?z46rWS3BTacacf97SF++0faUwSpz3YOhf430oVUuXRZwYlmUZaZ6ul/iR?= =?iso-8859-15?Q?Br9jZu9HP8sSYD3OdY+N3f8kKkReyTdHmMJT7pypL90sNJ4CfMyAXcK2O?= =?iso-8859-15?Q?AMx5AtD3+tuNfwkMSrivAmMgvQ1xjkq88VtbqeHBwPol7CrEIELLqHRdt?= =?iso-8859-15?Q?TPbeEQEF6QtELExbnyy55vZaNA4dqX+teHGw4QCYKT23j6+GkgYo42y4g?= =?iso-8859-15?Q?KAp9C15EdUvRHsjamyli9ly5CwzARpDOwbRxYNpdN64gsUFTkwyAWJ55D?= =?iso-8859-15?Q?m3nui6ZxgHugqhTTJhsosI2wm2wriUBYUL5Xt44WmXsaai2dPomcDhdzd?= =?iso-8859-15?Q?beSBhYRy6Ww/gVu47hIADMOIXBKzsSwlnTNRMCbDibwjOTp9WptSDN3f+?= =?iso-8859-15?Q?FeCgrHRejKP470yaSwcgEyF1Og54MRtoFAtqj+ZPWxf0VruV9ZAQrlX7d?= =?iso-8859-15?Q?2D8i2vfcl5Tp7heG3M1rieySe8mXVku7sQwDxzv6cGnwdv6taq9mhhvsO?= =?iso-8859-15?Q?5m8yST8kwFjuBqVcEY2qY0IYH717BuTF7e41gGheZfQm3cASMQPB4LIU9?= =?iso-8859-15?Q?kUoODeTuZoN5EosyWmtTJiLqhAefJwIlwVtkbtF+5auMoGlybEvgKB3iu?= =?iso-8859-15?Q?shDNUPdiul5Dprm+Xbl+u6tsOgy4aNXSmH1lHM/NzGQSic0s2yigXC8XP?= =?iso-8859-15?Q?lFaNxX848yGr4iibVuIgMItbcsH+YOxQDlaPDpCv51fPwieOnH3h4QYrn?= =?iso-8859-15?Q?dI2hfpRyW5yFvPhIF0mCalkwZaUGPTmtzDDR8sqxLL2x0Oyn2GFRHpGsU?= =?iso-8859-15?Q?NTT6hN2Rl6vArh50WvzQdLx7fn30tT84j5zSrsXuHbeir+XmSsS+40a5g?= =?iso-8859-15?Q?IBwNgjyrC6PIEQK6ju0gVjzh9JH8Srbd1xN84MDd3EIgHVE26g6hFvddS?= =?iso-8859-15?Q?BJllN6J2OWw06V/j/WYIjjdeHdPLa0vROD0a4R0KDNP4o9q4zNqLs3lGm?= =?iso-8859-15?Q?o1P61MQLvqFlnSDIh2KWJ5JapZ3eskcM5yZ48H56GlUqOd5KTZiaqknGB?= =?iso-8859-15?Q?9wK17LbHprBrEcwYYGhUwcrAiqk6e1MO/c9pUJh76P/g65GXZyhaM/rhj?= =?iso-8859-15?Q?ZBt+ygqRsG5y2BdSL8if01ihyebZNn71wJ8H5qWEg9syMCds1kYrnaDm6?= =?iso-8859-15?Q?AmQjMRi0+m+7Bmr0JytR+jmhqvCxuRTrKx9Fa+Vrrke3Rm8FnLkpgDcL+?= =?iso-8859-15?Q?QraeAInfQXd0k0Y3Qb0HOz2ypF6DRmsrccrkbvRLNDWerqxR8gPpwvUiN?= =?iso-8859-15?Q?crNtHeznbqsFd5V0+G2y8TFEQE8sNfTX0KtrZzdg=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR17MB5365.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ae09ee5-baa1-455d-95cd-08de7547cf5c X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2026 15:00:41.4657 (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: tjdFA1piMYKj2rY0i9mLlUlfXOVAgnpxyga6Bw8mgWxF0pzuRYQ0S3O382m+HSg/qvS1fhFc+Gz9dNTjAAMVXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR17MB4455 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: VtykqCOnBxOKgmdoCVeHBOiaOjYtM5lfAB7K0wa0smM_1772118045 X-Mimecast-Originator: labware.com Content-Language: en-US Content-Type: text/plain; charset=ISO-8859-15 Content-ID: <3AA42F4B0455B94EBD7AFD23A77C68C1@namprd17.prod.outlook.com> Content-Transfer-Encoding: quoted-printable 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 On Thu, 2026-02-19 at 13:02 -0700, Tom Tromey wrote: > > > > > > "Jan" =3D=3D Jan Vrany writes: >=20 > Jan> This commit simplifies find_compunit_symtab_for_pc_sect by removing = the > Jan> code that walks over all (currently expanded) CUs and delegating to > Jan> quick_symbol_functions::find_pc_sect_compunit_symtab instead. >=20 > Jan> With this commit on Linux x86_64 I see no regression. With -readnow > Jan> there are some regressions, mainly caused by slightly different orde= r > Jan> of expanding CUs. Since there's a proposal to remove -readnow suppor= t, > Jan> I have not fixed nor investigated failing tests in depth. >=20 > I think that proposal was rejected so I'm afraid you'll have to revisit > that. So I did that. The only regression I spotted is dw2-entry-points.exp in which the hand-written DWARF creates to CUs, first one with "hole".=20 And since blockvector::lookup() returns static block if no better block=20 is found and because the CU with hole happens to be tried first,=20 the test fails. If one changes the order of CUs in the test, it passed.=20 There's an easy "fix" for that - look for compunit that contains shortest= =20 block containing the PC, somewhat along the lines of "big chunk": in curren= t=A0 find_compunit_symtab_for_pc_sect (see patch below).=20 But: I'm not sure we want to do that. This brings us back to the idea that= =A0 blockvector::lookup() should never return static block. Or accept that regression.=20 Jan -- >8 -- >From a4b9d584634f4aff9fc0d2f4b3ce2a2a5019b3ad Mon Sep 17 00:00:00 2001 From: Jan Vrany Date: Wed, 25 Feb 2026 22:34:40 +0000 Subject: [PATCH] FIXUP: gdb: implement readnow_functions::find_pc_sect_compunit_symtab --- gdb/dwarf2/read.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2ed8b78d596..824f5081105 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2176,21 +2176,41 @@ readnow_functions::find_pc_sect_compunit_symtab /* This invariant is documented in read.h */ gdb_assert (per_bfd->index_table =3D=3D nullptr); =20 - /* Since we have no index, we simply walk all units until matching CU is - found (of there are no more CUs). */ + /* Since we have no index, we have to walk all CUs and find one with + best-matching block that contains PC. For the purpose of this method= , + a block B1 is considerent better matching than block B2 if B1 is not = null + and B2 is either null or has larger total span than B1. In other wor= ds, + smaller blocks are "better". */ + + auto better =3D [&] (const block *b1, const block *b2) + { + if (b1 =3D=3D nullptr) +=09return false; + if (b2 =3D=3D nullptr) +=09return true; + return (b1->end () - b1->start ()) < (b2->end () - b2->start ()); + }; + + compunit_symtab *best_cu =3D nullptr; + const block *best_bl =3D nullptr; + for (int i =3D 0; i < per_bfd->all_units.size (); i++) { dwarf2_per_cu *data =3D per_bfd->all_units[i].get (); =20 if (per_objfile->symtab_set_p (data)) =09{ -=09 compunit_symtab *result =3D find_pc_sect_compunit_symtab_includes ( -=09 per_objfile->get_symtab (data), pc); -=09 if (result !=3D nullptr) -=09 return result; +=09 compunit_symtab *this_cu =3D per_objfile->get_symtab (data); +=09 const block *this_bl =3D this_cu->blockvector ()->lookup (pc); + +=09 if (better (this_bl, best_bl)) +=09 { +=09 best_cu =3D this_cu; +=09 best_bl =3D this_bl; +=09 } =09} } - return nullptr; + return best_cu; } =20 void --=20 2.51.0