From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gI2uLizuDWoplwoAWB0awg (envelope-from ) for ; Wed, 20 May 2026 13:23:56 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=xgQII0jk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AB7DF1E098; Wed, 20 May 2026 13:23:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7F4F61E024 for ; Wed, 20 May 2026 13:23:55 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 477484BB58FF for ; Wed, 20 May 2026 17:23:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 477484BB58FF Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=xgQII0jk Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011039.outbound.protection.outlook.com [52.101.52.39]) by sourceware.org (Postfix) with ESMTPS id 82A9A4BA2E18 for ; Wed, 20 May 2026 17:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82A9A4BA2E18 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 82A9A4BA2E18 Authentication-Results: sourceware.org; arc=fail smtp.remote-ip=52.101.52.39 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1779297808; cv=fail; b=UYqhNIIyaZ5zBHPxrs2/cae5bZ9t5LbMNsG8Di3+xP7BELoh+Dz8JbIq0tmXKxlKG+NyS4Vcf5SURsA6jGa1MIa6D3VwtwoicuO+7x15S+I+b+B3D3NDEcNPHK7wZKwEgv8tXzEmI3wj0N3D9RO0pu/myO2h+1KMqxQ//OwQnHY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1779297808; c=relaxed/simple; bh=2d9o329yv1SglMgbD0CAfoYHgrUINY144t05GKVDV84=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PaMGbRG/pVMWymmvs738Zv0CauQ06B/RtuyL6C8dcu0nr9KmrrZLj9ckjIzoEHdAak3Rbe8IoZfFsQjZAF9A/10QHptSapTX5ZYaGDfFahx9bYda1iRZlPcj1IJuYt0DUb6giiaaYG+tzsRpKnVBgplOIZKJnR25dJBLw5Lam2Q= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=xgQII0jk DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82A9A4BA2E18 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QjB07n+dVcxKqmjdZOI+C+CyP8jOPWqFfi3DPu1IzdNUTGCN5xBXeg+rGyuslNYRrAS/MnjLKGzH8d8MNxz8XJrqjQD4Di2Y915ax8nS1wDwpG8TV6PIXn4WooBbN8MJ29qvpcDdujuBS7FIJylJ7z2MrDGjc6GUShAUndPdKgMa1EgFg5V0BvS+Jtu3qJHu8rVX04NOkR6MVFchAYR2VEgOIjOqgPk0lvNAUIg+5Q4ALb8IXg8+xWTmkaqXL1ERQlMdJAiJv4xxw0XD6msRLJ/2OswSIw3JeDxLtE7RbJArgKgzjuaABzUQUk0VPKFPQMufUImmr7jCyZQep5dUWQ== 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=1ENkacuRGt5JOKkT9+UItE8Wm1UkbX0G9b6cy4EPVP8=; b=R6+xV+cK9tBPNINeNczcnd5bPn+mUw+E8o4f+pJOTC1Balg3YdskMzxXnA47JAkq8V1SMnrq91K9mlNDDNJKV6t5ZZvODPtmrGuOrbmcFwmnGtesz0knZCQwat1AqOGw3bGS9g4VlrFgKjMKuWLYcy28Elg5VkE9DJzFNYoEPMIeVXCRxX14P8Vgklf8CYOYmI5x9m9lyASL/P746Zn9FN67CilzzREm2kk+FMlWuqCAyvKtFxELswPiCg3ph6MLrAu6pBuQr7Rgbqk3PrUQWN6i01K0SveBvB/30e58HFmshraUbxakP11a/UZLV7Hz+LqwhxkUwiXltFUFH9I9lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1ENkacuRGt5JOKkT9+UItE8Wm1UkbX0G9b6cy4EPVP8=; b=xgQII0jkpQzQoEMCstTP83UnG50mHoNYt8MK1aSroxjhr1g/ufW2CWUSxdOkQgLCttxD4UG8ZyO1O1FAWrVezgNg0MmT8stOz/A05gpQBXKnTaKq5UYYg1stBE0Y1PV32hrJ8VwjjlhvHWUT6mcK4pGrmpWWT+ujh9y/xyJXSz8= Received: from CH0PR03CA0418.namprd03.prod.outlook.com (2603:10b6:610:11b::19) by CY3PR12MB9656.namprd12.prod.outlook.com (2603:10b6:930:101::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.18; Wed, 20 May 2026 17:23:19 +0000 Received: from CH1PEPF0000AD80.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::b2) by CH0PR03CA0418.outlook.office365.com (2603:10b6:610:11b::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.48.14 via Frontend Transport; Wed, 20 May 2026 17:23:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000AD80.mail.protection.outlook.com (10.167.244.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Wed, 20 May 2026 17:23:19 +0000 Received: from khazad-dum.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Wed, 20 May 2026 12:23:17 -0500 From: Lancelot SIX To: CC: Pedro Alves , Tankut Baris Aktemur , Simon Marchi , Lancelot Six Subject: [PATCH] gdb/solib-rocm: add support for file URI on Windows Date: Wed, 20 May 2026 18:22:56 +0100 Message-ID: <20260520172256.629890-1-lancelot.six@amd.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD80:EE_|CY3PR12MB9656:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fa34fbe-defb-43b1-f16c-08deb6947c6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700016|3023799007|11063799006|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: w2UhcMGfyObQLVHf9mcDfyrY6Iha6aH4UamMJSpfUdOG4mNXzfD6Iu1r9Gr39lApaP0VZJRSQ7HuUalyPFLuH3erFLuZ0hbTpRE+rM7vG3oQgLDBJBWJgalCGUkEApMkLAxXzcDn4P0/aUWyhrDWF/Huuam0cIiQErBFod1WFoNrzp65rM87iA9xKV6y0Qgra8ealJjgBo7EvluBgn3tL89tmwwUOcRLgW2JhrNCL4HzLyv1cFGmkeQG6p1ynoSZfJfvFdl7YDv9Hqy0h+QXEsIWHblQmLWVKZI7qgLljdjs3FQRRGd4iXiQh0hvRtTMo0uIipETtbbI4v9J2dPXYVwMliu3ntiBqbhYN1ZBArI6OulcqR3gKMHPmq3EpRUGobdbup+gHkzy14My1ARUpJTaICA/gBvuM0elAYFFBks0HTLMyKL3UQcR24aN5crsAfgelXTH4gzBzenNYbdXyIrWImSVurPI1HFb6u7JzViP5/RTz2lZ1V1EK0eX3ifeUMO0akCssa1Qi7eSXvOzWc6QJwi3L+j9B/hhhpZeTyqIF/6Twg7yfqFWXA2yoNtuxA7CvK29nyULu5QWAMbNFdGRKcclSdPOCgjLpt3v9BLlin4WgKxQprQSrvvMgm9iHS3QhC2OH/DwHG6EYcAokoLYN+q3HuDOJ/9qRU8zhVzisJjCsW0SYS56w2LOjANaKMjVdOvog5GeXeAZnQzR4rY0dSr4XEAcRY7aMPQLbCU= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(1800799024)(36860700016)(3023799007)(11063799006)(18002099003)(56012099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z6Ulnhka3BERG0T3D13dhw+HHiTZg2ckUzLca7C4OKMxeNJwhvHFGw25PUVxGrZTnmqxg2EHDfa9aapQcbfpmZsTH2OLNmOnx26MEBddNPOSfrPUAdRLt/TpiQ+kN7FiK1Yf/CR5X02RCQg7sv4o3cG20g97+yAYLBMcakILB0PkSNtDXIAO3pJSxEEbuQDtrFPKRx9JOH8wWIwn58WHgL2uIZZ8N6/Nf5RDMarMJkaUclfdRTyXscgTVPVkuEfSCC/nWPP8/EqPt9/tx7Z6guHy5d6o5Cew+bPgclJ/IIoTO5pa4Tf4X9TCIrjvUMpr/lDgkMcjYX5MxT6GgDBl6dUyp7RYO5U8E6ygkFBFbEX4wpgeoZEu1AuH+9OwGvVvjUjiFpmfzj6ZVk7H5+XO5PIBJvEzzMtcZ20JRO+8AW63h4GOYkKMjug7cmRexh5/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2026 17:23:19.1768 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fa34fbe-defb-43b1-f16c-08deb6947c6f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD80.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY3PR12MB9656 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 From: Lancelot Six For processes using the ROCm runtime, GPU code objects are reported to the debugger in the form of a URI (those are available to GDB using the amd_dbgapi_process_code_object_list function and query the AMD_DBGAPI_CODE_OBJECT_INFO_URI_NAME property). Each URI can be of 2 forms: - "memory://$PID/mem#offset=$ADDR&size=$SIZE" - "file://$PATH#offset=$OFFSET&size=$SIZE" On the Windows platform, only the "memory" URI form is used at the moment, but future runtime changes might make it report code objects using the "file" form. When using the "file" form, when the runtime reports an absolute path, the URI will look something like this: file:///C:/foo/bar/file.exe#offset=0x123&size=0x321 The decoding scheme currently implemented in gdb/solib-rocm:rocm_bfd_iovec_open would extract the file path as "/C:/foo/bar/file.exe", and will eventually hand this path to solib_open. Surprisingly enough, solib_open still manages to locate the file properly. This is due to the following of code which effectively drops the leading "/" turning the path into a valid absolute path which can eventually be opened. /* If the search in gdb_sysroot failed, and the path name is absolute at this point, make it relative. (openp will try and open the file according to its absolute path otherwise, which is not what we want.) Affects subsequent searches for this solib. */ if (found_file < 0 && IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname)) { /* First, get rid of any drive letters etc. */ while (!IS_TARGET_DIR_SEPARATOR (fskind, *in_pathname)) in_pathname++; /* Next, get rid of all leading dir separators. */ while (IS_TARGET_DIR_SEPARATOR (fskind, *in_pathname)) in_pathname++; } This patch proposes to fix rocm_solib so we properly decode the file path and give a valid path to solib_open to properly support this scheme. Note that this patch only looks for forward slashes "/" in the pattern matching and not the traditional backslashes (as IS_TARGET_DIR_SEPARATOR would) as URIs use forward slashes, not backslashes. Current GDB does not really AMDGPU debugging on Windows (there are still a couple of missing necessary pieces), but this patch can still be applied upstream and will eventually be needed. I have tested this patch on top of the downstream ROCgdb windows branch[1]. I have also tested this patch on Linux + gfx1031 on top of master to ensure this causes no regression. [1] https://github.com/ROCm/ROCgdb/tree/amd-temp-windows --- gdb/solib-rocm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index d9ae4294c98..d8d36d2f3c0 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -30,6 +30,7 @@ #include "solib.h" #include "solib-svr4.h" #include "symfile.h" +#include "filesystem.h" namespace { @@ -586,6 +587,21 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) if (protocol == "file") { + /* Windows absolute file path can be encoded with a leading "/" in + the URI: "file:///C:/Users/foo/bar". This scheme is not strictly + standard but widely used (see RFC 8089 Appendix E.2). At this + stage, decoded_path would be "/C:/Users/foo/bar", which is not a + valid windows path. Drop the leading "/" as a normalisation step + to get a valid Windows path. */ + if ((effective_target_file_system_kind () + == file_system_kind_dos_based) + && decoded_path.length () >= 4 + && decoded_path[0] == '/' + && c_isalpha (decoded_path[1]) + && decoded_path[2] == ':' + && decoded_path[3] == '/') + decoded_path.erase (0, 1); + auto info = get_solib_info (inferior); fileio_error target_errno; target_fd fd = info->fd_cache.open (decoded_path, &target_errno); base-commit: edeef5fb9c2dac72899322c66a1132501729bede -- 2.43.0