Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp720180rdb; Tue, 31 Oct 2023 23:48:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5Jg6/XOFOfsTVuXgT+ULB71OwqR2DV6CZIR25NtIj7qQZE8iD77mBONhzpoN6uvumsY78 X-Received: by 2002:a05:6a21:35c2:b0:181:219f:4a76 with SMTP id ba2-20020a056a2135c200b00181219f4a76mr2855964pzc.38.1698821296774; Tue, 31 Oct 2023 23:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698821296; cv=none; d=google.com; s=arc-20160816; b=if1MXKfWMc/kxZDUQJX+NfPZuEDmCDx5k/P7bH2S6BCPKJxkEZ10Wks/V/M6LElao1 u/HxEY3XxqAVpmTkI+57x3w7l3RMeqzNwDcMkM/jaKCYatHzcdBr80wROylsRijULfF+ hR2rqmpHhNjDHvNZqz7+Wtn5vvUIYiJr6K//rZQJ2WUFk5H/R7PBO/nUQyJbqp1g5EyW 4Gv/fuy/PzWxuL1nndKDfRrQBol2Ck/Ikl2MLmjPtb4Ai+evYeDWR4C3GD7yhao+M13Y S2ekIToykg3OrSBHD0n833Paj2N3ZzMKDDnPkuUTIRG8FCRVpbR9azqKKYz/3n7yFswS YO4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=v0oj8BrfumLcdmBrd7QImOcIKrqrCUzvWNl5z9UBVOs=; fh=JXx1mv1fB650HoTkc5GIgpDQ5Ey550GcDyaNZ/s6bYc=; b=iDqYXaP+4mB6pSMaBsSHAc6zZes22Ostwg+LzL9ypw61oXbmUSKegAhofHS2uT1wgS MXF96hJg3iaziCnlY+gfYQhXR2P921jgaMxPnaAC35LvKWnepdAWAtxt9nHO406APFZZ t4dz/MOP6iKTp4GW3ZZ4QKI02jFpeRQawZsjtjXV/5p9Dq+/YuYDgdMOd/E9qcTIDMgx 3inuBg0pEC92NH4+RGCO5tgNFH456tU7NDYqfc5idOWnaAzBCkRHoHDZDpEX4ERRvW7c QdEqbsSH3c33IsaKT6ohQ3V/TVnffDuriHph0RISyQVXHTUCH556z5zxmgZFrBGN8XSb qQbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id na3-20020a17090b4c0300b0027b3755185dsi205973pjb.99.2023.10.31.23.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 23:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 362AF8022B7C; Tue, 31 Oct 2023 23:48:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345185AbjKAGsF (ORCPT + 99 others); Wed, 1 Nov 2023 02:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231597AbjKAGsE (ORCPT ); Wed, 1 Nov 2023 02:48:04 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81F7D98; Tue, 31 Oct 2023 23:48:00 -0700 (PDT) Received: from kwepemm000003.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SKyCB5ntszPnly; Wed, 1 Nov 2023 14:43:50 +0800 (CST) Received: from ubuntu2204.huawei.com (10.67.174.22) by kwepemm000003.china.huawei.com (7.193.23.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 1 Nov 2023 14:47:56 +0800 From: Yang Jihong To: , , , , , , , , , , CC: Subject: [PATCH v2] perf debug: List available options when no variable is specified Date: Wed, 1 Nov 2023 06:45:43 +0000 Message-ID: <20231101064543.1481957-1-yangjihong1@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000003.china.huawei.com (7.193.23.66) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 31 Oct 2023 23:48:14 -0700 (PDT) Minor help message improvement for `perf --debug` Before: # perf --debug No variable specified for --debug. Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS] After: # perf --debug No variable specified for --debug, available options: verbose,ordered-events,stderr,data-convert,perf-event-open Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS] Suggested-by: Arnaldo Carvalho de Melo Signed-off-by: Yang Jihong --- Changes since v1: - Provide helper to iterate debug_opts and print name instead of adding a new variable. tools/perf/perf.c | 6 +++++- tools/perf/util/debug.c | 13 +++++++++++++ tools/perf/util/debug.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/perf/perf.c b/tools/perf/perf.c index d3fc8090413c..f29c3ef818a3 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -279,7 +279,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) exit(0); } else if (!strcmp(cmd, "--debug")) { if (*argc < 2) { - fprintf(stderr, "No variable specified for --debug.\n"); + fprintf(stderr, + "No variable specified for --debug, available options: "); + perf_debug_fprint_options(stderr); + fprintf(stderr, "\n"); + usage(perf_usage_string); } if (perf_debug_option((*argv)[1])) diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 88378c4c5dd9..a014e6198d41 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -246,6 +246,19 @@ int perf_debug_option(const char *str) return 0; } +void perf_debug_fprint_options(FILE *file) +{ + struct sublevel_option *opt = debug_opts; + + if (!file) + return; + + while (opt->name) { + fprintf(file, "%s%s", opt == debug_opts ? "" : ",", opt->name); + opt++; + } +} + int perf_quiet_option(void) { struct sublevel_option *opt = &debug_opts[0]; diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index f99468a7f681..17294834cdb4 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -77,6 +77,7 @@ int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5) int veprintf(int level, int var, const char *fmt, va_list args); int perf_debug_option(const char *str); +void perf_debug_fprint_options(FILE *file); void debug_set_file(FILE *file); void debug_set_display_time(bool set); void perf_debug_setup(void); -- 2.34.1