From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IV2rLLcT8Gja/TUAWB0awg (envelope-from ) for ; Wed, 15 Oct 2025 17:35:51 -0400 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=WS39uULe; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B25B01E0BA; Wed, 15 Oct 2025 17:35:51 -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 server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 35A501E047 for ; Wed, 15 Oct 2025 17:35:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE7E4385842B for ; Wed, 15 Oct 2025 21:35:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE7E4385842B 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=WS39uULe 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 682023858428 for ; Wed, 15 Oct 2025 21:35:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 682023858428 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 682023858428 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=1760564104; cv=none; b=QtOXjpBGGg6zKlZZN41xN/YLAKKXVTheI2wRaXEJwHgtr2DNG3+SNwe0Jg+H4L90svan6SmZgUnIEoexBD5z/fQz5AC7BOxDwtGWFLRKVt7r+APG54WPhEBi+zHkzfko9RBnmowV5g+NzH3ys6dIX/HSGzk3fFDwiwbDUm3Y8ec= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760564104; c=relaxed/simple; bh=IiOX8pz7HYEiOyxRiQZz7iFtT+EBls8BmUzIP7vnL8o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e8SZK1bjH5y24rPEqqIf7VA8++ceLbWozG4qj2DEYCvCBEUwfp2zp7jgE0kXx/yDZ6N8N1Vs3BNqjAztnX8Rzx+8EWW5wTiFPCoSrQluh816UI8P3ODw3557dNqeM/yhBsRzyIaQevH8L8TD3TIf2LahWQWyUixukE7Jd2u4wrY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 682023858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labware.com; s=mimecast20220511; t=1760564081; 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=zeWz4BuC1AddOt3HrJWhtvwqJRCPH9G40gwsYqp5HP4=; b=WS39uULeA1PrHUFzDDnH/Cj2oc5oZ0kWW027X7HCgW7f66y1Ww/Q4fkNPcinXBI0N2V7m8 WPxADCsIf2hHRgA5vNpkHRCA1Jsf3LkRjknKr9yK3cOcj0wDrWgfTvjitIMK5XnKu6Vtoo 8qm/u4zs+lwV54mLYsYnbBTFBNgWnjc= Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11022102.outbound.protection.outlook.com [40.107.200.102]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-iqjUmof2NbOwjWZt7h8Yyw-1; Wed, 15 Oct 2025 17:34:39 -0400 X-MC-Unique: iqjUmof2NbOwjWZt7h8Yyw-1 X-Mimecast-MFC-AGG-ID: iqjUmof2NbOwjWZt7h8Yyw_1760564079 Received: from SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) by LV3PR17MB7368.namprd17.prod.outlook.com (2603:10b6:408:26e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.12; Wed, 15 Oct 2025 21:34:34 +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.9228.010; Wed, 15 Oct 2025 21:34:33 +0000 From: =?iso-8859-15?Q?Jan_Vran=FD?= To: "simark@simark.ca" , "gdb-patches@sourceware.org" , "aburgess@redhat.com" CC: "tom@tromey.com" Subject: Re: [PATCH 2/2] gdb: use std::vector<> to hold on blocks in struct blockvector Thread-Topic: [PATCH 2/2] gdb: use std::vector<> to hold on blocks in struct blockvector Thread-Index: AQHcPG6Ellw1Hk1rakOVS9eqt310wrTBvcKAgABOVwCAAbIGAA== Date: Wed, 15 Oct 2025 21:34:33 +0000 Message-ID: <9a92f0e07d06e0b2df57a19edff996b40b6b770d.camel@labware.com> References: <20251013182318.1045138-1-jan.vrany@labware.com> <20251013182318.1045138-3-jan.vrany@labware.com> <87v7kha5pg.fsf@redhat.com> <77c4be93-0eac-4477-a7c2-62724a841db9@simark.ca> In-Reply-To: <77c4be93-0eac-4477-a7c2-62724a841db9@simark.ca> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR17MB5365:EE_|LV3PR17MB7368:EE_ x-ms-office365-filtering-correlation-id: 88377c69-5222-480c-a00b-08de0c32a1d7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|366016|1800799024|38070700021 x-microsoft-antispam-message-info: =?iso-8859-15?Q?RAXQgCdFhQ7F2PYC+VLvVE0ZqofiSH2QL4RItBgXpAQSkZD2T/ojtiOJX?= =?iso-8859-15?Q?TOUS2yonoFeI0CJ2Li+L6Yybv3bDfwfagNyXsTr90EIy/el+2dBxLHBBx?= =?iso-8859-15?Q?2HWVafEFblkXhliwXh+/K0GvBHzKN94wPyXZ0QCOcKjH6vaIShizE9HwF?= =?iso-8859-15?Q?SU6dJld9q4KthWuKZBcU+7IRUPcU/ytQ3yQGcUuwAMfi8KqQ4AxGjVthH?= =?iso-8859-15?Q?TDqAoH+a1Zp5bjlNDSRhfvMinaTvfELifYTvHp2DpVpVXahIVvkAYENza?= =?iso-8859-15?Q?nVzDpskSfGYbqbZkdowCjLg+4EnB6EmV1M+jF+c/EJRVRFg6GX9d8Jpv0?= =?iso-8859-15?Q?+rZo1f6wgFvP+o0zTzEsd2lHL7EI6QhsW52Y55+jORNQuojHhVedVg3Rf?= =?iso-8859-15?Q?CoDk6WwC03boct97BQtQlnwAb3mPPOYE2JAla0aHj1WPQkdfrgRzjJgsB?= =?iso-8859-15?Q?CCmkHwbL/KbRbYeuHnL4dbF38b6IsSCKQo1di6/6XgwjJWNxJfzU0vmUh?= =?iso-8859-15?Q?jVWuaY3+Bm0VE3lWMA6nv82EVCvn46pwP/YjPMtQ4ucxS6lV6UpKAQGGC?= =?iso-8859-15?Q?uId1nb8+Z4w7gCQHN5OatGUoHmmKh9/F0yE9l13tDrhjQMsG41QYbYO9b?= =?iso-8859-15?Q?wEtDkTOF59W6mG/0xEaSvRbaUrtID8Hh7tyWdomugC+Hnm0QhqnUPswYN?= =?iso-8859-15?Q?wcS0pTqFfAhbCA8b3JgRtzxcJqmlMdA/MRtCHuOkB2yovD5boZ3ZKdivi?= =?iso-8859-15?Q?M25VHj+tY1ue76cTBu4IqyQ12xKzyHDOIExwvT6tS5aKDltfJHY1MiDXK?= =?iso-8859-15?Q?Zq/n/vD0v6lfKJX51DTEdA5jKXjtYeC9piTYmPgsVCkyyE26NRUgmIr8q?= =?iso-8859-15?Q?hgWwYCaeCPXhS/fgulmdCQP0pnon2fkc9Q1TVVrP+cYo5PUTp3sKfeOZ0?= =?iso-8859-15?Q?TATcOfK63dI6J5Gv7e9T4WH/6yjNDx2WmmHVxg+cu4aS0sw1zVB8CFF0e?= =?iso-8859-15?Q?moGTyaxwXTn4P7MfsbE/QLO/eCs+W3BOlpfTMjGNJjft5sUsKhGEapcNS?= =?iso-8859-15?Q?Of+JTnbqUscykN2IABtpXM3fhNaP256NRG+xnITN6jQqhoTCcPBU20ogW?= =?iso-8859-15?Q?y700DWedQN0DYq9ZjjMI5lWk/n0pF/zcRD8HYlZahevc4S2zUhk0FnIou?= =?iso-8859-15?Q?77S3bJaNcWGR0fxtXAyiP0gY6KK5VQa/kanLhCRYwePye9YOsvAlJPDWk?= =?iso-8859-15?Q?YL+ch974OyxzGyFAFuYwZ7KQttWAwBykkt0twRyZirIb5P0hdwZpSVCZu?= =?iso-8859-15?Q?o7w9VmEY/fHCjLNRbMPQh9qqSglkrz9B/nr1uof6V3xLG+fMECghlspmm?= =?iso-8859-15?Q?dhxWggUfDgAqNGmTKTf+HT+SF5Nahj2UCmOd22xilJNHiz2qGU4RHDIoC?= =?iso-8859-15?Q?u1wY+3GqD2QhluNPRBLrgC3u/UVDHv9JdeQg+6y/fn3UaK8gZqg22k0L6?= =?iso-8859-15?Q?Z/CYhgVmlS5jz2xp3+dGmUlapP+q52ODgLPTmjhZY7THLZC9WMHuYvRUU?= =?iso-8859-15?Q?9RBH2+NQOzcFV0cH9NPyMM/WsNpUVl2mfnG9x/7LUyrY7EcsQiYaM9?= 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)(376014)(366016)(1800799024)(38070700021); DIR:OUT; SFP:1102 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-15?Q?dbNKCodkNSUlDWpwi04uVhqOm23ZEKIOEIATMeKUHvP5tt0/0/X+KyrBx?= =?iso-8859-15?Q?6iYbr4pHGJQZELK39kLVtACN1fVvSzxo0S+VcQhtAseDHQe3d0C1Y2nkm?= =?iso-8859-15?Q?Fop7NXl8aqtuVjdgJt04X2Aa8UjdOLspmkmsp72UfeXrNhP+ZleDTQj1Z?= =?iso-8859-15?Q?LWqwMgC2ArTdYIaTEUJPYj2gwaEdLN+OtKLsdLxUdAtLya4xZhNZehGQB?= =?iso-8859-15?Q?ZvaJbRt7fgKNC9V4JVyBr6wyQpoMN5yID3vyyvxRl+lSjOqwL4bKVaJq0?= =?iso-8859-15?Q?cPVe2akFL2ODY2vbhpM5FdBVklHp6v3FJlmFR2RQfA66ZgdbdA+gvqgGX?= =?iso-8859-15?Q?kH/QQ4iuBt4bB3IRrq8bMuLqK7BjWK8r0FEgHpbxl8sQXmR2CkwuAVUMs?= =?iso-8859-15?Q?5cEUdambf9+ebXHzlFRBbrkrKdGi/HW1f/XAP103IgkbJPfo4S7TMxYHS?= =?iso-8859-15?Q?XS5YkzbS0JjaYjppdkkg5bWs3HhOtYRGOyIzGkEeZKqA/KJTaLaF8rWv4?= =?iso-8859-15?Q?OzdN8FHT/fmsqwUu9W7PqViPrIxyG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tFCeryPz67LrWStwipM9DJ118W0m+nqeMbMAVq1Nyxrq?= =?iso-8859-15?Q?1pFiSjrCBdKJZZZPuQUJ8TysEfNnqMhqOW9cZC/OvfshWHmQO9SEOX84W?= =?iso-8859-15?Q?OLBhCW+pL4a/Jc1Mgc5lv6954EdM5M5vxPSRdrNgjKcMShiZsXeF2VRPT?= =?iso-8859-15?Q?D6YtDnDHW7QfHgPVUP9/G45kCcbAta5sFJ4qYytsebd2R6qjOk7QhG2YN?= =?iso-8859-15?Q?JrC0CaFhNLpGJb616TroaYDRXw=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: 88377c69-5222-480c-a00b-08de0c32a1d7 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Oct 2025 21:34:33.6226 (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: TSEETj9n2m14uka3/yzqfh3dOQWxQNnrittxi7vDfuUL0rX9pTJ/yErE/KlXkg4ss738ToE5EI7Z6hJnSzkdDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR17MB7368 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: VglJ0R-DDxbJ9xXN549-yroutewb3OH9mb_nFxUOOLM_1760564079 X-Mimecast-Originator: labware.com Content-Language: en-US Content-Type: text/plain; charset=ISO-8859-15 Content-ID: <621FD1623B5A4D45BE8828C00FC095EC@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 Tue, 2025-10-14 at 15:41 -0400, Simon Marchi wrote: > On 10/14/25 11:00 AM, Andrew Burgess wrote: > > > @@ -809,6 +810,41 @@ make_blockranges (struct objfile *objfile, > > > =A0=A0 return blr; > > > =A0} > > > =A0 > > > +static bool > > > +block_ordering_predicate (struct block *b1, struct block *b2) > >=20 > > Functions should have a comment above them. > >=20 > > > +{ > > > +=A0 CORE_ADDR start1 =3D b1->start (); > > > +=A0 CORE_ADDR start2 =3D b2->start (); > > > + > > > +=A0 if (start1 !=3D start2) > > > +=A0=A0=A0 return start1 < start2; > > > +=A0 return (b2->end () < b1->end ()); > > > +} > >=20 > > I notice that we use a slightly different ordering function in > > buildsym.c, one that doesn't consider the end address.=A0 Probably does= n't > > matter, but maybe it's at least worth mentioning in a comment or the > > commit message, that way, if someone is looking at the code in the > > future they can understand why these things are different.=A0 Even if t= he > > reason is just "we have no motivating example for why these should be > > the same right now". >=20 > buildsym sorts them (locally, in its singly-linked list) in the inverse > order, but then fills the blockvector backwards.=A0 So the blocks end up > in the right order in the blockvector.=A0 I think this is an artefact fro= m > the past and could be simplified.=A0 The predicate for sorting blocks in = a > blockvector should probably be written just once (in block.h) and used > by whoever needs it. I think what Andrew meant is that mdebugread.c (and jit.c) sort blocks so that blocks with lower start PC appear before blocks with higher start P= C AND if both start at the same PC, enclosing (larger) block appears before nested (smaller) block.=20 Whereas buildsym.c sorts them only by start PC. In buildsym.c there's also explicitly said that blocks with the same start PC should not be reordered: /* Sort blocks by start address in descending order. Blocks with the =09 same start address must remain in the original order to preserve =09 inline function caller/callee relationships. */ I was wondering if there's a case where blocks in blockvector created by buildsym.c would violate mdebugread.c-style ordering (that takes start and end PC into an account). So I modified blockvector::set_block() as follows: void blockvector::set_block (int i, struct block *block) { if (i =3D=3D GLOBAL_BLOCK) gdb_assert (block->is_global_block ()); else if (i =3D=3D STATIC_BLOCK) gdb_assert (block->is_static_block ()); else { if ((i - 1) >=3D FIRST_LOCAL_BLOCK && m_blocks[i - 1] !=3D nullptr) =09gdb_assert (block_ordering_predicate (m_blocks[i - 1], block) =09=09 || m_blocks[i - 1]->end () =3D=3D block->end ()); if ((i + 1) < m_blocks.size () && m_blocks[i + 1] !=3D nullptr) =09gdb_assert (block_ordering_predicate (block, m_blocks[i + 1]) =09=09 || block->end () =3D=3D m_blocks[i + 1]->end ()); } m_blocks[i] =3D block; } Running db.base/*.exp and gdb.dwarf2/*.exp shown no regression. I also tried to change buildsym.c to use mdebugread.c-style ordering: same start address must remain in the original order to preserve inline function caller/callee relationships. */ std::stable_sort (barray.begin (), barray.end (), - [] (const block *a, const block *b) - { - return a->start () > b->start (); - }); + blockvector::block_ordering_predicate); =20 int i =3D 0; Again no regression. Not that this means it is safe to use the same ordering predicate in all three cases. Jan >=20 > Simon