Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp332362rdb; Tue, 31 Oct 2023 08:42:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcq1AdSvq8ztbkWu7QaH6zXh5mYNNYDmA8uYfMEU62TKW73cimv9F8mXv9wKbkZzn76W/g X-Received: by 2002:a05:6a00:148a:b0:68f:ce6a:8685 with SMTP id v10-20020a056a00148a00b0068fce6a8685mr4263801pfu.14.1698766950917; Tue, 31 Oct 2023 08:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698766950; cv=none; d=google.com; s=arc-20160816; b=Es6DqAXmavWExE9w7SIcr/+v/oau53ZfIu9zQBKKTECLIFys6ZUtwn2F08gZnlszD5 SzSdLif6ayuNk4h4lqra2vo04PVHvz2Yis2+pHjwxtTyOwExxl5dQPdf80wPNPDyfotp vw68qLYxDcW/SUMg8WQ76zGEeAyND7nIUaW47vixaXfXvold7fSjPTdNwYKXtN7IwO1G CeHpxvxSTQ0ncza8xOVWndklosZYnPtAtjDqjc7amnLGKwsP5RznOY0zxMyC5oCaQjcu TE1yYc3QgT3H+yWFu0VPuF/Z5oJy5R+5PiFMYjo7aauUEpUiDf6tSCgV2Ub7IY+zO20i mmyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lJVo1EWJLZSDXv2szBJS972cwNBl3+uzrdIyZuOri98=; fh=ONJLBIsP4/DUqk+5sRy0C2tKk83cVx+im8Ibr9fm8RI=; b=w31e0YGtZ4EBR3g5ekRH88Wmx3VK1qMD2F6HDaCO020qRycZBnciIwjdSdiuFg0zZR aif8aDYZQEW5yKmRdwgcyDV3H+aKXFjnIcouN6aUtEMGY4Tgif8nM2NtHrhBcul/kiKJ rrOeHiZSFKDbDFX+yG66smGkor3e0tOkpufTHsc82bSMs9aqSGldpOB0NQihivttqICn LNAI3cdQoH5DbkdYbLEI2UntLkSgBYA9/kQcZU+9Tf/u0ILux7kM1oKua9MWq1tzWMNK IIJV+z9Npe2/oEIgBVAcn18lzA6rptt6oe5zvT/z5GfnIBFBA6oj7FuaCzhH2sO30ObW PgRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXnFJTIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j6-20020a056a00234600b006c1222cac30si1146481pfj.193.2023.10.31.08.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 08:42:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXnFJTIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8B275802F560; Tue, 31 Oct 2023 08:42:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345087AbjJaPmS (ORCPT + 99 others); Tue, 31 Oct 2023 11:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345048AbjJaPmR (ORCPT ); Tue, 31 Oct 2023 11:42:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3E2D8F for ; Tue, 31 Oct 2023 08:42:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A384C433C8; Tue, 31 Oct 2023 15:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698766935; bh=Dw8ImV/4ZAJzS87ziXlkmmx+cmvVvi27xsx4oc2kmrk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LXnFJTIh2x0y83gcmvEuK8CV8TjQKH41UVhXf27AvAwsI5iNQYERacAaa+GPM8JOY GRXniM8O+WY4+aG2cXLYoDT4VRAPAk1gYW27oUbIg6AA40ahgYK0lev6cX+JQxusnI BU1ZuftgtsO+vPlMasr7wsdrfzk4D38XybhlBNg9fJltLH9/Lw7+7kqnWxpbQ3a9uP Nt5di+l2Wv7DX0qZXDpudwQOQMQSILEAtedOECu21mIj0KBj0EC6xQ+OaP90aJaTQS QFrRPvmd6Hj9Dw+7GpS/WRCSNPYKNDY+VKA3kQYkVWkCpYtSEFisEcpk43jOTfnQd3 2KOUjrItefzeA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 58E314035D; Tue, 31 Oct 2023 12:42:12 -0300 (-03) Date: Tue, 31 Oct 2023 12:42:12 -0300 From: Arnaldo Carvalho de Melo To: Yang Jihong Cc: peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf debug: List available options when no variable is specified Message-ID: References: <20231031080823.1418025-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231031080823.1418025-1-yangjihong1@huawei.com> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 08:42:28 -0700 (PDT) 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. - Arnaldo > static struct sublevel_option debug_opts[] = { > { .name = "verbose", .value_ptr = &verbose }, > { .name = "ordered-events", .value_ptr = &debug_ordered_events},