linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Yang Jihong <yangjihong1@huawei.com>
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: Tue, 31 Oct 2023 12:42:12 -0300	[thread overview]
Message-ID: <ZUEgVDlBQjFQB2W/@kernel.org> (raw)
In-Reply-To: <20231031080823.1418025-1-yangjihong1@huawei.com>

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},

  reply	other threads:[~2023-10-31 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31  8:08 [PATCH] perf debug: List available options when no variable is specified Yang Jihong
2023-10-31 15:42 ` Arnaldo Carvalho de Melo [this message]
2023-11-01  6:35   ` Yang Jihong

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=ZUEgVDlBQjFQB2W/@kernel.org \
    --to=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 \
    --cc=yangjihong1@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).