From patchwork Tue Aug 25 10:09:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 142162 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A8A254BA9025 for ; Tue, 25 Aug 2026 10:10:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8A254BA9025 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=aQ6pHM/J; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=aQ6pHM/J X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::3]) by sourceware.org (Postfix) with ESMTPS id 9A7ED4BA79A0 for ; Tue, 25 Aug 2026 10:10:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A7ED4BA79A0 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 9A7ED4BA79A0 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c201::3 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652613; cv=pass; b=GfMJSGq8nD0TU4DIHRvlf8EqxSKSbcQO4XdmcArBvVZydlazWab9StmTT6KoyvsSm4fln1/6cL/MoZTtcp7XU+x0HtNy+f8SpK4nKs5JSkKNYSFXCKsP36vNCXDnMalZw3xUGo6KQiOaxhzGPRKbuYA4Kddk6FbhI5p15gUr8is= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652613; c=relaxed/simple; bh=W6vr9aqUDwGQ43laknqNJ4YNErUKq3/VZfEvUVIao/4=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=TLfFFmqOxafjixIlxCIX+tO+K7coT6DRK+A8M8RlugC3dwVAqaQjAuUuNba8LMh0a2w8k6fBsML8nkwoE24s98ql4iEj2zUrrOeVQrNSW6I/JvTmBH709erZwTCgaeSrrgEb5inU14wVPLgOLSS5ypLbUeujBMQDO2orTmRgs7k= 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=aQ6pHM/J; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=aQ6pHM/J DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A7ED4BA79A0 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=V64fIr9DpzJ3nMl9IPqwbRv+k9x2T84MtHVUs12FxT10gsFSXdqhki+blyoHRu/z+g8grkhJRKtp4dgUJGqKCb7JQkU11re39v/fRaJ3QjJwf/L0CrQpKIKrNwCtRauM/RBF8N+D5OU46OcT0n+aR0xDcmTpfVUtXZn9RSwC2q7fZsv248/2wJVkkEafVTiWaiwHT8xr9xiTF5QhN0vet6wAN3DmPjWwFnBQtMZ+IChpfUq5/st1onsGO8E768IRSYQT4gSQ0C/eWbbW3axDiLHYodOaQpMUnzed6V/c9AGXRGzWDqa1iKdz9JhtzID1zIQU2IPHOWcx59kNB1cGEg== 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=8k4SK++9YNJ8800nIqE95UDlJ0YolGxznqdHe39lSGA=; b=ZzgrYDAtqDYdEIdE+Uqo2VrIDeUwDkhYgKlgVtBk+f2Sh553vdJB/A7jpi1N/WjjEpYGgaqCRgHcQ9IwAOq9tGAg1GvySqB+34fxsi8lowqgyPaOzpPcm+y1MYprI/zjr0IyVr6BxM6mS4QF5/szZpGjrlzr26qU3DseoCbKKDQXqgPqnBHgxyi1slZR0r9R7ZpC17yXDqb9/nd+woa75M6mVqt9OMm9tzO8flGDJqTRY3wua+jHvZs1upwj2pOkziEzacgLFGn1vwHzCRG4r8sL47wEKIs6P0SZWYSkfvL9/nzNuqHR3UdCPUJf/5+BOY8daGXqjVf/HkzRrX1Evw== 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=8k4SK++9YNJ8800nIqE95UDlJ0YolGxznqdHe39lSGA=; b=aQ6pHM/J2QEV6C38m2jOlrfqD82sQ1Bzn876c/+mFyiN1IXIvg9ML9UyOejbPfx/qvAS8XsF/rjZrQR822s3qnw3UeRcRI+Fmp652nOgkMSduMCE2SnVBlGDziVChjfZNfoZWgbipw8268TNF50Bn6qT720D16fcyyR2rabW+BY= Received: from DU7P191CA0021.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:54e::21) by GV2PR08MB7954.eurprd08.prod.outlook.com (2603:10a6:150:a8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.12; Tue, 25 Aug 2026 10:10:06 +0000 Received: from DB5PEPF00014B8B.eurprd02.prod.outlook.com (2603:10a6:10:54e:cafe::75) by DU7P191CA0021.outlook.office365.com (2603:10a6:10:54e::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:10:06 +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 DB5PEPF00014B8B.mail.protection.outlook.com (10.167.8.199) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S2U56rbbPmAAwtyUDelKFOgr/d/TzyiKD+Ne5ZMKmsBLTxPGG2+Brzlk2+hlkuOATATeu+5jGkEyStRhfpoAfRW7wFxk5zdCbpkQcZmI0fXxeVaiDg88JdOHpQ98y177oyhT+cwVA/LhazjtCiwWSsXHDz6FiEGZKZ5Wr3QLuDKDz5oPZxak3V+qu8w1phYhicSpjSta011iiCps8tH4NZgGRdOQj9rAGe07/QGeTjOl73tg98daAy4qBpwieYj9MZ0M9Wmi3f+YVt6BazzOpu15xeZFto8zLvLF9E8OPSuzao6BOwKB8gvA3SCEfK8RCcTzKmqVx3lL8ZH/0vzA3A== 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=8k4SK++9YNJ8800nIqE95UDlJ0YolGxznqdHe39lSGA=; b=L6sRK6p7sTS2z4PCNOwiZKlaBhPiRqfmNvI29XnrGAewmAWySb+6Q+i6PDK9aFHyYejb14avDy+A7L6BNf4HsKl2OVT6E4qsv2x+8ZY77/S/3F/kXdI2UUst4vnb/q4TvKS5Ryj4DYqGENwzQXxSB3ZuarqyOFxXLJAVJlYT5GnBbhPygFT7SHdXFMlf4q/9BIOGcXKmqkzU2jgatAqZRIQoxww1q+eGooNL4NMSg8tDJLO/Hjjag/4jJ0NyttODilGGp0IMH9mnO9U0/wjMqATgW06wEU1Ulx0G4u3WprsJOEhQMf/s5YMYEzbwEO77TCwu79jcvVrPsxzogklPFQ== 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=8k4SK++9YNJ8800nIqE95UDlJ0YolGxznqdHe39lSGA=; b=aQ6pHM/J2QEV6C38m2jOlrfqD82sQ1Bzn876c/+mFyiN1IXIvg9ML9UyOejbPfx/qvAS8XsF/rjZrQR822s3qnw3UeRcRI+Fmp652nOgkMSduMCE2SnVBlGDziVChjfZNfoZWgbipw8268TNF50Bn6qT720D16fcyyR2rabW+BY= Received: from AM8P191CA0025.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::30) by DB4PR08MB9382.eurprd08.prod.outlook.com (2603:10a6:10:3f2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Tue, 25 Aug 2026 10:09:31 +0000 Received: from AM4PEPF00027A64.eurprd04.prod.outlook.com (2603:10a6:20b:21a:cafe::6d) by AM8P191CA0025.outlook.office365.com (2603:10a6:20b:21a::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.12 via Frontend Transport; Tue, 25 Aug 2026 10:09:31 +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 AM4PEPF00027A64.mail.protection.outlook.com (10.167.16.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:09:31 +0000 Received: from AZ-NEU-EXJ02.Arm.com (10.240.25.139) by AZ-NEU-EX04.Arm.com (10.240.25.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 25 Aug 2026 10:09:27 +0000 Received: from AZ-NEU-EX04.Arm.com (10.240.25.138) by AZ-NEU-EXJ02.Arm.com (10.240.25.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 25 Aug 2026 10:09:26 +0000 Received: from PF4S4363.arm.com (10.57.48.229) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 25 Aug 2026 10:09:26 +0000 From: Matthieu Longo To: CC: Simon Marchi , Thiago Jung Bauermann , Luis Machado , "Luis Machado" , Christina Joos , Kevin Buettner , "Matthieu Longo" Subject: [PATCH v2 1/6] target_fileio_read_stralloc: add an optional length parameter Date: Tue, 25 Aug 2026 11:09:07 +0100 Message-ID: <20260825100912.514232-2-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825100912.514232-1-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM4PEPF00027A64:EE_|DB4PR08MB9382:EE_|DB5PEPF00014B8B:EE_|GV2PR08MB7954:EE_ X-MS-Office365-Filtering-Correlation-Id: 34414ede-f4b4-4ce0-bd38-08df029109bb 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|1800799024|23010399003|82310400026|3023799007|56012099006|10067099003|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info-Original: QAbUA16S7mqaOWzK+9pS+A/JQHp91t5ACLmQq6M4Xh1N1B0Er1tr/gGEpfBqUddE6jk1v7lOpnulqkLpW3eEHGST6ku4emUfSg5CtB+Ly3lBLVEfD6PBcYz+NVn2k3NK7u19ybLaytqxuuzngNahMKYbeYLIJ7OtyfBf3RRrxG5WpAcjQgn8vTlOHjYe7gbHfTLIeij1HMNmHpF2ZWXFf7G6Qxeihs0L894o6DFixYz4APKcjWNUgV1sBLw7ZA7AqtmNqgYyaCKHS8IUEd750ueV17VrRjUGnTwKXVJ2aX5aIDq97ZFken1MQoTDUEAM+PotxjAo2Gnh9ASTqpyXEMScjZDV2lopmFUtK7v9hqtpD+HsQdp7mJ4NEpE+LEfBS1C4pVAjXj4GphCTBSkqqa0gdxKNhzsLvKBLeiKG00zwGolb8qK9TdTNIRdAsQhYGUp13YUuZau04hia9dL+Z52vhUVwdxugrR7Pw5s3opcP0zkoCHS/gaFkXKpEti3PThkWFD/AH65BozxwInKhUcxHyQHj46k3BIAVohje2IedM6rxGTo041KoLJp0JDoJyylQXXnffQoC3J9QiZP8DEREfsl/rhh2Q1XI/E4Uz5zBFoVDD57chwK3e+ZANu3Z/T92fxz+7pRFdhWfHdzNkaOpxvNnk/P1z+9EusHeTbj9MZXhJkf685AwmXH8N/UDv23swOtPwNWxI//LKeMs7g== 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)(1800799024)(23010399003)(82310400026)(3023799007)(56012099006)(10067099003)(11063799006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: FRMaIXQ52EAH0uV7vDXKzttTdppH5gu47QQ9v3C7GT9ZNwHMfzybNsf2iEMQv7HgUvToPZbdMsA39VKD8kqFmmzislNEdsmyQ9hv0E5YZ2gia4tIOp1XVzWG3Qi6GBe6n4lVRBo3HWRqhavG2Wq1PO0V5SyH0E6702S1lTpTp40o6784/vHszxx84Fte5a4R0Jxu06XjKurTSnyxhXv8xwyQ105SPXAY3BYEC07sOe3vDuJ2KmDz30w6st5y4sF4rzIFbqbnlTh90Vdqd+tFR05/91a2oBZcfxzDPhGcY8W4vSX6jGonnqTcZ1fgGGWEv3MHTv7UgA4tYNhpx/BZ+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9382 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B8B.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 045de2ea-73a5-47e7-6f2c-08df0290f4ce X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700016|376014|23010399003|1800799024|14060799003|35042699022|3023799007|56012099006|10067099003|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: jgmdXnMY3xUfzwfSsUWbghnThTp5YxjiQgptCqLJBgmYTeKXr/C6x70PDsGscy8Tw2XwJV8YuZipZ6njKoiexAZkNrBF9S7L5VOlKEq8YDsWZ0PPNYobF0QelMKIHqRNe8MT2+/KHIMVs/CryCrvtuGfLRrId1ZgFTYW0yCETHGN4m2jyJ/M3UixLZzBYCn5zg8HflTkaQeifoYbYKkdUnNL7Xz+jG/63ddIy3TsSe+gONOl7tzdmNZdPqfp4bAEgVCRoqjFgx2Yi1V1L2efZXCXSPp/hASu93lPzT6gSCMaFH6zv5l2bEI2encFQb/NCuOFbn8kVCCPLO/Rl9vCwY31fM0MijeeTwPSz2vfVkfcyjw1MFx9iMgTaw6WxvJOd3vRe741n04wpsjtNtWg6kqf4C710IoAw2CytpGKDXR61QQxE8Mqt4Omin0E3SqHXOjGwU2vIUu6jbS6iy7cowu6pru+P82lk//2S33lcurzwabXRi9WLE5tgxUPeM9WwyOiEPE9Utu5obOMOBJvex84KNaGZqhdNFPUFLbqfofM8eHEN113Rc6wPzyYWN3At7nLd9pWg2Qv+IzxnxKz9zBhwfUFhVU9MZ2tp/g2N+WscW1DeP63zFflhrvAyvBIzG00zCjbt5F7L6o/QmA9jop/l1SRyS0rquAolgRsHPP42itTC6wjwrd9V7Z44erWZ8IhToVrDaxcKC8sGgqUaQ== 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)(82310400026)(36860700016)(376014)(23010399003)(1800799024)(14060799003)(35042699022)(3023799007)(56012099006)(10067099003)(11063799006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bJATgAL/nMOfeOlQyUWpewSXk7jbO19iXHS8M0r5EQ343jok9br4H6EvuZJGXVpi9vEui9fznubZhTqrzLabx6ynTGsO3yeIBZyF3eT+yBLAlwN6yDHisYfSHb21mXyy4TuJIyQiVgW1Tb/vbvEA8sO6rapeD5CGb0C1dSp1V7wuNp+EZ1BGo2n+0xwo3TbCSOYVDp5TjvMQbEZT/cz5jKObgSa9xNbCGKRiadGwtNEsilvT+X304QYSmZX7PbARBUTjWDabzuv1fzDPdx/s/eE/a0CGWQZsVzlisNFxO9/VxgMp4AwNSdsbmSx3sk+PEDSmaaPOOq8xkL7vz+TQMNb2euZTUAF6wq1/z2FDgdt6ZqCGXREcpiyP3T82xwM4B2YvxWNzEwoPStisMsJZbDb0Ba1HTuEYCfgR4k1PE51rQLAvIZrBxsmeEVZelwCm X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2026 10:10:06.5688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34414ede-f4b4-4ce0-bd38-08df029109bb 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: DB5PEPF00014B8B.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB7954 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org Extend target_fileio_read_stralloc with an optional output parameter that returns the number of bytes read, excluding the terminating NUL byte. Most callers only need the returned NUL-terminated buffer and can ignore the new parameter, but callers that need the number of bytes read can now obtain it without recomputing it. While updating the function, make a couple of minor cleanups by using '\0' instead of 0 for character literals and clarifying the function documentation. Reviewed-By: Thiago Jung Bauermann --- gdb/target.c | 11 ++++++++--- gdb/target.h | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index 5d937f3ae85..ebf0f30092c 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3547,7 +3547,8 @@ target_fileio_read_alloc (struct inferior *inf, const char *filename, /* See target.h. */ gdb::unique_xmalloc_ptr -target_fileio_read_stralloc (struct inferior *inf, const char *filename) +target_fileio_read_stralloc (struct inferior *inf, const char *filename, + LONGEST *len) { gdb_byte *buffer; char *bufstr; @@ -3556,17 +3557,21 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename) transferred = target_fileio_read_alloc_1 (inf, filename, &buffer, 1); bufstr = (char *) buffer; + /* Note: on failure, target_fileio_read_alloc_1 returns -1. */ + if (len != nullptr) + *len = transferred; + if (transferred < 0) return gdb::unique_xmalloc_ptr (nullptr); if (transferred == 0) return make_unique_xstrdup (""); - bufstr[transferred] = 0; + bufstr[transferred] = '\0'; /* Check for embedded NUL bytes; but allow trailing NULs. */ for (i = strlen (bufstr); i < transferred; i++) - if (bufstr[i] != 0) + if (bufstr[i] != '\0') { warning (_("target file %s " "contained unexpected null characters"), diff --git a/gdb/target.h b/gdb/target.h index 6d1c21f29f6..819279c08fc 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -2327,15 +2327,19 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf, const char *filename, gdb_byte **buf_p); -/* Read target file FILENAME, in the filesystem as seen by INF. If - INF is NULL, use the filesystem seen by the debugger (GDB or, for - remote targets, the remote stub). The result is NUL-terminated and - returned as a string, allocated using xmalloc. If an error occurs - or the transfer is unsupported, NULL is returned. Empty objects - are returned as allocated but empty strings. A warning is issued - if the result contains any embedded NUL bytes. */ +/* Read the content of the target file FILENAME from the filesystem as + seen by INF. If INF is NULL, use the filesystem seen by the debugger + (GDB or, for remote targets, the remote stub). + + If LEN is not NULL, store the number of bytes read, excluding the + terminating NUL byte. + + The returned buffer is NUL-terminated and allocated using xmalloc. + On error, or if the transfer is unsupported, return NULL and set + LEN to -1. Empty files are returned as allocated but empty strings. + A warning is issued if the file content contains embedded NUL bytes. */ extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc - (struct inferior *inf, const char *filename); + (struct inferior *inf, const char *filename, LONGEST *len = nullptr); /* Invalidate the target associated with open handles that were open on target TARG, since we're about to close (and maybe destroy) the From patchwork Tue Aug 25 10:09:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 142163 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1624B4BA79BB for ; Tue, 25 Aug 2026 10:11:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1624B4BA79BB 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=R2TSB9wb; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=R2TSB9wb X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010044.outbound.protection.outlook.com [52.101.69.44]) by sourceware.org (Postfix) with ESMTPS id 9CF6B4BA2E17 for ; Tue, 25 Aug 2026 10:10:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CF6B4BA2E17 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 9CF6B4BA2E17 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.101.69.44 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652625; cv=pass; b=nS+vbKRxqLvs2EscVh/QSUU9+VxgGj1wuLTcuGDjFDK49pVhy2oZrrxLhai1oXE0y47GXzvbzfp6U7dsycXgjE1skS2xZkikAwNG84CAGTJLN/dqgdBBCrdDQUKbfJcjNg+4oyHLUIpNvbzMbmYPUR1azA1hVLaoktHPomoTMPM= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652625; c=relaxed/simple; bh=/xHGvQfyjUl+1j5aztyB7fMK9Rz8sbUJBWGK0f24+g0=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=fioACeypk//T4nyqulYA4lnsKEaRxh+U0z5Xt+0QFd4Zgl3BtU7TbEUoc1apcExUwTiX7Rzi2piXGjwfJYTxTG1P1AtJzXe4xuQaewvZRujhyzVns2cBnT7EJ3P8WcncvB2Pxc11TFK2hUQkxVLVorV7gxR2/VAc1ignzzXVUCM= 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=R2TSB9wb; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=R2TSB9wb DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CF6B4BA2E17 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=wIqtggtHxvSKTpS9PkGmz9Cytj+dwz2hJEEKsvkg+XQ039SAJNmKE+suLBoFWTffXLKlMNYamU0egBllv//ITPPmYxSqquL9iqqy+brt8piM2e0I+KKRFvUONdLOugxNVO3As5tt1VgrBoJxMQSovgdGwD0R2e43jHApHIak4TOxXY4PJ77R+oHhcsBI3Pvmp5w1eyxVmD18OOibfMMsnjseOl1BvYgb1HSpzY93odecoJvvzmNVVQfCnkgAfPOeZ+PEZqkmThEDF16KYM1wZPY722ZnEdhJCNNR/eTiFV8ASob4+tvsF6wSMd/sNiSSRKZWbUrOa1nAvmuHQWF9Zg== 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=zJiq5+oja20/JYxemxTuMFF+gcGSDo5goKVaz7dTVq4=; b=eNOpAtiM1RlDDmrf98DijIg531+ADfpq1jlbLBqrm10u1WpJKQPyxN6gcUPUKI0agIL4LqZD0KElspgaauRFr1j3L6+2qnD3nBUYds0bi+rvPU64XiOik3OAkzoJ3aDahZTDixxGzB17Zel3GAWcSq2tWipTaN2fpCHDbw8SanK0wEJmsP4Omd9cDxoV1h9F+CuWlWOuUu3c6NDASpbAgD5du8fj7oygb/tyko4i69ji7soxM+fCYnKic/jJHpSns9m1WjBRD2SApOF+RsgqBc9YaOF23mG4tPrq8ZU3F/6TMuGUscCsI/e1Ks4lenL8y6TcEp0/8PxU/P8diMEm1Q== 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=zJiq5+oja20/JYxemxTuMFF+gcGSDo5goKVaz7dTVq4=; b=R2TSB9wbpOM7ManZePjiESgLP1nujfTVLidgeSNIzljOz9Ydj5kDCl1COQ/G5Qa8PxzxPK+qQSjUP2Vl0PvsnXVHqgUMHGDqyLCJGlptk3TjYhnpWFOdiZp7mpv+kWGHepHEGEoKgGftS/9jtcCkBQYIVU3dUOnlIvF/X1cLlGU= Received: from AS4P189CA0001.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5d7::6) by AS2PR08MB10294.eurprd08.prod.outlook.com (2603:10a6:20b:643::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Tue, 25 Aug 2026 10:10:13 +0000 Received: from AMS1EPF0000004E.eurprd04.prod.outlook.com (2603:10a6:20b:5d7:cafe::ab) by AS4P189CA0001.outlook.office365.com (2603:10a6:20b:5d7::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:10: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 AMS1EPF0000004E.mail.protection.outlook.com (10.167.16.139) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iRzHwQSIEjoZ1s/70cq4xb+xi6+9r2g3t8+EkqmGj/XIKOaRDmrg8CSoeK/qjWzgAxtjXltKyXbtcu2zukwwmuOeMQell2whnCpSiGmgz0gexpoc3TtztvPj9+fAxzMqpbsrLkYetHHVEhSeUPX3uZYCAknyoRegHwYjBVso1I8uya3JAoiFg3mS10srQsvG18mWwBCGAapV8W3mNVWAyXjYVv2HobraUzPLsKblRyA0aIuNe291wzPWRrJU0shQAQ3PaQUrvvS6Aje3RtR4siJVE09TzoT2JncvcsfnT9ynhYF9l6oVSRzZUYDBl3pGOnzhmNiDibimpk5VuqdV0g== 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=zJiq5+oja20/JYxemxTuMFF+gcGSDo5goKVaz7dTVq4=; b=PWM65Y0rsV7HuCKEUt4cfCqOjQGlJJaQxzKzbRg0fUPl9SwIwRuuDeAyNelvieF1NejFR9uBKyq54vxp1oNwvdyZFLyGSSdhT7SIauS0WXtWssFk8ka4vBliEbqwaWZQXFCQ4Hn94MhLZTH+kcYTgCxjfAQHKidKZoxyZpX56pj1ydUoi+RmZC6t5+LTgy3qdBS7N3AgWPylaX2WjAliu6SPTe2jXp8acrTCpKjg8qpezUn0t/nEfUOKpzIF5MYix23yvMAqr7t2n4sL15+VfpEeF2XVw7JBbi0btbh0LIPngmYzklRCh9n57MZuqszHwfWmEQ2YDgSWJVY5U+g7Vw== 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=zJiq5+oja20/JYxemxTuMFF+gcGSDo5goKVaz7dTVq4=; b=R2TSB9wbpOM7ManZePjiESgLP1nujfTVLidgeSNIzljOz9Ydj5kDCl1COQ/G5Qa8PxzxPK+qQSjUP2Vl0PvsnXVHqgUMHGDqyLCJGlptk3TjYhnpWFOdiZp7mpv+kWGHepHEGEoKgGftS/9jtcCkBQYIVU3dUOnlIvF/X1cLlGU= Received: from VIUP296CA0123.AUTP296.PROD.OUTLOOK.COM (2603:10a6:800:350::15) by GVXPR08MB10861.eurprd08.prod.outlook.com (2603:10a6:150:154::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Tue, 25 Aug 2026 10:09:38 +0000 Received: from MI3PEPF00008492.eurprd03.prod.outlook.com (2603:10a6:800:350:cafe::af) by VIUP296CA0123.outlook.office365.com (2603:10a6:800:350::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:09:38 +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 MI3PEPF00008492.mail.protection.outlook.com (10.167.240.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:09:37 +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, 25 Aug 2026 10:09:37 +0000 Received: from PF4S4363.arm.com (10.57.48.229) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 25 Aug 2026 10:09:37 +0000 From: Matthieu Longo To: CC: Simon Marchi , Thiago Jung Bauermann , Luis Machado , "Luis Machado" , Christina Joos , Kevin Buettner , "Matthieu Longo" Subject: [PATCH v2 2/6] gdb support: add gdb::ranges::replace algorithm Date: Tue, 25 Aug 2026 11:09:08 +0100 Message-ID: <20260825100912.514232-3-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825100912.514232-1-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: MI3PEPF00008492:EE_|GVXPR08MB10861:EE_|AMS1EPF0000004E:EE_|AS2PR08MB10294:EE_ X-MS-Office365-Filtering-Correlation-Id: 95531041-d9e2-46b5-fc84-08df02910d68 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|10067099003|11063799006|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info-Original: N1UL3n+gNhWO9RLGNOKitZ43bSmVBF40aiwpe2p9kBwxl3+8NAPxxaxj1bAnDa8C/22lJkYGcrG3Tejkd+j//wdRY86Xhc4cSn2EegR+6LGpqhh3pINM40upOd7KH3t2jm+HjHP8xMLNPo6jtY6HlhoFE8A5PJe4iVB4y9a4j4tljgxpRDrDHdeXhLpO5bLTdxUmiwcAAxi/gAY9J3uad9jBpn1S990keABI+eLLRmUL9V0NJV8CPJjvxKJ0U9zDtD1AICA/XmnBpgxakpKya1n10D19jTQWf2oPVaNVF8EiJT2KDh6Wa3fhK0JPlUrs3WlCPAAf5NStKum3+zjTzsnM+BuHHw4q6Ri1YVjsQChrOa9IoMrKH5hj5MAaPaHp9N9oLUInFfY1SAxJJRBCU47HFBbjLNl32OAolRBi1I77L0G7xOCa50uMBsOnp91OUvwGi1AVhvAi3+p0moskZvlnX2/2LN6MaHLZpCSFVIlKpVA+cJ08QpAt4xT22oJKn/mkoeM7HEMmuy/Taop32DNFUVJd6i344Pv7pWQMp+rohJhc5wrNDLKe2PE2Wyf0o1F2naD4k2du1QzXiUY511vuKKrwQgSpNef4hPGqFklW+SIiiFDS9dfE+xI1VlDMlRpU6+wq0uyFRlOUiSUpSQ== 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)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: 1mH4ElWObdwiPpgwVP1047SjlvRf+DkCI696I8w62LC09sCGclb8m6cU7CWufW4gbOx/K60+Z3JzWrLila8dw7XAtPYkcyjyi0cJ7UueZ5pgSINVzqzDc04XpIBIL8klWDeviYOOsFE/CWDtD+dZytN/+GriNEXpMO6XM9zMwcSgExzNR0Ppwec3ZpqE16FFxhH8nA3rWNtKShxYQeTSYVHesSk9EiiQEJ9lff31BP/kT12AdVqpVDll/N82DmdzMp+r5lJA89MfUr4tlbYpv+HoCdl9R483b5Wk9EySnXbyV4uU9p8TE3nzj3kcp6O2XbAecMHaIt/+NuhR8jy+Rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10861 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF0000004E.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: efd65caf-951f-44db-9bae-08df0290f8a0 X-Microsoft-Antispam: BCL:0; ARA:13230040|14060799003|36860700016|376014|23010399003|35042699022|82310400026|1800799024|10067099003|11063799006|56012099006|22082099003|18002099003|13003099007; X-Microsoft-Antispam-Message-Info: Bva+arjQNBfvoI3N3WgHwzOwzlsJ6MHoC2ShYWvIE4BX++JPbNzuznLKNsGfzZihSLODjRQ1ae9HW8eNRrzaHsIYSTbyNTsSe7BWRs/OWnVXJygIIf6wDNazsBhZsOlRegexTUjgO514vAnRUUeJfkwyhMEakXNXij8aUFoIZ8nykwgGyMD0anu2a98yKf28/Sf2vUvgaS3+ec+ZLOZjOq7Xt/F+h5maflSqvEOnQTPXOLxz5V53GrDJwydZFw/5YtBc7gJw5m7YOHnFsSjxy7XNnwWq8qvfzOtzHPcOhEnfXl577wpMHPhic2p1ySORUYFgicuRawoQay/BjUkkdf1UGv/4MoIIv3d3Grc/rHbggUIooN4VqIY8T8RkAi8Uk7pOlLZjdxMvBQ6zoecPEl9RRWZHZGOUutGK/+Lvwpel5FCoaes9VH7pqU/SUfRYF41T8eOzLRJwOZydoRsbPWl3EzAXEUOFQfK7lOgtSWtkh/1mUNmK3NSARcp4QFg3gfRycr6Pxe9PWQakDs4iLWwGnGvLrCpz7fFxYRW9LuvO2IzATVB5l3qeKNsNEZvYUgn7k7BXN6r3I+OIRnSVDuabxuC6z2KJszIoAgprW5a76mQKo0FjYcaHGgsiNIxNhl0ZPrTnz//9Kt719/f+zg== 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)(14060799003)(36860700016)(376014)(23010399003)(35042699022)(82310400026)(1800799024)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003)(13003099007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0+r1oZ6LBJ3dO7rrz5zFFjZIRDZMqfuElUHJXIuTm6BsH0k3p96HtxcQXNxaBFFFV7//2F2gyF11f2cvvJpFKbXAUeu0+48vgCRJlR19Dzcr4V6TsncWqp1mDllnZ+7V7FNnD+NM4tCgwUfhnrAJn/5RV9Tc0i62qesSuwnN4ykfNcmhxDmQ2pvbeFdKiv7lMrQFHUE7Ym/9Hxt400+Gp/peOGmWLvsq8657gq8NgcOD28NI/0IQ9dkFW7evsFzSxeA3sibdmT63RfdhudLOxj/JyYa9lrsUrL4RWZ8HP6/+uInRtoN6LGnfZOb5jvAXxfIfbGEPdv5Ybr5wZDDtiQDSU5io2Q2xyMQFY6pdo/8B71Tc4+vjLFtWeJ4j++IRTpX4+S8wIdqykUpJmj6+XJHzMHddYmHmOWhbAv0jln2jIo7Fz2qI2BZ79CTmLKfy X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2026 10:10:12.7431 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 95531041-d9e2-46b5-fc84-08df02910d68 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: AMS1EPF0000004E.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10294 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org Provide a C++17-compatible replacement for the C++20 std::ranges::replace algorithm, allowing callers to use a consistent interface until GDB transitions to C++20. The helper should be removed once the C++ standard library implementation become available. https://en.cppreference.com/cpp/algorithm/ranges/replace --- gdbsupport/array-view.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h index 8431d7f5add..f9842ecff30 100644 --- a/gdbsupport/array-view.h +++ b/gdbsupport/array-view.h @@ -225,6 +225,22 @@ void copy (gdb::array_view src, gdb::array_view dest) std::copy_backward (src.begin (), src.end (), dest.end ()); } +namespace ranges { + +/* Replace all occurrences of a value in the provided range. + + Note: this helper is a reimplementation of std::ranges::replace, only + available from C++20 onwards, and consequently, should be replaced by + std::ranges::replace once GDB switches to C++20. */ + +template +void replace (Range r, const T &old_value, const T &new_value) +{ + std::replace (r.begin (), r.end (), old_value, new_value); +} + +} /* namespace ranges */ + /* Compare LHS and RHS for (deep) equality. That is, whether LHS and RHS have the same sizes, and whether each pair of elements of LHS and RHS at the same position compares equal. */ From patchwork Tue Aug 25 10:09:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 142164 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF0644BA79BB for ; Tue, 25 Aug 2026 10:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF0644BA79BB 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=PYrfL0PO; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=PYrfL0PO X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from PA4PR04CU001.outbound.protection.outlook.com (mail-francecentralazon11013052.outbound.protection.outlook.com [40.107.162.52]) by sourceware.org (Postfix) with ESMTPS id E76924BA79BF for ; Tue, 25 Aug 2026 10:10:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E76924BA79BF 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 E76924BA79BF Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.162.52 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652635; cv=pass; b=Ij4xEeqeK05v48419R6/Z0AYXYTlTBnY+RTOVmFpYN+1YfAgONnv1lo+GdMANwqRFdrNSDF3j7FRU1MUbdtDlsdX4aXSEGHFv6YruKQAJRufd3Sw3LC02LptlgmMbUvRPBSJnQBdMLS9cP8jiTR7tp3/KxDucinggjPE2nLNnkQ= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652635; c=relaxed/simple; bh=31Daub5EYy/AgEYqwUF6C770t7xm2Q08Hl3t1FeVSN8=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=gaoU1bg2mshLLmpEqDmKKU5K2LxA9IBLiWGZ0TCHQqHjwOzpMu2Z8iGaAORV3S+mYMWt+JRXz9YMFmSY7BLO0AGYcgYcc/t5yGeNlZfF4h3cke4FpanVxP5AhZjPfX1hcmEY0m5aJfWVtBcbjyb3AhtUj4n+lYpknutKdRtkWEk= 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=PYrfL0PO; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=PYrfL0PO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E76924BA79BF ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=E20CcvByqo1m4womMYm/V2JwJj5eOCwp3vXI0bsdaijARlelyJssC700OGTtGQC4TOObN5r8fRljwUVP3ykWIt6jdkPXHiK295vOrog5Gpca9kBcRMofDcNodeZgX4DYwzLrKdo7yRRZRdES35CuEifkK1BQcJNsmCUE0v0LmPzv0nWV3Y7X/4gkqKw5BLdQtZakCs575I18Pux7ylRlnd4w2SwfqGoyZr32IN/dgx22TeQHhyPKRVDoQKu6aFiRb9P009a4AYuc+HUN2lpIRriDPie8tKQkY83cHJ405klAWDi+LBZiq2oLNYhGzzGhIfGPiByoLBivwykpW9V25A== 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=H/Qz3s53jKHLoqIGjc++H0xNsfeivHDu8jsqhNtOCt0=; b=GPjtKG6d9tQyAiOVlO9oZEaoXIfwXXM5VL3QmC3/MiljdR/N3eP8GORshauo6KBgAi+QBcKaOZ+Z5iawoHBXtWUN0E+S5zFS5yTIpfyd3eddNKj95V74M75cDWkWQcjIo/s3AwAWMi8A0lBtqwqHtsmnYfq5o1fc3ZSYINrdCEWDSsbHyV58XspzqeCTWwPx5ib7p5h8A7tdKBnobuQlFBbxP7h6P8jLF6Lty8JG3gdDI5JHH6fFKCGv+yQDtXPNCYdO6VW99ovay7DYM4pa1GkR5IAYVlpAZyyEVjyrHVr0gQXcNzWF1oosTFH/75Uooe4aMPysD9HIZ+cGrU0aZw== 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=H/Qz3s53jKHLoqIGjc++H0xNsfeivHDu8jsqhNtOCt0=; b=PYrfL0POy+0PAWkvdANjxvE7rZrb5aTOB8Sts3a82RoKcN0R3g8nQ80T7e8egT9EDKuPg7oLZrmjfFSjG16MtkhVxEeFJpJPO+3vpvWA/vctw5qkABGL24Z2kDFMqQPHYGnNUBAf+ptZ/ehavuTSawrX1hBvMzem+OgSV6roLA0= Received: from DB9PR05CA0020.eurprd05.prod.outlook.com (2603:10a6:10:1da::25) by AMDPR08MB11365.eurprd08.prod.outlook.com (2603:10a6:20b:71a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Tue, 25 Aug 2026 10:10:25 +0000 Received: from DB5PEPF00014B88.eurprd02.prod.outlook.com (2603:10a6:10:1da:cafe::3e) by DB9PR05CA0020.outlook.office365.com (2603:10a6:10:1da::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.12 via Frontend Transport; Tue, 25 Aug 2026 10:10:25 +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 DB5PEPF00014B88.mail.protection.outlook.com (10.167.8.196) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WtBfpZe0X96hqVWMbX8eJtwpB1HzJR5seWK3xFVRo2cOT2EUTpGZX6I3heulHuZZAqk5M8E3OFox3CW+rvNANWWUGPuqJF7vOMq+FTd3fcayNZJ6hlZDOkQ7y8ABtgeQ4wAQhzBvbzv1YWd4OmHRP9A5P9tNlQDGxeEXhj5NnoPNYdaM/DHtz3Edp721xaPK+astyMGlWZYa9pgoPaQV3V5Jb5v5I3Af+0WQWRcU3qbKbvVuh4jL2XOTtuQH9Ysi1Ajf2EHgNrBgsrDehv+fHvuuQWrjypqixPC58qAhB+XldoNhWVdpKEzZBC55wCxV3BRXfK7l/JNPl5Nq7mht8Q== 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=H/Qz3s53jKHLoqIGjc++H0xNsfeivHDu8jsqhNtOCt0=; b=BUhsCcRTH4QmKX8op4FiNo63RNWHac455i5eOrOPZuRb5ARRoJ0tiqZiKSBQgqTetUyClpqcIe78ZTBqGXftN6G5p3vgLew1ighW7zkQdW8Nzs6VHpVLZMLxpGLybeTXcXuKig1VX5j34xygmcAWntXKrUt4UdJGaqpaOmWQ1Aaj2kWWvnQyf+UK6DQMewIJXPLayu0U16VDzc5EqGnnuaAdT50as5Orv6/a9UbK7VovUNnQXm4KufeafrwKNrL+5DgOEXlcYc/3y7pfxOeGRcS5RMqqapV6WWnjS1FTiakyLFklXQXaKOR0Whvi6lMrF2K6ybJgFOKw2chTAjoB4A== 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=H/Qz3s53jKHLoqIGjc++H0xNsfeivHDu8jsqhNtOCt0=; b=PYrfL0POy+0PAWkvdANjxvE7rZrb5aTOB8Sts3a82RoKcN0R3g8nQ80T7e8egT9EDKuPg7oLZrmjfFSjG16MtkhVxEeFJpJPO+3vpvWA/vctw5qkABGL24Z2kDFMqQPHYGnNUBAf+ptZ/ehavuTSawrX1hBvMzem+OgSV6roLA0= Received: from MI2PEPF00000B81.ITAP293.PROD.OUTLOOK.COM (2603:10a6:298:1::418) by MMZPR08MB260451.eurprd08.prod.outlook.com (2603:10a6:190:53::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.12; Tue, 25 Aug 2026 10:09:50 +0000 Received: from MI3PEPF00008493.eurprd03.prod.outlook.com (2603:10a6:298:1::5a) by MI2PEPF00000B81.outlook.office365.com (2603:10a6:298:1::418) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:09:50 +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 MI3PEPF00008493.mail.protection.outlook.com (10.167.240.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:09:48 +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, 25 Aug 2026 10:09:48 +0000 Received: from PF4S4363.arm.com (10.57.48.229) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 25 Aug 2026 10:09:47 +0000 From: Matthieu Longo To: CC: Simon Marchi , Thiago Jung Bauermann , Luis Machado , "Luis Machado" , Christina Joos , Kevin Buettner , "Matthieu Longo" Subject: [PATCH v2 3/6] gdb: introduce helper class file_reader_t Date: Tue, 25 Aug 2026 11:09:09 +0100 Message-ID: <20260825100912.514232-4-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825100912.514232-1-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: MI3PEPF00008493:EE_|MMZPR08MB260451:EE_|DB5PEPF00014B88:EE_|AMDPR08MB11365:EE_ X-MS-Office365-Filtering-Correlation-Id: 05d67c56-b90f-41fd-4308-08df02911512 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|23010399003|36860700016|82310400026|1800799024|6133799003|10067099003|11063799006|56012099006|5023799004|18002099003|22082099003; X-Microsoft-Antispam-Message-Info-Original: hXXe9aDN2meVWAV6b3fKgXelPeOvhBfBbWYTwDHb4glLQzRq4e/h0B7443w74KkthqeM9eNRsCJzRGqX2K6qExTN0x1iHbMqMUcKOdq9VcCL1Aw182/Afb5xPzN04fX8lc5Q1RVjlyEwbV1qiOeSizCEAIl/rvrKWCxh3EsuZhNUhaM88AhDLxoDBM5TLCaR6sIOIrFg0B8hYT/xEmqnUB5UuygXwL0hRaDT0tistnLRyIT3Ke2O7AFbtt+sCzY5XdTjx+N0rMGHFEZWg14sSwMXgabeNyfFZmKUTCsmV2qdZzprvOsUtNtTRQPCHta+bWWt1BWp2bt2BbWVkYiSPn6N4BUXeGmKgMmmVAuMWBerCw59wlCwSy1uPWgb7DlMdj28PV3hZRgiI249sBbPM7eOzlAQCKk9kLaUioNFt+kOxf0w9UnO6RcjmDJ1AjYdWNWkdUCiGnZCtoXZLulQ7a5pun0jireufYs3CW6XwVm3U/2qNJsKMwiB3IuXdmdmC4bxXgsHjJmzx27dvBBdBfeXm/f0J53bSgBQBNTyhmSzl7ADCNZP7noHtBgBqQ7USERzZOzQnca98pTXj61ZViVsZ/NC++GmYqvNWlSJ0efmHPRsXnAEHSo6oDujlVsZ2oTFkAZdEVPeimiU41JRX6UYMUaA2g9+AfBm3O5mOzR8aFHC+2u3hHTlW8HGIfjCV0JVR2dYl/nBmTcuw/7hRw== 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)(376014)(23010399003)(36860700016)(82310400026)(1800799024)(6133799003)(10067099003)(11063799006)(56012099006)(5023799004)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: Oyp5CFIBTN+oWwFE8Tf+rR0xnVur3+cP+jeCNlWBDCDC3HdBsc2DQ6fvRRCilGn//0iY+qx/MD0cxvlCDuDqS1Z/weKBpPvmRxLbgO0wZlJGLKjTKfWK7YXpNGfXQXrwPwYdYpStV36/cd7jYpBIBThLwXzvoqYTgnmFiwFARp11P+YEZ166pgmXgQ3u7UKgD5EGDn3+fqRdFugfPHsWliNoiWWoLXMf24dYTONHsv0xzeEome0QNqMMsi4p5aXdUCoyfIFP4aOnAKOIjU/YxNt6IKhpEnN+cAxELl8wHYmStZ4jW2DBaQy+uGiTrORHCQuRzltwpsamjwtLzlZRSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MMZPR08MB260451 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B88.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 660a8032-7cea-4524-a140-08df0290ff15 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|376014|35042699022|82310400026|1800799024|14060799003|36860700016|22082099003|18002099003|5023799004|11063799006|56012099006|6133799003|10067099003; X-Microsoft-Antispam-Message-Info: 3r81Rrt5IwgsuxU2jLpeV9AI9y56pmGiIrlP4EirQlXM5QF8i/mhl9O5AaFYUbOI5OWl863Knio4UG5mxQxxQN67VWeJQfArHU0ShhpNWiYxuqX9Z2HU16t0nbH+UnJp/f7R5yIdNKb5cNcT7SM+HFizW2n2S6jYGqt5480vi8EiyU2aCvhqpJC4M/NKEjTlbnUU+AWZfpURJ/L2Y6Kv7A3sovbBNWpr8tTzhZ8aNCeSXLdSYLidGt/VtRnr7y/cXjQpkiPEcFx1FCm01ugip64Rh9MLJOK2PBErVkxJDsVpNWG5L+NZafxucbXDj0plR1mUmrrPMGcEXj4LSIjGRYFhKMCFZbzrQk8Y5Q73dzJWFQ6JJZ2grxpUcZhyRZkVIkGK1n498HoFiF5MiFkJ9l/ISRvekElWDGOzYVZtv+iy3+Zea/dmdmp3zcNuN/tf7Ha3bUKP694+XD9m9wGucVM3hJi6mFIGub5DhmRTWYCCqVUy2/rhLVe+QZrRGCjbzPvUrDT7Lpi88PZjj2vRolgcscSVJ+thrOKOtdblN9tLpyI3kZweE5unK8eCPTb21aXftAV6IqiRw2poIkozS4g8eWLHR+t9QS5P2Le6TXrmJ+LDrnyHu2h8iREvPQokOlkHe/IssXYQ8K1xrCIZ1HrfUQjdiQMtuGiX8kFKXmEtWC8B5S+GeBCoW+Xv9Mn0r3pRdssfFG9LJ7gUoRJHlQ== 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)(35042699022)(82310400026)(1800799024)(14060799003)(36860700016)(22082099003)(18002099003)(5023799004)(11063799006)(56012099006)(6133799003)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iZcXgychpMRiFdTZlfTezI0pcB6jORXr1ntzm4hsP3y9c9nVdXlKbqGb3H7MNReTY1T52clA6xW6dl7NCOspcoAOSzJDwS5q8fzWi9ObpYhospjlDa4n4TJLBbk6+0SC3eGEOEgKfe5dJBQUCA7IEl5RVWIPLH97PlI2TPncozuC4pWIAtPwrf3DH5/vLBqP+TbJwxj6aMpAbxL8aDSp5tzgYUYfOJap3E2tgQRpkqLnR/HLwl4fDqlEOkOQ7A6vnWxI/uCqygRoA994RsQkE7i96gh9c4iY09yp0M/Z0ZESvXVYgYkEWXORp8toVn2tYnGXsJM3e2BIJ0cc4+H+UMvAgPbBO1xpqAvjkW9BJ4QN2NojkT/QZ75Wb6j1T8/DmQkQX72cSInFWtsSAcoqo9t/EDyeqHaCPHRAlCX2XFhC6Z3lWnZDyvtscQshupVN X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2026 10:10:25.5849 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05d67c56-b90f-41fd-4308-08df02911512 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: DB5PEPF00014B88.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMDPR08MB11365 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@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. 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. Reviewed-By: Thiago Jung Bauermann Reviewed-By: Christina Joos --- gdb/amd64-linux-tdep.c | 12 ++-- gdb/linux-tdep.c | 122 ++++++++++++++++++----------------------- gdb/sparc64-tdep.c | 15 +++-- gdb/target.h | 78 ++++++++++++++++++++++++++ 4 files changed, 143 insertions(+), 84 deletions(-) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 9b23db72bbe..52f16c953d1 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1848,14 +1848,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) @@ -1867,7 +1864,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 588984a1ca4..84614bc91a0 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1551,7 +1551,7 @@ parse_smaps_key_value (const char *keyword, const char *line, DATA is the contents of the smaps file. The parsed contents are stored into the SMAPS vector. */ -static std::vector +static std::vector parse_smaps_data (const char *data, const std::string &maps_filename) { @@ -1561,7 +1561,7 @@ parse_smaps_data (const char *data, line = strtok_r ((char *) data, "\n", &t); - std::vector smaps; + std::vector smaps; while (line != NULL) { @@ -1673,7 +1673,7 @@ parse_smaps_data (const char *data, } } /* Save the smaps entry to the vector. */ - struct smaps_data map; + smaps_data map; map.start_address = m.addr; map.end_address = m.endaddr; @@ -1697,6 +1697,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. */ @@ -1708,17 +1714,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); for (const smaps_data &map : smaps) { @@ -1782,17 +1784,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; } } @@ -1813,10 +1811,9 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, } /* Parse the contents of smaps into a vector. */ - std::vector smaps - = parse_smaps_data (data.get (), maps_filename); + std::vector smaps = parse_smaps_data (data.get (), maps_filename); - for (const struct smaps_data &map : smaps) + for (const smaps_data &map: smaps) { /* Invoke the callback function to create the corefile segment. */ if (should_dump_mapping_p (filterflags, map)) @@ -2295,9 +2292,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. */ @@ -2319,24 +2313,27 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) gdb_assert (p != nullptr); - /* Obtaining PID and filename. */ - xsnprintf (filename, sizeof (filename), "/proc/%ld/cmdline", ptid.lwp ()); - /* 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/%ld/cmdline", ptid.lwp ())); + if (!cmdline_freader) + return false; - if (buf_len < 1 || fname.get () == nullptr || fname.get ()[0] == '\0') + /* /proc//cmdline stores the command-line arguments as a sequence of + NUL-separated strings. */ + gdb::array_view cmdline = cmdline_freader.cast_view (); + /* The buffer points to the full name of the program which generated the + corefile. */ + 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; } @@ -2346,27 +2343,24 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) p->pr_pid = ptid.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/%ld/stat", ptid.lwp ()); - /* 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/%ld/stat", ptid.lwp ())); + const 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 @@ -2438,13 +2432,10 @@ 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/%ld/status", ptid.lwp ()); - /* 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/%ld/status", ptid.lwp ())); + char *proc_status = status_freader.data (); + if (!status_freader || *proc_status == '\0') { /* Returning true since we already have a bunch of information. */ return true; @@ -2837,9 +2828,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; @@ -2877,7 +2865,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 @@ -2887,15 +2875,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)) { @@ -2913,8 +2900,9 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) } } } - else - warning (_("unable to open /proc file '%s'"), filename); + else if (task_maps_freader.error ()) + warning (_("unable to open /proc file '%s'"), + task_maps_freader.c_filepath ()); return false; } @@ -3241,16 +3229,12 @@ linux_address_in_shadow_stack_mem_range 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 (nullptr, smaps_file.c_str ()); - - if (data == nullptr) + file_reader_t smaps_freader + (string_printf ("/proc/%ld/smaps", ptid.lwp ())); + 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..97f8fa72e52 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) { 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)) { @@ -328,8 +326,9 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) } } } - else - warning (_("unable to open /proc file '%s'"), filename); + else if (adi_maps_freader.error ()) + 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 819279c08fc..017918b6582 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -2341,6 +2341,84 @@ 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 &&) = 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 ()); } + + /* Return a pointer to the data. */ + T *data () const noexcept + { return m_data.get (); } + + /* Return the number of bytes read. */ + LONGEST 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, reinterpreted as U objects. */ + template + gdb::array_view cast_view () const noexcept + { + return gdb::array_view (reinterpret_cast (m_data.get ()), + size () * sizeof (T) / sizeof (U)); + } + + /* Return the path of the file that was read. */ + const std::string &filepath () const noexcept + { return m_filepath; } + + /* Return the path 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 From patchwork Tue Aug 25 10:09:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 142165 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC8854BA79BF for ; Tue, 25 Aug 2026 10:11:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC8854BA79BF 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=I0oqY2Ym; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=I0oqY2Ym X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11011002.outbound.protection.outlook.com [52.101.65.2]) by sourceware.org (Postfix) with ESMTPS id 24D9E4BA900D for ; Tue, 25 Aug 2026 10:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24D9E4BA900D 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 24D9E4BA900D Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.101.65.2 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652644; cv=pass; b=wJQzKyBcldX3gdGEwpbuM8Js49aiQuSkZzkBukgfNY0olyOdLCy2P7BRnl0rouagSpHUnVI/eQEkn0rpRcpkVD3h7QGgAuBKpzSVLcf9P0qd1gJMHM1rD6cksVJs82ex74rII3SeipKd+VNy7I2weXm5OZs9KE0lYLW8R/Nof/s= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652644; c=relaxed/simple; bh=0bzf7luq2vDBcWejo1e+u5B6Q3+5yPf7t7s40GjIVqA=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=KWKf7CCRm2jtwyuQqn5fNxETmW3tO2GuWrV7nBdL8WPFkHcNHzyy5zwiqxfIv++CHaQWzNMmE+Wts8WCbd4tom+XGCjkaA0+NZRea7WVALJ0h9JHAGJL4Wtx2yo3T6H2KcAaGw/va0+XJvvXmMRz6aA7eza98uJFMu+SIjTiaa4= 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=I0oqY2Ym; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=I0oqY2Ym DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24D9E4BA900D ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=GJ2O2IBVQ2zpuQ7NVDRF3cSREDmriPP38VHsj0Hf/yZaQkqBIHxk4r5hcTDywtFEznNJnxG2uJdL5XZ6Sy69dP/0r/qze/7KWWKmiFVIDqYjWfTg6eunMm59b4EaqJ08tQ+534JVXj1wo0gp9M+3syfLJ3j2Dp70tInqnlGJ6s1H4SAwvU/HmAAulGvF5wJ65KfpxerY3PPkAlEvrQ20fI6Z+xIMEt/FJbEbsFntDH0Bpd4u586+a32i5GwS5Re/ANNVFroBAHaUUzVJx9xAHVLp4lnQkAXT6Gm6zaSYlXYPYBWJAtS27a5ArLOChOOFIgKMAn5BTEfA40+MqjE7tw== 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=qpnMIll2pwiT9a3sRHQx7Q5ENupg+gsq3lH2e5EqHQ0=; b=MNajDUizAsh3VDmKI4R0PVhJNhi5fCm+kJvWrghxC9bBQ3dijmPee9UumYJY4ZP/eEqoNgtwZ6LDtMPcja3ZdUVN+l0d19x4u32QNvR3vAjHGsfQhQPpB4A3v2NQWVjuzJcro2q3Y3jMv9eT+Tfbbt6ybn8xK8J9op11cAbEmEyc8w9mSIoXL9xhwVOpFTSC/++rfr93m74YtVPw1rx3NIyfs7nuMts7W0Gj+8EKE/Fm7rnpZnbBMxMU0zQBgjzHgENvKkqdXqV5An/0a9AxHAcXxPfWMWP+jD07MmfejsqVlfFH+oVzzxCbsKn7rakTbBadqPFSz+8I92FRWuEJEg== 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=qpnMIll2pwiT9a3sRHQx7Q5ENupg+gsq3lH2e5EqHQ0=; b=I0oqY2YmNoiCNJidopdlmeSP2hvr8T5b+3VRucw959zZAgBM2j8xrpK0ObFDqasK6SCQpHfQ691vHsT28ctak9te/9HJfsKoO+BygocUM4+2cuog11bn9XksiI4Rt6HY3KbJewQ7RLQs0JUvrZmxxEH5/nKJWd+kZk8doIe/bo0= Received: from PA7P264CA0278.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:373::16) by PAXPR08MB6528.eurprd08.prod.outlook.com (2603:10a6:102:15a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.12; Tue, 25 Aug 2026 10:10:34 +0000 Received: from MI3PEPF0000848F.eurprd03.prod.outlook.com (2603:10a6:102:373:cafe::87) by PA7P264CA0278.outlook.office365.com (2603:10a6:102:373::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:10:34 +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 MI3PEPF0000848F.mail.protection.outlook.com (10.167.240.150) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t4jOchDX+KRNKVnZuBEt1RWwSlPM0nNEmVz3jj/Yz4CwBrpxF24RyyRLKQaQijR6lwyrQfLHw2cMnx8O8ynZUBFgBLbkzumxffeOCdtc8mARY1t2HjMOZPimj79kswmEjQMm8dwn2Z+NLv3q4Ud3e+sqHZLih7KFri0oSz650deKDeJQ6rePGAcf67QZG/W3zlKAiEDE51yGzCPbQvK0QqHtL4xm/Q9tReiR6NMYG+N7b+VAyVwUGcPLYLfnezSsMqI749l+/jPqcbFxldfj+fCAjVujXj1Mle/Undagmaeks9L0sN96Crtup9gyL8qQzRq5E23g+4fqOOZghHbOOA== 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=qpnMIll2pwiT9a3sRHQx7Q5ENupg+gsq3lH2e5EqHQ0=; b=Un7jwZlpaDIBQp5gxA4L7rjE1ep+Q+kenRAIsMhvSTcjPlvagJhjCPh9rz4CdZ/w7NKfFt3lUbNrEGQROjwlB/SKPbUXBFcqya/Fg4WVO9Zs0rOTLb90DIBewXAKYC+63DbSG9N/1NVRF8ucrwml+XLjsO4Jkc4Rl/Jf3acbvi+Pu23WW60jcO1xRxy82LLp1aUrdboAgKEEQKZSxJJ1zSu9zdUojOdUtC9fGLDKeqwGLZmpGYxSrdQDRcoiox2vKsQdNlNpCVxts+HhyGY6gj3yTR6EjEJeTwUClVZqBRmTBnTPrSkUBUOy4mUutHRq8ci7ZajvyrS1kzC3SOGVcQ== 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=qpnMIll2pwiT9a3sRHQx7Q5ENupg+gsq3lH2e5EqHQ0=; b=I0oqY2YmNoiCNJidopdlmeSP2hvr8T5b+3VRucw959zZAgBM2j8xrpK0ObFDqasK6SCQpHfQ691vHsT28ctak9te/9HJfsKoO+BygocUM4+2cuog11bn9XksiI4Rt6HY3KbJewQ7RLQs0JUvrZmxxEH5/nKJWd+kZk8doIe/bo0= Received: from VE1PR03CA0021.eurprd03.prod.outlook.com (2603:10a6:802:a0::33) by AS4PR08MB7735.eurprd08.prod.outlook.com (2603:10a6:20b:512::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Tue, 25 Aug 2026 10:10:00 +0000 Received: from MI3PEPF00008491.eurprd03.prod.outlook.com (2603:10a6:802:a0:cafe::b) by VE1PR03CA0021.outlook.office365.com (2603:10a6:802:a0::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.12 via Frontend Transport; Tue, 25 Aug 2026 10:09:59 +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 MI3PEPF00008491.mail.protection.outlook.com (10.167.240.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:09:59 +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, 25 Aug 2026 10:09:59 +0000 Received: from PF4S4363.arm.com (10.57.48.229) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 25 Aug 2026 10:09:58 +0000 From: Matthieu Longo To: CC: Simon Marchi , Thiago Jung Bauermann , Luis Machado , "Luis Machado" , Christina Joos , Kevin Buettner , "Matthieu Longo" Subject: [PATCH v2 4/6] gdb/linux-tdep: migrate linux_info_proc to file_reader_t Date: Tue, 25 Aug 2026 11:09:10 +0100 Message-ID: <20260825100912.514232-5-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825100912.514232-1-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: MI3PEPF00008491:EE_|AS4PR08MB7735:EE_|MI3PEPF0000848F:EE_|PAXPR08MB6528:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e5a301d-505d-494d-c3b9-08df029119f3 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|82310400026|1800799024|36860700016|376014|8126099003|22082099003|18002099003|11063799006|56012099006|3023799007|6133799003|10067099003; X-Microsoft-Antispam-Message-Info-Original: 7n7wjEODAXKP/vFB+YceEiMmKFv1hEXz3V827PVFccWb3raLgy5fOC+OuxZ7EPM4jvLrO/H4OokBPkfVe+nD0yF0EDzGvw26XemO8JcG9NpMfKZxO+eN9av9aXxJekSbe+3fA8ZDfW/WflaPdzEnvX3u9Ydg/4pljGn+09AUtiRLOUEL9iGhgQcq7edllRVNr8qc6OUV61JCEXDTQbYJwSgPiyRaRtqcoUVTsvLoB7TvWNYNEHmAIAEnjoZ9rODL9P6M/NTCd4RTZoWsgG5aQmDspR2A5NQ45topqMsTgKdgalDmj9eAPi+ymgHJd4/HMIeLqOm2rsLpnopBvs4XM4KZl0RVvGM9xlPROy3DNF00oRjOq6ykOQMYbcccG/DKNX/nPk0sYpBFKXD47jw3M8hvS1d1QxxLTEEzFRzaeq+GO45/NHMkUnLAQOYjI7GyRJ0ZSGumlQcuypUkahi6Vu7N0+CoLLg5T2kQw79txuwp029ur7nCpVxCC+tZFuaUaEWruKF5LO+hg7odKVGqt42EIXU5Z+rKh3U9ZkdTLIL18QYORVfKHG0/X6wEeLFhtP4ABxt2Oxh5tQnFUKRnqrKa/t4gzDTKdRjT4a9waYEnes+psaF8yy9Zvzu0if8rpFraBL0EJOsJhfzqbxnsq8Ve/7rGrWbKEXdnXoRVHXvPruGUFfuLsLW1lH2ilLsAKZHr2IqKahk1L7iwxVcMTA== 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)(23010399003)(82310400026)(1800799024)(36860700016)(376014)(8126099003)(22082099003)(18002099003)(11063799006)(56012099006)(3023799007)(6133799003)(10067099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: hhnAS7djh6cIhrEWFVDZDZUnHd87NMp850fQrNK0h37dctcBatvhmahZYT6kW1N2nATKRXmKW/zIIugx/WWOJgpAzqdShr8MQJ1juSwJ311+DVLHfioJQ3+HnHfS9b5qx3VgaUdzZSeNxbRqWJBjSlCsLZ6roWsSr03yfkihyv/fnPvXJ+i8CdeCDEmJ2UB0mJHV0PNSLrPfnUgJHn1HXOv++oh70qqwYrvlvm9lSLwCL0GQgGBN/0+ddTcg4U0VlPg2TKR6iObjJeWrG2fCODJJLII2Ecb9vBnONm0CR1vRWHX/SFDRrfw1iSnKsn+9fy1Ray5gxJDuw5pN82ffuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7735 X-MS-Exchange-Transport-CrossTenantHeadersStripped: MI3PEPF0000848F.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c9491b7c-7e6f-4ea2-ecfb-08df029105ab X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|23010399003|36860700016|14060799003|82310400026|35042699022|1800799024|6133799003|10067099003|11063799006|56012099006|8126099003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: QaNDkxaGSaAW75S/1p8XWBXtxVdf9PunqYzAhdAUyjyEum2RuciyxDg43b7zVSumwqENGTktfZ5i+Rn/VT7TOE5NZZqzvl0sf1I+YI/rkIM0jbFnmhkRfEqZdUfrn5+E58GaoWVzD97M9YR1OBMQybXR03t8OA446ZLlKmDadEe9tt2zaQEskn9TXh/fzPGw8G+Ad7XIDReQM6+Wnu2rS2g3rilpSh5enQTBME/74B25uRtDinqc6Q3vhVw7Nqlwci5S5yRXa35eDdyvYkcw1m6FnnKmUFRiD4tbrbutrKWrzHLr6+5SUiAoynhfHm1IymDnNPhsS8APbCYsqKDEyJh1dXmw0xlXA7fqw4mpgXUiQAIjF9AXBCwPFAllxf+/nppMszvxlQKet29bSMRPgKLlkYLIJAL5jlOCX85wYgVSrIwfsan9Wsfzz/X5xO9HETDaluopsxOyMMX51o9MXdIYs2f6Y1KR1DrMPtsY/KFlat8Kn1iiQsnRw4iO0U8SI60NhP4DzKyZLz2EvvRC6S97LzasMvNqsIDqrqwy71OJoG2lfOk0YUdqEIRZPf9xUtl55EXx5YKOH8CBmetpk0nqNQmS+ldprtSPdw9+1LjIIT7Owo47Tas22zdMsN54LH56F07DWP2bQW0lQ/9d4qg9WcMV06PNtLMS5U6GoVfPHTh8UlfXgomAZA+4XiH1+g+qScvmXO9IVn3YnbRJcw== 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)(376014)(23010399003)(36860700016)(14060799003)(82310400026)(35042699022)(1800799024)(6133799003)(10067099003)(11063799006)(56012099006)(8126099003)(18002099003)(22082099003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xAIf4SH8Q5jrrTOXCT8p2m10vWkPNIhKrJDMUVuLlANbYyPVEZKb+mHwY0zdXSQv/eI2KH/qhVLMaTpn9cOOBpm4JdxdmOUJ3kG2pW/syBpLhe2tsynbgs3+ef9Vet4/Pxb35Ovi8WXwnr/o0SD6hTdTlIjxiPZhhk+HbKnWNjakwKzGhUc/jjJCrGHacUPwGViKi6UCF3Si0peW8QQVsjHabZ3LB+BAD1dRbMQkE0NmJx4IV/5zSALPGNwi9ef7WJUYFub/u/OICMqtU+qwttUAFLT4XPgBvLWGAWi+Qez3LeRhrVvow6CDSgS3vn8pLYExdUF56QYL6jaNe1juiAjzFJq2dDsbymjiYQ/nf88FQlaREWbwCmW0o22JrUp1aegE4Snh+pBxHVsVyCIUDPrMLjWG0u9RPpUZ8hSBhjwyLPjwTsvesAmx2FjJPFp9 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2026 10:10:33.6944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e5a301d-505d-494d-c3b9-08df029119f3 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: MI3PEPF0000848F.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6528 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org The patch migrates the code of linux_info_proc to use file_reader_t to 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. Reviewed-By: Thiago Jung Bauermann --- gdb/linux-tdep.c | 135 +++++++++++++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 51 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 84614bc91a0..e2c5b2d8815 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -866,6 +866,39 @@ dump_note_entry_p (filter_flags filterflags, const smaps_data &map) return true; } +/* 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}; +} + /* Implement the "info proc" command. */ static void @@ -914,25 +947,23 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, 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); + /* /proc//cmdline stores the command-line arguments as a + sequence of NUL-separated strings. */ + gdb::array_view cmdline = cmdline_freader.cast_view (); + gdb_assert (cmdline[cmdline.size () - 1] == '\0'); + /* Replace null characters splitting the arguments in the command + line by spaces, except for the last one. */ + gdb::ranges::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) { @@ -946,27 +977,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) { @@ -980,10 +1009,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"); @@ -997,12 +1025,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; + + /* 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); current_uiout->field_core_addr ("start", gdbarch, m.addr); @@ -1021,26 +1053,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))); @@ -1167,7 +1199,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 ()); } } From patchwork Tue Aug 25 10:09:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 142166 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A41C74BA2E17 for ; Tue, 25 Aug 2026 10:11:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A41C74BA2E17 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=JHhFsPgu; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=JHhFsPgu X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from PA4PR04CU001.outbound.protection.outlook.com (mail-francecentralazon11013021.outbound.protection.outlook.com [40.107.162.21]) by sourceware.org (Postfix) with ESMTPS id 93FCB4BA7995 for ; Tue, 25 Aug 2026 10:11:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93FCB4BA7995 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 93FCB4BA7995 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.162.21 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652677; cv=pass; b=f4AmxcEf+/pxJy94MAxf4o8+FRbiZJCjWQrD14w3JBVJJ0m5A4JY4Oxi6PrY4p53GcIRKjHmOmRiWga+dlBCmml15ANBMqnsCAAqqWSldC/7RxAOxblqttQMOxJknddm/54EQk+cslTHk77cCTb/ki0rurAuZ0GXQLEKPZXbI7A= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652677; c=relaxed/simple; bh=Z+aFS6CYAcpewa/ROwHg9MwQrzfh4Wohn8E8LG5D9uU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=k/xXV8hn76t5bjqHSpegpQuVkSQb8YhGIeMfoENOxlwXl2gMhFSIU8v07GUWD5+GaPFtyRsgft5KGBpYm8VR8Pn1xLo+8r9oh4wWQulGauXEMHIY5GnURxbShuL6utQbWyO5XvEXFtPVhOoeEtkXiQ1PYX3tJrYQxFjB0p2VkPc= 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=JHhFsPgu; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=JHhFsPgu DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93FCB4BA7995 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=JMECGFbk74oShn7xbiSjpkk4EzcX6qxwGAxe2i1rKSC2yiftDD0shHqtF0LiaI+J7U6v5FJn83JeQKHjYvK3dLvxG59TY9h1GsDXLhP/FDma2HG4iWUYUVUhTJELcTEyh8MwjA7bJRgPSjjx3DnAjhPcMpOZ2M+MQIaRM1xuqSzQgnOvVXtBho+3PdBD9ET04HWvjb10jnwFKzCZxHhGrnZG2QzsZo/NLdNw03tHSVqCmt343rEN74mdNzb13zqXX/MV/75vP4a18f0306/p/Ev9L7BXMfpQVH3JLjDj6xn52WQhXmNoLUvf+eTmlsrwWei2lcGY1rwvpa+BU4oZ6w== 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=S9dSJ94q5vSYwGadamo/hkneJDzcKozLebK0A/KkzEo=; b=jRb65KpHvMT+6Vu/twOrE6PxO+cbPrlhBluB5VGzzt2QQu7+k35BbBOBB2rEOE56o6WdNGSzC44IgDAD++8eVtDulp8ceT84oPvLNbFBfKetNmVi1QLuOrqv7fPd2zVaDFcdvXdoKru+TaLQMn+HzQU5ETVzivSdUwBEr3Dr3iqp1usJaKakj9CeaMK8Q5YMXwTU0AHI2lTLI+pkXt/roCrpjdFbkrr2xtO2Gt8E/2es3xq+9udGw7kmwAUxEkkN1ltQ0TDL4tZlmzYEX/ZrWn3h+Bn1tLDr2kWTIGBMn1THQgQQ0d7o0SZ6tBrhMGA2p7K7t7mhXQ5UoJT9PC+6VQ== 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=S9dSJ94q5vSYwGadamo/hkneJDzcKozLebK0A/KkzEo=; b=JHhFsPgubo8CS//TbX+DgahGzY1XKQllCgRXmc7kh3RlZnLDlZ1gusdTqR0q0w+eeXQKz/a9TzBwN4tgNn+LP/+x66f4Vy1kUEhzolrX5opeQqat/bc9Y0Japgs5s1uWW+7GQroEsprPWe8MJGAyxhu+frTdmZ8TcnG5V/mcO0s= Received: from DU7P250CA0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::8) by AS2PR08MB9200.eurprd08.prod.outlook.com (2603:10a6:20b:59f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.12; Tue, 25 Aug 2026 10:11:09 +0000 Received: from DB3PEPF0000885A.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::6e) by DU7P250CA0014.outlook.office365.com (2603:10a6:10:54f::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.12 via Frontend Transport; Tue, 25 Aug 2026 10:11:09 +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 DB3PEPF0000885A.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:11:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MbLuuDJhkKvusdamEVczfxuM889iYn3q2dPKsg7QVodIQJHbhf7S4pV61PhVuHtynMYLcEEUbxFC9aCTMZBRTDclff6sunsUaZJ8psM6DlCVN8dsC7g/bYdZ65cxyHv7tQKMn+YYRwiTRk4W7aOJfM2GJ9cvcmO5qq5sicqj96+Tf6RJZ6KYYyocUfzeh5wWZH2ekXw995tlgWjZW9g3fYsj7+5YFnfVdi77aV4Vx+AUX/YuXeOBGZmn5kB+qghOut2Y70Fs5ROogZLcY2XJi6fbMZiVSgJghrDHN27XoMtSBDVCVcq1CY4n0pe1pkmSu7ntzLiXzZgAvfXiAE6glw== 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=S9dSJ94q5vSYwGadamo/hkneJDzcKozLebK0A/KkzEo=; b=NCOc28kBIRBNelqE3eZjVsoDScLrCYQ9o53KQQtumOCD4H0Wjs7PqXXG5NdyAa2sOnFB0BZf3ry6yVId8cBkf7gSwhQE68+0gU8V0Pisj5h07JwXPXMgDBWh28RiPUaz/X9PKTiXcd6kcmKDqQcWhuqvxfY1yvMmKig0L5AtNhWbXJKpUsPsQz5pHaI2QM9M3CLDvE2P9UZRxHiKm1kQtPvL/KYm8IuQhSEDdR1ZSxEAxHPyjqeXWGvocS9xUVgiA89ZQ2G7/240OJLjzv0/l3HvBDPHC25P3GV94yLlKx4c+UEBZPphjnVPhkD4T8i9KOoa5YdQc4Sg1onItyyNKQ== 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=S9dSJ94q5vSYwGadamo/hkneJDzcKozLebK0A/KkzEo=; b=JHhFsPgubo8CS//TbX+DgahGzY1XKQllCgRXmc7kh3RlZnLDlZ1gusdTqR0q0w+eeXQKz/a9TzBwN4tgNn+LP/+x66f4Vy1kUEhzolrX5opeQqat/bc9Y0Japgs5s1uWW+7GQroEsprPWe8MJGAyxhu+frTdmZ8TcnG5V/mcO0s= Received: from PR3P193CA0012.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::17) by DBAPR08MB5862.eurprd08.prod.outlook.com (2603:10a6:10:1ac::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Tue, 25 Aug 2026 10:10:36 +0000 Received: from MI3PEPF0000848E.eurprd03.prod.outlook.com (2603:10a6:102:50:cafe::41) by PR3P193CA0012.outlook.office365.com (2603:10a6:102:50::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:10:36 +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 MI3PEPF0000848E.mail.protection.outlook.com (10.167.240.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:35 +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, 25 Aug 2026 10:10:09 +0000 Received: from PF4S4363.arm.com (10.57.48.229) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 25 Aug 2026 10:10:09 +0000 From: Matthieu Longo To: CC: Simon Marchi , Thiago Jung Bauermann , Luis Machado , "Luis Machado" , Christina Joos , Kevin Buettner , "Matthieu Longo" Subject: [PATCH v2 5/6] gdb/linux-tdep: migrate linux_find_memory_regions_full to file_reader_t Date: Tue, 25 Aug 2026 11:09:11 +0100 Message-ID: <20260825100912.514232-6-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825100912.514232-1-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: MI3PEPF0000848E:EE_|DBAPR08MB5862:EE_|DB3PEPF0000885A:EE_|AS2PR08MB9200:EE_ X-MS-Office365-Filtering-Correlation-Id: ec5488ba-d1e3-4046-d3c2-08df02912f23 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|82310400026|1800799024|36860700016|23010399003|30052699003|6133799003|10067099003|56012099006|11063799006|5023799004|22082099003|18002099003; X-Microsoft-Antispam-Message-Info-Original: fMfyZZqs3Trn8bTuw8Cjf9+URQzJmG69j2/AcLFIMSGnONLNMj+3g2k0t4LJCLfS5x8wZ/lUZgQmhSJtcsbS6mxC/24Xw9vrxwEHsPg/NSlwdcSNJDcb8QM8v8NOkexGTx/y46LnZkzRqn8w8zE7THozbXrO0ZSwot5V0hI0BMslcdVscqRRDdnbV0zg7+OTVJf9OT3W33r+bkc1K+Gu2H6JSMQe9YDfa3W3pZHfWarCjjaY5gErjYsm3jn3VtWCQl+gzSshQbSsKtqXfn7Z20YXyNe4oX5XGXOG9rqORTAhsC5Rvgru9kTvrrSnMo4HuVJGHsXPKmJYfiuSMqrVmAkaw5tj/0qtW1+xGPXuxgx3BEllboxgui+Cp6tTtHX91HwVqfmtL2vhn08pAjoMUz5w9f86rxN0kLCyyN8vUWumYSP/DHYoE9BE640AU1JrsvLQ/fzc+QgI1ILkpGncnmjKNv6t5gG2XiMuw4XIC8EbWju8W7mgbpv9UVHM+OLmuT0ijyHXSuqH7JgnO3NXZ7FL90Qf24sI4+PaQSrcmOr5omMvK0GiliNFpLVyUDS8/GZUQIh/Hdoa96wdozQsbOSrO/fLpfD0Yp5Wz0yAwsoqfmGKDfl3p6nzB119SX+QSGChUKMUaj8RHk2kxKhz+XFNSSOMcBFinxzUrNxm1+NRsNh3o0MtPC+A9pS2LkNBt20w/KhXU3jOjGJhDV17IQ== 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)(376014)(82310400026)(1800799024)(36860700016)(23010399003)(30052699003)(6133799003)(10067099003)(56012099006)(11063799006)(5023799004)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: pg8rn46eTjFF+AVm/MeE92kwprXtdaaRBMjNQxd8wkmh5b20Lq9M7Jh7H1ddsbPjQBxfrLAK8dkQEEgk4Lh7zC+P+7xc4FcQgXApZR/3jePVl36CShqWS9U9xiL3xorFkKkJtm76xTg7iaaSx4Ol65DL6H7mrWITwiYAQ1LNETVFpL1/FmlOrr2c+aZsYi6n+I6bFX23D7QeyO629BgBhAOHfBoH45tgS3bL1yKAsLRqE2C/vrrgugTFkNEJtepsyNbHA3IzGwcu7ET6c6japVWMhfMziFhpZAizft/4s/JfoAovnXSbamgbxoyKrMt4wDhgSmyYChPS2fZOWT5yAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5862 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB3PEPF0000885A.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6b828672-581b-4316-98a3-08df02911b00 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|35042699022|14060799003|30052699003|36860700016|23010399003|376014|1800799024|10067099003|6133799003|18002099003|22082099003|11063799006|56012099006|5023799004; X-Microsoft-Antispam-Message-Info: TMgBjcPQ73EvY//UYolp/tEjmi8nzveZpboGYPnMX3++C3LeyMEZVTMQIV1y88ZOKJhocPBhPKdh7sAXD7LYLHCEaZAIzSkAhxv1Gwwzr9jTKTLlC8sZXkjag74uR9bp9eqrhEs7ANn+/5hGoO3nc3mUacDJ0TsTGFyIHfAlGUd4VMm0E4Eh34NXtN1auJ4SBETj7uysSMcW4RxEevBzt0+8MS4BhdCxvc5XpgWtYwx9ixNNMLXQijCe84oZMV0wamNOtYDQJj6CFeW6YeCf/7/EZWuj4mRVTMdEp3izIyYrtuQPAXYYbk49GqJHbke89ABpcCCx+oQIr4vyfFRwsazYzans79QCA3DZQ4MKPNTXJHSkBemosDuCtx5dgNDeWven7b/ej4uTZAeas4a9plo4Fbj3UtTbMrDQHFoF6h3nPEp8GUiqwvh/ZCJXpR0iQboQocFV13UKfKZc6Jx+BvJvey6olyLhEoDPtsstDlGVoi0mIOnQrr3RAjJv8osRqZR7S2OZliB9gz89JLmqIR5sVXMaBhl5wxr5W08dyqLspQ4IENw2rArXwfnw32iFm59lN6//NLQG4io6YEb6ORqvXWzUPWRBxq2FpvX5eKBRECQJ/O1BpnmyWakPToWj/sUM4znsmiHvrHO2gf/FfQyMp+99B/qR7DTMLJPRHfIMDUWkcJKZLCwyLnigoLGxniuAmU6aolUj8yjNga/ayw== 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)(82310400026)(35042699022)(14060799003)(30052699003)(36860700016)(23010399003)(376014)(1800799024)(10067099003)(6133799003)(18002099003)(22082099003)(11063799006)(56012099006)(5023799004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zIG7P1ADtbO5SPOWkI+IM1sgeQtrvUFpfKsDtNclFTq1YcGFKAQgMm+7fIjRrpf25VjpHJngslus3x2Q6C2Zwncxjr9CQk1pSKqCk04Bjx0SGMGaNp75kP4NN7TCyVYV6L0PCHYvmCAgVUSRZW2al7s7SyOBBnAvw9njucN9iAaJxHOZXjHm6Qsz3NOX2Pn1IxBlFdJzQmb9Xw3gss5loFSX3k32tyozcL/kDCMI1guI/G94BfAJmw0wu/ZS2t9FhL7pRBl07scIsXyY/F4NkQl1kWbmgi+48953bMJwuV86VrCarViOf6KxnHu6BxG20IyHBINIjirKJ0WISMPVQuu+7bZV44oPTIzlTzPX0GgXjzfCkt4EKMqdSpqsAaRrbUTJVDO67kVRB+ftLrLN7GYyMoI/V01GOgbzCC3HPsKTJezkjh1A9F42XEcPWxkM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2026 10:11:09.3307 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec5488ba-d1e3-4046-d3c2-08df02912f23 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: DB3PEPF0000885A.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9200 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org The previous implementation of linux_find_memory_regions_full could still return success even when none of the /proc/PID/[s]maps files existed, or all reads returned 0 bytes (this last case can happen on Linux when the thread-group leader has exited). As a result, the function could incorrectly succeed, allowing core dump generation via the gcore command. This logical defect was allowing, by chance, the function to return success and hence, allowing fortuitously the coredump generation via gcore command (see gcore-stale-thread test for more details). A previous patch in this patch series fixed this issue by using the first LWP ID of the current inferior instead of relying on the PID. This patch adapts the code to use file_reader_t and makes the function return an error if reading any of the procfs files fails. Reviewed-By: Thiago Jung Bauermann --- gdb/linux-tdep.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index e2c5b2d8815..2833d8a4bb6 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1828,24 +1828,22 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, } } - std::string maps_filename = string_printf ("/proc/%ld/smaps", ptid.lwp ()); - - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); + std::vector smaps; - if (data == NULL) + file_reader_t smaps_freader + (string_printf ("/proc/%ld/smaps", ptid.lwp ())); + if (smaps_freader) + smaps = parse_smaps_data (smaps_freader); + else { /* Older Linux kernels did not support /proc/PID/smaps. */ - maps_filename = string_printf ("/proc/%ld/maps", ptid.lwp ()); - data = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); - - if (data == nullptr) + file_reader_t maps_freader + (string_printf ("/proc/%ld/maps", ptid.lwp ())); + if (!maps_freader) return false; + smaps = parse_smaps_data (maps_freader); } - /* Parse the contents of smaps into a vector. */ - std::vector smaps = parse_smaps_data (data.get (), maps_filename); - for (const smaps_data &map: smaps) { /* Invoke the callback function to create the corefile segment. */ From patchwork Tue Aug 25 10:09:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 142167 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C71484BA5433 for ; Tue, 25 Aug 2026 10:12:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C71484BA5433 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=Z4++okwz; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=Z4++okwz X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c200::3]) by sourceware.org (Postfix) with ESMTPS id 9E6954BA5434 for ; Tue, 25 Aug 2026 10:11:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E6954BA5434 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 9E6954BA5434 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c200::3 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652665; cv=pass; b=tedRneJYpjvNlkjGqC198MOIBwq+IVjU3uUe83dLryckJBUU/wh2qT+91Y5FPYMEn88uAJibqQ9szzcPkqm0cCOo7gIRB6nd0ioIw3eWargmmNYmXRKMCci/TxpnNebYX/TpSAvJ/vGPgQNPlaeZho6vJQWZF7smm2CTDoDapqY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1787652665; c=relaxed/simple; bh=VtHv/TVrpLE1BrWhI7KhQFViLCCrDf8gPR3dI0AuXNg=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=NTkkDIR5bHT0Ypu6kvAwpxJIxQ9G8vJuvg+dHeazfpOlOkR9hmRAZEwmcgbv5AZjZ2QT0NSIjcPEGUAy5HQz7uP1CWbdnc83TtqfNGND2S2MY+fNQlx3QeRWJRyGYoAB7lLByJepgFLoVcOl/ANzfaMTHonzgKHzHSveui+3o50= 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=Z4++okwz; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=Z4++okwz DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E6954BA5434 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=XDaM+dmvX9MRFdeJ99qblsaCN7x2hWktLvy8NoePGBj/vJ9HqaBEzNjnbnUCInOw6qr4ht9XVNiHCOOgKz9Jo9MsXgZjSiAeD44yQEcEUZMKNSlrLr/c2xXzCzHghrJI3DQMLDSoxDtQuLSPHAPZCbtb7O3E0sGXtvvxLBE/ZbmrsGUgoaHtKz8xZekRwJzsReFA59SpvifeUljZFbMTMDmMyqemvTkmsg7hP5nwgYtIVHQ0ZGvhGbS3xEtrIFUbsoLxuM5/U5fKRvmgb0/S61Qt6D81Ui05PLhRvWtGVMvBcobe+jqGiVzE+6lRnTshl9hyxZb+a7sYtpj6pCt8xg== 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=n1i+BlumYMpEE6ZqZl97ZG3xLnNtMkjr872lyHXvRt4=; b=eNMPVzU3TUk0NaO2tqAWqIYqOCqMcKT0Db2iefjA62lFrNATbrrQOaquyzLpvGT0TTJZFNmAF9bArUGUy+NM3cLlBwSjFXh67Xib0aoG6fEgIxmUk4u4Kni8jk91J73oYeoQFdHgpZPs1O6Yi34r0pVDZH/wNlJugCKvknngeYaFvVPEzBZO57W6cEb91ObcZRhqjwe9jyvy4+ELfkntyk45BJ8q8V0C4+K+PxnT0bDY3i03M0yDyQOqMln1nQGLAyhp/i5g45eU/VoAfvb+hp+mnjKx+F9acytRwEYqZ2djSuB/Kwcx2XcVgTvzcrIDvRZ/3eL0EAj4CL/mRpq+CA== 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=n1i+BlumYMpEE6ZqZl97ZG3xLnNtMkjr872lyHXvRt4=; b=Z4++okwzTue48dtLX4isGNRlRqL8dkdi8bezvYCl2kc5fsrRHwmB0VgWL0BeuwjUku/R3LnP8QD4urLrRATP77bcx9JMZ1sBGkSgKHb3VhvokqlMvvnBy6PTwm1mR9XE71sh4+U17l8Yopvc3k++bS7p8ZcTyBloVRuGTJ62ISk= Received: from ZR0P278CA0121.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:20::18) by PAWPR08MB9853.eurprd08.prod.outlook.com (2603:10a6:102:2e6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.12; Tue, 25 Aug 2026 10:10:59 +0000 Received: from MI3PEPF00008481.eurprd02.prod.outlook.com (2603:10a6:910:20:cafe::48) by ZR0P278CA0121.outlook.office365.com (2603:10a6:910:20::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.12 via Frontend Transport; Tue, 25 Aug 2026 10:10:59 +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 MI3PEPF00008481.mail.protection.outlook.com (10.167.240.168) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pAKoutP015+SB8BuLcnD78UA8Ld17byCABQxFmJqG9le3qiKBi4T1GH2VDAD61QPCPL7liLUwZpLWzVciNswVAaZVP8vFVa+cgGtH6grBWvVwjsgE2VCer8dIlEQQwF1lFJ80Y7YGbDP6LwwFB3s+qDwMA3ipU/Y+ajIqpVc4fnEGbdyGBP1hSYVZekZ9VHncsKQQfWE1+UUVVwc/42DGwXS3JEO+yD4K6XT3Xepv0IbryPXigHg+nY5YZVOJvPeCyJO2PZSHY0FgcfgofIje6ITGhxnmahE+CqEf/GeKtgYQbUZ1q7uYtfDOFbrZ9yiVuCDGHQMwQexfJouu9BkGg== 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=n1i+BlumYMpEE6ZqZl97ZG3xLnNtMkjr872lyHXvRt4=; b=BP52Izg25mCT8Iu6FdLy9SMjgybJkEwjcVwSDeGSd9bhak7l65IbPiZbWOXRH5QV/KnZ3z5vH5ywOZkwGCbKBPKlengweh1giAUjL6aESZUVoF69Ej9aa4IniPfltDynOHNJmCbrp+UcNcO2bbXn/uPnbHbzQLNWxA09+5iL3nYa9A1aGbPWq1QxTPeZ5hXRRG7qeLKJgLt/r0hsahGIWrVF0HLn/IplMLihvoOHzvuprpkbYb9JqlZKV0Z6TgZ4tY1dyUzg1gQPXNIuP1HuZBDKN1kSCJvzfqgqGocfDYnb1uOJsy0tBzLbDSp6iZ9Tb7D9jZiaf7T+6V8zWj3NEg== 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=n1i+BlumYMpEE6ZqZl97ZG3xLnNtMkjr872lyHXvRt4=; b=Z4++okwzTue48dtLX4isGNRlRqL8dkdi8bezvYCl2kc5fsrRHwmB0VgWL0BeuwjUku/R3LnP8QD4urLrRATP77bcx9JMZ1sBGkSgKHb3VhvokqlMvvnBy6PTwm1mR9XE71sh4+U17l8Yopvc3k++bS7p8ZcTyBloVRuGTJ62ISk= Received: from AS4P189CA0029.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::20) by PA4PR08MB6096.eurprd08.prod.outlook.com (2603:10a6:102:eb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.12; Tue, 25 Aug 2026 10:10:21 +0000 Received: from AM4PEPF00027A62.eurprd04.prod.outlook.com (2603:10a6:20b:5db:cafe::1a) by AS4P189CA0029.outlook.office365.com (2603:10a6:20b:5db::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.6 via Frontend Transport; Tue, 25 Aug 2026 10:10:21 +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 AM4PEPF00027A62.mail.protection.outlook.com (10.167.16.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Tue, 25 Aug 2026 10:10:20 +0000 Received: from AZ-NEU-EX04.Arm.com (10.240.25.138) by AZ-NEU-EX04.Arm.com (10.240.25.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 25 Aug 2026 10:10:20 +0000 Received: from PF4S4363.arm.com (10.57.48.229) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 25 Aug 2026 10:10:20 +0000 From: Matthieu Longo To: CC: Simon Marchi , Thiago Jung Bauermann , Luis Machado , "Luis Machado" , Christina Joos , Kevin Buettner , "Matthieu Longo" Subject: [PATCH v2 6/6] gdb/linux-tdep: remove legacy parse_smaps_data overload Date: Tue, 25 Aug 2026 11:09:12 +0100 Message-ID: <20260825100912.514232-7-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825100912.514232-1-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM4PEPF00027A62:EE_|PA4PR08MB6096:EE_|MI3PEPF00008481:EE_|PAWPR08MB9853:EE_ X-MS-Office365-Filtering-Correlation-Id: 04124130-4627-4e07-0670-08df02912846 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|1800799024|82310400026|23010399003|36860700016|11063799006|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info-Original: v1snXv4Ya+nLQW9sOBORkgBlYoZZiOq47giH6cn5PW1czCDJisO792Mji6FOdy3vARfYN6QEPZ1e+v1veJ+gYcnOycOENNx9nS+ibKPMwrmbejGqAFC29LMLZh838kErRNtBRWnZeiOJiAtpHeGu4RAV9Oz6S+N7H97yVAcrL6kJD6HU79LabOvS7BBLK+n12VBhhM0uGRBjPZ+6ZtInS+Af/e2WTIGn8Ef2t4r5RD5QXmLX5PZ8wgBPPUF8D96OwpPyRk0m2ybQZTkmw2AJ4Jim3fVjbTdLKpUqcN05aqtuSjMWH7V/EYFL1tnPlK9DlD82zukYscIWKC28T5fSJ0UeNd55AvLKyItqL5DSn0hfrSAP6A6YqwSK90bgfHONfnGyYsAKdo1IsEq1xeQLBP0AIN9t/DmVpK/5tZ66rBLMTbu1eb2LdUHcJ/SNJfN85vn097bCC5dFCR0+3OrBRZwg1RDX1WmLcR8shrqFjYsQFpQ/dJ8fjoIJlHrA1EzUQIbnGWSYaAwsOwOHTacsNVP/PGV0s32V6QIsFM5TSwzhbi9s1FL4EEb/wOwkkXPCJxkYonSRhA1ZymFG7n81uAKwwUAkcFjQDLgWpJEEyDdkM1IHKGR5AjqPe0/BcbjvnW8KGz9txvmhV8KrBmqjywZtwEKQ6ztHBCAwhCXwVRggZYHo/g52s9TODP6oRfC9bQe06LYlU7ELj06l7RhUVw== 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)(376014)(1800799024)(82310400026)(23010399003)(36860700016)(11063799006)(10067099003)(56012099006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: 3xDAML9W9m9cRLXULI76SAVB8uLKt9O0CTDFkjliGcdXWVplb+Vwt94Zd6hD1woDVFbOMWfhz8pH+//A2zsFFG1VNrrB4JI/7PNUMv+q9icXbZ/GRN1BmzXiECJztDOJHwondqnlche+BrhhzwUqNBLC9n8jH8ksIWtPlxZmjkl7gkhk0M9kJ0Ofys/UOFLWTAreECJ/82UrDr3lnvsQfAWPbW9nJPU8BM9xFm3DMglsWJead7wa3JbGxluQZQOgZIHroBptbkEVLFVpwLJ8AoUvJt5nnyUkr6WD3ePeRjMZj4W0iE8VySWPb0uYVCDTIPETkcGlVDvtbU0McEieNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6096 X-MS-Exchange-Transport-CrossTenantHeadersStripped: MI3PEPF00008481.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dcf0e15d-36ee-47c3-efca-08df02911248 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|14060799003|1800799024|35042699022|376014|82310400026|23010399003|18002099003|22082099003|11063799006|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: vL0OlV0BseDGoqbOGNaiT9dIhxL8WN9Ee8DJiJOeZgVUu+7pvB53uIg3u/yVZOuxQJkThD0AE+KiH3smRJkj8x0bD6SD5NlItV5p4lLRge1vGL7hUku0YhIsaRAiab9cg2Dqc4/5NIBd76kuJbQQEMDuQIakccAnJ+DEjzb0Jdb7SeF6NVBsP+2vV2qU6SJBRZqAvDfY4O3YhjVg9x/U5iAeQ3DRSZZIhRXY5ercWqEjlQDVVwH5WzwHLbdatz0yiK0oMCLSEi+ATDJ0GpcJv9p5pIa9m1GwVr/w2ZTS99DrVHMyUUbVBDekdxpJDqOM0sICYRYxc5mSjSpAIqn0kRvf7uR4KvBlZUGDaGmyxcGYUVM15ZmywrYGhe3rcrKHemI/4Y3OLizmtb5x77WTnGMXGtUa36w6eK56R7896m+tG5tngh0zCn3GQ8xw0cHeEhtvD8TTF1tdeI6hak6sdTrfvRiX4Ycb/DJ02/tCOj8fyCmAqwo4zgBKBTVwyfNvCDlRqOOcjL+mhnZSAuVS+/CnYTVwQUVIFdsQ6roJ0edD/7THMosZFrxcArM4B/et+BkYMT//gu8ODqDjphXTCOQ3SqglESf9mHrenWHEcbad3/C+0gCT2lETQUpaX6pbc7k1KD+aZDEyvkPBBMgLHpXdptqy+FZxwnLApGrKGTL6WTyzE4c2LMoo45L1cyadGvfAz2YP4xp+Kz5SzedNYg== 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)(14060799003)(1800799024)(35042699022)(376014)(82310400026)(23010399003)(18002099003)(22082099003)(11063799006)(56012099006)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ssxe/iixh8UtONK13SxCwI708OAvw+x5846RqwYYNlesjkZgZBWzy9eSKsdv3mHUBMLz7wUuAw+cfkmP4bxHtfRUk1zFbFcMrTlkxpyiMXoqTnAHHaiTkTrloVEXL0DHeSM2P+wBN5od020FM+FVmDk6oIxLEnumpz7BWxn31zcbtA/BH6IFo0sEhAQNHHwhvaJiifs4l+yetwNA127MWAD2p60B+lsjAwp7gJQ8y7W2cN8f+rDKn/Fs0MTvs0LkyuNNUKk8dj8K/vTOOsPGiYWd3pHJAFv4es2MUs1ylaU+lW5dxvTLFvBGuJjnDD7oUmyEQecnwI6n3l8CGs2gAGyDi2Pcgmh4liagMUch/h9AzP7toSwtwINZ4Kvv8fG4msPUfKxez8yM9ubJrszbLaQLVO7TF18mBBCuh5hNbwY33XWBO5/bq6WDcRDplM/c X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2026 10:10:57.7424 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04124130-4627-4e07-0670-08df02912846 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: MI3PEPF00008481.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9853 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org Now that all callers use the file_reader_t overload of parse_smaps_data, the legacy interface taking a raw buffer and filename separately is no longer needed. Fold its implementation into the file_reader_t version and remove the obsolete wrapper. This also simplifies the implementation by using the file_reader_t accessors directly. Reviewed-By: Thiago Jung Bauermann Reviewed-By: Luis Machado --- gdb/linux-tdep.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 2833d8a4bb6..4cdb02b9c09 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1581,18 +1581,17 @@ parse_smaps_key_value (const char *keyword, const char *line, /* Helper function to parse the contents of /proc//smaps into a data structure, for easy access. - DATA is the contents of the smaps file. The parsed contents are stored - into the SMAPS vector. */ + FREADER is a wrapper around the contents of the smaps file. + The parsed contents are stored into the SMAPS vector. */ static std::vector -parse_smaps_data (const char *data, - const std::string &maps_filename) +parse_smaps_data (const file_reader_t &freader) { char *line, *t; - gdb_assert (data != nullptr); + gdb_assert (freader); - line = strtok_r ((char *) data, "\n", &t); + line = strtok_r (freader.data (), "\n", &t); std::vector smaps; @@ -1648,8 +1647,8 @@ parse_smaps_data (const char *data, if (sscanf (line, "%64s", keyword) != 1) { - warning (_("Error parsing {s,}maps file '%s'"), - maps_filename.c_str ()); + warning (_("Error parsing keyword in {s,}maps file '%s'"), + freader.c_filepath ()); break; } @@ -1663,12 +1662,12 @@ parse_smaps_data (const char *data, decode_vmflags (line, &v); if (parse_smaps_key_value (keyword, line, "Rss:", - maps_filename, + freader.filepath (), &rss)) continue; if (parse_smaps_key_value (keyword, line, "Swap:", - maps_filename, + freader.filepath (), &swap)) continue; @@ -1679,8 +1678,9 @@ parse_smaps_data (const char *data, if (sscanf (line, "%*s%lu", &number) != 1) { - warning (_("Error parsing {s,}maps file '%s' number"), - maps_filename.c_str ()); + warning (_("Error parsing numeric value associated with " + "key '%s' in {s,}maps file '%s'"), + keyword, freader.c_filepath ()); break; } if (number > 0) @@ -1730,12 +1730,6 @@ 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. */