From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aa9yJUFqjWqKxj4AWB0awg (envelope-from ) for ; Tue, 25 Aug 2026 06:11:13 -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=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-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 939161E033; Tue, 25 Aug 2026 06:11:13 -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 [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6AD341E033 for ; Tue, 25 Aug 2026 06:11:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A03B24BA7986 for ; Tue, 25 Aug 2026 10:11:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A03B24BA7986 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 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-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. 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 -- 2.55.0