From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6aPAIbgzf2r+tCUAWB0awg (envelope-from ) for ; Fri, 14 Aug 2026 11:26:48 -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=ZKshAiPp; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ZKshAiPp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 842C01E0A3; Fri, 14 Aug 2026 11:26:48 -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=unavailable 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 BDDAA1E09B for ; Fri, 14 Aug 2026 11:26:47 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54F404BA79BB for ; Fri, 14 Aug 2026 15:26:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54F404BA79BB 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=ZKshAiPp; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ZKshAiPp Received: from PA4PR04CU001.outbound.protection.outlook.com (mail-francecentralazon11013003.outbound.protection.outlook.com [40.107.162.3]) by sourceware.org (Postfix) with ESMTPS id 0ED324BA7987 for ; Fri, 14 Aug 2026 15:26:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0ED324BA7987 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 0ED324BA7987 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.162.3 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1786721180; cv=pass; b=Bdq1Ga9CQ4zuU21+Cb9H6Q6LoPJ32HbKXJbCjv5kaLRhBK1jtZYVneKxwas4UPwpg2cxmvZ3Qqn4sjcfk9GRz5Uz/Z9LMcczdG+4oO0CJVWjqOa2GXE3LVjfFgPNKHtD+Gb74MebGuvawRZ5Ccj3teotoGw73J+hTkVm3/mKmwo= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1786721180; c=relaxed/simple; bh=pDs+WmlZ25XuNP4Y5OMluUqGZ6Epd2HC/Nu58m//UnI=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=pgUxjka0JpS+v0Xm7tb30ERv4dBVI1g5oETZ7VeWvkmyd8up8YZWk+Z5qkUdcgAlps7Ni6dAbdJAQrdLUy8fWxjfWbZzArRt0oWALbsBGzpasZ8X3/tEEEe1fHwHCWd22tdjubfjvlHkqAfTuzoXJrOeVPV0X7ASGUP6lXVmPWI= 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=ZKshAiPp; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ZKshAiPp DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ED324BA7987 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=IY3PVvrF7uwzxFk3Kr5z5FAQllYxvKKlcXtibw/qiGrhn2yiwPAn/go4lkAGwcR2tCYQtbRdoZ/V2vjGQX9QqyVYPQREpoD3ZTOAyG5+roMLQo5jaPc502CYVfGH4aeokqNVy3Hp2GuIAxn4FBf6oMpUmz3+w3PkCzT/gs+6XWirKOk7USsB+BA4z5f/A17jvLudo/Mee+F9eBh71+/xJCWOtQ8yXIT9ntVYWJTE4gxLfjZjs1gnJdpeDPcvyM/yDuW4Njozr5h5CKAOiVb6c5pdEo4hacngbmMo7ZDIazXVo8ejk9zIT0aMTxS3xzca0RM4CztGO2CueprtrK2UrQ== 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=/+e5FJzR5L4vT1krigD3AOBqNs2SgPqX7picXYl6P7A=; b=kscjaAu6y8986niuWDvcraV9ebzTsGlwo+ggERjUvWHe0MzqjZn0ANMbkEtohKSAM26YtIvuZL/Y2GIeC4YiPKkYTDq73u/ngLxvzuv3WFE7qFZy0OQwIQWkBR56UVZbY1H/tA8qKrYAdPGsc7fh1yYAQgFt3G37XK+UOWGcPQq0hUKZM1pVAGsPi5nCNaa2f4V1rL8EeeeF1nXKjirbakhxCAKx/B2MOmcw7CoF+9FdjdUYpW8zXYseCm2I9K/0OrhNd4UvFHWh75j1HD7AjTVjPyNpivlaRWSnzQIO2FtSwJ/2/tmW1wt5UlIU7k3C9du902vWvBpsrxFIsYh5kg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=intel.com 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] dkim=[1,1,header.d=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=/+e5FJzR5L4vT1krigD3AOBqNs2SgPqX7picXYl6P7A=; b=ZKshAiPpghZCJW6KQVYsWAfKxKK8tptn9Smx3LdPjDz7tiTvzqw+l8Ww5HBMlIo2/GJlWg074wnIWLEWaDkc4LcRDZL9FYx9Z4SYAKvis2ljeiiFzOlJl1mGgD8V8WF3b2n/zDtvmx2vE6P+NOFqlUiuE8WylRNg4pti6t79Kxs= Received: from DUZPR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::16) by AS8PR08MB6023.eurprd08.prod.outlook.com (2603:10a6:20b:291::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.16; Fri, 14 Aug 2026 15:26:13 +0000 Received: from DB1PEPF000509E8.eurprd03.prod.outlook.com (2603:10a6:10:469:cafe::3e) by DUZPR01CA0047.outlook.office365.com (2603:10a6:10:469::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.16 via Frontend Transport; Fri, 14 Aug 2026 15:26:13 +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 DB1PEPF000509E8.mail.protection.outlook.com (10.167.242.58) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.3 via Frontend Transport; Fri, 14 Aug 2026 15:26:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LtEzQkG6ttz+wgywfgXfg8KT5/vSbhZy3C2N4sfoby9YQyK0LsbkO8IU6Pc2DfkMyk8F3sO7uca+b9mL08VSb8prGVzFaa0yaKIczB5pd8UEDncHF+UKaAR9uNp6BPvuuGsqAfrCQR2MXWLt8xD6SqSRvcMzzQgw/vLiv7OT/GaTBKUlFKrgBuJ2Ny+qgsOZGqTv2CjFbjw9epHRuSiznO/MDYX2gMFY5wzO7ByEVs3dRG+1E8rdmDcuj5PjTZV78E0qLfZuA8IJRg1957FkuPKFKrP21HFQ46ILI5By5Dne8tecSUiS0V5Ci4ZJTW7BoQQihh6wgVuoSValViswNg== 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=/+e5FJzR5L4vT1krigD3AOBqNs2SgPqX7picXYl6P7A=; b=IsgnaIo1x+Uv3wGY2jZJW+pN9L5HowhrQaqagoFzHDQ+QVBCGXGnHKV0/i3HD0rS3QYIEFaVcz2hIwtjtH+7UHkc4q0cfvPOzskQvDgdGj1XLhAi3SH8XZDLWr+bY7MkKUgXfuFt10/+2rRMlysOMfFFvBNlbpauVOb7UuJFUcJbL/yQQFN844Q5ZOytCjNWnM6V2rv2Q/qzl3NG/mxFzaZeH/vITM0cdZrUuo4PmjmdunnyONIhX/iwCGY5sdJ3RplXybxabeA/+eIPzCiSeDgM5TBbF8QojTJ3M7Qtn8YlIf+7ZKAIyelc14/cFXzYOfecM1h/ZgAYmXpBQpX+RQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none 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=/+e5FJzR5L4vT1krigD3AOBqNs2SgPqX7picXYl6P7A=; b=ZKshAiPpghZCJW6KQVYsWAfKxKK8tptn9Smx3LdPjDz7tiTvzqw+l8Ww5HBMlIo2/GJlWg074wnIWLEWaDkc4LcRDZL9FYx9Z4SYAKvis2ljeiiFzOlJl1mGgD8V8WF3b2n/zDtvmx2vE6P+NOFqlUiuE8WylRNg4pti6t79Kxs= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from GV1PR08MB8667.eurprd08.prod.outlook.com (2603:10a6:150:85::13) by MI9PR08MB781463.eurprd08.prod.outlook.com (2603:10a6:290:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.15; Fri, 14 Aug 2026 15:25:41 +0000 Received: from GV1PR08MB8667.eurprd08.prod.outlook.com ([fe80::ae9c:f011:dbb4:c095]) by GV1PR08MB8667.eurprd08.prod.outlook.com ([fe80::ae9c:f011:dbb4:c095%2]) with mapi id 15.21.0315.014; Fri, 14 Aug 2026 15:25:40 +0000 Message-ID: <2c974a80-9ad6-4b46-a6a9-33a8e710d372@arm.com> Date: Fri, 14 Aug 2026 16:25:39 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 3/6] gdb: introduce helper class file_reader_t To: "Joos, Christina" , "gdb-patches@sourceware.org" Cc: Luis Machado , Luis Machado , Thiago Jung Bauermann , Simon Marchi , Kevin Buettner References: <20260728151700.253720-1-matthieu.longo@arm.com> <20260728151700.253720-4-matthieu.longo@arm.com> Content-Language: en-US From: Matthieu Longo In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0278.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:195::13) To GV1PR08MB8667.eurprd08.prod.outlook.com (2603:10a6:150:85::13) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: GV1PR08MB8667:EE_|MI9PR08MB781463:EE_|DB1PEPF000509E8:EE_|AS8PR08MB6023:EE_ X-MS-Office365-Filtering-Correlation-Id: cf44e06e-f0c8-473c-32ac-08defa185fea x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|23010399003|366016|376014|1800799024|56012099006|10067099003|22082099003|18002099003|4143699003|11063799006; X-Microsoft-Antispam-Message-Info-Original: qdD/wByUkihfKAOBxC+GvAx/kwOO4UF+AJGIfZbY37bdf8aTac79G8t5NUHKTHaBv6osUexLV5VbSTVOz0nhsIjZiARyPR4kEQuTxIjxUDsPS0JL74HdkoaVNPi3RaTGLUCQiwjDI7r/BUThseWLhIIHrzNqOQ4/GGldD8zzAKNZIQYdAGdrGwMKyDThO0EhlFNHZDZASW41l/u9c+bnI7sRBwEE1Ka/WXVp0j93Gg46BTm4IIYs1cx7MPM44REgSsCbSXsrqaM3i0vkBHrHedLJIbATnzM2NVa1S8bqEPpKlh/FsA+FWy2oPhhf2nX76v87ecdC8lApihOPZgXQ/7yM4Lan3dZbBzsdglRhEDs/dtRZtsagx+iisA1TgBxFImQRmMLb+ByU/mAAnFw6yPOLSIGIfs8hPKUJ2HAZaCoG04C16nAr1zJm2QQskbvAyFP980J5xP5DCSZhkFbVxr5o9uhxXA6W8iYPm1b5UUQpGu2pSXFJF66E0kcOo1wW2IDskJMomtMBLhvQZB3245U5IiV5P+vOB8iTle6XzbsU57x0y15KdH+K6cTXs8Ff6dMYIgrQtl2U6VGG6zo6HQBSFwjPXQfn84EWY3wkFsyZnTVdgdVvgKyinHGifdjWEtheq87lHHrJ3F0+1HLnhSH60SuTsEOlDXCJU6NjhkY= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV1PR08MB8667.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(366016)(376014)(1800799024)(56012099006)(10067099003)(22082099003)(18002099003)(4143699003)(11063799006); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: aHjZO8g0cv3R32YZzmSuGWRoFDfT8YqA1V+tvUeBNh7g+fbgqVl/fZVFKx0lUdiIrfDOsCN2oAJtuqXpuMDabBnY6luUV2P8fLtj6R34B+f0HjUVk7AHzWQliWCSzRWsrSQD7+RdjtZgSKMvFu7Hp42PKyx/yxlEIZ6Zyz2/CoNiku1ZYbCjQpqive6auXu3mdAlfElz4nAMJJRJ4Wl1YO9g1rN0DKQGUx3F6L16k8HzWMswU6l6JHjKonYy8XkuS0woeKF2OtwTZjuL8/Mng2UJQ9kV8vN3YPxBoSXNQXNgCyhBgdUFwJreTUvrC5VmPQoORuFxn2DfaKP1OYgtsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MI9PR08MB781463 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509E8.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ef1eca5e-3d24-4193-b292-08defa184c96 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|35042699022|36860700016|14060799003|23010399003|82310400026|376014|56012099006|10067099003|18002099003|22082099003|11063799006|4143699003; X-Microsoft-Antispam-Message-Info: eE6Sg3R20EDnnxxYIOEMzpxhtZh/R/Jix7CUSBJjO7perg1UXxyFmc6ug0V5iFbFCD8zxiv7Ynyp3awocHdLpxLxruMC/fRT9jEuqtdfXHJUgMVZs28Dd0qNSC3NdTNtv5tqbMnFSAmln4ATaGr9u9cH6fvge+7LXwHxtoaZcUJArNjqlQ3b/D2MamGwBBygEBSW07iejQUQsP08c5vWZPYL1rwRadpX2zVZQqYbR0GlnLAAL0w+fUbkrVXRYjC0JZCcApxlrq+Qs7JWDWwu6gl2ZFEhAcWAtm1r8cPjlGQIUP/VLxcumZsUwlXd6Oaa78d08yiljoiCc1TJySJOEEZlNroxpp6+mr2a/4RqOaLrxx5S3cjKQ93E1m/R5FMqTBGwHNAdSTdUb6CZew56KJlUhhNWjTtu2HsJGiTHL7bKhEW7gFPw0lwqnW6jSHIW2d3iBVpCaW30N+H0G753tb5EHeOwXKbtE9TdfADTSbBxBycWla5xdunJJyv/xbXgqDEdiQ6g/Br+khuvijK8XAS0xG9YJCC/zFq8A5gcooGL0ar8wq8rDs7FiIej87oG7K+ZRA9yA8EZET6fPbWTioOzJnDzrlpS+2OLk4ahr3Vr8TO9fe1n2JdcfzRwkCTLZ7Au8D4V0wlkZjNK/kT09XO8Elq2VdAnDGjKGhsLy7jm+TYiv4XNi55LcfzYaRQFawtdn1ldWd/FkwPBzC6PZA== 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)(1800799024)(35042699022)(36860700016)(14060799003)(23010399003)(82310400026)(376014)(56012099006)(10067099003)(18002099003)(22082099003)(11063799006)(4143699003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FIha/KInFDpnSAKXoCpHYpO1gVN90Lk+pmPcpv7P6s8/Ah3Qbyf3zh6oRtoaVDY3K6NAvSr4OU6dsRMrGnSb6HzUDl3YHz49S54Mvf/XUrtvcX8FTZDQKiBhJYGQFlFPRdhkC8usfpjvatmgbjm7W7+9zju3v7AHis7c03/Qqm8j0XIm63qzhhh4wx5wGxtWgUhkFaxm+XZxenXfJfbwmz+w5Mf3IPuI4ZKl/YP1PTWTz43yRwyqJXLn86nOGNPNeV4mFiygoZzqJC9P4RFhLsz5EwQryiI3so2tl55vYsUJpId7O3rL6iiFEJC4q1oVdHdtVCHoI0Ks3C0hMUPrv5AxeVNMhp5ANaA1T0hRPNBbWe7eNalKrMm46lA44CAFv/Vl6duFgCsciSAkyOYkcPBDiuExzvq/toAPZExYbRdWTG/6eVIuSLCcEH2Fr72k X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2026 15:26:12.7389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf44e06e-f0c8-473c-32ac-08defa185fea 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: DB1PEPF000509E8.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6023 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 10/08/2026 14:07, Joos, Christina wrote: > Hi Matthieu, > > Please find my feedback below. > >> -----Original Message----- >> From: Matthieu Longo >> Sent: Dienstag, 28. Juli 2026 17:17 >> To: gdb-patches@sourceware.org >> Cc: Luis Machado ; Luis Machado >> ; Thiago Jung Bauermann >> ; Simon Marchi ; Kevin >> Buettner ; Joos, Christina ; >> Joos, Christina ; Matthieu Longo >> >> Subject: [PATCH v1 3/6] gdb: introduce helper class file_reader_t >> >> 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 | 109 ++++++++++++++++++----------------------- >> gdb/sparc64-tdep.c | 13 +++-- >> gdb/target.h | 79 +++++++++++++++++++++++++++++ >> 4 files changed, 137 insertions(+), 76 deletions(-) >> >> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index >> 9bdcc55a0e1..11f0a6952ea 100644 >> --- a/gdb/linux-tdep.c >> +++ b/gdb/linux-tdep.c >> @@ -1698,6 +1698,12 @@ parse_smaps_data (const char *data, >> return smaps; >> } >> >> +static std::vector > > Nit: we should omit the struct keyword here. > Fixed. And in others places where it is relevant. >> +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. */ >> >> @@ -1709,17 +1715,13 @@ linux_process_address_in_memtag_page >> (CORE_ADDR address) >> >> ptid_t ptid = get_process_reference_ptid (); >> >> - 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); > > Like amd64_linux_lam_untag_mask we have a minor behavioural change here. > But I again see it as an improvement, as the result should be the same, we just > return earlier. There might be some more cases in linux-tdep.c, but I did not check > all of them. > > I think it's worth pointing out in the commit message. > Amended this paragraph in the commit message: The patch converts some of the existing Linux, AMD64, and SPARC code that reads files from /proc to use file_reader_t. As a side effect, amd64_linux_lam_untag_mask and linux_process_address_in_memtag_page may now return earlier in case the file is empty. >> diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index >> 93db3417a2a..955631b87df 100644 >> --- a/gdb/sparc64-tdep.c >> +++ b/gdb/sparc64-tdep.c >> @@ -301,18 +301,16 @@ adi_tag_fd () >> static bool >> adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) { >> - char filename[MAX_PROC_NAME_SIZE]; >> 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.error ()) > > Didn't you mean > if (!adi_maps_freader.error ()) > > ? > Yes, you're right. However, I am wondering why the diagnostic message is not an error instead of warning. Any idea ? I would also like to change the program flow to something like: file_reader_t adi_maps_freader (string_printf ("/proc/%d/adi/maps", pid)); if (adi_maps_freader) { // This is skipped when the file is empty ... } else if (adi_maps_freader.error ()) error (_("unable to open /proc file '%s'"), adi_maps_freader.c_filepath ()); return false; >> diff --git a/gdb/target.h b/gdb/target.h index 819279c08fc..09830dfe3a9 >> 100644 >> --- a/gdb/target.h >> +++ b/gdb/target.h >> @@ -2341,6 +2341,85 @@ extern LONGEST target_fileio_read_alloc (struct >> inferior *inf, extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc >> (struct inferior *inf, const char *filename, LONGEST *len = nullptr); >> >> +/* Helper class for reading the content of a file on the target. */ >> +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; >> + /* Number of bytes read. */ >> + LONGEST 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)); >> + } >> + } >> + >> + file_reader_t (file_reader_t &&other) >> + : m_filepath (std::move (other.m_filepath)) >> + , m_data (std::move (other.m_data)) >> + , m_size (other.m_size) >> + {} > > I hope I get the C++ rules right here: > AFAIK, since we have the move constructor, we implicitly delete the copy > constructor and the copy assignment operator. > > Wouldn't it be clearer if we'd write this explicitly using DISABLE_COPY_AND_ASSIGN ? > I agree. Added. > I also wondered if the default move constructor is doing the same thing, so we could write sth. like: > file_reader_t (file_reader_t &&other) = default; > > instead. > Fixed as follows: file_reader_t (file_reader_t &&) = default; file_reader_t &operator= (file_reader_t &&) = default; DISABLE_COPY_AND_ASSIGN (file_reader_t); >> + /* Return true if the file was read successfully but contained no >> + data. */ bool empty () const noexcept { return m_data != nullptr && >> + m_size == 0; } >> + >> + /* Return true if the file could not be read. */ bool error () >> + const noexcept { return m_data == nullptr || m_size < 0; } >> + /* Return true if the file was read successfully and is non-empty. >> + */ explicit operator bool () const noexcept { return !(error () || >> + empty ()); } > > To me it would feel more natural if we return true also in case the file is empty. > Then we could also omit the error function. > > But I don't have a very strong opinion about this. > > > Christina The cases where we use .error (), the alternative should check whether the file is not empty. From this perspective, including !.empty () in the boolean operator makes sense. See for instance linux_vsyscall_range_raw or adi_is_addr_mapped, the loop with strtok_r() will be skipped if the content is empty. Matthieu