From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ge7mNprIaGor4zEAWB0awg (envelope-from ) for ; Tue, 28 Jul 2026 11:19:54 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=m2b1HSC3; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=m2b1HSC3; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DB1F71E09E; Tue, 28 Jul 2026 11:19:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9F2141E099 for ; Tue, 28 Jul 2026 11:19:53 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6EB314BB24F1 for ; Tue, 28 Jul 2026 15:19:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EB314BB24F1 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=m2b1HSC3; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=m2b1HSC3 Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazlp170130007.outbound.protection.outlook.com [IPv6:2a01:111:f403:c20f::7]) by sourceware.org (Postfix) with ESMTPS id 033574BB24EB for ; Tue, 28 Jul 2026 15:19:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 033574BB24EB 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 033574BB24EB Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c20f::7 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1785251951; cv=pass; b=vcL/Did1yH4rum7dvDUoeFxEvXEm7TS/aps4+TtnidBqCZ2f7fd5hhoSh1EcRLUaXsS8IDRudG0avV6aYMh82L0OvOolnWN1zIAtwq7TLaxNEgCiL+NsovLGDFMZRWupy2VAPGsJBD77ICwPaOlPlWjIl6H4y6Ik/vJTx8PtJr0= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1785251951; c=relaxed/simple; bh=0i7x7dwjL5y2rlwu8JSmAa/tqS49YTdwQA5yGIJGCzQ=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=cbskv4hyXsHCPTzQNHsBOiFPTH12xUaB8rLt//Z95L8Z/OhTS2RkIOT26kIcNf6R2K0XeZ4P28+PmFZ8NlA2iUrZET3+LzZaKWF4ogEIy7vnYrrtl46HbTBXwMsIr2F1+Ej6j1P01r8VEi1UaBKTP0Nhae9MteGEmrRuzMCpnsQ= 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=m2b1HSC3; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=m2b1HSC3 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 033574BB24EB ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=MlXcXPPiRnfEoduRfi/w3O4p1dVqK+MWfQSlQXoQNovA0yINOHgsu0u5ruv+b9wHUs6S9MC2bU5TIUQWCLLRJvW4TOmqd9HyI33UFkAUeLFK45Bu8iKaZsUfbCvmDZKjw4IesciFDdHKPrVlJN2e/Ggyu4BaFtCwaFINlXKp1q+zH1l3rAZ3gLQl6CfGq+/nOWpJcCKfIIUR7ut3SlH/6fKOGDOUqXAZlR0XgAQvyaFKgvrXGcpRaygnj7/H5kR6H1WYcUVmnGGP+lx3U9RNqw7eGB1aliq6yOEx2oq3Yq+Ylh1ZTwVEDIFPltC2PPnrNd1RZKlS0feSgr76PulrLg== 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=7TGUiLRwkyy3NNruNPiFtWf0VNi8GqYiCEgvS/3sNt0=; b=x6g1fueOERaARjuoaiQiG2sYpjjktlAZyosu+3tt2n9FsXrszDuOYTQ25vQbjn+Pgp2BZL82TlM4tdPgpz/x7y1UQ++LavteUNorE3V/vtrBrgM+3OIOF6i1Z4uHbjpABgM+sIH31ExyrZtl2TdKE5qJ3pH079tzk8G6zVxl0z/H2LwDSVUx55vccCIfBz8zxV/J8XR9ol5cA3Kn/mMdqYLnTSmbUJItBHfyn0af/ErCeGeBLMxv+lXuAsjcY+9UiKqsc/KF95a7XU0w2kgxTwecEVIoxZZtmN9gkUV+XkjJaZeA6N//lGqZEJfgJ9XgWn8tyLOVDorwFw3V8DjfMA== 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=7TGUiLRwkyy3NNruNPiFtWf0VNi8GqYiCEgvS/3sNt0=; b=m2b1HSC3eNw43py5iOwFYfAx7yxo90PAgxDQmJ+wkwS93uFLx/cCXU4LJ4ABsSaSIkVwX+gDP7WqtAujUXBauFqxyvkCm0TEpVPd1GRJJsrIRd+IfXN0gdj327b6rw8lBWl4PSX0pdRcXKR+d1cMYQxiENdUfrzeqRoJyZrjNvo= Received: from DU6P191CA0029.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53f::28) by AM8PR08MB5859.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.13; Tue, 28 Jul 2026 15:19:03 +0000 Received: from DB1PEPF000509FE.eurprd03.prod.outlook.com (2603:10a6:10:53f:cafe::87) by DU6P191CA0029.outlook.office365.com (2603:10a6:10:53f::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.13 via Frontend Transport; Tue, 28 Jul 2026 15:19:03 +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 DB1PEPF000509FE.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Tue, 28 Jul 2026 15:19:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QNI+KV+ux43sjCRMCfh3k9AGnuI5HhA6DnzetFOyMzSCGdAdNmSXrPf0NVdsWe165SB/gcHJ+CHqJlNaeuXQ96Ole4DL3VrmpqjU3km0c53hjATdvoghtVOdc7g1ymfDziP9gv8jNTt+i76rsCGLS+GO6Ca4bBPjAg4lwS250M3eKva6qMjNUU86fzFEk7g5QApCPjZXIPyK1TDdwoUQbncrUagHyCUHD+qtegDQsvVujiKfNg+woaMNZxostXnmIhOhF/iNHG8ALaK+wNWueS9i3iWal3OVkAb9INfDXm74Viw0xXabvD16RTDdcT3XZjWCrG2jFIk1pH/v0D8zcw== 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=7TGUiLRwkyy3NNruNPiFtWf0VNi8GqYiCEgvS/3sNt0=; b=hLa1oaG7D4KFsN3JHCiiMA0uBPvwgtvFyjzxzH6DF14EZA7bagqwhvIO7zTZeUPPwdT/0OeoIeeugOFTYzFLcc8PblHdq/FYJJW43MByj1bqnUylQIX+Z9MhpKzpbBSpIcryTOehLXNYLFyy5HYV+cei5GdlSP0z8n51p1OzccjHPf9IbUGWoEeXdFQ0Fol3b31bDqb5dTkC8Pzhvn5kuZeS1HWyZv8e3sr/+mJmoRVpBTLbThoeqKIl+BbAoc3mvjSYqOOzep6zKToobyz8M8rAoc+Jocca7eoV8QQbTvWRWP3q75V/WNiYVNjKBKy0uQQxbuEAH6THrAbB/g+T2g== 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=7TGUiLRwkyy3NNruNPiFtWf0VNi8GqYiCEgvS/3sNt0=; b=m2b1HSC3eNw43py5iOwFYfAx7yxo90PAgxDQmJ+wkwS93uFLx/cCXU4LJ4ABsSaSIkVwX+gDP7WqtAujUXBauFqxyvkCm0TEpVPd1GRJJsrIRd+IfXN0gdj327b6rw8lBWl4PSX0pdRcXKR+d1cMYQxiENdUfrzeqRoJyZrjNvo= Received: from AM8P189CA0025.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::30) by DU4PR08MB11150.eurprd08.prod.outlook.com (2603:10a6:10:577::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.12; Tue, 28 Jul 2026 15:17:57 +0000 Received: from AMS0EPF00000191.eurprd05.prod.outlook.com (2603:10a6:20b:218:cafe::4d) by AM8P189CA0025.outlook.office365.com (2603:10a6:20b:218::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.12 via Frontend Transport; Tue, 28 Jul 2026 15:17:55 +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 AMS0EPF00000191.mail.protection.outlook.com (10.167.16.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Tue, 28 Jul 2026 15:17:55 +0000 Received: from AZ-NEU-EXJ02.Arm.com (10.240.25.139) 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, 28 Jul 2026 15:17:38 +0000 Received: from AZ-NEU-EX03.Arm.com (10.240.25.137) 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, 28 Jul 2026 15:17:38 +0000 Received: from PF4S4363.arm.com (10.57.42.206) by mail.arm.com (10.240.25.137) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 28 Jul 2026 15:17:37 +0000 From: Matthieu Longo To: CC: Luis Machado , Luis Machado , Thiago Jung Bauermann , Simon Marchi , "Kevin Buettner" , Christina Schimpe , Christina Joos , Matthieu Longo Subject: [PATCH v1 3/6] gdb: introduce helper class file_reader_t Date: Tue, 28 Jul 2026 16:16:57 +0100 Message-ID: <20260728151700.253720-4-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260728151700.253720-1-matthieu.longo@arm.com> References: <20260728151700.253720-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AMS0EPF00000191:EE_|DU4PR08MB11150:EE_|DB1PEPF000509FE:EE_|AM8PR08MB5859:EE_ X-MS-Office365-Filtering-Correlation-Id: f871eba2-d806-4b46-8199-08deecbb8ee0 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|82310400026|36860700016|23010399003|1800799024|376014|11063799006|10067099003|56012099006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info-Original: NV2IGyBt8cZiDtslgZwPYpFonBgPdgXIQuVTwDh50dsDq6jxYZrBGpdMFWBBEcC9Pv6f2N1cX3kN4oK9oxV2inlD6oUpjF+H3iNxb16oEZaWs64b+GTGf4nos7fNzrWbtepJRmzCW1vdu5yxK/CWY6bWOxKcnLgoQZHKE+M02Tsn55qG+46rahRNQeqFnsszIJ2MUsb9KC7w59YlKp5JWiNUbMG998l81c4qh5WEvmNdUqqtqwGXalM8lajAF2gs+u9ORpFChA7Wj9Nj4PR/ah0pXVMYbSGkICk/yW600c3zRF5bSVQhPX8KVaWm/uerAymIhrLi4x1LmBxb8KDRzTSw58tVP9VPozXNmHQCDsJyK8f4UWRAMQKte/LcmZ1Ujnr/Oh0XOVGQ9CzA3hS7tWKOQqack8NBssiCTjYfqj6pA+mM2xwj0hWdtS9WlqZJ3TcAq6zAOwfgvFnv/Q7nK/q3dBPdjLPBV0/d0RPQFlAII2mJ47TXwHwOff+691jp6XtEAPla83X/pjm0U7zHaImroluRejEq4lJNc63LEUPD5wGQ8VZf8w+E024bqO2KTiFfo0AI5xvUjRtsQcsIVy8rM6aO119ENb3YgBaidBvyfG+35tYHpelL0s/2lngg/wzXc82FAerCNQrYithmd4SaPDoNADO17ybPDv2mqG7qnLC1g0ZLLlpVkp6FebyFB8mue2uFvY2RKrIosDVtKQ== 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)(82310400026)(36860700016)(23010399003)(1800799024)(376014)(11063799006)(10067099003)(56012099006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: Z24MXiNt2MsdrNl/zpEcWVEsfa8bYCm0c2odK88GcxlQWLzCt9IaDBsZ5M6XeFIXQoB1NIPw3lnM5oERDtvhK0VOS+91QjLEmVB+Wga0FAm9RrYlTzDUz/LlhA1qhuDm0EwkExGoxzXEVV6SMLINw0vwxPvFCdW5wxP/yWWQeZe3d4/Hi7ooq4vFXJtwK2W6+fJ94vuPlKyOZQMnLvOUCRuXYNIFo/9iHRj19Oq3CqZfK4XuuV5oO3exotL/xBGaCrYm/iR0V6fotc/bwI0Pwkq3h/+kOfWmroVdF2foSH6m3ynRpFVRCOLQz+a8UwY1GDIJVhujOu7o/Le32s/fuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR08MB11150 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509FE.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 71252e9f-889a-408e-90e4-08deecbb6683 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|36860700016|1800799024|14060799003|376014|82310400026|35042699022|11063799006|10067099003|56012099006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: Efg9XuNTkWyu2/T0cBIqVWTJLua57bBPqEba0KZLwhrzzh/5Y2X676bncwB+XUZNLKmfpI5cXOeI8Iy30LS9QynQ+SvexowGSHdDTD6jybKPJGZIxUFNTEVzvKRHoFI1aEz/P4NFcB0HDT7TzakEX6zfaK0LQCYbi5XtHse3eQKDSzXg7547hXeIegwM9YDYtYRgA16z/D9uvDvfh1sNSZoffMjn2HoASg2lyxwZjrow53eOCtxn4EFP+1Ayen/8iQHhp64zqNas2qew6SvFUvbgHTvveOPWptSAQwPn+JcKcTawNy7EDUJC50DvbNTjQIW2HzBpNIh0yFjwLDsn7w3+0JG2JzD9dvy4ygjYuOLv/oUKKMU07+hUHvz4m/D7g1LG7S5dOW4z7IjByXqrQn9ze8vuEoQWW8VFu9B9PfR6uUsFb5j/ITlaYt2MtXzhlv6ahCo2GUT4cH4xP6AZXaaW4o1swCLF2wAAx/IkI/Jsg7yWpKsblBEyrHh+iq4Lh9mKlV9z9CjW++v4HmVhLjhIBF210FKndDs520hZsghPF4uA/1NYgDSZERULE0/o+SPKR0JiKiCyI+CtDFu45iCTT5vLNwIiFlTjIYEa0QY2z5iRep14uMZzsyALLq3+9qaFq3NJ3fqxzkY6RC5+d36U4B+0Xzp2ZhlX6byTpQl/49wrVef0Rh1oN8jCbJn6WwlxPsUtCsOC5YEDVTrA9A== 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)(36860700016)(1800799024)(14060799003)(376014)(82310400026)(35042699022)(11063799006)(10067099003)(56012099006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qnyd5WD7mj3D65ntUQ4ZrxxOtnCi2RwYQzk37gRysNmzTJu+ixyCs291wu0W3Xc6Gl9iaxQzFsor8WTpbptitPmABOYSKxJVriOfNGEvBiJe77f/QTVzw9StAUe7XLV33OUmxWWegRcNyJGrim/bO28ZVuB7ZXn/vDOaYz4NbzU4VJ7mZHKpFTTiSM88BFnxnU5XZ2szUbBbmkMxWe9sfNSN6sNuVQxTGMyetIXjMJjrT8hIgEP+OXJuuyru5ROFQiNyIBra88BJ/oxivyR2304V5BNuHgItP/NIZTipg+WuLosIqswwn1RNASaaRH47SnfIaSfUcTylWDW2EkUTFrtqLEPZOKGiLztzMullHVdwLrrCrtAot42W6UJjPZI+KidPa53GKd5uSfrLGGbXh5lrMLakQh919X23xCTgzbMtq39a0l5ctUqj+jszPGMn X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2026 15:19:03.2225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f871eba2-d806-4b46-8199-08deecbb8ee0 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: DB1PEPF000509FE.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5859 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Wrap all the boilerplate code required to read a file in a new helper class: file_reader_t. The class owns the file contents together with the file path, and provides convenient accessors for the data, size and typed views. It supports both null-terminated text files and binary files. This helper eliminates repeated calls to target_fileio_read_stralloc and target_fileio_read_alloc, remove explicit memory management with gdb::unique_xmalloc_ptr, and simplifies the casting logic when working with binary data. The patch converts some of the existing Linux, AMD64, and SPARC code that reads files from /proc to use file_reader_t. --- gdb/amd64-linux-tdep.c | 12 ++--- gdb/linux-tdep.c | 109 ++++++++++++++++++----------------------- gdb/sparc64-tdep.c | 13 +++-- gdb/target.h | 79 +++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 76 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 9bdcc55a0e1..11f0a6952ea 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1698,6 +1698,12 @@ parse_smaps_data (const char *data, return smaps; } +static std::vector +parse_smaps_data (const file_reader_t &freader) +{ + return parse_smaps_data (freader.data (), freader.filepath ()); +} + /* Helper that checks if an address is in a memory tag page for a live process. */ @@ -1709,17 +1715,13 @@ linux_process_address_in_memtag_page (CORE_ADDR address) ptid_t ptid = get_process_reference_ptid (); - std::string smaps_file = string_printf ("/proc/%ld/smaps", ptid.lwp ()); - - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (NULL, smaps_file.c_str ()); - - if (data == nullptr) + file_reader_t smaps_freader + (string_printf ("/proc/%ld/smaps", ptid.lwp ())); + if (!smaps_freader) return false; /* Parse the contents of smaps into a vector. */ - std::vector smaps - = parse_smaps_data (data.get (), smaps_file); + std::vector smaps = parse_smaps_data (smaps_freader); for (const smaps_data &map : smaps) { @@ -1783,17 +1785,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; } } @@ -2296,9 +2294,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. */ @@ -2320,24 +2315,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; } @@ -2347,27 +2345,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 @@ -2439,13 +2434,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; @@ -2838,9 +2830,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; @@ -2878,7 +2867,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 @@ -2888,15 +2877,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.error ()) { 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)) { @@ -2915,7 +2903,8 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) } } else - warning (_("unable to open /proc file '%s'"), filename); + warning (_("unable to open /proc file '%s'"), + task_maps_freader.c_filepath ()); return false; } @@ -3242,16 +3231,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..955631b87df 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -301,18 +301,16 @@ adi_tag_fd () static bool adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) { - char filename[MAX_PROC_NAME_SIZE]; size_t i = 0; pid_t pid = inferior_ptid.pid (); - snprintf (filename, sizeof filename, "/proc/%ld/adi/maps", (long) pid); - gdb::unique_xmalloc_ptr data - = target_fileio_read_stralloc (NULL, filename); - if (data) + file_reader_t adi_maps_freader + (string_printf ("/proc/%d/adi/maps", pid)); + if (adi_maps_freader.error ()) { adi_stat_t adi_stat = get_adi_info (pid); char *saveptr; - for (char *line = strtok_r (data.get (), "\n", &saveptr); + for (char *line = strtok_r (adi_maps_freader.data (), "\n", &saveptr); line; line = strtok_r (NULL, "\n", &saveptr)) { @@ -329,7 +327,8 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) } } else - warning (_("unable to open /proc file '%s'"), filename); + warning (_("unable to open /proc file '%s'"), + adi_maps_freader.c_filepath ()); return false; } diff --git a/gdb/target.h b/gdb/target.h index 819279c08fc..09830dfe3a9 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -2341,6 +2341,85 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf, extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc (struct inferior *inf, const char *filename, LONGEST *len = nullptr); +/* Helper class for reading the content of a file on the target. */ +template +class file_reader_t +{ + /* The filepath of the file being read. */ + std::string m_filepath; + /* Smart pointer to the data. */ + gdb::unique_xmalloc_ptr m_data; + /* Number of bytes read. */ + LONGEST m_size; + +public: + file_reader_t (const std::string &filepath) + : m_filepath (filepath) + , m_size (0) + { + if constexpr (std::is_same_v) + m_data = target_fileio_read_stralloc (nullptr, m_filepath.c_str (), + &m_size); + else + { + gdb_byte *buf = nullptr; + m_size = target_fileio_read_alloc (nullptr, m_filepath.c_str (), &buf); + m_data = gdb::unique_xmalloc_ptr (reinterpret_cast(buf)); + } + } + + file_reader_t (file_reader_t &&other) + : m_filepath (std::move (other.m_filepath)) + , m_data (std::move (other.m_data)) + , m_size (other.m_size) + {} + + /* 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 -- 2.55.0