From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by sourceware.org (Postfix) with ESMTPS id 54B603858435 for ; Mon, 22 Apr 2024 19:39:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54B603858435 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54B603858435 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713814758; cv=none; b=Qbcmd9AVrFRn/4noC3mXX6fLG9EgSHQdLJENlD1WwLOXVy1aeSMjgRQEVboLGXoHcJrVioTjZIpIeWkNG0Zw6UppqLzCHY1R8Qxy6FtGkx3XBgv6w9s2QonaZQ2p4EsdYGrHbGuiQQDGlfkHKiRuj+s1QPldfoPfEgoSf81907E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713814758; c=relaxed/simple; bh=f/pSVIdzy08FNUDbZZTa6oA4WQN3nqiv5WIJNWKsr5U=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=qU92+YTVLVu2rgh9+21Q9sf9QFqIa0m/6p8Hzxwbx/RhJ9PolXGel4ukmQLbC1eeZdO5wysM8lUPdF7hdJ7wY2yVr67sL6owkoHBFCqN+oguu8d4c32j3tDoGe3bT//8NETP/IhZaq+Hzl5Lpa97K8MWW4pavVEHh4Z/c1SQ+HY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-345b857d7adso3805744f8f.1 for ; Mon, 22 Apr 2024 12:39:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713814755; x=1714419555; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+eqGArD3b+9f5UBXb6NLjLFuoMi+dG6KZ56Fhc+NGZ4=; b=uXiDy7uvBLQICKLln7+9ls9XeYWboTDcEq1vgK+BucTvPTSTJWAFNsL0IJAsiychTq t4KQUYG+enBmao9nc78JF8KfTfY7v2phHV8ckfX69Po+rqSeS8nDaFf0ANXf1oc/s6Ft 6Oe0UBSe+DmNet1u6fbNMAySHWeaDE5OHdaHoilmBVCSZuzCRmt3HBjk+TJkl5e6SCdO /OvUT/1lutUjrnwLrxCSCOrafmXJZ06QRTTEz9lYIIlT/eM+DOVLpocu/WNUhdUuRiq/ kiySaSHx7xf8Yh60c/YJWaCSQED7o7Uvii6+vZDIqy25tir6mw+usYI0vmGtLiVj99pK HC+A== X-Forwarded-Encrypted: i=1; AJvYcCXOJEPELLTtjurcVPB/4u/e5tjCdrwXxB146PBiTAWw1u+OW97MNWbUFvUhus3AG0WjI52jySUWkheD83uDvsfOhCiUwmRjq4bSZw== X-Gm-Message-State: AOJu0YzvTckLhngWGTSFCltv0v3AfTmbFdQdP/nVKrA2vVY7JUHdP+fx AeFPuLI7qLFuZOq0Li5/nBv+20Dd2fkqX6jWRP5jM3fLvUh9myii X-Google-Smtp-Source: AGHT+IHywJYlDUVu7pIi/vKWtS0+Z3RJIF4tSmaNx3FNIYMyJtOFUy4nLudYzJxSVZRXzIBJ95WRVA== X-Received: by 2002:a5d:598a:0:b0:34b:8bf:6019 with SMTP id n10-20020a5d598a000000b0034b08bf6019mr3407652wri.70.1713814754920; Mon, 22 Apr 2024 12:39:14 -0700 (PDT) Received: from ?IPV6:2001:8a0:f93d:b900:8880:21cb:6a55:2a43? ([2001:8a0:f93d:b900:8880:21cb:6a55:2a43]) by smtp.gmail.com with ESMTPSA id hg12-20020a05600c538c00b00415dfa709dasm17512858wmb.15.2024.04.22.12.39.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Apr 2024 12:39:14 -0700 (PDT) Message-ID: <2e437b3c-4f0b-44e4-892e-490f4dac2c9a@palves.net> Date: Mon, 22 Apr 2024 20:39:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/3] gdb/nat: Use procfs(5) indexes in linux_common_core_of_thread To: Thiago Jung Bauermann , gdb-patches@sourceware.org Cc: Christophe Lyon , Luis Machado References: <20240420055652.819024-1-thiago.bauermann@linaro.org> <20240420055652.819024-2-thiago.bauermann@linaro.org> From: Pedro Alves Content-Language: en-US In-Reply-To: <20240420055652.819024-2-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: On 2024-04-20 06:56, Thiago Jung Bauermann wrote: > diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c > index 6ffabe90aa7d..079f9ea20c37 100644 > --- a/gdb/nat/linux-osdata.c > +++ b/gdb/nat/linux-osdata.c > @@ -52,6 +52,10 @@ 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 > + > + /* 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. */ If you're going to have macros, then the comment shouldn't be repeating the numbers. This is one way I thought it would be worse -- before the numbers were all in the same four lines, there was basically no chance of getting them out of sync. Now they are spread out in two different places. For the logic below, what isn't obvious and deserves a comment is, IMO: - the state field is that one that comes first after the command name field. - we want to get to the "processor" field (not obvious because we call it "core"). > + for (int i = LINUX_PROC_STAT_STATE; i <= LINUX_PROC_STAT_PROCESSOR; ++i) > { > /* Find separator. */ > pos = content->find_first_of (' ', pos);