From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id tXyWLryRZ2pUbjAAWB0awg (envelope-from ) for ; Mon, 27 Jul 2026 13:13:32 -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=Z7lVbwFa; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=Z7lVbwFa; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AB8161E09E; Mon, 27 Jul 2026 13:13:32 -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 [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 73EC31E099 for ; Mon, 27 Jul 2026 13:13:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A00A4BAE7FC for ; Mon, 27 Jul 2026 17:13:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A00A4BAE7FC 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=Z7lVbwFa; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=Z7lVbwFa Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11012017.outbound.protection.outlook.com [52.101.66.17]) by sourceware.org (Postfix) with ESMTPS id 902D44BA79A5 for ; Mon, 27 Jul 2026 17:13:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 902D44BA79A5 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 902D44BA79A5 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.101.66.17 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1785172383; cv=pass; b=SRJhDzNbvd6VHDqUsMXKMU4gAd430ONupRGpil/OJaKoQxrtXTIablrpZKCsoRT+08jgAKWieOqlyDdBJEXkTgi3QBcdVGX8NR3oi/tUadeQQcpHJ7he0bqhrb+cvZT3WJmxDTQw1gJ9ELHbMWkxq6jhxZRuZnMWVZse+yjTJls= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1785172383; c=relaxed/simple; bh=YAZ6eCaxKujwTdfhaV5wyzi9Ogz3Pu/zzSCgaTeAFj8=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=W0Db7cstLQS2rfoTy3sj6MtWvLP7ScscjPMwJ6TydY5B/3SK3kwbpBy2l8DHe06heZZRN0FatVIMw0QbYn6K3h6LX8m3HzfDMatm6Gh3c5zjaRAoxyXyRjksIDoZpkQ7v20YPLjDAEWbFOE1gp77i4h3Dg+KvBIExJTtWOWAV0E= 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=Z7lVbwFa; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=Z7lVbwFa DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 902D44BA79A5 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=UD2Qtfak7bzXBEEvyFhxObu2B7NcuVILqFeudTb9f8kwqtRI9Z14fkWovlVGHHPvBR8vgMraYSzs61A/2GoIo9hgIxdm7flzXkxvNx1BJpW8yMeDrp+5OTHjLFiin5y9IJa7Z9sc6NbVMmYNyVAaD3GnsHEbjVTr7ySfdw9echDN+fg78bcK4oo4ckmnMjUr0iPM8X2OgOv9pSYyDXtScdUocwL7F1UZisym0sukA+ZrGQ7ViXLq8PWUuo3eEhz0UXVJ74nbpglDixkUE5Dh+Q/Bt4JKaTaCGTFJMpT9dfgQ6S2Jqpky7hTF0nqtwZixKtEARxE+0ZxDZEnAi6lAIA== 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=67R4yCn/HtrI6UoYqa4Pu98xRRmSgWEWd74OHnGeSfA=; b=zQM506/alN4GNDRcbL23zBXIisarUaZ4kvqjqvuqbEPi9pdCAjfB1VNVq4ZA+yAocxDacm13WtdeGaCf6Sx1iUeGI3G6ATIGsX0GR+f0Lma/TN4sgPl+zdWgDBeY/PklKb40pG4dXbjucNH+KEkYceDd59x75CJT7mswabDs3eDoYuoV5iY643rAAD5yIS/qZ88LggkBFMduoKAWR+oGvKLrX3Qk2DT+o+JOcMlbWxMNaCVtK1q5KvcqR3qA88I4KiOUvI0gxw7xDsbnfyBXGmhd02UeY1yON6qJfnhpsGqR55GdnHalZewLPymO8takC2691zuRK6VinChwzls1Rg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=gmail.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=67R4yCn/HtrI6UoYqa4Pu98xRRmSgWEWd74OHnGeSfA=; b=Z7lVbwFa6eJeZHmVTTbj3PhBeoXeNw84fLkAbSRLipJ+ROi7SAYADEgVcUqtjvWvb66zf2169Lp0vVfpb9vlpOuWFLJ7xJ4VGD5q3K33JwOxu4GLkuVo89SY+oiMph4yhqD5ef89OZnhw+n3YNYAXxJXiszSO3/uSeXBPoe0w+k= Received: from DUZPR01CA0317.eurprd01.prod.exchangelabs.com (2603:10a6:10:4ba::27) by AM9PR08MB6196.eurprd08.prod.outlook.com (2603:10a6:20b:283::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.13; Mon, 27 Jul 2026 17:12:49 +0000 Received: from DU2PEPF0001E9C4.eurprd03.prod.outlook.com (2603:10a6:10:4ba:cafe::62) by DUZPR01CA0317.outlook.office365.com (2603:10a6:10:4ba::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.13 via Frontend Transport; Mon, 27 Jul 2026 17:12:49 +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 DU2PEPF0001E9C4.mail.protection.outlook.com (10.167.8.73) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Mon, 27 Jul 2026 17:12:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gDT7jmQVxR3nwphl23Iurzj22SYicai1FUZuLqIp+E4S9j5l0aO6mojriN8OnXJ84SFjhtd6YbcY3jcuuwyav5f59F3ds1t+S7kaAyzCuQk/u16flMtebjEgMHP9EZUN82/ouzt3j24kY+bsNhxfgedbDMrcMgyJ+Hq5bTeZj0CMr9WICnzmrwBjNjKCPrlOoGHiTtxZI5y4BmwowDrKsF2hUjyqRj1rQMQVcxglp+FzUoZa/7JIj/PWspL8YjV9mBh0b3t4k3FLb2jfEx45anD0m2XNerEPMUADJKOxPRcA3dJoSl2OiOKtDeZPq/KsfY9qm7Dz6OHFF64y0Lyhlw== 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=67R4yCn/HtrI6UoYqa4Pu98xRRmSgWEWd74OHnGeSfA=; b=Ogu5efYxZieEO8R4Lm7AFdQtU8fjvm6cJyCPQsSBxNV1GEwhEcg+yZsr3EGUyNgpMqWLg/TCOyatqEs1/K/o71k24yprPBGlaH7CoXWzHKs5ilEGxq/E5LUVXUk8hfy1W4twSIvCMncyP6Fb9thqFy7EWxlOnTto0KQl0Fj+53VXrXBlChNdzstlE+4oLW4hKBLJEtS5EZ3+1QxB6SocDIw7Q/WrI1epF7JU39miISrVG7CQaf6bZZuVfHeDjuVEWiYjCKHTjXX1PThwv7oi4zSoVI1lnNHFWShGIQOitf+GcW/R6yIsH7Tt/0jYEYXS8MqDPz7Ms/7RQH3ErtrEYg== 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=67R4yCn/HtrI6UoYqa4Pu98xRRmSgWEWd74OHnGeSfA=; b=Z7lVbwFa6eJeZHmVTTbj3PhBeoXeNw84fLkAbSRLipJ+ROi7SAYADEgVcUqtjvWvb66zf2169Lp0vVfpb9vlpOuWFLJ7xJ4VGD5q3K33JwOxu4GLkuVo89SY+oiMph4yhqD5ef89OZnhw+n3YNYAXxJXiszSO3/uSeXBPoe0w+k= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB8659.eurprd08.prod.outlook.com (2603:10a6:20b:563::10) by AS2PR08MB10207.eurprd08.prod.outlook.com (2603:10a6:20b:647::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.13; Mon, 27 Jul 2026 17:11:44 +0000 Received: from AS8PR08MB8659.eurprd08.prod.outlook.com ([fe80::96bf:2de3:5eab:70ae]) by AS8PR08MB8659.eurprd08.prod.outlook.com ([fe80::96bf:2de3:5eab:70ae%5]) with mapi id 15.21.0245.012; Mon, 27 Jul 2026 17:11:43 +0000 Message-ID: <51eeb8c8-c0d6-4c51-971b-0cf038d301af@arm.com> Date: Mon, 27 Jul 2026 18:11:42 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 06/10] gdb/linux-tdep: migrate linux_info_proc to file_reader_t To: Luis , gdb-patches@sourceware.org Cc: Luis Machado , Andrew Burgess , Yury Khrustalev , Pedro Alves , Tom Tromey References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-7-matthieu.longo@arm.com> Content-Language: en-US From: Matthieu Longo In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0242.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::13) To AS8PR08MB8659.eurprd08.prod.outlook.com (2603:10a6:20b:563::10) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB8659:EE_|AS2PR08MB10207:EE_|DU2PEPF0001E9C4:EE_|AM9PR08MB6196:EE_ X-MS-Office365-Filtering-Correlation-Id: 2009353e-e349-4976-9e09-08deec0248d3 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|366016|1800799024|23010399003|56012099006|11063799006|10067099003|4143699003|6133799003|8126099003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info-Original: Vz7Ex+c0V1G6VRZSEhkOFS4VhM7AJUdjF89+SPjE3yFlPQ2qgEpK9xr+GZlhnmHhvZ5GLPgVMzb+oN3bkODocmI0j0Trtdi4QZjz7NJYENhGIgwJKvsKP/6w+7NKY/pGdCz2jgQczoImEcASz/dunnAApm+T/FRMGtRqj0Z1L4jKvtj9KE9qoMkS/lSVPrRwYAg5BwjMLM622w5B4PD7k6GpATgaowyUNFU1hhbQaZYssKT8ZMan9ETCIiI/qy1CffR40aQ9qegNT9pHWdc9ybuRQnttAcHks8yJBWJ7N8OnIZb2I6EwS2/mQxnEwZbn8mrx2JpdKf/+QD8qW8xzZ++h0tiX2Uzk+6Ebg6rvjOZg3EyEMQ2WyxRTZPokO4BsqJforYLEl3lx7JmUZX/duVFm7ih+/jDK0gDzclIqCpk3tvSp7+BhMUl2Gl0V4i7+1MlfIdqM7KzLSfmRJCz1isK1yTv3iwuaDPWEA94wKgcQLSuAnSSIFfqwZ7wlgk7/TKWwJq9zmvTNIxUfCjjh5p/U7xj1gN2j9y4t4JTxXd/5VNNlstyic86U4H9t0HSa9y6pqcOLbyXZ/jN9GXJgQeIqOlvxpxu1sG60Ob4uFMTZpPc3rp/aiv86+MkfT2FzIL/86VLm1jYI+QwgnW020pnItz2kn9GYEsfC5i7amAE= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB8659.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(23010399003)(56012099006)(11063799006)(10067099003)(4143699003)(6133799003)(8126099003)(18002099003)(22082099003)(3023799007); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: Q9Km2ntlM4AFg/SI7iVAaS5ZruTFtI8FAZgQpo50PDFEqqUPIgbPeYTVjtP9rHw11lO7BqIv+GD6Bt4NztVZKHSEFk6ozgNpVTgdaLg7O3t4r7GXs411Jat8L4PF8lGyLprxauuyVGOV3oZJYtP56uUg4vp4lQxQ7JB2x+sjSLqEcfC5jP4ITveln2AbxGcYFjPNxq2hv0RQN5JdHW6u5VqlM2b2tYMuknc7KgwXv9LbseHo+JxpERBHjP33JJnIsGahBR9QuTmjxWiAWPhi6SFQGbtGkHOSAbd4EfzWLBm/vP8rIEy+9ICb0IPj4FAW00d0/zCatoxjNl70rnyz7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10207 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C4.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cd91f9d0-4387-4960-8acf-08deec0221f3 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|1800799024|23010399003|376014|14060799003|82310400026|35042699022|3023799007|8126099003|10067099003|11063799006|56012099006|4143699003|6133799003|13003099007|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 56S7DzZOoeWrhMERf65FgTFe2iQTCo/crIdGLkOUwXpzetAa7z1Yeqj1YUNwG5pj0MM9w814YxXrMCspxO6XX6qf4P2aINU6V9Pq2ObrgBTZ/pFVJiFIRRxgzB866Utr289So/fEdl32W6I+A/c6gY9tVtOPP+L4MGo9h5Q7GltlocqehzofJazthF6JNKQ/CfgcFkH9K1I4utm3ijTbdY6fxRCm6k5ahrA6yLuT69gceBpZzZMg5ZZUzRzuODmqg5AH2J2r8fKAc8gQcd1eACsoYoc6X3H7AI4q1nzAYed8xTyVSBOXaQg78W3brxdwdaz2Cnx3sNUG3DuQ66WhPLCpc0BHabUoaMgMY5tb/8mY5qVrNqpujOMYTioJbZgeV2g+rAsrZ4gcev/ETMYjCGEKjiKp4S2Xr7G5K4YSmvtcGPQqB4hegcWiNQTuPcp5YHoFjoj7bjtcRdpm5YjvQJinrHgaoCK4S4IUaGAuNmbwd8lSJ4R2WR3cdAI5bDUI/pfFO7XzYoPyyvKS1A9WPhzQkuPSv0cjLEBGlieqDfLhVhBTkEzFPI29U3Tz8vCpOzeWXnDA7KQJGpzDoerw6HgBsMRUrG8CIwInMgiTyHb6I2jqe1cN0u+H/V7oeB3sVTxRj+uQ8AqAn44sSCDY1p+10rNFdGsy5Glc48a8B97VVuP84IIp+8f2J9is69+dQor3tCH45fhoeHliglPfRQ== 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)(36860700016)(1800799024)(23010399003)(376014)(14060799003)(82310400026)(35042699022)(3023799007)(8126099003)(10067099003)(11063799006)(56012099006)(4143699003)(6133799003)(13003099007)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mDtnljs3LEFmmxhXhQ6g4ixbIOb+qc4c2/HAEzIgh6a4yCDiB+joVJ8QQ6/GGITAps6jipDZMQs0pCU7NCd0cqvh5e4+j8NJnR9l/oFVQOED1McSc94jGciGt1qKEsnM6Kcmu80tUgfml5d/ZqS9mTFnMJ7DSGyRJpJc42n/mit/IJxBh6zPHs21n7km5PeM8e3XC0BkjfT24fO1owgAFG6PRtv2GNGe/qAH+WcU7XM1yKmmKSh3R2lRddh5VuwqkYoQENZy4wUcXJe3TQW9POwZwL2pldbaGuIyWyTLijdH8JvxeHdm+LpDxGXpNuFgTKBoy0phkDKoe1Fj6Ab6aq2xaXEjt/LcWydKWPiO2lY8GM9mc321WduG28yYIQe8j0cYpx3dW4UCDHdmcriltHK9Li72LQGcVzqsKqbIhGY+t/518bEjZ9zYLyeIHdE5 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2026 17:12:48.8025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2009353e-e349-4976-9e09-08deec0248d3 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: DU2PEPF0001E9C4.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6196 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 21/07/2026 22:43, Luis wrote: > Drive-by review. > > On 07/07/2026 16:48, Matthieu Longo wrote: >> The patch migratse the code of linux_info_proc to use file_reader_t to > > Typo: migratse > Fixed. >> read the procfs files. >> The availability of array_views allows to also simplify the logic in >> several places, where null-terminating characters are replaced by spaces, >> or where the file content is iterated line by line. >> In the last case, a new helper function, extract_string_view_from_buffer, >> encapsulates the logic for such iterations where string are separated by >> tokens. >> --- >>   gdb/linux-tdep.c | 120 +++++++++++++++++++++++++++-------------------- >>   1 file changed, 69 insertions(+), 51 deletions(-) >> >> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c >> index a12a69f03a2..a2af1586d35 100644 >> --- a/gdb/linux-tdep.c >> +++ b/gdb/linux-tdep.c >> @@ -836,6 +836,27 @@ dump_note_entry_p (filter_flags filterflags, const smaps_data &map) >>     return true; >>   } >>   +/* In a character buffer where entries are separated by a SEPARATOR character, >> +   extract the string view starting at START. >> +   Return the extracted view and the iterator to the next entry.  */ >> + >> +static std::pair, gdb::array_view::iterator> >> +extract_string_view_from_buffer (gdb::array_view &buffer, >> +                 gdb::array_view::iterator start, >> +                 char separator = '\0') >> +{ >> +  if (start < buffer.begin () || start >= buffer.end ()) >> +    return std::make_pair (gdb::array_view (), buffer.end ()); >> + >> +  auto it = std::find (start, buffer.end (), separator); >> +  if (it == buffer.end ()) >> +    return std::make_pair (gdb::array_view (), buffer.end ()); >> + >> +  auto next_start = std::next (it); >> +  return std::make_pair >> +    (gdb::array_view (start, next_start), next_start); >> +} >> + >>   /* Implement the "info proc" command.  */ >>     static void >> @@ -878,25 +899,20 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >>     gdb_printf (_("process %d\n"), ptid.pid ()); >>     if (cmdline_f) >>       { >> -      xsnprintf (filename, sizeof filename, "/proc/%ld/cmdline", ptid.lwp ()); >> -      gdb_byte *buffer; >> -      LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); >> - >> -      if (len > 0) >> +      file_reader_t cmdline_freader >> +    (string_printf ("/proc/%ld/cmdline", ptid.lwp ())); >> +      if (cmdline_freader) >>       { >> -      gdb::unique_xmalloc_ptr cmdline ((char *) buffer); >> -      ssize_t pos; >> - >> -      for (pos = 0; pos < len - 1; pos++) >> -        { >> -          if (buffer[pos] == '\0') >> -        buffer[pos] = ' '; >> -        } >> -      buffer[len - 1] = '\0'; >> -      gdb_printf ("cmdline = '%s'\n", buffer); >> +      gdb::array_view cmdline = cmdline_freader.cast_view (); >> +      gdb_assert (cmdline[ cmdline.size () - 1] == '\0'); > > Formatting: Stray space before cmdline.size () > Fixed. >> +      /* Replace null characters splitting the arguments in the command >> +         line by spaces, except for the last one.  */ >> +      gdb::replace (cmdline.slice (0, cmdline.size () - 1), '\0', ' '); >> +      gdb_printf ("cmdline = '%s'\n", cmdline.data ()); >>       } >>         else >> -    warning (_("unable to open /proc file '%s'"), filename); >> +    warning (_("unable to open /proc file '%s'"), >> +         cmdline_freader.c_filepath()); >>       } >>     if (cwd_f) >>       { >> @@ -910,27 +926,25 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >>       } >>     if (environ_f) >>       { >> -      xsnprintf (filename, sizeof filename, "/proc/%ld/environ", ptid.lwp ()); >> -      gdb_byte *buffer; >> -      LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); >> - >> -      if (len > 0) >> +      file_reader_t environ_freader >> +    (string_printf ("/proc/%ld/environ", ptid.lwp ())); >> +      if (environ_freader) >>       { >> -      gdb::unique_xmalloc_ptr dealloc ((char *) buffer); >>         gdb_printf (_("Environment variables:\n\n")); >> - >> +      gdb::array_view buffer = environ_freader.cast_view (); >>         /* Entries are separated by the null character. >>            Print each environment variable, line by line.  */ >> -      gdb_byte *buffer_end = buffer + len; >> -      while (buffer < buffer_end) >> +      for (auto it = buffer.begin (); it != buffer.end ();) >>           { >> -          gdb_printf ("  %s\n", buffer); >> -          /* +1 for the null character.  */ >> -          buffer += strlen ((char *) buffer) + 1; >> +          auto [ntbs, next_start] >> +        = extract_string_view_from_buffer (buffer, it, '\0'); >> +          gdb_printf ("  %s\n", ntbs.data ()); >> +          it = next_start; >>           } >>       } >>         else >> -    warning (_("unable to open /proc file '%s'"), filename); >> +    warning (_("unable to open /proc file '%s'"), >> +         environ_freader.c_filepath()); >>       } >>     if (exe_f) >>       { >> @@ -944,10 +958,9 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >>       } >>     if (mappings_f) >>       { >> -      xsnprintf (filename, sizeof filename, "/proc/%ld/maps", ptid.lwp ()); >> -      gdb::unique_xmalloc_ptr map >> -    = target_fileio_read_stralloc (NULL, filename); >> -      if (map != NULL) >> +      file_reader_t map_freader >> +    (string_printf ("/proc/%ld/maps", ptid.lwp ())); >> +      if (map_freader) >>       { >>         gdb_printf (_("Mapped address spaces:\n\n")); >>         ui_out_emit_table emitter (current_uiout, 6, -1, "ProcMappings"); >> @@ -961,12 +974,16 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >>         current_uiout->table_header (0, ui_left, "objfile", "File"); >>         current_uiout->table_body (); >>   -      char *saveptr; >> -      for (const char *line = strtok_r (map.get (), "\n", &saveptr); >> -           line != nullptr; >> -           line = strtok_r (nullptr, "\n", &saveptr)) >> +      auto content = map_freader.view (); >> +      for (auto it = content.begin (); it != content.end ();) >>           { >> -          struct mapping m = read_mapping (line); >> +          auto [line, next_line_begin] >> +        = extract_string_view_from_buffer (content, it, '\n'); >> +          it = next_line_begin; >> + > > Is there a risk we will drop a final chunk of the data when the buffer does not end in \n here (or > more generally, does not end in whatever separator we're looking for), comparing it with the old > strtok_r behavior? > > It's a corner case, but I thought I´d check. > You were right. There was a bug when the separator is not present at the end of the buffer. See https://godbolt.org/z/fh5Y7fv8P for testing. I will change the implementation in the next revision to the below. /* Extract a string view from BUFFER starting at START and ending at the first occurrence of SEPARATOR. Return the extracted view together with an iterator to the beginning of the next entry, skipping any successive separators. If no separator is found, return the remainder of BUFFER starting at START. If there is no following entry, the returned iterator is BUFFER.end (). */ static std::pair, gdb::array_view::iterator> extract_string_view_from_buffer (gdb::array_view &buffer, gdb::array_view::iterator start, char separator = '\0') { auto next_start = buffer.end (); /* Reject a START iterator that does not point into BUFFER. */ if (start < buffer.begin () || start >= buffer.end ()) return {gdb::array_view (), next_start}; auto it = std::find (start, buffer.end (), separator); /* If no separator is found, the remainder of BUFFER is the final string. */ if (it != buffer.end ()) { /* Otherwise, skip successive separators so that NEXT_START points to the beginning of the next string, if any. */ for (next_start = std::next (it); next_start != buffer.end () && *next_start == separator; next_start = std::next (next_start)); } return {gdb::array_view (start, it), next_start}; } >> +          /* read_mapping() expects a null-terminated string.  */ >> +          *std::prev (it) = '\0'; >> +          struct mapping m = read_mapping (line.data ()); >>               ui_out_emit_tuple tuple_emitter (current_uiout, nullptr); >>             current_uiout->field_core_addr ("start", gdbarch, m.addr); >> @@ -985,26 +1002,26 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >>           } >>       } >>         else >> -    warning (_("unable to open /proc file '%s'"), filename); >> +    warning (_("unable to open /proc file '%s'"), >> +         map_freader.c_filepath ()); >>       } >>     if (status_f) >>       { >> -      xsnprintf (filename, sizeof filename, "/proc/%ld/status", ptid.lwp ()); >> -      gdb::unique_xmalloc_ptr status >> -    = target_fileio_read_stralloc (NULL, filename); >> -      if (status) >> -    gdb_puts (status.get ()); >> +      file_reader_t status_freader >> +    (string_printf ("/proc/%ld/status", ptid.lwp ())); >> +      if (status_freader) >> +    gdb_puts (status_freader.data ()); >>         else >> -    warning (_("unable to open /proc file '%s'"), filename); >> +    warning (_("unable to open /proc file '%s'"), >> +         status_freader.c_filepath ()); >>       } >>     if (stat_f) >>       { >> -      xsnprintf (filename, sizeof filename, "/proc/%ld/stat", ptid.lwp ()); >> -      gdb::unique_xmalloc_ptr statstr >> -    = target_fileio_read_stralloc (NULL, filename); >> -      if (statstr) >> +      file_reader_t stat_freader >> +    (string_printf ("/proc/%ld/stat", ptid.lwp ())); >> +      if (stat_freader) >>       { >> -      const char *p = statstr.get (); >> +      const char *p = stat_freader.data (); >>           gdb_printf (_("Process: %s\n"), >>                 pulongest (strtoulst (p, &p, 10))); >> @@ -1131,7 +1148,8 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >>   #endif >>       } >>         else >> -    warning (_("unable to open /proc file '%s'"), filename); >> +    warning (_("unable to open /proc file '%s'"), >> +         stat_freader.c_filepath()); > > Formatting: Space before parens. Multiple cases. > Fixed. >>       } >>   } >>   > Matthieu