From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IfC7Bn4gTWqkLisAWB0awg (envelope-from ) for ; Tue, 07 Jul 2026 11:51:26 -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=DcaucHWG; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DcaucHWG; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 165221E024; Tue, 07 Jul 2026 11:51:26 -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 44A861E024 for ; Tue, 07 Jul 2026 11:51:25 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 036354BA23EB for ; Tue, 7 Jul 2026 15:51:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 036354BA23EB 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=DcaucHWG; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DcaucHWG Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::1]) by sourceware.org (Postfix) with ESMTPS id C258F4BA23E4 for ; Tue, 7 Jul 2026 15:50:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C258F4BA23E4 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 C258F4BA23E4 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c201::1 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783439445; cv=pass; b=sPA35GahiTDUs2qujjHC0WR6lKGWt3/Eg0SReeOqq7IvcNp1/4ceRcv4/EVit5yD564hwVM30DraHol4urkEl1Lnk4qdqxMS5UbNSZWqxzUJxdrAI1kNpIGXkMm2CF7Gg/uP9v98MWnonvdlG81mlH5GSxXOszvRzxWlT0giff4= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1783439445; c=relaxed/simple; bh=+2Gc6wIf9PFDxTPZjuHQ5nXasCVqY96jmf+y/ZFtIAg=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=bgYX/zM16AkMYr0cLCOfMMKTk2Mz+pnkm2Y3Hk9Qls8vDDIpTDd6EJRGI5KohGmTli1Z7FZMnKzQcT2yNqFDvGLf5yO68ZnWqlN6/SbfApD/QmdGO1PyFHz4Mh57RxYGX/sELcZvJui/Kuym5Ui7Ah6cX3vo8JTWTOY59XOi6go= 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=DcaucHWG; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DcaucHWG DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C258F4BA23E4 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=sYwg7aScd6Pyr72z5iui0sjOYC/tsByuxbqExv4VMnvcZ2TU1Xt4A74IcI36yoIF9OpdvaDTq2VD29x3+A2eK4DcEZ9pmfuOXCsZZqfVTRKz6GaNDKNrFPfv3sf9xaFRqEX6KqKqlTKYm0kxZ7NBrAUEumI/jxvfJpMWCFgE8gvuw6FJZmxfzjAvMRTj92Hg0P1fi+7a4bwLU5WYGInv4Hoy+HJm0NCCE5x48JKQNjwXFw/0YvLXCWxVcgwtJWsc1464bw4mnD6E0qUH+wJvf9W88zz7GQbENnSfxF2aZ+BSrznaUz0HJ4+Y05mlONAQDX/EbzKgJk30LMkBKKebkg== 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=p1eaz0eVP2nRH9daiju5c3DWIqAqVHSDHxPgoIrqz3k=; b=pNBUTWQtFI6Vv/8WujBTt1F9NH5CGZEZT+M2ick/QwR2RquR6DjHzB8yzXcn8efXcqkHTklVFf/NLQAx/C+beula36awGbj3rApx+djR74DMPN4pLVzl3HF716/Jc/ROxu3BSlGIkb3gwpcd0A9k84XrLU1KwYZMqYw2QSoYZIWmbdQWGLw1jrU8vfAvVpu47Zup4j9+o9dnhEYhtqotkOngWlO31JZi01FJEIJk90TzaIeFRsU4kj5QMRW6DWMiujn01wbvEvQBr16bugLB78saK4llErEdWB3geSrgAza1brYpYb78VpTa77QLKPGBKDV5CuCbF21vPWFid534JQ== 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=p1eaz0eVP2nRH9daiju5c3DWIqAqVHSDHxPgoIrqz3k=; b=DcaucHWGTc1+s8kQ8mEchc+QjROQs9xmTy65/3wkk1JVitdf0IyHWFpLPfVrQoLyWLH7KBV7a2XqihgiMRfmWDfME1TZZ2NDv5eoxo9lnnFfXIZA63oEl/HwoOXK20esy3vVKDPhoKP+LiWhnOATz2CbsZtcBIdpgmqeJ0nLrRI= Received: from AS9PR06CA0723.eurprd06.prod.outlook.com (2603:10a6:20b:487::6) by DU5PR08MB10467.eurprd08.prod.outlook.com (2603:10a6:10:519::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.11; Tue, 7 Jul 2026 15:50:37 +0000 Received: from AM3PEPF00009BA1.eurprd04.prod.outlook.com (2603:10a6:20b:487:cafe::9) by AS9PR06CA0723.outlook.office365.com (2603:10a6:20b:487::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.13 via Frontend Transport; Tue, 7 Jul 2026 15:50:37 +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 AM3PEPF00009BA1.mail.protection.outlook.com (10.167.16.26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.181.6 via Frontend Transport; Tue, 7 Jul 2026 15:50:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JDNEF2jYHC+hbMKqWIBvoFKCvQV7PZWrjY0yDE3WKU9EJCtUnck2QRSVgKwMadiKwtBsrHREeZErzYEJYnCzEcOXJGwKO+3U00Sx7scjT8k6DZ/krvPar9Ckv1RSQU3Lh4h9aoTKS+SAAzazNOTIbmbXNNqPFwpREZ4Z2/cqXeWQtvUcEPa1YiXrhBFMpeaGNRFgf5aLTn9yujPat3w5I+CkrIIeRlo5L+6lkTJoHB5JAalyw3uNsM8bk/QL7B1Qy+VSoiCn0thXsWXeisrb2R/A3UZjDqEBUt0QOR1lT/dQIfBKhQ6PKmStOzK8PE6BupW57JDTtkg2IT+7qI5+1A== 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=p1eaz0eVP2nRH9daiju5c3DWIqAqVHSDHxPgoIrqz3k=; b=dSkLBlc/xOTU59WmcvwTZLZ0fhplEOwoqdxStGE7fQvQNlZzehZ1XetLdYp17btrkP31kTUKB5lGN6K2Cs5Zq/i/C3R6t8XBjA9aL7XlN0zRMKo2clhWBfBLpdIMibvB7p7vJRx3xTa8LGhSJI20HXDtOoxc2vZbqBd00AqHfi/wlzLlnMfPzkQQbARNMygMrUZvZSngNb7OyAAiwW9qsemt3uMLBUHMVDZO9aN3jiIw9g62FB3P6N/9gJrA36O7Z2lJCpNEGANTPD71H/d5/wFnCYrH3d/mIrxmFO2avAEGopLk8tDXtY7zzZn8z17j1aMmz6ixMos/dqKTkBnL1g== 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=p1eaz0eVP2nRH9daiju5c3DWIqAqVHSDHxPgoIrqz3k=; b=DcaucHWGTc1+s8kQ8mEchc+QjROQs9xmTy65/3wkk1JVitdf0IyHWFpLPfVrQoLyWLH7KBV7a2XqihgiMRfmWDfME1TZZ2NDv5eoxo9lnnFfXIZA63oEl/HwoOXK20esy3vVKDPhoKP+LiWhnOATz2CbsZtcBIdpgmqeJ0nLrRI= Received: from AS9PR05CA0031.eurprd05.prod.outlook.com (2603:10a6:20b:489::18) by AM9PR08MB6115.eurprd08.prod.outlook.com (2603:10a6:20b:2df::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.13; Tue, 7 Jul 2026 15:49:29 +0000 Received: from AM1PEPF000252DF.eurprd07.prod.outlook.com (2603:10a6:20b:489:cafe::88) by AS9PR05CA0031.outlook.office365.com (2603:10a6:20b:489::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.9 via Frontend Transport; Tue, 7 Jul 2026 15:49:29 +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 AM1PEPF000252DF.mail.protection.outlook.com (10.167.16.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.6 via Frontend Transport; Tue, 7 Jul 2026 15:49:28 +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; Tue, 7 Jul 2026 15:49:25 +0000 Received: from PF4S4363.arm.com (10.57.40.47) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 7 Jul 2026 15:49:25 +0000 From: Matthieu Longo To: CC: Luis Machado , Luis Machado , Andrew Burgess , "Yury Khrustalev" , Pedro Alves , "Tom Tromey" , Matthieu Longo Subject: [PATCH v1 02/10] gdb: rely on the first alive thread TPID when reading Linux procfs files Date: Tue, 7 Jul 2026 16:48:52 +0100 Message-ID: <20260707154900.94542-3-matthieu.longo@arm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260707154900.94542-1-matthieu.longo@arm.com> References: <20260707154900.94542-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM1PEPF000252DF:EE_|AM9PR08MB6115:EE_|AM3PEPF00009BA1:EE_|DU5PR08MB10467:EE_ X-MS-Office365-Filtering-Correlation-Id: 23ab70f0-2a95-4943-a2a1-08dedc3f7c50 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|1800799024|376014|36860700016|82310400026|23010399003|56012099006|11063799006|22082099003|18002099003|6133799003|3023799007|13003099007; X-Microsoft-Antispam-Message-Info-Original: UIEzi0rZR0a7Yb/9Rn+KIFvISsPAMWSjSpacmsyQ2lhdOnfajnl9YQOZu6cIdMcGVgWpVCqa8INmSVhA3r6oMtuMqCT007GF+4Uw/t9U6PEjZxMPyURA0CZxfV+zZSyVJZTuavx2sHA0H9uaskFYHxjFapJcFCMezA+3778m2lFC5LZKcfe6teDtvFyP3uYB7KaJobUtiC2JPqq4tiE1KCdHbMd62SdPHllz1JAzTsxLgL/vu6qso7mamd8y3sPDjt4UVxpsYL2/EkrQHV6yDpZrLPQ3X53Y47UzCFXBdO9PeOoB9JjbECTxcUuqgghjeNNfawo73tihXNTzLxbUCqssXbKJIpVCVxKou2z4zOZAiw3GYXxIOG7CJVwdQYVL1u/9xg5fifxty5Y9sBeJlQhc1BkPKEV08Emw+MxZn70DpFFUn5nVmquqBnxsUPc+QRlKBjmNbXQGTr+WKgYJZpZVb7Ou7eU350IX46m9y/fs40Z8dzupt1nzXSmWiZnzmdIwUWBu+c+f5JB9LL3GOFAM2lbw84Rs/QxDc0bOX9Mj03hw8J2MVDhFodj28q7dDnpZxzKBb0L2oLIAronbz6mPsKPoXZkCh/IrsGDGMXdtWQCmSeLd1QTJcfUBdcsNsFBXgRfcC1vDGncsw738xmaeuK0dWBjFtMgcvO4uwtmyg7mZenyMtVo2Z5Arjtec 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)(1800799024)(376014)(36860700016)(82310400026)(23010399003)(56012099006)(11063799006)(22082099003)(18002099003)(6133799003)(3023799007)(13003099007); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: FVM4YUuC832g64oIO/sw9k4VuGM0SdQtP5zXwLKZdIQ78Sthx4VhU+ICyARmPffpXqxBy3CjL0F3ZkaQgoMF+w2ARpuYudsL1btoAvtKwFs0k8VP++oueJPWx42goMOfdP0O7enLwbB4Lm8uSs+IpvORWL93nBUrRFr3cMks4UIllpCvW5LalLDFsgBO2cnVXGK1N7XvKPdXbj9hbGDw7Yerdh7N/Ut+kD27dh99X7/9AFyZF6nQxik92ooX/SWO66Tu7MlPrveqxbJenpoUt31+iXsHxpHi+QacNoHAIrjqhBuZxY8/Mn4qgHl8z0BQrkJphS6AZ2uLQCeq3wvdug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6115 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF00009BA1.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2e170856-f8c4-49a8-983d-08dedc3f5434 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|14060799003|82310400026|36860700016|376014|35042699022|23010399003|11063799006|3023799007|56012099006|22082099003|18002099003|6133799003|13003099007; X-Microsoft-Antispam-Message-Info: E280Vga1v4O7JVgYYX5pYdQsQZXDkQnjA7ziIwFuj7xaMnnLXmKAQUGUOQHDF2taro7LkQ+f3OD/O4Gfs8HtQU7K15yDQX013CsvEi0xnBLfyt11l2KRPRL5c2s4gaV6tgJgRQfxPBu5FcyCIX7pkx0SU0tJNbqDLmnv4jfMK6hg91sAaQRS4oFl6vHwgbS+RRHvFj/jzWNtfJGG36xEqHJClNFZN4TbYXPOf4NOAxl4khtbkooxKRlqgsTlFjv1MGDPKCpUlS5U4QZa6UyPrm1JRAyaDNHZZoMHEMU1jkbyTdNK35KpX/f14K9rq7jLYq5z7r0VKcHHxPqthL6VS1qgk7B8gppxycA+pmh9oXAmW48cNo8392LDMmP1Hot0irTbih08pwAjedrBFUdJOD5rBgKdEnl58gpfCA7Dn3Uges1KLTSU36uPZ1rcAnzmEqJk1M5UWKjd8gbsQ/GbnHYOuMgtErjbt/K88/bWgO23n6+2rDdS+6FcaLFnA+fTBIAsaroGDgd4YMh+95HdCliEkQc2qS2qEEaHFo4zjX1eE/WSJ755H5/A4UDPi7sfBmwGMR/Y37ys/vbFTZrLPtaKdXrUnsba9pb/M9O++nHxKy4RHqfJSu6TRQfi9q9XnmyJzTkvFi0+xDASNmecbVy8Z4+u6e3gOIyLvuaaAz3DkF8ESBN4mmjWQIJIyUuG 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)(1800799024)(14060799003)(82310400026)(36860700016)(376014)(35042699022)(23010399003)(11063799006)(3023799007)(56012099006)(22082099003)(18002099003)(6133799003)(13003099007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6gr7LUjwL2kpqBsqeFOzNo4jmRRKC9kGb49CJTYRMnR+sP7A6IoZVxnnT5O78XfLMwXCXNobW0m16AsU7dAtJai/rjSwTk9Vyc+AefMMjhF26ifg2ETbSKWoNLk6XhkWmnC57m+IS+RCdtE94dc/nyLO13z08cAn4PgzoJ9LNRufhHfaU+p/8JKebQz+WgY0YOkJ8h4BXspKRO02aJdUKN7fDsXvUZ+jQSpr0LTQY14jwyxw8KJwARNnDR5seg/xj2b6qJKnaK2ghuctnzBGH12R9oMZSKaojt76ADQNO4ADB0MLgbB3zpHyKp3sC7eB51YrxeDgWxLoDnJv1BOqLpBKnlXLnyquTQjoZ/mB8WvxJLZK33RNmSVltilr4kMO6N6jypEcEmI+zV51NnQaJ9VsxkPFwzFjWJvKS2b6X35yGss4DK4cKUqiM3LWOErp X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2026 15:50:35.8720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23ab70f0-2a95-4943-a2a1-08dedc3f7c50 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: AM3PEPF00009BA1.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU5PR08MB10467 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 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(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index 1481f46cdd1..3b6ec60fb1b 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -250,6 +250,18 @@ inferior::find_thread (ptid_t ptid) /* See inferior.h. */ +ptid_t +inferior::first_alive_thread () const +{ + auto it = this->ptid_thread_map.cbegin (); + if (it != this->ptid_thread_map.cend ()) + return it->first; + else + return ptid_t::make_null (); +} + +/* See inferior.h. */ + void inferior::clear_thread_list () { diff --git a/gdb/inferior.h b/gdb/inferior.h index 9c031035a23..305b1d31830 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -513,6 +513,15 @@ class inferior : public refcounted_object, /* Find (non-exited) thread PTID of this inferior. */ thread_info *find_thread (ptid_t ptid); + /* Return the first (non-exited) thread PTID of this inferior. + + This method should be used in place of current_inferior ()->pid for any + features relying only on the PID like the reading of procfs files. + 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. */ + ptid_t first_alive_thread () const; + /* Delete all threads in the thread list, silently. */ void clear_thread_list (); 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); + 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 ()); 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 ()); std::optional contents = target_fileio_readlink (NULL, filename, &target_errno); if (contents.has_value ()) @@ -945,7 +944,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, } if (mappings_f) { - xsnprintf (filename, sizeof filename, "/proc/%ld/maps", pid); + xsnprintf (filename, sizeof filename, "/proc/%ld/maps", ptid.lwp ()); gdb::unique_xmalloc_ptr map = target_fileio_read_stralloc (NULL, filename); if (map != NULL) @@ -990,7 +989,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, } if (status_f) { - xsnprintf (filename, sizeof filename, "/proc/%ld/status", pid); + xsnprintf (filename, sizeof filename, "/proc/%ld/status", ptid.lwp ()); gdb::unique_xmalloc_ptr status = target_fileio_read_stralloc (NULL, filename); if (status) @@ -1000,7 +999,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, } if (stat_f) { - xsnprintf (filename, sizeof filename, "/proc/%ld/stat", pid); + xsnprintf (filename, sizeof filename, "/proc/%ld/stat", ptid.lwp ()); gdb::unique_xmalloc_ptr statstr = target_fileio_read_stralloc (NULL, filename); if (statstr) @@ -1671,9 +1670,9 @@ linux_process_address_in_memtag_page (CORE_ADDR address) if (current_inferior ()->fake_pid_p) return false; - pid_t pid = current_inferior ()->pid; + ptid_t ptid = current_inferior ()->first_alive_thread (); - std::string smaps_file = string_printf ("/proc/%d/smaps", pid); + 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 ()); @@ -1731,7 +1730,6 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, linux_dump_mapping_p_ftype *should_dump_mapping_p, linux_find_memory_region_ftype func) { - pid_t pid; /* Default dump behavior of coredump_filter (0x33), according to Documentation/filesystems/proc.txt from the Linux kernel tree. */ @@ -1744,12 +1742,12 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, if (current_inferior ()->fake_pid_p) return false; - pid = current_inferior ()->pid; + ptid_t ptid = current_inferior ()->first_alive_thread (); if (use_coredump_filter) { std::string core_dump_filter_name - = string_printf ("/proc/%d/coredump_filter", pid); + = string_printf ("/proc/%ld/coredump_filter", ptid.lwp ()); gdb::unique_xmalloc_ptr coredumpfilterdata = target_fileio_read_stralloc (NULL, core_dump_filter_name.c_str ()); @@ -1763,7 +1761,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, } } - std::string maps_filename = string_printf ("/proc/%d/smaps", pid); + std::string maps_filename = string_printf ("/proc/%ld/smaps", ptid.lwp ()); gdb::unique_xmalloc_ptr data = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); @@ -1771,7 +1769,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, if (data == NULL) { /* Older Linux kernels did not support /proc/PID/smaps. */ - maps_filename = string_printf ("/proc/%d/maps", pid); + maps_filename = string_printf ("/proc/%ld/maps", ptid.lwp ()); data = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); if (data == nullptr) -- 2.55.0