From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kePNBNUgTWocLysAWB0awg (envelope-from ) for ; Tue, 07 Jul 2026 11:52:53 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MEfhhquG; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MEfhhquG; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0BB071E098; Tue, 07 Jul 2026 11:52:53 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 F190A1E024 for ; Tue, 07 Jul 2026 11:52:51 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09D694BA23E6 for ; Tue, 7 Jul 2026 15:52:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09D694BA23E6 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MEfhhquG; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MEfhhquG Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazlp170130006.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::6]) by sourceware.org (Postfix) with ESMTPS id D7D974BA23F9 for ; Tue, 7 Jul 2026 15:51:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7D974BA23F9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D7D974BA23F9 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c201::6 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783439489; cv=pass; b=C6ZTqNJ1quD3wgSvoG1peXskzMvw37E6O3OwRCpMYcceRCFIf6/pYiLks5GtGGQ6PZqtdbt8cFqEe9JYcKqDhSDF1R1/ZYQEWQcTXBrvJWoc93zajjrDXBbzxpJoVrU/PoH5sg9l3Mc3SLXmY8iKiTMz9ua4GOBf5yXkHSBIjOc= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783439489; c=relaxed/simple; bh=AgbsLlcTdf6XnVsIw25xLQp9XfdXTPTDS5eJSAPelfI=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=Y2cmWL8T11peCllwXQDRhX1B3QYWPpwUAJAzMcgRMpBHpravwDCvsAPBzj1FJcedSCxTz0KJW0hmYGOaWyy0pVWBWAsSGWh/uUybw0hgcc1BHeJFEqUmfXTX0RNxBfLn29ZuN0105+FQ+oon9QrF/ldkntymQZvQScyyPdY5qrA= ARC-Authentication-Results: i=3; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MEfhhquG; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MEfhhquG DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7D974BA23F9 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=yUoOHeQwIjivzyIp97BsuJN4KaSOFEyqiZDC2tv3BV+8nCeLjgmOhEzDPVUzmEB5Emkj8UkzB+APPt4jzgNCTTwqJfG3GS2/2WyK2gvICV1cmf7gzwqo3Yxpyh+zj9F+xN7nFiETlvFNH2vxF2ZXJeOYgU6UFhbv1l0QnC032PSio2xb1gwMho7GlmpNM2/7axEGxpzYXybSpeX4++iDUOJR8FTG/FH7IG22FG+2BYCWgOv3PyET8f68dvKt6hP0oq1BVOtTeGA/g9YnHnFhJq3MaqFSyCKZsqw7rA/bxgRrv8aC0BmuivCMg2k11dn3U8rMogtpLHtxvlfEUw/u7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jMJbrrPRKyyDRf87U/edqmYqATgwpSDuIfjjKMX++NA=; b=ngEEPQhMPqPwFYlzTCG7yLOwfbr41tLfhA7ncQ28/QmJQHASLIisJE6rdjLPRvQPseW/IZoN/RWWJrgtEOsY3XjCCm6eUylRssuoRKaRo5wDF1R57DP2Ddf2KAxafXZoL0dcmGR0Bq0tpdl3jIAV39AgRO24P3AX3dyP4mSCoPRez6+cdfhh9V4N24aqDr4VG0pV92tdEME3jtRJQ2AGWkbhnWroPQh4SH5O6kQY8cl20YYCMNb5+9bRskfZZIMuaIgd1wbWnajRwmHGL+YI6G6lGlLInWhxkfMxyXm9jlUut1338MSbdhBaTBm7vSDKAKRZ2spfQw2WMyqAAcOQDg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jMJbrrPRKyyDRf87U/edqmYqATgwpSDuIfjjKMX++NA=; b=MEfhhquGlkIAgai2SVrWWhoqwxGaZNchlk4FL4JPMGLGF+KOosgcEOKVWTqAgH3BOEP21R6Fy7aEvXM+Ou2rf7fR9r/iTn0Ik3rzHgvtLzzJjZU5QaygU4pYbsATGrjNg4/DPVVp7nf+3zJxNnNGuZ+RE8wjgE59d/TAmBzHuqk= Received: from DUZPR01CA0072.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c2::10) by PAWPR08MB10042.eurprd08.prod.outlook.com (2603:10a6:102:34e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.9; Tue, 7 Jul 2026 15:51:19 +0000 Received: from DU6PEPF00009526.eurprd02.prod.outlook.com (2603:10a6:10:3c2:cafe::58) by DUZPR01CA0072.outlook.office365.com (2603:10a6:10:3c2::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.13 via Frontend Transport; Tue, 7 Jul 2026 15:51:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; pr=C Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by DU6PEPF00009526.mail.protection.outlook.com (10.167.8.7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.6 via Frontend Transport; Tue, 7 Jul 2026 15:51:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tqcO+iAKtn7LMhoVMbEYSIccj+5CRuK3erbuUC8yrWq72YTYMc+6QOjVYtLQf0Kq/JfK8FaBLyJEEFpvCCQGbR9Ul1rd60IOED71LPcKwnoUQ8XYia7oXbhI7J/gnCQxp61pGyMaYPd8s3MnRNH++vHdFQfv7ULKc+/ZsUX+NgMfh7e9W/WLPDuTTZivlXbwtMnZjV4htrKGr/KfoJ/oBGj0i6Kjk50/1Vi9AUMdbtyAsFg3ip1QpQvvKrDkix/Hpe8a2eJwgNPqcQCeqUYmGTOS6Zirfn+C1gZm0Jx+m5FHDfZKqZoNJitgVUmnbjwP+i6q9pPJGR93JqqXenVd9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jMJbrrPRKyyDRf87U/edqmYqATgwpSDuIfjjKMX++NA=; b=Z5M4oHmSGxF1eRaarfvJYrnO26xp3UR3yGSymsHmuAFZTluApvi2dE+N/IvSHS0Ud56x+QTa9kuH+/b47Ix/uGb8DXeSJNQJAMUwDo/9EvrpAvyCjJfettQ/TwaZ77zHyuCt8SRqeSu2JVCL6ZWwgNnS9/HiODsFlviuUTEONgNRh05YVrtukgtkpR/4IeNAptS0kfJ0xzow2bdM3gsDEn2t9J9Fst4swY+D/hFMp8r52AnOOZVudJXZcZ6P+lj1+CSukRM1MruxPgfD3XRD676NZ49NvKRqu4MF7RLSYLaDposUtskM/w2dgdIJfzEEYPRHAC4sDL6oVRhey/kSDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jMJbrrPRKyyDRf87U/edqmYqATgwpSDuIfjjKMX++NA=; b=MEfhhquGlkIAgai2SVrWWhoqwxGaZNchlk4FL4JPMGLGF+KOosgcEOKVWTqAgH3BOEP21R6Fy7aEvXM+Ou2rf7fR9r/iTn0Ik3rzHgvtLzzJjZU5QaygU4pYbsATGrjNg4/DPVVp7nf+3zJxNnNGuZ+RE8wjgE59d/TAmBzHuqk= Received: from DUZPR01CA0178.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::20) by PA4PR08MB7571.eurprd08.prod.outlook.com (2603:10a6:102:270::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.10; Tue, 7 Jul 2026 15:50:14 +0000 Received: from DB5PEPF00014B9F.eurprd02.prod.outlook.com (2603:10a6:10:4b3:cafe::6) by DUZPR01CA0178.outlook.office365.com (2603:10a6:10:4b3::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.13 via Frontend Transport; Tue, 7 Jul 2026 15:50:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (172.205.89.229) by DB5PEPF00014B9F.mail.protection.outlook.com (10.167.8.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.6 via Frontend Transport; Tue, 7 Jul 2026 15:50:14 +0000 Received: from AZ-NEU-EX04.Arm.com (10.240.25.138) by AZ-NEU-EX03.Arm.com (10.240.25.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 7 Jul 2026 15:49:59 +0000 Received: from PF4S4363.arm.com (10.57.40.47) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 7 Jul 2026 15:49:58 +0000 From: Matthieu Longo To: CC: Luis Machado , Luis Machado , Andrew Burgess , "Yury Khrustalev" , Pedro Alves , "Tom Tromey" , Matthieu Longo Subject: [PATCH v1 05/10] gdb: introduce helper class file_reader_t Date: Tue, 7 Jul 2026 16:48:55 +0100 Message-ID: <20260707154900.94542-6-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260707154900.94542-1-matthieu.longo@arm.com> References: <20260707154900.94542-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9F:EE_|PA4PR08MB7571:EE_|DU6PEPF00009526:EE_|PAWPR08MB10042:EE_ X-MS-Office365-Filtering-Correlation-Id: 993ac96d-0f3c-47c1-3bb9-08dedc3f9601 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|36860700016|376014|23010399003|82310400026|1800799024|11063799006|6133799003|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info-Original: SX3hamHc76hjO4Pf8y6SgqYSblc+6FKXcp1+d02gYCrRHJUoNOsem9l+B2iiXcXU9KiVn135EHahYJWRJKwkm6Fm+Rm+TK3RlSIJndwo1HxLZuT0NtKEZ62vGpHE3WtQJnJn9TUKQ9tv3mqT1w4EeUBWk3YCu7bzgn7wvaHMVY8/7Bg74Nxj9H049nBeEwBVvLwIQQ+rnzZF8jM+wprBpMo/taWlX46OKoCPjNhStHMijmyfk2H+69CQicvWMk2jtK90+Hbb5qFhDG5XrLdKCmJZq179PjPP0uXBTwdpCa7m87X+yZugYj9OVmSg7Y+MY3jFaeYVVB386fv2v7HNXCCNaItOAEVYCSaqqr35TAo+/YpvVuCPWwPEJtRmhZhJG3tG4O76UMfWdaXuzFKq7iCP3+Jw+4yMt7lRxWyEvKdWM4t8Z2A4OY6dhf+rRs1eLSNmu/E8Gq6sksNWLnwZyYYzDk51xd2/rHtxVgXHu4KUC2pQibxoBbTrciPgvLBVMhh/s5wx1adu1dH3Nf9pSIuIza5NjqulB0j+7OccQXnbda26J625rbV8NekwHUoVuj/7c4t2EaiY8cwB1JUCr0uaIbWq0Iu6PnLu86dJYGcMZNUOkjikmWf4dn2kAqVkWDp9qcEe8aVW8fGf6E3RFCaP3ui+Bn7aVf5QH5PC19IDfJKplMLvmnZ+ewWR7tuyXoXIjJ6jzMAjQy8nrniS4A== X-Forefront-Antispam-Report-Untrusted: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(376014)(23010399003)(82310400026)(1800799024)(11063799006)(6133799003)(56012099006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: HlQDGc6oFFQ39bvMBvgIYvJPM2mtYZUSn12l+Q3dA/MhqYr0/CRVrw5Pvlv07fR2VUfZq8UUMj/k/5tc3A4p+R66xAAHIAXXn+HfxMX96xltQi1/KchqSQMrZY3sCWVt0Jf7yfrhXFp+Jsm7pQFEq+gtGDRGxyodbgFU6NY+wDh7/IjNTHF1FIftsK28GZSwMzcRB7oLqToslsJh/NiYscrZC4MFfPjegDaAwpYm2xVqzASXmJBw2IjRcJ7M1BMhx2ZYBmhTWAN+52iLB+2MHQuFR/FWc8WHeU/fGUssURsDHLlEol9ShmbcpqOJ3yK3YyUHoxV7bqF66NO5S/qkUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7571 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF00009526.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6a0b68ff-a08a-4946-0673-08dedc3f6f3f X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|376014|82310400026|36860700016|1800799024|14060799003|35042699022|18002099003|56012099006|11063799006|6133799003|22082099003; X-Microsoft-Antispam-Message-Info: LPEXnrBhRAr2Lvq/DXtGDn4B0e0qDkZZ/XCRgTNB38V10u4zc4SB4rfsLHcb3H4KofRqNkxPwNT1Nxn0Z56rdx/e0JUQKqNZy3CW1LIRFSFClEqjabUMiAEaBzEpZ2lfryqNUbXP1ZcomMOP1MHWdCXB4XYOAqkDwgUqi7yG7kLURH+gKHpVVB3rwVzNiVWJzrX/fL5axc1zRGEhFxXz+mSprUdYzi0F/02XNXyDTB42vU+pFGLp5nC73xMQjCIB25FhF7NVoJsjA6KeuRlQAgUuyu9ExvccuUQ5rMgdgVw9eHrvjDNyCKMzEMC9M0Nh+WgAMljkoFllCoelW49TUwIv2iIMcSP4DhUkotVWA3dxpJcYXk2looZjcjvu+GsAUYDd+/xOLMxnKA++fOCxsdw4l2NicT7zVhkG5kkQRievmJb1cSSEL4fY1QzYjjsdhUuz76eDK2AkR1/nPaRsylLhW2RdyNO+uT7DEDKeJNM1HCKyknM5rg5wD6KBHWOQWWTe56AXDiSeyL5oJKMa//7TzjT1nwearFr4cmqilMg3V6zi+oT6UVHEZifSAApeeNd2KYSF8fKUgrnZakyk/G58TSeMQ2TWjuIHQ86qUpHyvpZmNoaWqnvh++VQikrnmcPjF/1zyMTjvoF8FzLcdDOs6RcUhOWTKiKJXz5SE5uOxPtO93vyiwx9zsUTrwtiCClneKxIR7Ef4QfKE6GSCw== X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(376014)(82310400026)(36860700016)(1800799024)(14060799003)(35042699022)(18002099003)(56012099006)(11063799006)(6133799003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vzuzJc2U8Q4puRuUxhB2NMS1yczKiSm+/+oRLjfzdh5E5Zn5huPHVlLm+06ddlv2oNBvMg48G4PTZUh+IFXaeodIw5ls5azMgGmkOLWutZzv5hKKopH1fquyn2ph7eVv5H83Bofu6zg5Cy3Wo+5/c0SHoU9Xw4OwQc6rbr1izz+sGfm4w7mb0+Lspv/ZoN1tczd1fo1c21O9A0DFCGAWMj0e80JWaKnw9fzKcrh9zstlwrv92I/9oDnLZl85a3xlVxi5QNF9lyYbRZ09IKmTXAhyS7v61Cj5FQCiSL7heTRpiW51gXBxjponwTp6kqoNrFn7Or4hOcHJ2M0ZEiocr8Z3sGMr1ol82JyDobCsHzHirmOoVGshk1bVbCkofqIb1PhFTOUH2L3hZfky7yCOXVtqLOIApORqFZlEFH5UEnCTgZ9WiHl9vViNw8IMb61j X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2026 15:51:18.9759 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 993ac96d-0f3c-47c1-3bb9-08dedc3f9601 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: DU6PEPF00009526.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10042 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 Wrap all the boilerplate code required to read a file in a new helper class: file_reader_t. The class owns the file contents together with the file path, and provides convenient accessors for the data, size and typed views. It supports both null-terminated text files and binary files. This helper eliminates repeated calls to target_fileio_read_stralloc and target_fileio_read_alloc, remove explicit memory management with gdb::unique_xmalloc_ptr, and simplifies the casting logic when working with binary data. The patch converts some of the existing Linux, AMD64, and SPARC code that reads files from /proc to use file_reader_t. --- gdb/amd64-linux-tdep.c | 12 ++--- gdb/linux-tdep.c | 102 +++++++++++++++++------------------------ gdb/sparc64-tdep.c | 12 ++--- gdb/target.h | 65 ++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 74 deletions(-) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index a5ac26654cf..e7841917eaf 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1851,14 +1851,11 @@ amd64_linux_lam_untag_mask () if (inf->fake_pid_p) return DEFAULT_TAG_MASK; - const std::string filename = string_printf ("/proc/%d/status", inf->pid); - gdb::unique_xmalloc_ptr status_file - = target_fileio_read_stralloc (nullptr, filename.c_str ()); - - if (status_file == nullptr) + file_reader_t proc_status (string_printf ("/proc/%d/status", inf->pid)); + if (!proc_status) return DEFAULT_TAG_MASK; - std::string_view status_file_view (status_file.get ()); + std::string_view status_file_view (proc_status.data ()); constexpr std::string_view untag_mask_str = "untag_mask:\t"; const size_t found = status_file_view.find (untag_mask_str); if (found != std::string::npos) @@ -1870,7 +1867,8 @@ amd64_linux_lam_untag_mask () unsigned long long result = std::strtoul (start, &endptr, 0); if (errno != 0 || endptr == start) error (_("Failed to parse untag_mask from file %ps."), - styled_string (file_name_style.style (), filename.c_str ())); + styled_string (file_name_style.style (), + proc_status.c_filepath ())); return result; } diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index b89f4ee0717..a12a69f03a2 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1661,6 +1661,12 @@ parse_smaps_data (const char *data, return smaps; } +static std::vector +parse_smaps_data (const file_reader_t &freader) +{ + return parse_smaps_data (freader.data (), freader.filepath ()); +} + /* Helper that checks if an address is in a memory tag page for a live process. */ @@ -1672,17 +1678,13 @@ linux_process_address_in_memtag_page (CORE_ADDR address) ptid_t ptid = current_inferior ()->first_alive_thread (); - std::string smaps_file = string_printf ("/proc/%ld/smaps", ptid.lwp ()); - - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (NULL, smaps_file.c_str ()); - - if (data == nullptr) + file_reader_t smaps_freader + (string_printf ("/proc/%ld/smaps", ptid.lwp ())); + if (!smaps_freader) return false; /* Parse the contents of smaps into a vector. */ - std::vector smaps - = parse_smaps_data (data.get (), smaps_file); + std::vector smaps = parse_smaps_data (smaps_freader); for (const smaps_data &map : smaps) { @@ -1746,17 +1748,13 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, if (use_coredump_filter) { - std::string core_dump_filter_name - = string_printf ("/proc/%ld/coredump_filter", ptid.lwp ()); - - gdb::unique_xmalloc_ptr coredumpfilterdata - = target_fileio_read_stralloc (NULL, core_dump_filter_name.c_str ()); - - if (coredumpfilterdata != NULL) + file_reader_t coredump_filter_freader + (string_printf ("/proc/%ld/coredump_filter", ptid.lwp ())); + if (coredump_filter_freader) { unsigned int flags; - sscanf (coredumpfilterdata.get (), "%x", &flags); + sscanf (coredump_filter_freader.data (), "%x", &flags); filterflags = (enum filter_flag) flags; } } @@ -2259,9 +2257,6 @@ linux_corefile_parse_exec_context (struct gdbarch *gdbarch, bfd *cbfd) static bool linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) { - /* The filename which we will use to obtain some info about the process. - We will basically use this to store the `/proc/PID/FILENAME' file. */ - char filename[100]; /* The basename of the executable. */ const char *basename; /* Temporary buffer. */ @@ -2285,23 +2280,24 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) /* Obtaining PID and filename. */ pid = inferior_ptid.pid (); - xsnprintf (filename, sizeof (filename), "/proc/%d/cmdline", (int) pid); - /* The full name of the program which generated the corefile. */ - gdb_byte *buf = nullptr; - LONGEST buf_len = target_fileio_read_alloc (nullptr, filename, &buf); - gdb::unique_xmalloc_ptr fname ((char *)buf); + file_reader_t cmdline_freader + (string_printf ("/proc/%d/cmdline", pid)); + if (!cmdline_freader) + return false; - if (buf_len < 1 || fname.get () == nullptr || fname.get ()[0] == '\0') + /* The full name of the program which generated the corefile. */ + gdb::array_view cmdline = cmdline_freader.cast_view (); + if (cmdline.size () < 1 || cmdline[0] == '\0') { /* No program name was read, so we won't be able to retrieve more information about the process. */ return false; } - if (fname.get ()[buf_len - 1] != '\0') + if (cmdline[cmdline.size () - 1] != '\0') { warning (_("target file %s " "does not contain a trailing null character"), - filename); + cmdline_freader.c_filepath ()); return false; } @@ -2311,27 +2307,23 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) p->pr_pid = pid; /* Copying the program name. Only the basename matters. */ - basename = lbasename (fname.get ()); + basename = lbasename (cmdline.data ()); strncpy (p->pr_fname, basename, sizeof (p->pr_fname) - 1); p->pr_fname[sizeof (p->pr_fname) - 1] = '\0'; const std::string &infargs = current_inferior ()->args (); /* The arguments of the program. */ - std::string psargs = fname.get (); + std::string psargs = cmdline.data (); if (!infargs.empty ()) psargs += ' ' + infargs; strncpy (p->pr_psargs, psargs.c_str (), sizeof (p->pr_psargs) - 1); p->pr_psargs[sizeof (p->pr_psargs) - 1] = '\0'; - xsnprintf (filename, sizeof (filename), "/proc/%d/stat", (int) pid); - /* The contents of `/proc/PID/stat'. */ - gdb::unique_xmalloc_ptr proc_stat_contents - = target_fileio_read_stralloc (NULL, filename); - char *proc_stat = proc_stat_contents.get (); - - if (proc_stat == NULL || *proc_stat == '\0') + file_reader_t stat_freader (string_printf ("/proc/%d/stat", pid)); + char *proc_stat = stat_freader.data (); + if (!stat_freader || *proc_stat == '\0') { /* Despite being unable to read more information about the process, we return true here because at least we have its @@ -2403,13 +2395,9 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) /* Finally, obtaining the UID and GID. For that, we read and parse the contents of the `/proc/PID/status' file. */ - xsnprintf (filename, sizeof (filename), "/proc/%d/status", (int) pid); - /* The contents of `/proc/PID/status'. */ - gdb::unique_xmalloc_ptr proc_status_contents - = target_fileio_read_stralloc (NULL, filename); - char *proc_status = proc_status_contents.get (); - - if (proc_status == NULL || *proc_status == '\0') + file_reader_t status_freader (string_printf ("/proc/%d/status", pid)); + char *proc_status = status_freader.data (); + if (!status_freader || *proc_status == '\0') { /* Returning true since we already have a bunch of information. */ return true; @@ -2802,9 +2790,6 @@ linux_gdb_signal_to_target (struct gdbarch *gdbarch, static bool linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) { - char filename[100]; - long pid; - if (target_auxv_search (AT_SYSINFO_EHDR, &range->start) <= 0) return false; @@ -2842,7 +2827,7 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) if (current_inferior ()->fake_pid_p) return false; - pid = current_inferior ()->pid; + long pid = current_inferior ()->pid; /* Note that reading /proc/PID/task/PID/maps (1) is much faster than reading /proc/PID/maps (2). The later identifies thread stacks @@ -2852,15 +2837,14 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) a few thousand threads, (1) takes a few milliseconds, while (2) takes several seconds. Also note that "smaps", what we read for determining core dump mappings, is even slower than "maps". */ - xsnprintf (filename, sizeof filename, "/proc/%ld/task/%ld/maps", pid, pid); - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (NULL, filename); - if (data != NULL) + file_reader_t task_maps_freader + (string_printf ("/proc/%ld/task/%ld/maps", pid, pid)); + if (task_maps_freader) { char *line; char *saveptr = NULL; - for (line = strtok_r (data.get (), "\n", &saveptr); + for (line = strtok_r (task_maps_freader.data (), "\n", &saveptr); line != NULL; line = strtok_r (NULL, "\n", &saveptr)) { @@ -2879,7 +2863,8 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) } } else - warning (_("unable to open /proc file '%s'"), filename); + warning (_("unable to open /proc file '%s'"), + task_maps_freader.c_filepath ()); return false; } @@ -3168,16 +3153,11 @@ linux_address_in_shadow_stack_mem_range const int pid = current_inferior ()->pid; - std::string smaps_file = string_printf ("/proc/%d/smaps", pid); - - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (nullptr, smaps_file.c_str ()); - - if (data == nullptr) + file_reader_t smaps_freader (string_printf ("/proc/%d/smaps", pid)); + if (!smaps_freader) return false; - const std::vector smaps - = parse_smaps_data (data.get (), smaps_file); + const std::vector smaps = parse_smaps_data (smaps_freader); auto find_addr_mem_range = [&addr] (const smaps_data &map) { diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 93db3417a2a..811b76f27d8 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -305,14 +305,13 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) size_t i = 0; pid_t pid = inferior_ptid.pid (); - snprintf (filename, sizeof filename, "/proc/%ld/adi/maps", (long) pid); - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (NULL, filename); - if (data) + file_reader_t adi_maps_freader + (string_printf ("/proc/%d/adi/maps", pid)); + if (adi_maps_freader) { adi_stat_t adi_stat = get_adi_info (pid); char *saveptr; - for (char *line = strtok_r (data.get (), "\n", &saveptr); + for (char *line = strtok_r (adi_maps_freader.data (), "\n", &saveptr); line; line = strtok_r (NULL, "\n", &saveptr)) { @@ -329,7 +328,8 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) } } else - warning (_("unable to open /proc file '%s'"), filename); + warning (_("unable to open /proc file '%s'"), + adi_maps_freader.c_filepath ()); return false; } diff --git a/gdb/target.h b/gdb/target.h index 4215553033c..d6fc101f205 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -2338,6 +2338,71 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf, extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc (struct inferior *inf, const char *filename, size_t *len = nullptr); +/* Helper class for reading a file. */ +template +class file_reader_t +{ + /* The filepath of the file being read. */ + std::string m_filepath; + /* Smart pointer to the data. */ + gdb::unique_xmalloc_ptr m_data; + /* Size of the data. */ + size_t m_size; + +public: + file_reader_t (const std::string &filepath) + : m_filepath (filepath) + , m_size (0) + { + if constexpr (std::is_same_v) + m_data = target_fileio_read_stralloc (nullptr, m_filepath.c_str (), + &m_size); + else + { + gdb_byte *buf = nullptr; + m_size = target_fileio_read_alloc (nullptr, m_filepath.c_str (), &buf); + m_data = gdb::unique_xmalloc_ptr (reinterpret_cast(buf)); + } + } + + /* Return true if the file was read successfully. */ + operator bool () const noexcept + { return m_data != nullptr && m_size > 0; } + + /* Return a pointer to the data. */ + T *data () const noexcept + { return m_data.get (); } + + /* Return the size of the data. */ + size_t size () const noexcept + { + /* For char buffers, size() corresponds to the size of the read data. Some + null-terminator characters are possibly scattered throughout the data. + Consequently, strlen() might not reflect the actual size. */ + return m_size; + } + + /* Return a span of the data. */ + gdb::array_view view () const noexcept + { return gdb::array_view (m_data.get (), size ()); } + + /* Return a span of the data, cast to a different type. */ + template + gdb::array_view cast_view () const noexcept + { + return gdb::array_view (reinterpret_cast (m_data.get ()), + size () * sizeof (T) / sizeof (U)); + } + + /* Return the filepath of the file that was read. */ + const std::string &filepath () const noexcept + { return m_filepath; } + + /* Return the filepath of the file that was read as a C string. */ + const char *c_filepath () const noexcept + { return m_filepath.c_str (); } +}; + /* Invalidate the target associated with open handles that were open on target TARG, since we're about to close (and maybe destroy) the target. The handles remain open from the client's perspective, but -- 2.55.0