From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2084.outbound.protection.outlook.com [40.107.247.84]) by sourceware.org (Postfix) with ESMTPS id 129063846410 for ; Thu, 25 Apr 2024 09:00:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 129063846410 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 129063846410 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.247.84 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1714035617; cv=pass; b=gNb6/brNMzVjx7kwJogAZafz8AN/TI9pJ1esyUUG5Vy8KyEBBteAJp4x7DW0BQ7mHOgsPKiMQ1XGwEXCqWk6Lkvzj4RkqKlRpol17k9yzi/vb6FgkLBwYKmkIjOAwbXdZsidCxJEE5cnmq3PxEAUI50v5LOT/bmDSPtRjmwTicw= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1714035617; c=relaxed/simple; bh=gUjq8P5x4JFQAWoUJ0VGz6TYYeKGx49eIDxNnJzWovU=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=ojtmzXsM6b5MLFOgH+RJeDbp6JbaOyeelq2KZLpY4QUKK37PyNAD3QL9X7MSs7O1NoRbEd7SuudF4Tj8QW5PzQC3cE7E15M4Jfl9pnQ86slN6sqbhVaUAwFc2WbCgMWtflmm51ZPC1n7rzUzInMOm5CsBtHbL04Liz9CC83O8rg= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=PgPQj6MbhFR4fCtVABT2xVQCeyt25WVyG/j4ObuJg8zwlmjMP4rmEP8VehBAKcZ/BvHbddnz1GX5+wzNd5OdiePVDoMQP5MJVIKiutwGBO4AGeTi/2fXjKNtbLI8AO6EHVbUoVGiEwBDFQxCHUeDOclhFd/+IDLY1EuE4IBsCFwUJPNKX4Ln8kIH7gHlHS4whOu8Z2KP8Y9SjFLSK0qjOmc//QX4TVKTimBicBanxqxVdvVYCriAXvKhGLVWcQAEKvtO72WBSaugJ9vJblHuR4zn5pXWQWQzwY+dU9UmLbOuuCBl/4Dwd63IAvrWrgtwQNsQEale097sukmsBOFfqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=kPa1V5FtZ2sxarniZlZVw4jSwCZexdd0CBmbDQdPooU=; b=c2MpRhTD30bX0TSkVgmSQf+zqF/xWyNX6eZ04vGVm85MgFmMxC2l2ZgRrx5NCDtenKY4P6qhugmDNfs52QUUfxlkdYx9l3HfQA0GTeTaseus9fI1UI5VZEF12eV3Y1r1kYIAPtIiquzTKdZLlKrtSRX75V6Ya+Tmde0z+UyLdE0vc2vd7xyHs7y6pdqgdRrmiOAjwizjCvt/7nLOo7nIeNfrdU5R83Jr8eBEyBQvR0gBtEXcqAJjvOfzHGVkir7gYmLD82aP0cQ77qg+xy+8RSRmb9JgopcPYOrEYz9sbsV2z44FyEWQos7h01oq6p+04jsdoRvvom4LEqOOw3pp1g== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) 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] 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=kPa1V5FtZ2sxarniZlZVw4jSwCZexdd0CBmbDQdPooU=; b=g4iMOpdmGwbPvH7HZj2a4nQxxJeyTC/hntSmcdx3KJk4rvMX8W6at/JXbB5ndJHjT3tzAqrf9rlfchWXbx6Q8H1tOPe33koOquD3wAkB+G1sIpRBaqsMK0c9L04RtuJwQCdAPu4tlTahtJK3O+d6S+P6N1OSUDQ5CQwKxGWNwqo= Received: from AM9P250CA0008.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:21c::13) by VE1PR08MB5728.eurprd08.prod.outlook.com (2603:10a6:800:1a0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Thu, 25 Apr 2024 09:00:11 +0000 Received: from AM4PEPF00025F9B.EURPRD83.prod.outlook.com (2603:10a6:20b:21c:cafe::eb) by AM9P250CA0008.outlook.office365.com (2603:10a6:20b:21c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22 via Frontend Transport; Thu, 25 Apr 2024 09:00:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) 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 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM4PEPF00025F9B.mail.protection.outlook.com (10.167.16.10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7519.0 via Frontend Transport; Thu, 25 Apr 2024 09:00:10 +0000 Received: ("Tessian outbound af213ececc3d:v315"); Thu, 25 Apr 2024 09:00:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a35c8f1f49a95011 X-CR-MTA-TID: 64aa7808 Received: from 88813b8d8be2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 184101E7-805E-4C77-80C2-0AFF4E8E41E5.1; Thu, 25 Apr 2024 09:00:04 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 88813b8d8be2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 25 Apr 2024 09:00:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kvB2woFIgsPyZM68+6m3oeHzh1lq5U6atM26n9PobdPAycICMs7Zh6TO08bc5tDhYwh3YXAP1ztZ0xIYYdX48mhrt3KwCfWV6Wq6f5R2ARptZugp62rQacC39/DwIlN/81srnvQ8IZcAcSL7RDB4n2kp85rZ8hoxzZt4EuJuCZYrbV0PItK8dqX6h41cQg2O8mScB3LoM6g/xuniTBPuRKCSiTTUb/UbNQFho3rL70+6yZtPQC2+2ydp1dAC9HjfcaOIkEX15Lu7X4c6zerGL+MqfWvstF4S7kPK4ZwKLsF3jdr5QX18wQZoGeDNJHwzp7raI0FZHWmBex3bBut+tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=kPa1V5FtZ2sxarniZlZVw4jSwCZexdd0CBmbDQdPooU=; b=EfWco0oCihAO9wOAPeOp0LvjEGXcQHQjMpoSOtSeGEIsEjN80wW9Fu3n2T6RQGosSAoV5hujMWzwLxLj/lv6peJQMgzrrBBuTO3IbkWMkCGfOJXrDZVZl8g9YDO/uDXuh7MGRScD21RWy7v0Y3Bryw+MR35dHL+hCTSwGymzL2FicB+yGWQdD/WLAAIYls0877MHiF1+/QJHzR/QhXtDrg+79mOP8a0a1X+4/X8/ttP3BTq6hjcnpYo8/bb5kh3hWxLU0i4rs5G8dhJZZcN8EzJjKphpGlBqMC4OQyg4tCOPE5hZluhB0yj3JGoc3pNpT4tRIU+vqazz7vxhD4iNPA== 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=kPa1V5FtZ2sxarniZlZVw4jSwCZexdd0CBmbDQdPooU=; b=g4iMOpdmGwbPvH7HZj2a4nQxxJeyTC/hntSmcdx3KJk4rvMX8W6at/JXbB5ndJHjT3tzAqrf9rlfchWXbx6Q8H1tOPe33koOquD3wAkB+G1sIpRBaqsMK0c9L04RtuJwQCdAPu4tlTahtJK3O+d6S+P6N1OSUDQ5CQwKxGWNwqo= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by GV1PR08MB7756.eurprd08.prod.outlook.com (2603:10a6:150:57::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Thu, 25 Apr 2024 09:00:01 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::77d4:d040:b19d:6472]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::77d4:d040:b19d:6472%4]) with mapi id 15.20.7519.021; Thu, 25 Apr 2024 09:00:00 +0000 Message-ID: <4f0352e1-dc25-48ee-8366-0a3135cbc353@arm.com> Date: Thu, 25 Apr 2024 09:59:53 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/3] gdb/nat: Factor linux_proc_get_stat_field out of linux_common_core_of_thread Content-Language: en-US To: Thiago Jung Bauermann , gdb-patches@sourceware.org Cc: Christophe Lyon , Pedro Alves References: <20240424231551.1577518-1-thiago.bauermann@linaro.org> <20240424231551.1577518-3-thiago.bauermann@linaro.org> From: Luis Machado In-Reply-To: <20240424231551.1577518-3-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA9PR10CA0027.namprd10.prod.outlook.com (2603:10b6:806:a7::32) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|GV1PR08MB7756:EE_|AM4PEPF00025F9B:EE_|VE1PR08MB5728:EE_ X-MS-Office365-Filtering-Correlation-Id: 67225b43-6717-40cc-2eb7-08dc65061cdd x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?B?OGdRQTNudDljWXNwN2ZjRGVucnJMbndNVFdLZFZGU29OQ29uN1VQT1M3NHox?= =?utf-8?B?eFlJZVlrSkRjRWZPRzFpcDV5U0p4Mng4dGw5OFYzTDJZZXRNWFFucnVvNFhy?= =?utf-8?B?dmVWZTFUQnFJM0hEcWJQZXJIZTk3ZElGU3l6QWYrNUtYZ0EvMjVrL25HTnE2?= =?utf-8?B?WGl1V05CQk9Ic0NyMytRaGpvWENXaTJ5alNOZGFoSHJvajhXeDZtOHpndFBY?= =?utf-8?B?UkpEMTJZOHFqYmRTam5WNXZsNmxUZ3h6b2U5Y3hwRXZoNUp2WVVwOU5hNFpE?= =?utf-8?B?OXYxN3dXVy9EbmZQaHB6NmVYU3dHUGlNbUpTdzU3YlV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BkRmFXbC9ORGp2M0hodnB5V3A4Tlk4U0FqWDlQODZRUUxL?= =?utf-8?B?bmNGRFQvOE43clgyZ2dqa0I1RlVLWDdTaVFDa2VoYzBROFpRYXhDYWVkdmFO?= =?utf-8?B?VERJa0YwS29XZDVuTzVOTXRhYi8zM3lqYTlkTGFKcmEyc1owcGl4Z3JLNzNY?= =?utf-8?B?Z1NWSWJubUVvR0dGTkdxL2NZaE1lSnZrYUg1Q2Q4V1ZCcUhqNGg2UURKY3E3?= =?utf-8?B?VHFjbDZWTC8rOC8vRTB1cWVUWmdROHNNNWJSTGtSL0hUekFsa3VLa1A4MGty?= =?utf-8?B?ZTJLMVM1ZUFXU0Z5M0d6MFVOTkthRldXUU9Qc1RXV1dOQVJHQWhuWlU1VXpZ?= =?utf-8?B?S3B6dEZIL2RNclIxSzRFa1RRbTQrazV2QW9UTUZnMktLTWFlMGE4alpOcWVh?= =?utf-8?B?eEtYZm9rWE5BdUpnSHo3V1VDQzFQNUZzZytrSzNaSDhKbFlqSi9XRnE3azFG?= =?utf-8?B?Y2ErTmV5SXU3VndaSlVlSVZzREhBZEVMRGxlRENqdGVKdm5xblRZOGVnPT0=?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7756 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00025F9B.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 96241dad-fd07-4efd-1cc3-08dc650616ae X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|82310400014|36860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VTNzTDF5NUx0RGcrdytwNXEzNlNrK2RzZUptakFJOUlsRjNGOVVWbTJO?= =?utf-8?B?akExc1ZvNW9vT0Nvb2tEYkJJaFc5WEh0T2wxUUFFc3loWDNScHo3NlZrT1Nr?= =?utf-8?Q?BmCPF7SE3F8ie?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2024 09:00:10.7453 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67225b43-6717-40cc-2eb7-08dc65061cdd X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00025F9B.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5728 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 4/25/24 00:15, Thiago Jung Bauermann wrote: > The new function will be used in a subsequent patch to read a different > stat field. > > The new code is believed to be equivalent to the old code, so there > should be no change in GDB behaviour. The only material change was to > use std::string and string_printf rather than a fixed char array to > build the path to the stat file. > > Also, take the opportunity to move the function's documentation comment to > the header file, to conform with GDB practice. > > Reviewed-By: Luis Machado > --- > gdb/nat/linux-osdata.c | 41 +++++---------------------------------- > gdb/nat/linux-osdata.h | 3 +++ > gdb/nat/linux-procfs.c | 44 ++++++++++++++++++++++++++++++++++++++++++ > gdb/nat/linux-procfs.h | 10 ++++++++++ > 4 files changed, 62 insertions(+), 36 deletions(-) > > Changes in v3: > - Preserve comment mentioning why we use that field in the for loop in > linux_proc_get_stat_field. > > Changes in v2: > - Added macros for field indexes in /proc/PID/stat (Suggested by Luis). > - Moved linux_find_proc_stat_field from linux-osdata.c to linux-procfs.c > and changed prefix to linux_proc (Suggested by Pedro). > - Use string_printf in linux_proc_get_stat_field to build path to stat > file, to avoid having to copy the PID_T and MAX_PID_T_STRLEN macros. > > diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c > index 4812bc735e86..3a6215015f12 100644 > --- a/gdb/nat/linux-osdata.c > +++ b/gdb/nat/linux-osdata.c > @@ -36,6 +36,7 @@ > #include > #include "gdbsupport/filestuff.h" > #include > +#include "linux-procfs.h" > > #define NAMELEN(dirent) strlen ((dirent)->d_name) > > @@ -52,50 +53,18 @@ typedef long long TIME_T; > > #define MAX_PID_T_STRLEN (sizeof ("-9223372036854775808") - 1) > > -/* Index of fields of interest in /proc/PID/stat, from procfs(5) man page. */ > -#define LINUX_PROC_STAT_STATE 3 > -#define LINUX_PROC_STAT_PROCESSOR 39 > - > -/* Returns the CPU core that thread PTID is currently running on. */ > - > -/* Compute and return the processor core of a given thread. */ > +/* See linux-osdata.h. */ > > int > linux_common_core_of_thread (ptid_t ptid) > { > - char filename[sizeof ("/proc//task//stat") + 2 * MAX_PID_T_STRLEN]; > + std::optional field > + = linux_proc_get_stat_field (ptid, LINUX_PROC_STAT_PROCESSOR); > int core; > > - sprintf (filename, "/proc/%lld/task/%lld/stat", > - (PID_T) ptid.pid (), (PID_T) ptid.lwp ()); > - > - std::optional content = read_text_file_to_string (filename); > - if (!content.has_value ()) > + if (!field.has_value () || sscanf (field->c_str (), "%d", &core) == 0) > return -1; > > - /* ps command also relies on no trailing fields ever contain ')'. */ > - std::string::size_type pos = content->find_last_of (')'); > - if (pos == std::string::npos) > - return -1; > - > - /* The first field after program name is LINUX_PROC_STAT_STATE, and we are > - interested in field LINUX_PROC_STAT_PROCESSOR. */ > - for (int i = LINUX_PROC_STAT_STATE; i <= LINUX_PROC_STAT_PROCESSOR; ++i) > - { > - /* Find separator. */ > - pos = content->find_first_of (' ', pos); > - if (pos == std::string::npos) > - return {}; > - > - /* Find beginning of field. */ > - pos = content->find_first_not_of (' ', pos); > - if (pos == std::string::npos) > - return {}; > - } > - > - if (sscanf (&(*content)[pos], "%d", &core) == 0) > - core = -1; > - > return core; > } > > diff --git a/gdb/nat/linux-osdata.h b/gdb/nat/linux-osdata.h > index 833915cdb2fd..a82fb08b998e 100644 > --- a/gdb/nat/linux-osdata.h > +++ b/gdb/nat/linux-osdata.h > @@ -20,7 +20,10 @@ > #ifndef NAT_LINUX_OSDATA_H > #define NAT_LINUX_OSDATA_H > > +/* Returns the CPU core that thread PTID is currently running on. */ > + > extern int linux_common_core_of_thread (ptid_t ptid); > + > extern LONGEST linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf, > ULONGEST offset, ULONGEST len); > > diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c > index e2086952ce6b..c11eaf3cc6fd 100644 > --- a/gdb/nat/linux-procfs.c > +++ b/gdb/nat/linux-procfs.c > @@ -230,6 +230,50 @@ linux_proc_pid_is_zombie (pid_t pid) > > /* See linux-procfs.h. */ > > +std::optional > +linux_proc_get_stat_field (ptid_t ptid, int field) > +{ > + /* We never need to read PID from the stat file, and there's > + command_from_pid to read the comm field. */ > + gdb_assert (field >= LINUX_PROC_STAT_STATE); > + > + std::string filename = string_printf ("/proc/%ld/task/%ld/stat", > + (long) ptid.pid (), (long) ptid.lwp ()); > + > + std::optional content > + = read_text_file_to_string (filename.c_str ()); > + if (!content.has_value ()) > + return {}; > + > + /* ps command also relies on no trailing fields ever contain ')'. */ Probably an existing typo, but s/contain/containing? No need to send a v5 for this though. > + std::string::size_type pos = content->find_last_of (')'); > + if (pos == std::string::npos) > + return {}; > + > + /* The first field after program name is LINUX_PROC_STAT_STATE. */ > + for (int i = LINUX_PROC_STAT_STATE; i <= field; ++i) > + { > + /* Find separator. */ > + pos = content->find_first_of (' ', pos); > + if (pos == std::string::npos) > + return {}; > + > + /* Find beginning of field. */ > + pos = content->find_first_not_of (' ', pos); > + if (pos == std::string::npos) > + return {}; > + } > + > + /* Find end of field. */ > + std::string::size_type end_pos = content->find_first_of (' ', pos); > + if (end_pos == std::string::npos) > + return content->substr (pos); > + else > + return content->substr (pos, end_pos - pos); > +} > + > +/* See linux-procfs.h. */ > + > const char * > linux_proc_tid_get_name (ptid_t ptid) > { > diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h > index 880afbcdd615..ec1f37651fbf 100644 > --- a/gdb/nat/linux-procfs.h > +++ b/gdb/nat/linux-procfs.h > @@ -54,6 +54,16 @@ extern int linux_proc_pid_is_zombie_nowarn (pid_t pid); > > extern int linux_proc_pid_is_gone (pid_t pid); > > +/* Index of fields of interest in /proc/PID/stat, from procfs(5) man page. */ > +#define LINUX_PROC_STAT_STATE 3 > +#define LINUX_PROC_STAT_PROCESSOR 39 > + > +/* Returns FIELD (as numbered in procfs(5) man page) of > + /proc/PID/task/LWP/stat file. */ > + > +extern std::optional linux_proc_get_stat_field (ptid_t ptid, > + int field); > + > /* Return a string giving the thread's name or NULL if the > information is unavailable. The returned value points to a statically > allocated buffer. The value therefore becomes invalid at the next Otherwise looks OK.