From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EaLnHy4HSGrbGCQAWB0awg (envelope-from ) for ; Fri, 03 Jul 2026 15:02:06 -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=DFdWGD2l; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DFdWGD2l; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7D3DF1E024; Fri, 03 Jul 2026 15:02:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [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 1A0E71E024 for ; Fri, 03 Jul 2026 15:02:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 37C394BA2E1D for ; Fri, 3 Jul 2026 19:02:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37C394BA2E1D 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=DFdWGD2l; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DFdWGD2l 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 08ED94BA23D3 for ; Fri, 3 Jul 2026 19:01:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08ED94BA23D3 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 08ED94BA23D3 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=1783105286; cv=pass; b=pzRQ02Wjdrbk99ukwsQbObUDBqaEBh4ElZvrM1OwSX0m4DYlGOdVD2/A96BmRtqqOpRPn8e9eT3W97Ce7Y/kUYvL0WCEthm0SLXZVFTvIiX+wn4rC0hwdsBS+c3DDIhYj+KAJBLiqPZ2GeUBFi3Ko5P8j5L5uijGpI0NfKXb6TY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783105286; c=relaxed/simple; bh=Ms5M81FIqs14zVTo1MKTKzSHFrWqSqNMIMiuyqMxTr8=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=UNGcdfxm4iKYzbrBiqplyqPEJgNyntHXj52L5769crHqVXxZ5eTfTy1K/U+azvYeTgP16QeVKHlbSjWteWFW91INXMTjGzgWfAT9HDPEyf2OTWKfOcVzUJxVMwJ1bZeO2UPYwMUzcnOiLhO6Ou8TxOMqtd3HhrirP4BrktJga+8= 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=DFdWGD2l; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DFdWGD2l DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08ED94BA23D3 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=sQiZyh3VW4kQ5wquEQUViHyBJbiRlK5JMHmXR7QGtIsuESmkDKtM5KadiTr8kGPt3KafVnuzin0CPLXwTS4SHWKducr82EviSotEmGUOagL++CuQmBR9+79j9XAsWNRreX/pkqtT3hzwSOesR2vfOWgQ8w998zc9y6CNBaz/Z0+NYT+xn0ocqtEi/FYvbX3W/6uCOlPPk/JLev8TZZUvz1L1akJbsNSbchCtvc/HC/eVxLvBDUwmObEtPNMIUpuPTgiED/m/YVdWbZU0LbYpU797TKANwMrVoUTO8g1bsnFUxncXJmAC5lkSBHSq1NJ/oBpUbnKVODWjyyXmgvzzZQ== 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=jxgCslvjjSBE8N20ZCwMI+ulTzutDqqYmfVZahFFm3M=; b=B/wuQ4HHkGvxT37UNzlhP4ToGN3EijT0ysRMan+8ag+GQESimIS4ckditu/6WVQ3dJF4gnLqi6pS8P/YoXYuFDCKFVBN4NBimWefrxe7+wZH5qWvxN4asqIMWoNFtAB1c0ihN+IQmTHmA7skCrOxl8xM2aaBVxpTIfgTkSci4wI+dDUbZpGVI3hGzSNV8sU691hmcmPcnr1rqLj/tnw674AITSF4QGPunqG/FKZgpMk4piBExvPTXaRCX08Ee6wtFCYWHu6z2JEC3e7xHXiQiN4IRf/eKYinNHnmVt0CGbMYCAUKpRfOQA3leS7wX5AZ5qwLhdglYWmpWJwn3f1gxw== 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=jxgCslvjjSBE8N20ZCwMI+ulTzutDqqYmfVZahFFm3M=; b=DFdWGD2lrNKAQMoHBsIeyyM7KQPbonGcY8zx+fd7b0N6HffH67fcPCje2DstNjM5Kg2hXehTAYcyQvP8jfz+RyngNpOd1iKl/+L98ldSnXT/nKhwYCBrAwZJaEAe69+zETnPb9z8MDcgXEms09g4BTtG/WmgK4eIKBPasolhhDY= Received: from DU2PR04CA0199.eurprd04.prod.outlook.com (2603:10a6:10:28d::24) by DB3PR08MB10334.eurprd08.prod.outlook.com (2603:10a6:10:43e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.10; Fri, 3 Jul 2026 19:01:17 +0000 Received: from DU2PEPF0001E9C1.eurprd03.prod.outlook.com (2603:10a6:10:28d:cafe::3) by DU2PR04CA0199.outlook.office365.com (2603:10a6:10:28d::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.10 via Frontend Transport; Fri, 3 Jul 2026 19:01:17 +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 DU2PEPF0001E9C1.mail.protection.outlook.com (10.167.8.70) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.6 via Frontend Transport; Fri, 3 Jul 2026 19:01:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wo++EmEDIsHB3shKysK9NsdBmeCgA9nDomUxWUxH5CpMnhtwvPBxrnTDyMVE22L2yzpigBANkGU9BbeytG3O8JHjW2gyoklHQ/qWKVyxxYOqX5q91KxnV69HZxgfM0NygjANk1ZxIZYYK6M2F+8HrWrgY2XWr2aiOSP3JkGkF+Sps+vSd29Dg0MBPOyu4+5yDOlK6FfbJUjRDr3YoHSOy8cc8cox8E9/lQmHCCNeUdK6SlbX7RZsUN1INYEenLLPEwaY6cQGFDF3LNIsPgk5DhBkLDMi9OJJBc7EOFDd0Opqm7F3VNVqSKc0cZ36h+HskLvF00gdXIVZwBB62d5UoQ== 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=jxgCslvjjSBE8N20ZCwMI+ulTzutDqqYmfVZahFFm3M=; b=TJjHN5Et7j3eKNmCCDNYGONzSRaJrq8mEIvTymDrN3vLJ2GxK7oqatBBEoYhhzk0YlOM2kZowfpgTwDQn7y/vGigTghOIgu9Xz4cIEq+D8WPXpo0qdp52KP+zoWfIiRFoLYYJj+ZTFnzZVJ+AXWbFIF8R5BaOh1JJwKyhwEgZ8KrPmO3kGi1IQHBlapHspThIwGYprG0GBfAwyx8EOffwSfASU7f5xakOVHYHIpq4gclH4zsIlDqPEo8hUAMBhJGaVDQDwTzYmGxmgDm3gCWRUyN1uwmU5ZP/kCYgII0Hncx0or42Fb78sEW21QGygyS6D1gJsMT/WzNo6hgaivLBw== 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=jxgCslvjjSBE8N20ZCwMI+ulTzutDqqYmfVZahFFm3M=; b=DFdWGD2lrNKAQMoHBsIeyyM7KQPbonGcY8zx+fd7b0N6HffH67fcPCje2DstNjM5Kg2hXehTAYcyQvP8jfz+RyngNpOd1iKl/+L98ldSnXT/nKhwYCBrAwZJaEAe69+zETnPb9z8MDcgXEms09g4BTtG/WmgK4eIKBPasolhhDY= Received: from AM8P190CA0017.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::22) by VI0PR08MB11265.eurprd08.prod.outlook.com (2603:10a6:800:2f8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.10; Fri, 3 Jul 2026 19:00:08 +0000 Received: from AM4PEPF00025F99.EURPRD83.prod.outlook.com (2603:10a6:20b:219:cafe::88) by AM8P190CA0017.outlook.office365.com (2603:10a6:20b:219::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.159.19 via Frontend Transport; Fri, 3 Jul 2026 19:00:07 +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 AM4PEPF00025F99.mail.protection.outlook.com (10.167.16.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.0 via Frontend Transport; Fri, 3 Jul 2026 19:00:06 +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; Fri, 3 Jul 2026 19:00:03 +0000 Received: from PF4S4363.arm.com (10.1.37.19) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Fri, 3 Jul 2026 19:00:03 +0000 From: Matthieu Longo To: CC: Luis Machado , Luis Machado , Andrew Burgess , "Matthieu Longo" Subject: [PATCH v1 6/8] gdb: introduce helper class file_reader_t Date: Fri, 3 Jul 2026 19:58:51 +0100 Message-ID: <20260703185853.450440-7-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260703185853.450440-1-matthieu.longo@arm.com> References: <20260703185853.450440-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM4PEPF00025F99:EE_|VI0PR08MB11265:EE_|DU2PEPF0001E9C1:EE_|DB3PR08MB10334:EE_ X-MS-Office365-Filtering-Correlation-Id: d5069859-ff88-4d80-9115-08ded935765e 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|376014|36860700016|23010399003|1800799024|8126099003|18002099003|22082099003|6133799003|3023799007|11063799006|56012099006; X-Microsoft-Antispam-Message-Info-Original: are/dyQCtAilIRF6wmMzTR4zJYuq0GzGVeE0oCL6n7pwS1eQb+IApw3eOVx6YNjDTgiZDB2HQ0fl/svWGEcXgjtsyTQPhqSH5FGf6b3tFwfczOimNLZoIWwonafyrt7sxfcLSVdArIRpQPCidb9Hh+0wDbqOgWwEmqo+tt2JnJKHgR+nyAR9J2Jcl+NX1JphICIJwS/RGOQN7/a3rqSa3pi4iPwUXf7MhU9tCKr7YC5Vn2doEP4t+Fjb5lk+x49FHK2cTT8FmdBuOIwUHXWn4RPTHWt7aEIttvlVHt4iyytMojVYA2fmd45VEkbtG4ZfMXd1XACGF2RBF2z/xQMVyMKNUludpsvz4nIVHeLFbBjYhCxeNBXreuPxe6hSslEj3bH3Kd3+e4kBN/kAhjol47V1PfsyRJ0qgiY4Kg+JEpFDlfDo3Mtfx0WVMD3dolO74y1GR1lkft+AlU5tfxEd7X3KiKQyFOdi6IA09KL6lbAY+ftimTw8fIC9HbSlSPRSPgMe3yEUCno7iAw9niU5tgeoNKjpLddF0dtm8JbEWQayx3ylsMcx+MtYbRIDG0fqlStBNncGQDxTiOxXj2I9xfemq1MLiqCF2gZPEDEl1GRVS1+q+YvRb8tpkwY7VlbS640V0cqI0rXKsl2zROlFspOjQWr2kjzmchBYjzqONSAJBIpfR9NoAQ8/FgwYQCs/ynwvlyNak1GngXPXvq3JJg== 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)(376014)(36860700016)(23010399003)(1800799024)(8126099003)(18002099003)(22082099003)(6133799003)(3023799007)(11063799006)(56012099006); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: mCcvAudxYrxNaTJjOT0JiWoaJC0FY7bjjwoithf1pn+EEXCNYjSxWTo5cHswQ84xgzhpJ/qgqE2jFFK8Q+BuomVk+PccpwN6hepIIT0vvjz3rAnRKRqWi25SplHX+ejWqabNjVsO+cMe3E1qhu8RAknpig5jbhJRcqIIWirgKPVJ8PKD+qgjHAAlsWibQupc+gg9UEOiR87sTs9hG6X04IO46XxMOwa0nresuArh4wLak5UiXzzusUH6iXhQsWoVGKUs1JBM1hPTH6XUda02koAhAQgoOLmQHpFLZBS6GXz4lR36IF4c95wHoCBLxx62ncjK8SX4foIwrhFY3dYRrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR08MB11265 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C1.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a24cb543-e303-4b8d-c016-08ded9354c4f X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|36860700016|1800799024|82310400026|14060799003|376014|23010399003|18002099003|22082099003|3023799007|8126099003|6133799003|11063799006|56012099006; X-Microsoft-Antispam-Message-Info: rlkvsXwhmBiXXkfCyL30doOxG8/+41bGTW4LaU9q+sDMDitm4Yd2bcKVdvRjyp1tW6Lwq6gfupuzDoq+0EhZoXNU6bNUVgjz3Qn9fAGMmaebNZ+r0BmJvs6FdqPeMig2uUi30o16lV/WMDH5enmCzaUC/o5g/aU+UFYpQ2Im1LSio61pnia8mp1V2czxlfacTjOhzUGPXPIaapn00yflkZAOr4LfiHvOuUWnmwaBzJs1c0V/6ek2NnlTHmDLQxcFOyc82nW//8ERZVA9cx1Cqo/pWBJrJiQojYgt9TxbG/3apZz91oi0/8str8tG0fkr1hqeVJMIJYePy8oKUuiVcrVKDNkhTE+odpdL0hX0YArPsc+NL+KyqBpZ7NXt/72h390Lu9Dl0qeQU1d2boIgYWW075/usN2si45mHaKcRIwZVgljQnnBdMfcoQp8w7hrI5SCGTAh9eG8XQ/KWSiXDyPheFlcjTlj72JFXXQVAj56Gqq4fh6+3xR0qcWYjVnFOT4BzE73et13vnOx3gKmWbgCWzefW2PpmV2Yy5KmC/XLrsnkVOY4mhFriTKZLgPBzkTHHXpVwRqdY2RcHlLXhNpyFJFmXvDj7St9DFcVVOBscWadkdF2fg/WGEIb50wKzPyKBjLX0+eKAMuZQ6x9ORNCnPm17KyVc8MuEL7uXZZA5vDQENnG+opGDmAlDpQbiLd0QqbnTlpr1pAg1WmrOA== 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)(35042699022)(36860700016)(1800799024)(82310400026)(14060799003)(376014)(23010399003)(18002099003)(22082099003)(3023799007)(8126099003)(6133799003)(11063799006)(56012099006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8Ez+QszzNaPjQCwdKa/AGcpzxfwodY25FJ6yAvP7lIKPIJgKUUC3CzJIUQpWJru4wyKfQ5UvBbvaRHDHGzRSoKXhMCyCrCad7+cLkaWl0T87hQFzzebXTD22WptFud7o9ub1uJnc/y9wGYHWp6/0CGhV+Dyr+qhyF81wjQKKGlPc0D12awrOi48Gp5r6ohLZYakHVc6IPOO0mdVPxo+BnTegzRQpi62MEsj0QWRMcmt9P6K/eFYXeU7rw5C3PKl3Bf2H2z055Raz1gOgRAYfKRc3hl3j7rsRh4pv3NaJkml5St0vEqsEmZZihir1w21Ce8fgqqpA2eZP5BNFVugqfWQR3WV7CUt/l1JSKne4VcEGdjHFEjWCmGZfOOMztt0UgzqwjXjE/09yUur1uCR0R8OJf2k+W7kcN/G3cBv2tmvAXoijYjiWckRNZ/E6T84s X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2026 19:01:17.4462 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5069859-ff88-4d80-9115-08ded935765e 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: DU2PEPF0001E9C1.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB10334 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. The availability of array_views allows to also simplify the logic in several places, where null-terminating characters are replaced by spaces, or where the file content is iterated line by line. In the last case, a new helper function, extract_string_view_from_buffer, encapsulates the logic for such iterations where string are separated by tokens. --- gdb/amd64-linux-tdep.c | 12 +- gdb/linux-tdep.c | 254 +++++++++++++++++++---------------------- gdb/sparc64-tdep.c | 12 +- gdb/target.h | 65 +++++++++++ 4 files changed, 195 insertions(+), 148 deletions(-) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index a5ac26654cf..e7841917eaf 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1851,14 +1851,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) @@ -1870,7 +1867,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 0da33ba379b..e6697669f3d 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -839,6 +839,27 @@ dump_note_entry_p (filter_flags filterflags, const smaps_data &map) return true; } +/* In a character buffer where entries are separated by a SEPARATOR character, + extract the string view starting at START. + Return the extracted view and the iterator to the next entry. */ + +static std::pair, gdb::array_view::iterator> +extract_string_view_from_buffer (gdb::array_view &buffer, + gdb::array_view::iterator start, + char separator = '\0') +{ + if (start < buffer.begin () || start >= buffer.end ()) + return std::make_pair (gdb::array_view (), buffer.end ()); + + auto it = std::find (start, buffer.end (), separator); + if (it == buffer.end ()) + return std::make_pair (gdb::array_view (), buffer.end ()); + + auto next_start = std::next (it); + return std::make_pair + (gdb::array_view (start, next_start), next_start); +} + /* Implement the "info proc" command. */ static void @@ -880,25 +901,20 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, gdb_printf (_("process %d\n"), pid); if (cmdline_f) { - xsnprintf (filename, sizeof filename, "/proc/%d/cmdline", pid); - gdb_byte *buffer; - LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); - - if (len > 0) + file_reader_t cmdline_freader + (string_printf ("/proc/%d/cmdline", pid)); + if (cmdline_freader) { - gdb::unique_xmalloc_ptr cmdline ((char *) buffer); - ssize_t pos; - - for (pos = 0; pos < len - 1; pos++) - { - if (buffer[pos] == '\0') - buffer[pos] = ' '; - } - buffer[len - 1] = '\0'; - gdb_printf ("cmdline = '%s'\n", buffer); + gdb::array_view cmdline = cmdline_freader.cast_view (); + gdb_assert (cmdline[ cmdline.size () - 1] == '\0'); + /* Replace null characters splitting the arguments in the command + line by spaces, except for the last one. */ + gdb::replace (cmdline.slice (0, cmdline.size () - 1), '\0', ' '); + gdb_printf ("cmdline = '%s'\n", cmdline.data ()); } else - warning (_("unable to open /proc file '%s'"), filename); + warning (_("unable to open /proc file '%s'"), + cmdline_freader.c_filepath()); } if (cwd_f) { @@ -912,27 +928,25 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, } if (environ_f) { - xsnprintf (filename, sizeof filename, "/proc/%d/environ", pid); - gdb_byte *buffer; - LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); - - if (len > 0) + file_reader_t environ_freader + (string_printf ("/proc/%d/environ", pid)); + 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) { @@ -946,10 +960,8 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, } if (mappings_f) { - xsnprintf (filename, sizeof filename, "/proc/%d/maps", pid); - gdb::unique_xmalloc_ptr map - = target_fileio_read_stralloc (NULL, filename); - if (map != NULL) + file_reader_t map_freader (string_printf (PROC_PID_MAPS, pid)); + if (map_freader) { gdb_printf (_("Mapped address spaces:\n\n")); ui_out_emit_table emitter (current_uiout, 6, -1, "ProcMappings"); @@ -963,12 +975,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, nullptr); current_uiout->field_core_addr ("start", gdbarch, m.addr); @@ -987,26 +1003,24 @@ 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/%d/status", pid); - 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/%d/status", pid)); + 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/%d/stat", pid); - gdb::unique_xmalloc_ptr statstr - = target_fileio_read_stralloc (NULL, filename); - if (statstr) + file_reader_t stat_freader (string_printf ("/proc/%d/stat", pid)); + if (stat_freader) { - const char *p = statstr.get (); + const char *p = stat_freader.data (); gdb_printf (_("Process: %s\n"), pulongest (strtoulst (p, &p, 10))); @@ -1133,7 +1147,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()); } } @@ -1514,18 +1529,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; @@ -1581,8 +1595,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; } @@ -1596,12 +1610,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; @@ -1612,8 +1626,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) @@ -1674,17 +1689,12 @@ linux_process_address_in_memtag_page (CORE_ADDR address) pid_t pid = current_inferior ()->pid; - std::string smaps_file = string_printf (PROC_PID_SMAPS, pid); - - 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_PID_SMAPS, pid)); + 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) { @@ -1748,39 +1758,30 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, if (use_coredump_filter) { - std::string core_dump_filter_name - = string_printf ("/proc/%d/coredump_filter", pid); - - 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/%d/coredump_filter", pid)); + if (coredump_filter_freader) { unsigned int flags; - sscanf (coredumpfilterdata.get (), "%x", &flags); + sscanf (coredump_filter_freader.data (), "%x", &flags); filterflags = (enum filter_flag) flags; } } - std::string maps_filename = string_printf (PROC_PID_SMAPS, pid); - - 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_PID_SMAPS, pid)); + if (!smaps_freader) { /* Older Linux kernels did not support /proc/PID/smaps. */ - maps_filename = string_printf (PROC_PID_MAPS, pid); - data = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); - - if (data == nullptr) + file_reader_t maps_freader (string_printf (PROC_PID_MAPS, pid)); + 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); + else + smaps = parse_smaps_data (smaps_freader); for (const struct smaps_data &map : smaps) { @@ -2261,9 +2262,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. */ @@ -2287,23 +2285,24 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) /* Obtaining PID and filename. */ pid = inferior_ptid.pid (); - xsnprintf (filename, sizeof (filename), "/proc/%d/cmdline", (int) pid); - /* 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/%d/cmdline", pid)); + if (!cmdline_freader) + return false; - if (buf_len < 1 || fname.get () == nullptr || fname.get ()[0] == '\0') + /* The full name of the program which generated the corefile. */ + gdb::array_view cmdline = cmdline_freader.cast_view (); + 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; } @@ -2313,27 +2312,23 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) p->pr_pid = 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/%d/stat", (int) pid); - /* 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/%d/stat", pid)); + 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 @@ -2405,13 +2400,9 @@ 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/%d/status", (int) pid); - /* 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/%d/status", pid)); + char *proc_status = status_freader.data (); + if (!status_freader || *proc_status == '\0') { /* Returning true since we already have a bunch of information. */ return true; @@ -2804,8 +2795,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]; - if (target_auxv_search (AT_SYSINFO_EHDR, &range->start) <= 0) return false; @@ -2853,15 +2842,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/%d/task/%d/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/%d/task/%d/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)) { @@ -2880,7 +2868,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; } @@ -3169,16 +3158,11 @@ linux_address_in_shadow_stack_mem_range pid_t pid = current_inferior ()->pid; - std::string smaps_file = string_printf (PROC_PID_SMAPS, pid); - - 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_PID_SMAPS, pid)); + 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..811b76f27d8 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -305,14 +305,13 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) 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)) { @@ -329,7 +328,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 4215553033c..d6fc101f205 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -2338,6 +2338,71 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf, extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc (struct inferior *inf, const char *filename, size_t *len = nullptr); +/* Helper class for reading a file. */ +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; + /* Size of the data. */ + size_t 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)); + } + } + + /* Return true if the file was read successfully. */ + operator bool () const noexcept + { return m_data != nullptr && m_size > 0; } + + /* Return a pointer to the data. */ + T *data () const noexcept + { return m_data.get (); } + + /* Return the size of the data. */ + size_t 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, cast to a different type. */ + template + gdb::array_view cast_view () const noexcept + { + return gdb::array_view (reinterpret_cast (m_data.get ()), + size () * sizeof (T) / sizeof (U)); + } + + /* Return the filepath of the file that was read. */ + const std::string &filepath () const noexcept + { return m_filepath; } + + /* Return the filepath 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