Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp716628rdb; Tue, 31 Oct 2023 23:36:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGSePNYN7nRS6VD0DFjcFEfx1//ITC39rVhwdAxjOzC3mIe7PH7FUQ8rhHbpb/YmSo6DAX X-Received: by 2002:a17:902:bd05:b0:1ca:dee1:4d1a with SMTP id p5-20020a170902bd0500b001cadee14d1amr11739575pls.25.1698820615028; Tue, 31 Oct 2023 23:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698820615; cv=none; d=google.com; s=arc-20160816; b=vZFCKusy+4Uy0Ucy2xW4PrNGe1GsGlEqFExO65yuVnZd+9mmC5dZacqfEZXi7EGhgh VTuF6oVyJtDBLM5hxROYNYivSELmkjjwFZU+2G7/COY90zMqFEhATQ5UA6GRT5+OtkFK k/3PX4okdnfYOiKpmHwujIT49Gl2WFf+X+yqFIzLauDkhd19JbBZLG7GYbhkpKbq4x0U 2v0RmMV+i5J5AbUc+qVu1XWR6cCL9WE5XU1jEsXcMj9m/e+R5r7IfMHiUGsvyNsuaym3 0Kf9+Tj5P5O3HBtTBwBjzJe1lybbPzjZvTremOVMQtWpVHXpz63YKq0L8a5Hx0O6urnt k/aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=dJzNZXWr/0uQhOyU0JBJOyzJ98pWGer9uiHyuaNtX+U=; fh=a7XCc2KPGC5VhMcGv5ncm2JS0IzSffkzr8zX9xZupSE=; b=RnG5RwCKrlmaGqwkOi2vx5jAUgPTvlbKAb5c3pQIU/3fM+x0zWJ/jOSQ+K8FFqqf9e R2glJr//RBTXSGhfydqC+20vbsGaDwNA8w8GHD5peK9x0dcZyv2P4GD/yMBtYUQa+/bQ BkVAUwussrH764ZyKQqG1HKi+mKAdZrs7K5hJe2CHIzIFnegkTMDPXU78h42eQF5uX8X OnWL0h7MKFkaN0RvKdjobUqwpvkz7k+8myeH80ING7R1+0p/bUNWk9VXRSfdSFvGg30p XC3StBdTd3gjdrpqC/o7vW/7n+DKifbnc5fhweb+yBMbAktLdR1QCr1YC66aR8qHwiY+ X+bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b5-20020a170902d40500b001c6182d9fdasi2216647ple.326.2023.10.31.23.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 23:36:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id A355780B79EF; Tue, 31 Oct 2023 23:36:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345185AbjKAGgN (ORCPT + 99 others); Wed, 1 Nov 2023 02:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345167AbjKAGgL (ORCPT ); Wed, 1 Nov 2023 02:36:11 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1629C199; Tue, 31 Oct 2023 23:35:59 -0700 (PDT) Received: from kwepemm000003.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SKxyb5f1Gz1P7jD; Wed, 1 Nov 2023 14:32:55 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) 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:35:56 +0800 Subject: Re: [PATCH] perf debug: List available options when no variable is specified To: Arnaldo Carvalho de Melo CC: , , , , , , , , , References: <20231031080823.1418025-1-yangjihong1@huawei.com> From: Yang Jihong Message-ID: <7cd2db58-03ad-4424-94a7-712d03c4adb0@huawei.com> Date: Wed, 1 Nov 2023 14:35:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm000003.china.huawei.com (7.193.23.66) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-3.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 23:36:52 -0700 (PDT) Hello, On 2023/10/31 23:42, Arnaldo Carvalho de Melo wrote: > Em Tue, Oct 31, 2023 at 08:08:23AM +0000, Yang Jihong escreveu: >> Before: > >> # perf --debug >> No variable specified for --debug. > >> After: > >> # perf --debug >> No variable specified for --debug, available options: verbose,ordered-events,stderr,data-convert,perf-event-open. > > Looks useful, but the implementation can be different to reduce > maintainership costs, see below: > >> +++ b/tools/perf/perf.c >> @@ -279,7 +279,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) >> } 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: %s.\n", >> + perf_debug_options_string); >> usage(perf_usage_string); > >> +++ b/tools/perf/util/debug.c >> @@ -215,6 +215,9 @@ void trace_event(union perf_event *event) >> trace_event_printer, event); >> } >> >> +const char perf_debug_options_string[] = >> + "verbose,ordered-events,stderr,data-convert,perf-event-open"; > > Instead of adding a new variable that has to be kept in sync with > debug_opts[], you could provide a function that iterates debug_opts, > printing its options names, then use that function on perf.c handle_options. Thanks for the advice. OK, will send a v2 patch according to this scheme. Thanks, Yang