From patchwork Thu Mar 21 23:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 781597 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp1080011wrj; Thu, 21 Mar 2024 16:19:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVH47Rpg3EU/slgrlSwwUqv0seynHexukNXeHOvMI2QUrkKRLWR2Uz6bkQYLSlbfvm8hIQCXTjhNhR85+tuDyzn X-Google-Smtp-Source: AGHT+IF4+aFjEUxKhzuKMISFPVKdzo/uETUIillJSL6gK++UzQhJ+ivZ5F4zBcx5frHm64xe4gdR X-Received: by 2002:a25:b21d:0:b0:dc7:4854:1b1e with SMTP id i29-20020a25b21d000000b00dc748541b1emr674319ybj.54.1711063182058; Thu, 21 Mar 2024 16:19:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711063182; cv=pass; d=google.com; s=arc-20160816; b=ruzQeQKznCryAmnv2BTtPqbrxlzdwAwkNzgXdcRyvI6GGmOsN416u9Mb3fTIyP8H2g otbmmWZeM/B5Dz8dbIN08SoFNJkEn3c+9ePFXhnRVADqZhTj6eB3sqm0iTOprQfwndaI VGVwYv4pdungrQtw948YQmOn4hl44Q4lyRtGmnKMei2dSDRWxdsEKcRktpXaLouw7W5K 2b1B+5toDwmb57UeIMFS6t08FWGzkOMu+NvbH0THW3JIKqihD9k18gPwD1yip5OFebrK YbUt2q3bfySjrLLSFM4nQ5ddFbO8XAxqCuQEAu8w3cK8I0Yt1dANgiyAL7+2kriWayzZ Z97g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Ii9Tppm+h0NUn2okDBnn43pxmy2QsohdlV0FH6w6L+c=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=bavtUcGw7lIrRqQhSVoEA3t47+VaDSvb5/c1wJYYVijgJmlckuZb1b2cI1pZnGnUit jRl6JQsekrDkc6QzvcXgX9ORq2W6dKegTFcK9wn1qeEVNcBqURjAcn22c4dcIqjE7LxA zkLhGzq2yown0fkyCTmlnx2vgLSYkOAK9lDnW+zFpn72zsjJbwT08t1NfDxZmf1Bx6gx EAP1t0YQXTxSO4aYq/u241y9qVGeyOudf62/HFY9bCHX8RPeWT2xvtaKv4twEUUlEkoH pwE8loKxRIbUGuw65z4xDQfe3Yec+filB6nZjXrVhAZuvQMyA+OsPdSia6JAo7oIxbar GY5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xsFBTy2+; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v16-20020ac85790000000b00430d738da53si811773qta.135.2024.03.21.16.19.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 16:19:42 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xsFBTy2+; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B53F43858D28 for ; Thu, 21 Mar 2024 23:19:41 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-vk1-xa2a.google.com (mail-vk1-xa2a.google.com [IPv6:2607:f8b0:4864:20::a2a]) by sourceware.org (Postfix) with ESMTPS id 18A813858D28 for ; Thu, 21 Mar 2024 23:19:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18A813858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 18A813858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711063164; cv=none; b=cRuVViA5AyonoI1+uJOJrNimAD0U3rVY7dK9fy7OmyfPZX5GDqGe42Hnswxcbg2SKHRwU3FyCB6ctDNqKDnFmiWwROe+5gcfQ/0bRMtt9w+yZT9v8D+d+a6qvveFTLqlTKBHsFFN3OGV+9hCVeCiXxHEIEXMOcC5c+MKUt6PGiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711063164; c=relaxed/simple; bh=cSbphJ1LC3FBkmjUtwQCyiFr3lNZmJYbxFDuoOguxo4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Nq66UF2Ino/ozoXq5g0kCxGTp6Ff+cglJJTLMaRu1LRtMW61dNqIMldsftStlxBP40TZi803zlS9UqOx7gZZFc87aO90eHkgRfP2h7mUVUguZLxWcuC8X7Avz45t+EbZuhKZ6mmV+k3OjsgllvlbQ52lTj4gzmXWkZbW5g3Iy6s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-4d42ea640f0so551181e0c.3 for ; Thu, 21 Mar 2024 16:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711063161; x=1711667961; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Ii9Tppm+h0NUn2okDBnn43pxmy2QsohdlV0FH6w6L+c=; b=xsFBTy2+ncAHCFsgCZczG9LFm3ufxobkFA7cYEI5tEFOzipui+bWyB+CnhA2DFc+H3 oKnKxqI3fnCDPh5V14iSrckM0NeH+2uYN7YZLW5pKx7/RGJLSMsPg7AFuSRM0v3N5SJO jJJovJJp/+/RkpkT2F6ll2UltOjuZP4JWidT+bomLRQEoMnmtIzFmsJ0RPbmxVX3Y/Vg G3onUDPVfwQnBGJLDKEzMNB9Xd+1kQNUgVQcGQjKE+hCqDyqUBf+8SqvY4Tw71ZPj7X1 otuEv2/Io39qAApqR9Idxd+R4mcgnH0b82Z/B8lBHa4v7i3KlAesHwKOV0VbRF6btP88 Ccxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711063161; x=1711667961; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ii9Tppm+h0NUn2okDBnn43pxmy2QsohdlV0FH6w6L+c=; b=vcsEWbtlWN9mzcDAnBELM2Q0D2b/HZnToa4aQioOgsGYSCeXfMlxWHaY4B8IIb3wv5 TLZCmYR0D8AZgpEHnW2Q5LvNU8bTYuV2MVdadkEgIqbEO1AwqVzj3VvRBnTc5aXWffim 6IIOZAXqxkV1W+WXhA8E7VQKbvikoaz7lw4KEDJ/Ooq5Yi5wcZMn2QU7sz4LxTkWMwgG eWijH3lk8nMkNQRerpH70JrrjqbIKaKyk01W79ozlwWze9h6N+Of15vwMsk7O2rcckaV 5J2DOVWaRokcVLCwIBJLw4mjEllclHwqFRptq1Kxru//JArpZ8SlsnWjNREvWRi3nqGi Q5KQ== X-Gm-Message-State: AOJu0YxgSOcGILkHXX2bGzQGkpjyxkRcIy0cmzDuih0zPGfPTvkyNBjy 7XH5KSb2Vt7YgzNMdc0zIAb7Ky4cNhFXJ87ulLmOk/uWMFg6UEMOO+PZ1U/SvdjjxJLu7AveHnb Z X-Received: by 2002:a05:6a20:bca5:b0:1a3:4469:5967 with SMTP id fx37-20020a056a20bca500b001a344695967mr947826pzb.57.1711062715999; Thu, 21 Mar 2024 16:11:55 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:e28:f7d5:8d63:c544]) by smtp.gmail.com with ESMTPSA id n4-20020a62e504000000b006e64a9104fdsm375185pff.114.2024.03.21.16.11.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 16:11:55 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [RFC PATCH 1/3] gdb/nat: Use procfs(5) indexes in linux_common_core_of_thread Date: Thu, 21 Mar 2024 20:11:47 -0300 Message-ID: <20240321231149.519549-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321231149.519549-1-thiago.bauermann@linaro.org> References: <20240321231149.519549-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patch=linaro.org@sourceware.org The code and comment reference stat fields by made-up indexes. The procfs(5) man page, which describes the /proc/PID/stat file, has a numbered list of these fields so it's more convenient to use those numbers instead. This is currently an implementation detail inside the function so it's not really relevant with the code as-is, but a future patch will do some refactoring which will make the index more prominent. Therefore, make this change in a separate patch so that it's simpler to review. Reviewed-By: Luis Machado --- gdb/nat/linux-osdata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c index c9192940f236..172fea5cea85 100644 --- a/gdb/nat/linux-osdata.c +++ b/gdb/nat/linux-osdata.c @@ -75,10 +75,10 @@ linux_common_core_of_thread (ptid_t ptid) if (pos == std::string::npos) return -1; - /* If the first field after program name has index 0, then core number is - the field with index 36 (so, the 37th). There's no constant for that - anywhere. */ - for (int i = 0; i < 37; ++i) + /* If the first field after program name has index 3, then core number is + the field with index 39. These are the indexes shown in the procfs(5) + man page. */ + for (int i = 3; i <= 39; ++i) { /* Find separator. */ pos = content->find_first_of (' ', pos);