From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2b4rOILffWpcaiMAWB0awg (envelope-from ) for ; Thu, 13 Aug 2026 11:15:14 -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=ppk1eW7+; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ppk1eW7+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E0C921E166; Thu, 13 Aug 2026 11:15:14 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 549BC1E09B for ; Thu, 13 Aug 2026 11:15:14 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB2F44BAE7EC for ; Thu, 13 Aug 2026 15:15:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB2F44BAE7EC 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=ppk1eW7+; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ppk1eW7+ Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010011.outbound.protection.outlook.com [52.101.69.11]) by sourceware.org (Postfix) with ESMTPS id 100C24BA9025 for ; Thu, 13 Aug 2026 15:14:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 100C24BA9025 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 100C24BA9025 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.101.69.11 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1786634077; cv=pass; b=V3kJIsgnq0qOYCDS+aNMIYeiWcU+dIY+lvm+w4wrfWiusB1mNjoq4mjP4W9lAXVcZrxj9mhz7+rT8R26K7kAsL2Y/fSK4FjrDVtkLUOD4c8cYPkJHr/Yd0vuTlRWIsmj+r06NYbpA069mg3m2DJPrv9fppfumL6aggsVyHv1yYc= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1786634077; c=relaxed/simple; bh=6bEI4XnC5ElhEWziEcvt/LNx9syitdErB1j73F10LoA=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=l+BcC6XDu1S8ua2TjBkUgJgZqhWyHTuYCqD04jk5ya334IamJfkH3qBzq4V3N3jQpeoyTOmYiuOD8oH/ssY43BcUhFmikNEoWEvrXetain8GHOGD0uqQ0fhpsRN9nYb9PMiYxs6TDzRuyLL2J1alL6znvG/LrMJGagQQYdET5Ys= 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=ppk1eW7+; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ppk1eW7+ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 100C24BA9025 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=vEmgTQ9ad8HU5SNVwUzvkYswgS1g/Dlf2uNvqYH/i2pkZSyvQhCBV/1dPKyCmG23qWYRd/dkrZhuw5krL5QJTm4afuNfDDhV6eXYNiYnWQs4OHe6XIgO/rRJWmavo6dTgZRIkRLQrQlnqYuB4O0fkz6m12aHa7zu3B2mRRQ7Hhe7i7nh04wZHYznns5SmiNq0Yf48+5cTs6Wz4IrmLA/e98+5H1xo/TMCVNAKJ19E370ATEGjFaTrlJTGYg84YY8F2EJ4HplzPu+PrPbAorO3yiQrrxMc8XEmY4IIKc5HrU3yhA59ZjaIwOEt1ZwwRluUQy2+T0T7x5MGk69J9G8Ag== 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=5QD46Wdaa5WUuXjL/89rCjA7HkOuRUKsgCOf3bCnCHY=; b=YglDWWzKT1seVy1bjOPfjXCD9IWpLLVw9ON2WR6cfihjYDS0+zSMHDD55QPFPeIiAfU2gvmTkFc/kc3golzm2GU+mQnTxeedOQTs2uBBQ2bso0KDSkJH2uxb5Y4MDXwmZNfZqjWkYqWdipd4gbdZc+A09PGmGn8t+uvWpSGs22d4BH1eCZiM+cbtMNyzHbp//KNQh6kjGczUaLvHw2kb+7D/9a9Qvf54C76zGNul+Hn/38g4kbscCKgY/LBXtqruMtrpnU7L3lmXczEyjFwcu6RYvuvPSHcLEECYcUP0y8YCuZRrDGgxcIfQxhoTgnn0jpOg1Da+4fmhiGBJ2NV+ZQ== 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=5QD46Wdaa5WUuXjL/89rCjA7HkOuRUKsgCOf3bCnCHY=; b=ppk1eW7+fJVLXvuZjj8zQTl8PARSKwLyisGD0NJriK+r706scN+8Af4TBLF4RWiLMsS/VdLnaY3Yz0V9zWJqFX9VPz2cUSTDlOF4ScAc7rgUEP3eh+UBbpgG+CymLIjlsqJ8w0XXpDrDUg0yy9DeB3t7tBOFbsDtwNMZO7fCGto= Received: from AM0PR10CA0034.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::14) by BESPR08MB999849.eurprd08.prod.outlook.com (2603:10a6:b10:107::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.19; Thu, 13 Aug 2026 15:14:24 +0000 Received: from DU6PEPF0000B620.eurprd02.prod.outlook.com (2603:10a6:20b:150:cafe::6a) by AM0PR10CA0034.outlook.office365.com (2603:10a6:20b:150::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.14 via Frontend Transport; Thu, 13 Aug 2026 15:14:23 +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 DU6PEPF0000B620.mail.protection.outlook.com (10.167.8.136) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.3 via Frontend Transport; Thu, 13 Aug 2026 15:14:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cjHZTcZcA6Tsr5h5qPsZzIRBOMsIXhOi99zhrTm5oSuU/3xePq5LIB/FpI7FWsJBi7L9NPTV1/3nU5/CFOaaEgUlM4P/43FvrIhJBnfy6TMn1Dl36mWz0B8FaJU8QxRZqm/Kc3YVH3+p0ASWTiY57Y6oR69G9WGuWfxAeQ3WAha6ROuV2y5r48p5/bdGnZBwuOfiOfqgKeLt+EDIKtM/Q0HM73aPTGztVxNjzngBxi0XvmPl1yDp8eCXu09rAF6VlE2xKM2ZCmLYMazlw7AQRcXVdzuFREyeWtp0ZUTULBMtDtN1w3VQmCyQdME+R9oi//Poi0koCoFzGEkWFIzT/A== 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=5QD46Wdaa5WUuXjL/89rCjA7HkOuRUKsgCOf3bCnCHY=; b=GRLX6FeoFMFIE7m6c5nN4E9vFy83Fli8IYjGSqXDlQ3dbu/+lrd0ygyF2xWTp10UAuwPkWqUYFe2mqwekOgUGE1EPgwH77sHncclX6bdQotDmjrDbkL8rtLwIyiupdWYmFncY4oVXrj0KOruMwuMi11KdVYUo7j3nGpH9p22gF1TTY5XvO5swn2KlvD1kXYX4+ZKvB60+YqYeLmpiFPcMU2hCYaIlGsBZ0i+BTOLf0obdtm2pefPWat5ytQmryZ5YZuoVG9IsGn8EOe1vk8PjJB4zEZvOxnhCWBXNSUCwFJwASOvtqfc0bwME2vs0ybHIBBcwewG998nvZmru9dEQA== 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=5QD46Wdaa5WUuXjL/89rCjA7HkOuRUKsgCOf3bCnCHY=; b=ppk1eW7+fJVLXvuZjj8zQTl8PARSKwLyisGD0NJriK+r706scN+8Af4TBLF4RWiLMsS/VdLnaY3Yz0V9zWJqFX9VPz2cUSTDlOF4ScAc7rgUEP3eh+UBbpgG+CymLIjlsqJ8w0XXpDrDUg0yy9DeB3t7tBOFbsDtwNMZO7fCGto= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from GV1PR08MB8667.eurprd08.prod.outlook.com (2603:10a6:150:85::13) by PAWPR08MB10974.eurprd08.prod.outlook.com (2603:10a6:102:46b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.15; Thu, 13 Aug 2026 15:13:48 +0000 Received: from GV1PR08MB8667.eurprd08.prod.outlook.com ([fe80::ae9c:f011:dbb4:c095]) by GV1PR08MB8667.eurprd08.prod.outlook.com ([fe80::ae9c:f011:dbb4:c095%2]) with mapi id 15.21.0315.014; Thu, 13 Aug 2026 15:13:47 +0000 Message-ID: <46a67f67-2147-45b9-882b-86dc46291876@arm.com> Date: Thu, 13 Aug 2026 16:13:45 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 2/2] gdb: rely on the first non-exited thread TPID when reading Linux procfs files To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org, Luis Machado , Luis Machado , Simon Marchi References: <20260728143317.245389-1-matthieu.longo@arm.com> <20260728143317.245389-3-matthieu.longo@arm.com> <87tspb3j2s.fsf@linaro.org> Content-Language: en-US From: Matthieu Longo In-Reply-To: <87tspb3j2s.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0313.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:390::15) To GV1PR08MB8667.eurprd08.prod.outlook.com (2603:10a6:150:85::13) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: GV1PR08MB8667:EE_|PAWPR08MB10974:EE_|DU6PEPF0000B620:EE_|BESPR08MB999849:EE_ X-MS-Office365-Filtering-Correlation-Id: bfbc1821-4e11-4681-7d43-08def94d8ec9 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|366016|1800799024|376014|56012099006|22082099003|18002099003|10067099003|4143699003|11063799006|6133799003; X-Microsoft-Antispam-Message-Info-Original: O2ohCTUuhf6TFXvIqZeU5mekKRm/MKvuFMpB0mNh8q5HJqO1lWf69wQCYzQ9Wh8pP/x6Spwm5EWPdv8DEoyFAa0PUZt9rAI4+UWqGT4moItO7I9ZpcM+YkzYxZmkc+K7lnZvw02LtgpWYd5byGpgjoYiqqZn+FJMlfWwp+JKlBaQ8jht2DNLpVPjVy2C70tNFZrbudtb+vbNB5q6IFmJqWU9NFqrS6TeZspW9Fc3Qk8ww19E1CGEJ3z7CtpyRH+qnma0u9eaDwc+1YGyNrDC8en3ls8njmY+UoT/Dr+cAcyE9FcauYFbVAvkIc4NrEgqtA8Tt/Ffl7XSFSmu7Ad9cc8ID+gQie5py1HgW3W6qYBDACAfRTVWfyUxtI/oQPVhEIWsYv833RQ1kWUNOcDLwb4j/XHRCxD7KbsvIvY//ONLZvWyS8ZVFNFywx+imxfl5l8cYs20kgOnn/UpymEA80TifnuI8xYi0Qs96dMjxA0eH3BO3jIy/wF5k3XWcW5K0Rpo5nlq0SnLjdrCWd7vzyv/7q/7BSt93viBhad6hyWlmgVGerTLvunambspXEBwge6ERfRQDUchx8v8oZxrtQ/dWjLFw7tiMxAX6mb5fIhgY+Wq41Jc51kcM97u9NK3lePPrqwrCe2sS9MPl9kFMqqAoLzqr+T6LUQItfVZ1rA= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV1PR08MB8667.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(366016)(1800799024)(376014)(56012099006)(22082099003)(18002099003)(10067099003)(4143699003)(11063799006)(6133799003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: nPbpVhzKwZpuTCGVFmwRc9SeV58i1hRukFoFC5928hcXcA6bR8WsqThNTCSrXcxte4ZJKP2H09KygttecY8sQxL/HdXcSfHyDPhvrMfMUlfudHXErcnpJ8sHUD7+tFKqVz9DRiIM8P5kESVVFV3TvKhNf/AFoHcPEB7M8XjDJku0tL1xuRQ9jcc3W8r4Td7zkbLARq1cuTGhF5s3yoUrPD1OjmYyTfnaWTzF2GjlVzW9/XiaZ0k/rW1womhQBVaXQxIhXcihZVZmobuOpnGHIRWUL/MjKx/FzIsmPOb7K62T51Nni+LvHBX3JsgfHsu0ryckqGgZmeW/YxPf1AxIQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10974 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000B620.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 68e42351-0ad2-494f-1fc1-08def94d78f9 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|82310400026|23010399003|1800799024|376014|36860700016|14060799003|13003099007|6133799003|56012099006|10067099003|11063799006|4143699003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: N6HDfN+whxWZxRWZ3PumXiwIKpUReEJriSMfs2w4zqrg9gc4cr5za0H3VPQd2Xhs1gBW5RS3ubdbrg1dw9cc3zXe9gj+cuLX0+5PfjBmejRFvDU5BWQgX+yUAibpL9Oxrs3YJD1b2EfI+mAdgoe0Xt0oORNOpVTWTZ8CUNr1F+dJHarq3RHmkvdLMfHKAPkd7HsZhA8lMxM2f8bWx0svSFshPkq3b8F8cM8FPhNKIeK3S0XFj7J3ch/dBvWEmuTJUBAYmlnbg58BbEH1G3WwH8U0nqQ8+oGPK8MjZUYvqcEnYJvhs7gXsrIihXp3zimbk21J73z5WQlOea+5RzIrJMnCJDIqZf8PWzaLrwm427q8gVRv7S79RSMDm1M3oPTt3UFj/UOhA/eBBXt2fTbBbXA38Ym46kRpbMJELfp2z/76HWgV7K3tXlk3mlfqmWKQga6zEY9CWV/IXmlMtETCWX8oOK0JtqUuo24bWq13v6Fzfi7fMX5CHrgGX364eudg+LwTolx5awzxTJsHSnkqUZ8594xPTgPHE9vAdEzjqIDHRpiOxhz1W8rIyKQxtU12wuoLXgFBcKpOQoPqs1CET4R4KYrZlKV0bfPfBZQQ0uWGTmxmOv/BO9vMbB7GRS06K35GBqyc0J28YJgZceqVYr8jxqi2BrFEc+s7amNUv+ewARdS11cbGlwNohojtxT0HZUJgNMH4A9D6TWqLenZVg== 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)(82310400026)(23010399003)(1800799024)(376014)(36860700016)(14060799003)(13003099007)(6133799003)(56012099006)(10067099003)(11063799006)(4143699003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G2M1JCahsNJp2i7z3MXouACNEN6uqa8Caz8hriEvS8KpoX9Eri8BmTxIVp0dRPIWSPpE0uTKa6nXHFb2KgFCDtCNrdj5feisx46bp+4r+MxduMh0qS1Se/jvvXo1/6mVufkQRD204OqjrDDgqcLbRbRAjI5VC+arWM+Ukx5WuUc6flEvcrEVmQ8ZGy/iihEeaIPpsMxl9IznC/X86tjjc0vukNB6Y/COUr36fPo5k8xSVwrblJMccleZQQVx9dzuzA+t3PEekrijZwFXIqy6jLYDeyaLcvLZbl5IYOg7d2X4VpqwKbobbFZNvClLz+jUoXWmyF3MHf0mtqb2PXIzRtJfN/ocEnxu/5BT14rdX2J7znZDUftuDqdWdmtt9/mDXdg+5d9sPg19ZiRW/gFTEKwbXlZmiaoAqR0HpBxQY+Ndorq0abTDAowUzE81YlEr X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2026 15:14:23.5564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bfbc1821-4e11-4681-7d43-08def94d8ec9 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: DU6PEPF0000B620.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR08MB999849 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 03/08/2026 05:48, Thiago Jung Bauermann wrote: > Hello Matthieu, > > 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_non_exited_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. >> >> This is a best-effort choice of a thread that is expected to still exist >> in the target. Since GDB's view of the threads list may be stale, the >> selected thread may already have exited by the time it is accessed. >> Callers must therefore still be prepared to handle that case. >> >> Update the following functions: >> - linux_info_proc >> - linux_process_address_in_memtag_page >> - linux_find_memory_regions_full >> - linux_fill_prpsinfo >> - linux_address_in_shadow_stack_mem_range >> to use the first non-exited thread's LWP ID instead of the inferior PID >> when constructing procfs paths. >> >> Add a new test in gdb.threads. >> >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31207 >> --- >> gdb/inferior.c | 12 +++ >> gdb/inferior.h | 11 +++ >> gdb/linux-tdep.c | 90 +++++++++++++------ >> ...access-procfs-while-thread-leader-exited.c | 48 ++++++++++ >> ...cess-procfs-while-thread-leader-exited.exp | 78 ++++++++++++++++ >> 5 files changed, 211 insertions(+), 28 deletions(-) >> create mode 100644 gdb/testsuite/gdb.threads/access-procfs-while-thread-leader-exited.c >> create mode 100644 gdb/testsuite/gdb.threads/access-procfs-while-thread-leader-exited.exp > > Reviewed-by: Thiago Jung Bauermann > > Just one nit: > >> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c >> index 8c53ffd5e89..9bdcc55a0e1 100644 >> --- a/gdb/linux-tdep.c >> +++ b/gdb/linux-tdep.c >> @@ -457,6 +457,44 @@ linux_has_shared_address_space (struct gdbarch *gdbarch) >> return linux_is_uclinux (); >> } >> >> +/* Return a PTID that identifies the current process and can be used to >> + access procfs safely. >> + >> + The returned PTID is that of the thread-group leader whenever it is >> + still alive. If the leader has already exited, the PTID of the first >> + non-exited thread in the current inferior is returned instead. >> + This ensures that the returned PTID always refers to a live thread >> + whose procfs entries are present and populated. */ >> +static ptid_t >> +get_process_reference_ptid (bool verbose = false) >> +{ >> + /* Get the current thread. */ >> + thread_info *thr = inferior_thread (); >> + >> + /* Construct the PTID of the thread-group leader. On Linux, >> + the leader's LWP ID is equal to the process ID. */ >> + ptid_t leader_ptid (thr->ptid.pid (), thr->ptid.pid ()); >> + >> + /* Use the thread-group leader if it is still alive. Otherwise, use >> + the first thread that has not exited. */ >> + thread_info *leader_thr >> + = current_inferior ()->find_thread (leader_ptid); >> + ptid_t ptid = (leader_thr == nullptr >> + ? current_inferior ()->first_non_exited_thread () >> + : leader_ptid); >> + >> + if (!verbose) >> + return ptid; >> + >> + if (leader_thr != nullptr) >> + gdb_printf (_("process %d\n"), leader_ptid.pid ()); >> + else >> + gdb_printf (_("process %d [Note: information where gathered from LWP %ld " \ > > s/where/was/ > > Though actually IMHO it reads just as well with s/where //. > Fixed. Matthieu