Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp281723lqo; Thu, 16 May 2024 06:20:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDiuLkZLOjbOG19Sbkk3Upj8nIV9j/kZlMPNdRnrhtizLvctA9YPTEnxggIGDVy8+1BuAb21Oc7N84dVbVwijLKrBquAnE+9mpvbCvPQ== X-Google-Smtp-Source: AGHT+IGy9lFEOwdOLOuiYpDLUrqCZB52I6LqyQ2b27u6f4gbJ0gaZULvCoqD0Op0/uPTW1Ar60Au X-Received: by 2002:a17:902:f602:b0:1e4:19e3:56cb with SMTP id d9443c01a7336-1ef43c0954cmr320719135ad.12.1715865608541; Thu, 16 May 2024 06:20:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715865608; cv=pass; d=google.com; s=arc-20160816; b=zpgoFBt3+MqhWgBcFDT2/toqsWSQnYDGTMzWfOEiDXC5FzWsr4htmi9Eiz2JiO8Onz tjaXNcvzXtxCKQcucBhue/bnPEfoREKkcqDdjK7bgw/zpKcrbR1d6krd7kS++O2CsQy6 ieUU+duHZGUV8rrxFsn78fbH7wMT8x5rR4mvLXTmvoanUcUtEVG4o7lHvyZySFCG2eVB SRiihZy8u/uSQ3D00GA2ZT1azWDKTRAn1x6S4zVxxVBpcQCrONnC6h+FEuUQ9mx5Fw2f Sl8QKSt4Yw3C+JZD+IsGRYkKQo1srxynFha15HPb3YzZWyHJAbeEJuGJ9cJaTzRtiIEG yYMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=KdGWxoXF3gHnPOdYFh5gyCjeUx8D+oDKEyOSzHQOiAA=; fh=IUyJQv7K/bdR0QmTouwWFM8stiT9PQC02/vxh+P6YE4=; b=F2/zZ/VtqcUKxvxVuaGfXoddWP4v2lCft9ZONGjivHLJn/V6ArJBQYDn38vDsQprdz KOI2VSL6P3flx9nXjwKEKtBGeDOvWGYlKbFNjZSoXVmX46bgLOTkMILnPstMQCGeoeGB jQ93n/wDZ6U+OwCGvr9Jj/fLziWx8I3A9gy1a8Czr1KByxTHaPiQcY93EpD1BI8cNTK/ JAgztWuYHMtYgHMH/GfwFKz6Ky+n39GHNVLFVhdX9mUEdlB/K8PyDV19HfRNuPfwMyIu lttPajnmAqqWAA0YRqzJloCmIpd3b1/slMona10s9Slcx1HC2icL4UoCgcxv/EgElZ2/ zPEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-181101-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181101-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c15f4dcsi145584065ad.538.2024.05.16.06.20.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 06:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181101-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-181101-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181101-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 921EE282561 for ; Thu, 16 May 2024 13:19:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8705414B071; Thu, 16 May 2024 13:18:47 +0000 (UTC) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 366B5143862; Thu, 16 May 2024 13:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715865527; cv=none; b=iI0oQT4ucw19HB+h0VETRBAcJt0A48Gsr0HYCfOYdDRz7S94NZoHa4reECKt2zGDAIIBVcZo2z28fY0RyHlGIkUDr+zf1NOYNv4XAO23MjJ5uV8I9Ij+aixK+0pHf+9EOSzBpO0j2vpl8zDPu8YNyoDlDv/KTl2K1uaq1Mnj/sI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715865527; c=relaxed/simple; bh=IwDcXBrM7FxrzumjpWEBXxVI/Sjr7Q8mo1aSkT0G6Uk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=P7NffrFNLaPphIILmjjOSq/aQpRQoU9svECn/59jNh1csX/RffDwtF1P/+sVR3bM9NaIkAocXZLDBT0ZWw2F/7kG3tB/GTrWO/UUHK1Z+gQIFv2J3njiqgBRf3qVNprM/F4KPo7tb9l+BgWHMaf4r1rBI6wnZhgItvRCe4RPAj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a5ce2f0deffso105140366b.3; Thu, 16 May 2024 06:18:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715865523; x=1716470323; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KdGWxoXF3gHnPOdYFh5gyCjeUx8D+oDKEyOSzHQOiAA=; b=HPodG0Dx5rerUOwXaeKOwUywuAVuf5sQnLIOEo1jMZpSgpVoD+xilhx3NQKwsTUYCK kwjgejwxjX8AF2QS9K2h++x1mstGPaQSR3KsHy7kbXOxKtwyfM9AmqT/L/hJPJ/5ux/o 5qppnrbnXdUXLNZH6Nf0LrF/C48wIS57f8P3GvXSGav7tbH7H5Y01unZIjtUFqxsPh2+ jb5z4Y1mBCN7Vp1WGjJCLi/swemP7JKNitQ/cVm1c7cvyJ84z1gE07Z3ZIALzBh+0ZDZ P6QXy29EgBpZq5Hv2YX7c8Q7PNioMUQd4BDAvWcJADXKjTclSWb+hzvhQKMu4gTS/NNZ MRog== X-Forwarded-Encrypted: i=1; AJvYcCVkprhqgFWgktACURSFEFLgEo3y7PP6JbXsJ4kOWzwWQ6qZprW5Zw55+i2aDFKOLBUf61EQQIBQyT6J+ZT/E9HjVRlkWw8kVfSaft4NJ11YW1op2wMzrnJdr+nRwheni2l4aCudVu11mpWsQNk1sQ== X-Gm-Message-State: AOJu0Yw1SrZ/0hRRok25b/FXe6q/tSN0pC6VDAC+GvwR9KZ/GqxyGlP6 g6YRn2Uf7VK09QsXBWp2/XG3ToAd/4zEs30cCXRSlyTcRPrfcIEa X-Received: by 2002:a17:906:aa4d:b0:a59:c23d:85d8 with SMTP id a640c23a62f3a-a5a2d6653f4mr1274823266b.51.1715865523323; Thu, 16 May 2024 06:18:43 -0700 (PDT) Received: from localhost (fwdproxy-lla-009.fbsv.net. [2a03:2880:30ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a17b17870sm976435666b.216.2024.05.16.06.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 06:18:42 -0700 (PDT) From: Breno Leitao To: irogers@google.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter Cc: leit@meta.com, linux-perf-users@vger.kernel.org (open list:PERFORMANCE EVENTS SUBSYSTEM), linux-kernel@vger.kernel.org (open list:PERFORMANCE EVENTS SUBSYSTEM) Subject: [PATCH v3] perf list: Fix the --no-desc option Date: Thu, 16 May 2024 06:15:43 -0700 Message-ID: <20240516131544.2885917-1-leitao@debian.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, the --no-desc option in perf list isn't functioning as intended. This issue arises from the overwriting of struct option->desc with the opposite value of struct option->long_desc. Consequently, whatever parse_options() returns at struct option->desc gets overridden later, rendering the --desc or --no-desc arguments ineffective. To resolve this, set ->desc as true by default and allow parse_options() to adjust it accordingly. This adjustment will fix the --no-desc option while preserving the functionality of the other parameters. Signed-off-by: Breno Leitao --- Changelog: v3: * Applied the same logic to default_print_metric() and json_print_event() functions, as identified by Ian Rogers. v2: * Do not print desc if long_desc is being printed, as identified by Ian Rogers. --- tools/perf/builtin-list.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 02bf608d585e..8a0e123587f3 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -149,7 +149,11 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi } else fputc('\n', fp); - if (desc && print_state->desc) { + if (long_desc && print_state->long_desc) { + fprintf(fp, "%*s", 8, "["); + wordwrap(fp, long_desc, 8, pager_get_columns(), 0); + fprintf(fp, "]\n"); + } else if (desc && print_state->desc) { char *desc_with_unit = NULL; int desc_len = -1; @@ -165,12 +169,6 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi fprintf(fp, "]\n"); free(desc_with_unit); } - long_desc = long_desc ?: desc; - if (long_desc && print_state->long_desc) { - fprintf(fp, "%*s", 8, "["); - wordwrap(fp, long_desc, 8, pager_get_columns(), 0); - fprintf(fp, "]\n"); - } if (print_state->detailed && encoding_desc) { fprintf(fp, "%*s", 8, ""); @@ -243,15 +241,14 @@ static void default_print_metric(void *ps, } fprintf(fp, " %s\n", name); - if (desc && print_state->desc) { - fprintf(fp, "%*s", 8, "["); - wordwrap(fp, desc, 8, pager_get_columns(), 0); - fprintf(fp, "]\n"); - } if (long_desc && print_state->long_desc) { fprintf(fp, "%*s", 8, "["); wordwrap(fp, long_desc, 8, pager_get_columns(), 0); fprintf(fp, "]\n"); + } else if (desc && print_state->desc) { + fprintf(fp, "%*s", 8, "["); + wordwrap(fp, desc, 8, pager_get_columns(), 0); + fprintf(fp, "]\n"); } if (expr && print_state->detailed) { fprintf(fp, "%*s", 8, "["); @@ -395,17 +392,16 @@ static void json_print_event(void *ps, const char *pmu_name, const char *topic, deprecated ? "1" : "0"); need_sep = true; } - if (desc) { - fix_escape_fprintf(fp, &buf, "%s\t\"BriefDescription\": \"%S\"", - need_sep ? ",\n" : "", - desc); - need_sep = true; - } if (long_desc) { fix_escape_fprintf(fp, &buf, "%s\t\"PublicDescription\": \"%S\"", need_sep ? ",\n" : "", long_desc); need_sep = true; + } else if (desc) { + fix_escape_fprintf(fp, &buf, "%s\t\"BriefDescription\": \"%S\"", + need_sep ? ",\n" : "", + desc); + need_sep = true; } if (encoding_desc) { fix_escape_fprintf(fp, &buf, "%s\t\"Encoding\": \"%S\"", @@ -491,6 +487,7 @@ int cmd_list(int argc, const char **argv) int i, ret = 0; struct print_state default_ps = { .fp = stdout, + .desc = true, }; struct print_state json_ps = { .fp = stdout, @@ -563,7 +560,6 @@ int cmd_list(int argc, const char **argv) }; ps = &json_ps; } else { - default_ps.desc = !default_ps.long_desc; default_ps.last_topic = strdup(""); assert(default_ps.last_topic); default_ps.visited_metrics = strlist__new(NULL, NULL); -- 2.43.0