From: Yang Jihong <yangjihong1@huawei.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
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
Date: Wed, 1 Nov 2023 14:35:55 +0800 [thread overview]
Message-ID: <7cd2db58-03ad-4424-94a7-712d03c4adb0@huawei.com> (raw)
In-Reply-To: <ZUEgVDlBQjFQB2W/@kernel.org>
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
prev parent reply other threads:[~2023-11-01 6:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 8:08 Yang Jihong
2023-10-31 15:42 ` Arnaldo Carvalho de Melo
2023-11-01 6:35 ` Yang Jihong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7cd2db58-03ad-4424-94a7-712d03c4adb0@huawei.com \
--to=yangjihong1@huawei.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®