From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Cx5CGkisVGo8OwUAWB0awg (envelope-from ) for ; Mon, 13 Jul 2026 05:13:44 -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=fZIr9y7W; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=fZIr9y7W; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 499A21E098; Mon, 13 Jul 2026 05:13:44 -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 [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 B03111E04F for ; Mon, 13 Jul 2026 05:13:41 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD85C4BA2E19 for ; Mon, 13 Jul 2026 09:13:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD85C4BA2E19 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=fZIr9y7W; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=fZIr9y7W Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazlp170130007.outbound.protection.outlook.com [IPv6:2a01:111:f403:c202::7]) by sourceware.org (Postfix) with ESMTPS id D96D24BA2E14 for ; Mon, 13 Jul 2026 09:13:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D96D24BA2E14 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 D96D24BA2E14 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c202::7 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783933981; cv=pass; b=lcS2GDLMQxZbPAkiahtBLB3N6/DWJIcf+hREGpD9xgsk21Xw4XA0Bu66CwB2eUcR4jcvbKDge/frkuDstdBpNk/pXcva8fmG5Nw8iF6tmv81WR1Ec09VrPM5/Y7uXvNV29kpu/jQly6tww4/v8UtOlLZcNTAqnYrBlwtpHUuHr4= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783933981; c=relaxed/simple; bh=4WzCU3rtZ0416AH7rbTplBvIkdLe5cN7Xz+qMz0NmGY=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=fsq+hgyHEFPDV3zOT6l4X0yjAhD8MnriAXQ1N8i4PoS/s2qGvN7zjQgsDF6nilRtzdXoi1maY2LrJ3HxRV3BcaJX39OBBkkmMaSVMjQDWqIkQkqFJOHQG5CusFS8BgHCRU/PAhJIS7i/0Dcj+MHvt4yQ259Ua+vJvpiVzscEfFE= ARC-Authentication-Results: i=3; sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=pymLvaZhe2EluasQN6Ud/TXeVJy1Kr/d42GBp+xwxeI8Tt69rDneihgDx0BA4N7QUT4r6Z/lkVAZwtTAuuoau9OLe7wNLVbUdQ3A7ykPBqVvLN6bi3ujcUr1REI2OoxDop+6Ag1sqTMYlY45OFBFy4BVAc3TgdFbKfDIerDFu2RuK2eS130pkbgdZPh849Cj6o2yUgFlQ9Dti7xkEarMferpJG92rkpOiPycFqEs3NgLDPDrzD64HsonZGaluRZ9Ey1rugJJrJWA9HxzahPPFK6U6sE77AVG6EtNEMrn2A78l3eQhOOPDdWb1rDaMZ2QzIJ9A3xEFQdDjLw8SM0VPQ== 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=WtYv8Iak08evn6bNuweYLGwBAsDWjfzEhjgGhuiezuc=; b=UAZZ6si7CM4ZDpsnKZ+2SoJ7dX14Ck98/VfBFxHLoqyTkeNSpmTaQlcvuht+0maTmAPd2vp+aiMIpCX1g/sZBXojjIvFAnj11+LeDVzXAN8MFrQI/pnXTodcE0Oe3wHPVvjUyL0OnreiSpyad7yLTE07qVNnTHQDIfTZKNFjFy7D0nj8BweYI9KyAxmhHLGovwJhEtRYKHrSjgNlV31V7igc2RJq3j6BUoQa6NVtndRQpYHAV7ibuLT8+nedtr/iWVlf6c9/s1uLyS+PlZr+N39qjuzPLRdlZ3Or9wZa16vF75MTtRXRSYEXvKaNnghA6lnULLWgm5t1wbdQ9EMgQA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=linaro.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] dkim=[1,1,header.d=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=WtYv8Iak08evn6bNuweYLGwBAsDWjfzEhjgGhuiezuc=; b=fZIr9y7WP0bVCuRSAFkdNFe2BQZM1FW6D1ilAtYOY8FDrDiPOoqKniUKoeV0IpNaHGNTWrrzaD2tOHQhAc0NvNmDVPepOp8eXqzXZJ0W8HklZ8uicrBkuVMwDf1z3LZYhUQVmcrCdGa1M8EXIwLyNZbye6410dHIMRXigpMGhh0= Received: from AS9PR06CA0707.eurprd06.prod.outlook.com (2603:10a6:20b:49f::27) by PA4PR08MB6174.eurprd08.prod.outlook.com (2603:10a6:102:e6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19; Mon, 13 Jul 2026 09:12:51 +0000 Received: from AM4PEPF00025F9A.EURPRD83.prod.outlook.com (2603:10a6:20b:49f:cafe::47) by AS9PR06CA0707.outlook.office365.com (2603:10a6:20b:49f::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 09:12:51 +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 AM4PEPF00025F9A.mail.protection.outlook.com (10.167.16.9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.3 via Frontend Transport; Mon, 13 Jul 2026 09:12:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xV/85afnSPhZ/YAr6R3c3JI8g9bcuO5ekOBoiRkDA9jn8Xq+0eIOMsMXhPbTJelDcAC9yrRT3HX2TcM5ErXMlGlr8aThsnMB757SDpIGRCfD4m1fNwTuqFruCngR3+Rwaev96UHeUzP8+MoKEBfDhkn++AnY9m0/p4jD1Bg5aq84yT7GiE0145OqjVMFEO+bfVkxB0DAzqFUEvZOOzimET6MTmy8Gpu4YGjmrWq2cNsooHNmQcprFUR+KW1/EvBTzg6CcPwYPAPI8aIyTpWMzQ4HfLVx33pFeJHoiPN3imAR8ZB9mfOWAfzIfqfMLpBOUYRlnTbSidX7tmgzWxfc/Q== 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=WtYv8Iak08evn6bNuweYLGwBAsDWjfzEhjgGhuiezuc=; b=uh0H+CLl1GyxMZfb17pFgkA/8dbSneMKyTx/LeidokVSl5dd9+9fFqcVe89JBLBxv6kzcFhdmdm83yQSy/bOZYmJlus60CbKzNlo2EbjrM23gBM1SU/wdhcB9oVe+tQXWrc9a/AKAHL2d6/2cIpXPM5zhEmEZWgKSQKsOqQ01f8lVDNNnU3/XuccO4xRZTUSEU+3wKB8GFk9zOJgoGO0h6s6sNvyrKkkUNgBaJzCneC+3NxLBz8uruxNT83aUaMVPJnaueiXHwoMirxXRLHn3bBaGReKt9OoJtt+Jc/xKc8k4VqM6WkSG23DAAaZt+jN6TOvdLJ7xitdN1N8T3lRgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none 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=WtYv8Iak08evn6bNuweYLGwBAsDWjfzEhjgGhuiezuc=; b=fZIr9y7WP0bVCuRSAFkdNFe2BQZM1FW6D1ilAtYOY8FDrDiPOoqKniUKoeV0IpNaHGNTWrrzaD2tOHQhAc0NvNmDVPepOp8eXqzXZJ0W8HklZ8uicrBkuVMwDf1z3LZYhUQVmcrCdGa1M8EXIwLyNZbye6410dHIMRXigpMGhh0= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DU0PR08MB8664.eurprd08.prod.outlook.com (2603:10a6:10:400::16) by AS4PR08MB8141.eurprd08.prod.outlook.com (2603:10a6:20b:58c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.18; Mon, 13 Jul 2026 09:11:47 +0000 Received: from DU0PR08MB8664.eurprd08.prod.outlook.com ([fe80::9438:8617:f487:336f]) by DU0PR08MB8664.eurprd08.prod.outlook.com ([fe80::9438:8617:f487:336f%5]) with mapi id 15.21.0181.016; Mon, 13 Jul 2026 09:11:45 +0000 Message-ID: Date: Mon, 13 Jul 2026 10:11:43 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 02/10] gdb: rely on the first alive thread TPID when reading Linux procfs files To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org, Luis Machado , Luis Machado , Andrew Burgess , Yury Khrustalev , Pedro Alves , Tom Tromey References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-3-matthieu.longo@arm.com> <87o6gg1xrq.fsf@linaro.org> Content-Language: en-US From: Matthieu Longo In-Reply-To: <87o6gg1xrq.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0086.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bd::19) To DU0PR08MB8664.eurprd08.prod.outlook.com (2603:10a6:10:400::16) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DU0PR08MB8664:EE_|AS4PR08MB8141:EE_|AM4PEPF00025F9A:EE_|PA4PR08MB6174:EE_ X-MS-Office365-Filtering-Correlation-Id: 478f70e6-027c-431e-b03d-08dee0beea8a x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|23010399003|376014|366016|1800799024|56012099006|11063799006|4143699003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info-Original: 15guuu5fPo4T7OUsZz7MFWUCSzLG9Ew39mdt9D0p0QGGZT/wbLOrdJKpXpLtYsTGXun+yXiBg7IRCEuaz8C/3yuCl75wlmDvsANiVpWnnIYzwx5re8M/pzlZJtOSUMXrdCWIeTBjbyzAO540YD/AXTwTgg8yIy13U+32i9/zu5Mj9/yCdOYGxnOHX5N/fxoOSwvJEajjfbmcSOpdk+EnaVq628FmfHfNTJbQA4LE9TooJQsh6CzRDQg+X8dU5XtnGUD/+pNkNOgmF6OlsU/6Dt2B3PlGcPU8hT0JW0/MIauJqgA0eMqEJd860tsyzr+enZPT0LjjNYUOZiOZtB+iJw4g4mJpQ0PivZyh7GMF9aRPfIAPQibEc1U+HD2U8QdkC3qr+SnBFmkcbbFacnc/bbY6RM/ndlhiCYCge+5yOiBHqQU3EGMy4fOH1arwqm+tPGkow2rwfSdZ4KO0HYNrKLSiZ+9lx0+SXiO708BtovAXIgHdNlHrEvOMIah0DOlT/h66/2b9RJrP9/5iRLWNKBWZ9vnuLjfLulCkRGyPhzpdPXhEF7fFsDNDK3CL3Xhlu+aUliJv+uOpxaW1GAC9ZTotKOKNAaZhjSz5HHNje3o= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR08MB8664.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(376014)(366016)(1800799024)(56012099006)(11063799006)(4143699003)(18002099003)(22082099003)(3023799007); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: DtytkeSLZUT6Mk5dC1xPq3kVrjbhSHDBs59BgGPit3SlGcaqrS4TNR8aFRXUdBx5Cpny65z+hzyg9ps3QIA1q5PmOC0/4sjorbqVpztOYIehtbZDDhLHmIkeuTUsiwRtqIZEL+4vLfYwzKdqNbD0uY4Tyi3mh76boQp7g9GuNE+fqqANL6aieJCZBkilbOxtM+fAnvk6srlpX/+DXe93eP/eS02U0JSQsUYLBadHPNCLIcxxOIqF/KdXPZ8uDUXf/XVm6xQ+Wp40U3apBkV/XZRgRcgI9M4TSr4EbUMQrS+KrjoV4FQYF/rM739w/BSecB8/ttv8H+4aXpNPCU9Aow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8141 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00025F9A.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 467fb740-6e8a-4097-5c3e-08dee0bec2bf X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|376014|1800799024|14060799003|82310400026|36860700016|23010399003|13003099007|18002099003|22082099003|56012099006|11063799006|4143699003|3023799007; X-Microsoft-Antispam-Message-Info: Hyv9qY0w2jDSWngjX7UhFldJvdeWaFnRqM/tVM96YXm8Y39AlRY3h+uaA5+3PYyOefeFzvpgBP/r3tYRX+vMyWFpLdbl9u+w0nBZh4ZktpaIGIEubz191n6DSFsN6Ecx8CYNE8KU0bDUYAintniMzvY0BOBUjDbzBXklBKtht3tjNPE2uZP8AkHz1EMyux8tJkDCkbRtn3OhbqExRR0XVLlgiAabb91/RctjMeJGqP5azmExxXVTJL2zGZhHqr11+E0vdYK0+sL3HWXP19kF1BZb28cGnBgXR7I0WSBNWVvdkoTiimcwv0u549/kMIOuCOvnQdH6xmYX74DJfUQgRyl/BAM6iAzjRMcWBB0F4y4s/ucXX0Iq+Ctzk3w3yygwwCKj4hNA34h56xVlpwJncIg+Wwg6VV5hy6EfbZ3wd2xst5g9lZaxnUsT6z4Vv4GkRNBwhDsheinfUtxwewx8A+Lu0zcXoGeNOMN2KTzVosCGomgsRAkQNhfyJaVBPhRF4sXs2bmiLl/8/qF89D6m+v5489PcQ8IORoCEzRACb0+dx4YlCvCmtDZJwvl/x3sPd8WB7V6ClQZQgRXsEDwwgl218HbW1YeiFS13bolcqvfOERbXutIMuXrFo3C8cgqOP/xOL5ab/3rHQqZWZGSDCQ== 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)(376014)(1800799024)(14060799003)(82310400026)(36860700016)(23010399003)(13003099007)(18002099003)(22082099003)(56012099006)(11063799006)(4143699003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +cdk4j56BJ38qkx8OANM9L6OZyD/Aq8HUbX3SDdQJWCPoBYqhdi98PQbY9A/fSziQkgDG1TN4sqnwBc/tiT7BZWDVcuMXRKzCAbpw5Rx2ZR/Ih4mCFvyklXYFl4XU0Tjomtp9qpBXZvi7Dz9Wv7YHIJdCLjufrH6V8eR0yIrgRPWH2RR+v3v1rt73r6+sAKAFEyiqrTBnyE18uChGE0Ithe7Jx6Tnd3wl6VPDTKxwD0HMri9zxA2y/Jj9lrr7wJmkbY5+tIAxfMZ/oOhnzR0ulUTHEnUkdsNzXUrXLc+v21fWnlcRwCBQV0xvLF5a1zXcG71oIe9EXgAR1lp9AznG25ZPKUNh7MyXbVX9oCgRxR5SUUAgZrnw3zTeZy+bE026RM42IFQYmJ0Pfn05mRUKavHJ4Vbx8lgDt5YEjWDL6UVvBbESsis2+diloN+ynl+ X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 09:12:51.5571 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 478f70e6-027c-431e-b03d-08dee0beea8a 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: AM4PEPF00025F9A.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6174 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 On 09/07/2026 07:29, Thiago Jung Bauermann wrote: > Matthieu Longo writes: > >> On Linux, /proc/ is keyed by the thread-group leader PID. When >> the leader has exited, some /proc//... entries become unavailable >> even though another thread is still alive. This can happen, for instance, >> when the main thread calls pthread_exit() and another thread continues >> the execution (existing test: gcore-stale-thread). >> >> This causes GDB to fail to read procfs entries such as cmdline, cwd, >> exe, maps, and smaps when it uses 'current_inferior ()->pid' after the >> thread-group leader has exited. >> >> Fix this by adding inferior::first_alive_thread(), which returns the >> PTID of the first non-exited thread of the inferior. Use its LWP ID >> when accessing procfs entries that only need a representative live LWP >> belonging to the process. >> >> Update linux_info_proc, linux_process_address_in_memtag_page, and >> linux_find_memory_regions_full to use this live-thread LWP ID instead >> of the inferior PID when constructing procfs paths. >> >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31207 >> --- >> gdb/inferior.c | 12 ++++++++++++ >> gdb/inferior.h | 9 +++++++++ >> gdb/linux-tdep.c | 38 ++++++++++++++++++-------------------- >> 3 files changed, 39 insertions(+), 20 deletions(-) > > It's a pity that the patch originally proposed to solve this bug: > > https://inbox.sourceware.org/gdb-patches/20250412201140.31510-1-dominik.b.czarnota@gmail.com/ > > was approved but never committed. But your version is more > comprehensive, since it also makes the change for other procfs files. > It also explicitly looks for a live thread. > > I have a couple of comments below, but regardless: > > Reviewed-by: Thiago Jung Bauermann > >> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c >> index 155d6e874d9..b89f4ee0717 100644 >> --- a/gdb/linux-tdep.c >> +++ b/gdb/linux-tdep.c >> @@ -842,9 +842,7 @@ static void >> linux_info_proc (struct gdbarch *gdbarch, const char *args, >> enum info_proc_what what) >> { >> - /* A long is used for pid instead of an int to avoid a loss of precision >> - compiler warning from the output of strtoul. */ >> - long pid; >> + ptid_t ptid; >> int cmdline_f = (what == IP_MINIMAL || what == IP_CMDLINE || what == IP_ALL); >> int cwd_f = (what == IP_MINIMAL || what == IP_CWD || what == IP_ALL); >> int environ_f = (what == IP_ENVIRON || what == IP_ALL); >> @@ -859,7 +857,8 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >> { >> char *tem; >> >> - pid = strtoul (args, &tem, 10); >> + auto pid = strtoul (args, &tem, 10); > > The actual type of pid here will be long, right? Unless there's a an > advantage to using auto, I think in this case the code is clearer if the > type is explicitly mentioned. > Fixed. >> + ptid = ptid_t (pid, pid); >> args = tem; >> } >> else >> @@ -869,17 +868,17 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >> if (current_inferior ()->fake_pid_p) >> error (_("Can't determine the current process's PID: you must name one.")); >> >> - pid = current_inferior ()->pid; >> + ptid = current_inferior ()->first_alive_thread (); >> } >> >> args = skip_spaces (args); >> if (args && args[0]) >> error (_("Too many parameters: %s"), args); >> >> - gdb_printf (_("process %ld\n"), pid); >> + gdb_printf (_("process %d\n"), ptid.pid ()); >> if (cmdline_f) >> { >> - xsnprintf (filename, sizeof filename, "/proc/%ld/cmdline", pid); >> + xsnprintf (filename, sizeof filename, "/proc/%ld/cmdline", ptid.lwp ()); >> gdb_byte *buffer; >> LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); >> >> @@ -901,7 +900,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >> } >> if (cwd_f) >> { >> - xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", pid); >> + xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", ptid.lwp ()); > > proc_pid_cwd(5) says: > > In a multithreaded process, the contents of this symbolic > link are not available if the main thread has already > terminated (typically by calling pthread_exit(3)). > > I think it's ok to leave the code as is for consistency, but it's worth > mentioning this detail in a comment. > The manual seems incomplete for others threads will still have those files available until they exit. I could not find a written proof in the manual or https://docs.kernel.org/filesystems/proc.html, but the files are still valid in the non-exited threads. See also the reply from Simon about this. >> std::optional contents >> = target_fileio_readlink (NULL, filename, &target_errno); >> if (contents.has_value ()) >> @@ -911,7 +910,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >> } >> if (environ_f) >> { >> - xsnprintf (filename, sizeof filename, "/proc/%ld/environ", pid); >> + xsnprintf (filename, sizeof filename, "/proc/%ld/environ", ptid.lwp ()); >> gdb_byte *buffer; >> LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); >> >> @@ -935,7 +934,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, >> } >> if (exe_f) >> { >> - xsnprintf (filename, sizeof filename, "/proc/%ld/exe", pid); >> + xsnprintf (filename, sizeof filename, "/proc/%ld/exe", ptid.lwp ()); > > Same comment here. proc_pid_exe(5) has the same observation. > See answer above. >> std::optional contents >> = target_fileio_readlink (NULL, filename, &target_errno); >> if (contents.has_value ()) > Matthieu