* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
[not found] <1444282190-13605-1-git-send-email-sriram.r@nokia.com>
@ 2015-10-13 14:57 ` Arnaldo Carvalho de Melo
2015-10-13 15:24 ` Ramkumar Ramachandra
0 siblings, 1 reply; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-10-13 14:57 UTC (permalink / raw)
To: Ramkumar Ramachandra, Yunlong Song
Cc: Sriram Raghunathan, a.p.zijlstra, Linux Kernel Mailing List
Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:
> Minor change, adding --list-opts to usage string. So that it is
> visible to the user on running perf --help. or just perf
> from command line.
Ramkumar, Yunlong, are you ok with this?
- Arnaldo
> Signed-off-by: Sriram Raghunathan <sriram.r@nokia.com>
> ---
> tools/perf/perf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 07dbff5..92b5007 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -19,7 +19,7 @@
> #include <pthread.h>
>
> const char perf_usage_string[] =
> - "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
> + "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
>
> const char perf_more_info_string[] =
> "See 'perf help COMMAND' for more information on a specific command.";
> --
> 2.6.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
2015-10-13 14:57 ` [PATCH 1/1] perf:Adding --list-opts to usage string Arnaldo Carvalho de Melo
@ 2015-10-13 15:24 ` Ramkumar Ramachandra
2015-10-14 2:29 ` Yunlong Song
0 siblings, 1 reply; 18+ messages in thread
From: Ramkumar Ramachandra @ 2015-10-13 15:24 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Yunlong Song, Sriram Raghunathan, Peter Zijlstra,
Linux Kernel Mailing List
Arnaldo Carvalho de Melo wrote:
> Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:
>> Minor change, adding --list-opts to usage string. So that it is
>> visible to the user on running perf --help. or just perf
>> from command line.
>
>
> Ramkumar, Yunlong, are you ok with this?
Not sure I understand the motivation, but I suppose it can't hurt to
show this detail?
Ram
>> Signed-off-by: Sriram Raghunathan <sriram.r@nokia.com>
>> ---
>> tools/perf/perf.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
>> index 07dbff5..92b5007 100644
>> --- a/tools/perf/perf.c
>> +++ b/tools/perf/perf.c
>> @@ -19,7 +19,7 @@
>> #include <pthread.h>
>>
>> const char perf_usage_string[] =
>> - "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
>> + "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
>>
>> const char perf_more_info_string[] =
>> "See 'perf help COMMAND' for more information on a specific command.";
>> --
>> 2.6.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
2015-10-13 15:24 ` Ramkumar Ramachandra
@ 2015-10-14 2:29 ` Yunlong Song
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 18+ messages in thread
From: Yunlong Song @ 2015-10-14 2:29 UTC (permalink / raw)
To: Ramkumar Ramachandra, Arnaldo Carvalho de Melo
Cc: Sriram Raghunathan, Peter Zijlstra, Linux Kernel Mailing List, wangnan0
On 2015/10/13 23:24, Ramkumar Ramachandra wrote:
> Arnaldo Carvalho de Melo wrote:
>> Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:
>>> Minor change, adding --list-opts to usage string. So that it is
>>> visible to the user on running perf --help. or just perf
>>> from command line.
>>
>>
>> Ramkumar, Yunlong, are you ok with this?
>
> Not sure I understand the motivation, but I suppose it can't hurt to
> show this detail?
>
> Ram
Agree with Ramkumar, --list-opts is redundant due to the existing [OPTIONS] in
the perf_usage_string[].
>>>
>>> const char perf_usage_string[] =
>>> - "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
>>> + "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
--
Thanks,
Yunlong Song
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
2015-10-14 2:29 ` Yunlong Song
@ 2015-10-14 3:10 ` Arnaldo Carvalho de Melo
2015-10-14 3:42 ` Namhyung Kim
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-10-14 3:10 UTC (permalink / raw)
To: Yunlong Song
Cc: Ramkumar Ramachandra, Sriram Raghunathan, Peter Zijlstra,
Adrian Hunter, Jiri Olsa, Namhyung Kim, David Ahern,
Linux Kernel Mailing List, Wang Nan, Ingo Molnar
Em Wed, Oct 14, 2015 at 10:29:05AM +0800, Yunlong Song escreveu:
> On 2015/10/13 23:24, Ramkumar Ramachandra wrote:
> > Arnaldo Carvalho de Melo wrote:
> >> Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:
> >>> Minor change, adding --list-opts to usage string. So that it is
> >>> visible to the user on running perf --help. or just perf
> >>> from command line.
> >>
> >> Ramkumar, Yunlong, are you ok with this?
> > Not sure I understand the motivation, but I suppose it can't hurt to
> > show this detail?
> Agree with Ramkumar, --list-opts is redundant due to the existing [OPTIONS] in
> the perf_usage_string[].
I see, thinking about it now, it seems that this is because 'perf -h'
behaves differently from other tools, i.e.:
$ perf -h
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
<SNIP>
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace strace inspired tool
probe Define new dynamic tracepoints
See 'perf help COMMAND' for more information on a specific command.
--------------------------
While:
$ perf stat -h
usage: perf stat [<options>] [<command>]
-T, --transaction hardware transaction statistics
-e, --event <event> event selector. use 'perf list' to list available events
--filter <filter>
event filter
-i, --no-inherit child tasks do not inherit counters
-p, --pid <pid> stat events on existing process id
-t, --tid <tid> stat events on existing thread id
-a, --all-cpus system-wide collection from all CPUs
<SNIP>
-I, --interval-print <n>
print counts at regular interval in ms (>= 10)
--per-socket aggregate counts per processor socket
--per-core aggregate counts per physical processor core
--per-thread aggregate counts per thread
-D, --delay <n> ms to wait before starting measurement after program start
--------------------------
One doesn't show what options can be used, the other does, so there is
an inconsistency, this and the fact that 'perf -h' outputs to stdout,
'perf stat -h' and the other builtins output to stderr. I think all
should output to stdout, just like 'ls --help', what do you think?
- Arnaldo
> >>>
> >>> const char perf_usage_string[] =
> >>> - "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
> >>> + "perf [--version] [--help] [--list-opts] [OPTIONS] COMMAND [ARGS]";
>
> --
> Thanks,
> Yunlong Song
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
@ 2015-10-14 3:42 ` Namhyung Kim
2015-10-14 13:31 ` Yunlong Song
` (2 subsequent siblings)
3 siblings, 0 replies; 18+ messages in thread
From: Namhyung Kim @ 2015-10-14 3:42 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Yunlong Song, Ramkumar Ramachandra, Sriram Raghunathan,
Peter Zijlstra, Adrian Hunter, Jiri Olsa, David Ahern,
Linux Kernel Mailing List, Wang Nan, Ingo Molnar
Hi Arnaldo,
On Wed, Oct 14, 2015 at 12:10 PM, Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
> Em Wed, Oct 14, 2015 at 10:29:05AM +0800, Yunlong Song escreveu:
>> On 2015/10/13 23:24, Ramkumar Ramachandra wrote:
>> > Arnaldo Carvalho de Melo wrote:
>> >> Em Thu, Oct 08, 2015 at 10:59:50AM +0530, Sriram Raghunathan escreveu:
>> >>> Minor change, adding --list-opts to usage string. So that it is
>> >>> visible to the user on running perf --help. or just perf
>> >>> from command line.
>> >>
>> >> Ramkumar, Yunlong, are you ok with this?
>
>> > Not sure I understand the motivation, but I suppose it can't hurt to
>> > show this detail?
>
>> Agree with Ramkumar, --list-opts is redundant due to the existing [OPTIONS] in
>> the perf_usage_string[].
AFAIK the --list-cmds and --list-opts options are just for completion
scripts, not for human. I don't think we need to expose them to
normal users.
>
> I see, thinking about it now, it seems that this is because 'perf -h'
> behaves differently from other tools, i.e.:
>
> $ perf -h
>
> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
>
> The most commonly used perf commands are:
One nit, these are not commonly used commands, but all commands. :)
Anyway it'd be better to add option descriptions here for consistency.
> annotate Read perf.data (created by perf record) and display annotated code
> archive Create archive with object files with build-ids found in perf.data file
> bench General framework for benchmark suites
> buildid-cache Manage build-id cache.
> buildid-list List the buildids in a perf.data file
> <SNIP>
> test Runs sanity tests.
> timechart Tool to visualize total system behavior during a workload
> top System profiling tool.
> trace strace inspired tool
> probe Define new dynamic tracepoints
>
> See 'perf help COMMAND' for more information on a specific command.
>
> --------------------------
>
> While:
>
> $ perf stat -h
>
> usage: perf stat [<options>] [<command>]
>
> -T, --transaction hardware transaction statistics
> -e, --event <event> event selector. use 'perf list' to list available events
> --filter <filter>
> event filter
> -i, --no-inherit child tasks do not inherit counters
> -p, --pid <pid> stat events on existing process id
> -t, --tid <tid> stat events on existing thread id
> -a, --all-cpus system-wide collection from all CPUs
> <SNIP>
> -I, --interval-print <n>
> print counts at regular interval in ms (>= 10)
> --per-socket aggregate counts per processor socket
> --per-core aggregate counts per physical processor core
> --per-thread aggregate counts per thread
> -D, --delay <n> ms to wait before starting measurement after program start
>
> --------------------------
>
> One doesn't show what options can be used, the other does, so there is
> an inconsistency, this and the fact that 'perf -h' outputs to stdout,
> 'perf stat -h' and the other builtins output to stderr. I think all
> should output to stdout, just like 'ls --help', what do you think?
I'm ok with changing to stdout.
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
2015-10-14 3:42 ` Namhyung Kim
@ 2015-10-14 13:31 ` Yunlong Song
[not found] ` <CA+JHD92p0QUJGrqKTMYD8FUKj5tS9MUV_njsvoFwaHhsQevn_Q@mail.gmail.com>
2015-10-14 13:44 ` [PATCH] perf help: Add options description to 'perf -h' Yunlong Song
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
3 siblings, 1 reply; 18+ messages in thread
From: Yunlong Song @ 2015-10-14 13:31 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ramkumar Ramachandra, Sriram Raghunathan, Peter Zijlstra,
Adrian Hunter, Jiri Olsa, Namhyung Kim, David Ahern,
Linux Kernel Mailing List, Wang Nan, Ingo Molnar
On 2015/10/14 11:10, Arnaldo Carvalho de Melo wrote:
> One doesn't show what options can be used, the other does, so there is
> an inconsistency, this and the fact that 'perf -h' outputs to stdout,
> 'perf stat -h' and the other builtins output to stderr. I think all
> should output to stdout, just like 'ls --help', what do you think?
>
> - Arnaldo
>
I think the reason that options do not show in 'perf -h' but show in
other builtins is not the different use of stdout or stderr. I will
send a patch to fix this instead.
--
Thanks,
Yunlong Song
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] perf help: Add options description to 'perf -h'
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
2015-10-14 3:42 ` Namhyung Kim
2015-10-14 13:31 ` Yunlong Song
@ 2015-10-14 13:44 ` Yunlong Song
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
3 siblings, 0 replies; 18+ messages in thread
From: Yunlong Song @ 2015-10-14 13:44 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme
Cc: linux-kernel, wangnan0, namhyung, artagnon, sriram.r,
adrian.hunter, jolsa, dsahern
Add options description to 'perf -h' to make it consistent with other builtins
(e.g., 'perf stat -h').
Example:
Before this patch:
# perf -h
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
<SNIP>
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace strace inspired tool
probe Define new dynamic tracepoints
See 'perf help COMMAND' for more information on a specific command.
After this patch:
# perf -h
Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
--help help
--version version
--exec-path exec-path
--html-path html-path
--paginate paginate
--no-pager no-pager
--perf-dir perf-dir
--work-tree work-tree
--debugfs-dir debugfs-dir
--buildid-dir buildid-dir
--list-cmds list-cmds
--list-opts list-opts
--debug debug
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
<SNIP>
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace strace inspired tool
probe Define new dynamic tracepoints
See 'perf help COMMAND' for more information on a specific command.
As shown above, the options description really appears now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
tools/perf/builtin-help.c | 2 +-
tools/perf/builtin.h | 3 +++
tools/perf/perf.c | 12 ++++++++----
tools/perf/util/parse-options.c | 9 ++++++++-
tools/perf/util/parse-options.h | 3 +++
5 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 36486ea..5cb29fe 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -470,7 +470,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
}
if (!argv[0]) {
- printf("\n usage: %s\n\n", perf_usage_string);
+ usage_with_options_return(perf_usage, perf_options);
list_common_cmds_help();
printf("\n %s\n\n", perf_more_info_string);
return 0;
diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h
index 3688ad2..4439db0 100644
--- a/tools/perf/builtin.h
+++ b/tools/perf/builtin.h
@@ -3,9 +3,12 @@
#include "util/util.h"
#include "util/strbuf.h"
+#include "util/parse-options.h"
extern const char perf_usage_string[];
extern const char perf_more_info_string[];
+extern const char * const perf_usage[];
+extern struct option perf_options[];
extern void list_common_cmds_help(void);
extern const char *help_unknown_cmd(const char *cmd);
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 5437134..3bcaa10d 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -21,6 +21,10 @@
const char perf_usage_string[] =
"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+const char * const perf_usage[] = {
+ perf_usage_string,
+ NULL
+};
const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
@@ -127,7 +131,7 @@ static void commit_pager_choice(void)
}
}
-struct option options[] = {
+struct option perf_options[] = {
OPT_ARGUMENT("help", "help"),
OPT_ARGUMENT("version", "version"),
OPT_ARGUMENT("exec-path", "exec-path"),
@@ -261,8 +265,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
} else if (!strcmp(cmd, "--list-opts")) {
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(options)-1; i++) {
- struct option *p = options+i;
+ for (i = 0; i < ARRAY_SIZE(perf_options)-1; i++) {
+ struct option *p = perf_options+i;
printf("--%s ", p->long_name);
}
putchar('\n');
@@ -578,7 +582,7 @@ int main(int argc, const char **argv)
argv[0] += 2;
} else {
/* The user didn't specify a command; give them help */
- printf("\n usage: %s\n\n", perf_usage_string);
+ usage_with_options_return(perf_usage, perf_options);
list_common_cmds_help();
printf("\n %s\n\n", perf_more_info_string);
goto out;
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 9a38b05..0ebfa4d 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -648,7 +648,7 @@ int usage_with_options_internal(const char * const *usagestr,
if (!usagestr)
return PARSE_OPT_HELP;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
while (*usagestr) {
@@ -677,6 +677,13 @@ void usage_with_options(const char * const *usagestr,
exit(129);
}
+void usage_with_options_return(const char * const *usagestr,
+ const struct option *opts)
+{
+ exit_browser(false);
+ usage_with_options_internal(usagestr, opts, 0);
+}
+
int parse_options_usage(const char * const *usagestr,
const struct option *opts,
const char *optstr, bool short_opt)
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
index 367d8b8..8130f83 100644
--- a/tools/perf/util/parse-options.h
+++ b/tools/perf/util/parse-options.h
@@ -161,6 +161,9 @@ extern int parse_options_subcommand(int argc, const char **argv,
extern NORETURN void usage_with_options(const char * const *usagestr,
const struct option *options);
+extern void usage_with_options_return(const char * const *usagestr,
+ const struct option *options);
+
/*----- incremantal advanced APIs -----*/
enum {
--
1.8.5.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1/1] perf :redirection of usage strings to stdout
[not found] ` <CA+JHD92p0QUJGrqKTMYD8FUKj5tS9MUV_njsvoFwaHhsQevn_Q@mail.gmail.com>
@ 2015-10-14 17:10 ` Sriram Raghunathan
2015-10-15 7:22 ` Sriram Raghunathan
2015-10-15 7:11 ` [PATCH 1/1] perf:Adding --list-opts to usage string Yunlong Song
1 sibling, 1 reply; 18+ messages in thread
From: Sriram Raghunathan @ 2015-10-14 17:10 UTC (permalink / raw)
To: a.p.zijlstra, paulus, acme, yunlong.song
Cc: mingo, artagnon, hemant, jolsa, dsahern, sriram.r, linux-kernel
This patch is to redirect the usage/builtin help strings
to stdout rather than stderr. This is follows the patter
similar to that of some of the coreutils (ls, rm).
This patch originated from the discussion on a mail loop
about the inconsistency usage of stdout/stderr usage.
Tested the piece of code below with
# perf stat -h > /tmp/foo 2>> /tmp/bar
# perf --help > /tmp/foo 2>&1 /tmp/bar
Signed-off-by: Sriram Raghunathan <sriram.r@nokia.com>
---
tools/perf/util/parse-options.c | 54 ++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 01626be..c81b2e3 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -563,9 +563,9 @@ static void print_option_help(const struct option *opts, int full)
int pad;
if (opts->type == OPTION_GROUP) {
- fputc('\n', stderr);
+ fputc('\n', stdout);
if (*opts->help)
- fprintf(stderr, "%s\n", opts->help);
+ fprintf(stdout, "%s\n", opts->help);
return;
}
if (!full && (opts->flags & PARSE_OPT_HIDDEN))
@@ -573,16 +573,16 @@ static void print_option_help(const struct option *opts, int full)
if (opts->flags & PARSE_OPT_DISABLED)
return;
- pos = fprintf(stderr, " ");
+ pos = fprintf(stdout, " ");
if (opts->short_name)
- pos += fprintf(stderr, "-%c", opts->short_name);
+ pos += fprintf(stdout, "-%c", opts->short_name);
else
- pos += fprintf(stderr, " ");
+ pos += fprintf(stdout, " ");
if (opts->long_name && opts->short_name)
- pos += fprintf(stderr, ", ");
+ pos += fprintf(stdout, ", ");
if (opts->long_name)
- pos += fprintf(stderr, "--%s", opts->long_name);
+ pos += fprintf(stdout, "--%s", opts->long_name);
switch (opts->type) {
case OPTION_ARGUMENT:
@@ -593,11 +593,11 @@ static void print_option_help(const struct option *opts, int full)
case OPTION_UINTEGER:
if (opts->flags & PARSE_OPT_OPTARG)
if (opts->long_name)
- pos += fprintf(stderr, "[=<n>]");
+ pos += fprintf(stdout, "[=<n>]");
else
- pos += fprintf(stderr, "[<n>]");
+ pos += fprintf(stdout, "[<n>]");
else
- pos += fprintf(stderr, " <n>");
+ pos += fprintf(stdout, " <n>");
break;
case OPTION_CALLBACK:
if (opts->flags & PARSE_OPT_NOARG)
@@ -607,19 +607,19 @@ static void print_option_help(const struct option *opts, int full)
if (opts->argh) {
if (opts->flags & PARSE_OPT_OPTARG)
if (opts->long_name)
- pos += fprintf(stderr, "[=<%s>]", opts->argh);
+ pos += fprintf(stdout, "[=<%s>]", opts->argh);
else
- pos += fprintf(stderr, "[<%s>]", opts->argh);
+ pos += fprintf(stdout, "[<%s>]", opts->argh);
else
- pos += fprintf(stderr, " <%s>", opts->argh);
+ pos += fprintf(stdout, " <%s>", opts->argh);
} else {
if (opts->flags & PARSE_OPT_OPTARG)
if (opts->long_name)
- pos += fprintf(stderr, "[=...]");
+ pos += fprintf(stdout, "[=...]");
else
- pos += fprintf(stderr, "[...]");
+ pos += fprintf(stdout, "[...]");
else
- pos += fprintf(stderr, " ...");
+ pos += fprintf(stdout, " ...");
}
break;
default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
@@ -636,10 +636,10 @@ static void print_option_help(const struct option *opts, int full)
if (pos <= USAGE_OPTS_WIDTH)
pad = USAGE_OPTS_WIDTH - pos;
else {
- fputc('\n', stderr);
+ fputc('\n', stdout);
pad = USAGE_OPTS_WIDTH;
}
- fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+ fprintf(stdout, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
}
int usage_with_options_internal(const char * const *usagestr,
@@ -648,23 +648,23 @@ int usage_with_options_internal(const char * const *usagestr,
if (!usagestr)
return PARSE_OPT_HELP;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stdout, "\n usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
- fprintf(stderr, " or: %s\n", *usagestr++);
+ fprintf(stdout, " or: %s\n", *usagestr++);
while (*usagestr) {
- fprintf(stderr, "%s%s\n",
+ fprintf(stdout, "%s%s\n",
**usagestr ? " " : "",
*usagestr);
usagestr++;
}
if (opts->type != OPTION_GROUP)
- fputc('\n', stderr);
+ fputc('\n', stdout);
for ( ; opts->type != OPTION_END; opts++)
print_option_help(opts, full);
- fputc('\n', stderr);
+ fputc('\n', stdout);
return PARSE_OPT_HELP;
}
@@ -684,16 +684,16 @@ int parse_options_usage(const char * const *usagestr,
if (!usagestr)
goto opt;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stdout, "\n usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
- fprintf(stderr, " or: %s\n", *usagestr++);
+ fprintf(stdout, " or: %s\n", *usagestr++);
while (*usagestr) {
- fprintf(stderr, "%s%s\n",
+ fprintf(stdout, "%s%s\n",
**usagestr ? " " : "",
*usagestr);
usagestr++;
}
- fputc('\n', stderr);
+ fputc('\n', stdout);
opt:
for ( ; opts->type != OPTION_END; opts++) {
--
2.6.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf:Adding --list-opts to usage string
[not found] ` <CA+JHD92p0QUJGrqKTMYD8FUKj5tS9MUV_njsvoFwaHhsQevn_Q@mail.gmail.com>
2015-10-14 17:10 ` [PATCH 1/1] perf :redirection of usage strings to stdout Sriram Raghunathan
@ 2015-10-15 7:11 ` Yunlong Song
1 sibling, 0 replies; 18+ messages in thread
From: Yunlong Song @ 2015-10-15 7:11 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Sriram Raghunathan, Wang Nan, Ramkumar Ramachandra, Namhyung Kim,
Jiri Olsa, Ingo Molnar, Peter Zijlstra,
Linux Kernel Mailing List, David Ahern, Adrian Hunter,
Arnaldo Carvalho de Melo
On 2015/10/14 21:40, Arnaldo Carvalho de Melo wrote:
>
> Le 14 oct. 2015 10:33 AM, "Yunlong Song" <yunlong.song@huawei.com <mailto:yunlong.song@huawei.com>> a écrit :
>>
>> On 2015/10/14 11:10, Arnaldo Carvalho de Melo wrote:
>>
>> > One doesn't show what options can be used, the other does, so there is
>> > an inconsistency, this and the fact that 'perf -h' outputs to stdout,
>> > 'perf stat -h' and the other builtins output to stderr. I think all
>> > should output to stdout, just like 'ls --help', what do you think?
>> >
>> > - Arnaldo
>> >
>>
>> I think the reason that options do not show in 'perf -h' but show in
>> other builtins is not the different use of stdout or stderr. I will
>> send a patch to fix this instead.
>
> Sure, I mentioned two problems. The invonsistency in stdout/stderr usage has nothing to do with options being not showed in 'perf -h'. :-)
>>
Sorry, I understand now. I think it makes sense that the builtins use stderr everywhere
to show its usage info when the opts or cmds are incorrectly used. Usually, there is an
error description followed with the usage info, for example:
# ./perf stat -f
Error: unknown switch `f'
Usage: perf stat [<options>] [<command>]
-T, --transaction hardware transaction statistics
-e, --event <event> event selector. use 'perf list' to list available events
--filter <filter>
event filter
-i, --no-inherit child tasks do not inherit counters
<SNIP>
-I, --interval-print <n>
print counts at regular interval in ms (>= 10)
--per-socket aggregate counts per processor socket
--per-core aggregate counts per physical processor core
--per-thread aggregate counts per thread
-D, --delay <n> ms to wait before starting measurement after program start
As shown above, I think the error description and the usage info should output to the same
stderr area as it is now to be clear.
Thus I think it is better to make perf output its usage info to stderr instead of stdout for
consistency. I will resend patches to fix this.
--
Thanks,
Yunlong Song
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] perf :redirection of usage strings to stdout
2015-10-14 17:10 ` [PATCH 1/1] perf :redirection of usage strings to stdout Sriram Raghunathan
@ 2015-10-15 7:22 ` Sriram Raghunathan
0 siblings, 0 replies; 18+ messages in thread
From: Sriram Raghunathan @ 2015-10-15 7:22 UTC (permalink / raw)
To: Sriram Raghunathan, a.p.zijlstra, paulus, acme, yunlong.song
Cc: mingo, artagnon, hemant, jolsa, dsahern, linux-kernel
Sorry, I made a mistake please ignore this patch.
Sriram
On Wednesday 14 October 2015 10:40 PM, Sriram Raghunathan wrote:
> This patch is to redirect the usage/builtin help strings
> to stdout rather than stderr. This is follows the patter
> similar to that of some of the coreutils (ls, rm).
>
> This patch originated from the discussion on a mail loop
> about the inconsistency usage of stdout/stderr usage.
>
> Tested the piece of code below with
>
> # perf stat -h > /tmp/foo 2>> /tmp/bar
> # perf --help > /tmp/foo 2>&1 /tmp/bar
>
> Signed-off-by: Sriram Raghunathan <sriram.r@nokia.com>
> ---
> tools/perf/util/parse-options.c | 54 ++++++++++++++++++++---------------------
> 1 file changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
> index 01626be..c81b2e3 100644
> --- a/tools/perf/util/parse-options.c
> +++ b/tools/perf/util/parse-options.c
> @@ -563,9 +563,9 @@ static void print_option_help(const struct option *opts, int full)
> int pad;
>
> if (opts->type == OPTION_GROUP) {
> - fputc('\n', stderr);
> + fputc('\n', stdout);
> if (*opts->help)
> - fprintf(stderr, "%s\n", opts->help);
> + fprintf(stdout, "%s\n", opts->help);
> return;
> }
> if (!full && (opts->flags & PARSE_OPT_HIDDEN))
> @@ -573,16 +573,16 @@ static void print_option_help(const struct option *opts, int full)
> if (opts->flags & PARSE_OPT_DISABLED)
> return;
>
> - pos = fprintf(stderr, " ");
> + pos = fprintf(stdout, " ");
> if (opts->short_name)
> - pos += fprintf(stderr, "-%c", opts->short_name);
> + pos += fprintf(stdout, "-%c", opts->short_name);
> else
> - pos += fprintf(stderr, " ");
> + pos += fprintf(stdout, " ");
>
> if (opts->long_name && opts->short_name)
> - pos += fprintf(stderr, ", ");
> + pos += fprintf(stdout, ", ");
> if (opts->long_name)
> - pos += fprintf(stderr, "--%s", opts->long_name);
> + pos += fprintf(stdout, "--%s", opts->long_name);
>
> switch (opts->type) {
> case OPTION_ARGUMENT:
> @@ -593,11 +593,11 @@ static void print_option_help(const struct option *opts, int full)
> case OPTION_UINTEGER:
> if (opts->flags & PARSE_OPT_OPTARG)
> if (opts->long_name)
> - pos += fprintf(stderr, "[=<n>]");
> + pos += fprintf(stdout, "[=<n>]");
> else
> - pos += fprintf(stderr, "[<n>]");
> + pos += fprintf(stdout, "[<n>]");
> else
> - pos += fprintf(stderr, " <n>");
> + pos += fprintf(stdout, " <n>");
> break;
> case OPTION_CALLBACK:
> if (opts->flags & PARSE_OPT_NOARG)
> @@ -607,19 +607,19 @@ static void print_option_help(const struct option *opts, int full)
> if (opts->argh) {
> if (opts->flags & PARSE_OPT_OPTARG)
> if (opts->long_name)
> - pos += fprintf(stderr, "[=<%s>]", opts->argh);
> + pos += fprintf(stdout, "[=<%s>]", opts->argh);
> else
> - pos += fprintf(stderr, "[<%s>]", opts->argh);
> + pos += fprintf(stdout, "[<%s>]", opts->argh);
> else
> - pos += fprintf(stderr, " <%s>", opts->argh);
> + pos += fprintf(stdout, " <%s>", opts->argh);
> } else {
> if (opts->flags & PARSE_OPT_OPTARG)
> if (opts->long_name)
> - pos += fprintf(stderr, "[=...]");
> + pos += fprintf(stdout, "[=...]");
> else
> - pos += fprintf(stderr, "[...]");
> + pos += fprintf(stdout, "[...]");
> else
> - pos += fprintf(stderr, " ...");
> + pos += fprintf(stdout, " ...");
> }
> break;
> default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
> @@ -636,10 +636,10 @@ static void print_option_help(const struct option *opts, int full)
> if (pos <= USAGE_OPTS_WIDTH)
> pad = USAGE_OPTS_WIDTH - pos;
> else {
> - fputc('\n', stderr);
> + fputc('\n', stdout);
> pad = USAGE_OPTS_WIDTH;
> }
> - fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
> + fprintf(stdout, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
> }
>
> int usage_with_options_internal(const char * const *usagestr,
> @@ -648,23 +648,23 @@ int usage_with_options_internal(const char * const *usagestr,
> if (!usagestr)
> return PARSE_OPT_HELP;
>
> - fprintf(stderr, "\n usage: %s\n", *usagestr++);
> + fprintf(stdout, "\n usage: %s\n", *usagestr++);
> while (*usagestr && **usagestr)
> - fprintf(stderr, " or: %s\n", *usagestr++);
> + fprintf(stdout, " or: %s\n", *usagestr++);
> while (*usagestr) {
> - fprintf(stderr, "%s%s\n",
> + fprintf(stdout, "%s%s\n",
> **usagestr ? " " : "",
> *usagestr);
> usagestr++;
> }
>
> if (opts->type != OPTION_GROUP)
> - fputc('\n', stderr);
> + fputc('\n', stdout);
>
> for ( ; opts->type != OPTION_END; opts++)
> print_option_help(opts, full);
>
> - fputc('\n', stderr);
> + fputc('\n', stdout);
>
> return PARSE_OPT_HELP;
> }
> @@ -684,16 +684,16 @@ int parse_options_usage(const char * const *usagestr,
> if (!usagestr)
> goto opt;
>
> - fprintf(stderr, "\n usage: %s\n", *usagestr++);
> + fprintf(stdout, "\n usage: %s\n", *usagestr++);
> while (*usagestr && **usagestr)
> - fprintf(stderr, " or: %s\n", *usagestr++);
> + fprintf(stdout, " or: %s\n", *usagestr++);
> while (*usagestr) {
> - fprintf(stderr, "%s%s\n",
> + fprintf(stdout, "%s%s\n",
> **usagestr ? " " : "",
> *usagestr);
> usagestr++;
> }
> - fputc('\n', stderr);
> + fputc('\n', stdout);
>
> opt:
> for ( ; opts->type != OPTION_END; opts++) {
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2015-10-14 13:44 ` [PATCH] perf help: Add options description to 'perf -h' Yunlong Song
@ 2015-10-15 7:39 ` Yunlong Song
2015-10-15 7:39 ` [PATCH v2 1/3] perf help: Add options description to 'perf -h' Yunlong Song
` (2 more replies)
3 siblings, 3 replies; 18+ messages in thread
From: Yunlong Song @ 2015-10-15 7:39 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme
Cc: linux-kernel, wangnan0, namhyung, artagnon, sriram.r,
adrian.hunter, jolsa, dsahern
Hi,
Make some fixes to perf's help for consistency.
Yunlong Song (3):
perf help: Add options description to 'perf -h'
perf help: Change 'usage' to 'Usage' for consistency
perf help: Change the usage's stdout to stderr for consistency
tools/perf/builtin-help.c | 13 +++++++------
tools/perf/builtin.h | 3 +++
tools/perf/perf.c | 14 +++++++++-----
tools/perf/util/parse-options.c | 11 +++++++++--
tools/perf/util/parse-options.h | 3 +++
5 files changed, 31 insertions(+), 13 deletions(-)
--
1.8.5.2
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/3] perf help: Add options description to 'perf -h'
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
@ 2015-10-15 7:39 ` Yunlong Song
2015-10-19 15:29 ` Namhyung Kim
2015-10-15 7:39 ` [PATCH v2 2/3] perf help: Change 'usage' to 'Usage' for consistency Yunlong Song
2015-10-15 7:39 ` [PATCH v2 3/3] perf help: Change the usage's stdout to stderr " Yunlong Song
2 siblings, 1 reply; 18+ messages in thread
From: Yunlong Song @ 2015-10-15 7:39 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme
Cc: linux-kernel, wangnan0, namhyung, artagnon, sriram.r,
adrian.hunter, jolsa, dsahern
Add options description to 'perf -h' to make it consistent with other builtins
(e.g., 'perf stat -h').
Example:
Before this patch:
# perf -h
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
<SNIP>
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace strace inspired tool
probe Define new dynamic tracepoints
See 'perf help COMMAND' for more information on a specific command.
After this patch:
# perf -h
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
--help help
--version version
--exec-path exec-path
--html-path html-path
--paginate paginate
--no-pager no-pager
--perf-dir perf-dir
--work-tree work-tree
--debugfs-dir debugfs-dir
--buildid-dir buildid-dir
--list-cmds list-cmds
--list-opts list-opts
--debug debug
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
<SNIP>
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace strace inspired tool
probe Define new dynamic tracepoints
See 'perf help COMMAND' for more information on a specific command.
As shown above, the options description really appears now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
tools/perf/builtin-help.c | 2 +-
tools/perf/builtin.h | 3 +++
tools/perf/perf.c | 12 ++++++++----
tools/perf/util/parse-options.c | 7 +++++++
tools/perf/util/parse-options.h | 3 +++
5 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 36486ea..5cb29fe 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -470,7 +470,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
}
if (!argv[0]) {
- printf("\n usage: %s\n\n", perf_usage_string);
+ usage_with_options_return(perf_usage, perf_options);
list_common_cmds_help();
printf("\n %s\n\n", perf_more_info_string);
return 0;
diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h
index 3688ad2..4439db0 100644
--- a/tools/perf/builtin.h
+++ b/tools/perf/builtin.h
@@ -3,9 +3,12 @@
#include "util/util.h"
#include "util/strbuf.h"
+#include "util/parse-options.h"
extern const char perf_usage_string[];
extern const char perf_more_info_string[];
+extern const char * const perf_usage[];
+extern struct option perf_options[];
extern void list_common_cmds_help(void);
extern const char *help_unknown_cmd(const char *cmd);
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 5437134..3bcaa10d 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -21,6 +21,10 @@
const char perf_usage_string[] =
"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+const char * const perf_usage[] = {
+ perf_usage_string,
+ NULL
+};
const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
@@ -127,7 +131,7 @@ static void commit_pager_choice(void)
}
}
-struct option options[] = {
+struct option perf_options[] = {
OPT_ARGUMENT("help", "help"),
OPT_ARGUMENT("version", "version"),
OPT_ARGUMENT("exec-path", "exec-path"),
@@ -261,8 +265,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
} else if (!strcmp(cmd, "--list-opts")) {
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(options)-1; i++) {
- struct option *p = options+i;
+ for (i = 0; i < ARRAY_SIZE(perf_options)-1; i++) {
+ struct option *p = perf_options+i;
printf("--%s ", p->long_name);
}
putchar('\n');
@@ -578,7 +582,7 @@ int main(int argc, const char **argv)
argv[0] += 2;
} else {
/* The user didn't specify a command; give them help */
- printf("\n usage: %s\n\n", perf_usage_string);
+ usage_with_options_return(perf_usage, perf_options);
list_common_cmds_help();
printf("\n %s\n\n", perf_more_info_string);
goto out;
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 9a38b05..494089b 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -677,6 +677,13 @@ void usage_with_options(const char * const *usagestr,
exit(129);
}
+void usage_with_options_return(const char * const *usagestr,
+ const struct option *opts)
+{
+ exit_browser(false);
+ usage_with_options_internal(usagestr, opts, 0);
+}
+
int parse_options_usage(const char * const *usagestr,
const struct option *opts,
const char *optstr, bool short_opt)
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
index 367d8b8..8130f83 100644
--- a/tools/perf/util/parse-options.h
+++ b/tools/perf/util/parse-options.h
@@ -161,6 +161,9 @@ extern int parse_options_subcommand(int argc, const char **argv,
extern NORETURN void usage_with_options(const char * const *usagestr,
const struct option *options);
+extern void usage_with_options_return(const char * const *usagestr,
+ const struct option *options);
+
/*----- incremantal advanced APIs -----*/
enum {
--
1.8.5.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 2/3] perf help: Change 'usage' to 'Usage' for consistency
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
2015-10-15 7:39 ` [PATCH v2 1/3] perf help: Add options description to 'perf -h' Yunlong Song
@ 2015-10-15 7:39 ` Yunlong Song
2015-10-20 7:48 ` [tip:perf/core] " tip-bot for Yunlong Song
2015-10-15 7:39 ` [PATCH v2 3/3] perf help: Change the usage's stdout to stderr " Yunlong Song
2 siblings, 1 reply; 18+ messages in thread
From: Yunlong Song @ 2015-10-15 7:39 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme
Cc: linux-kernel, wangnan0, namhyung, artagnon, sriram.r,
adrian.hunter, jolsa, dsahern
Capitalize 'usage' to make it consistent with all the other 'Usage' in the
codes, e.g., usage_builtin.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
tools/perf/builtin-help.c | 2 +-
tools/perf/util/parse-options.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 5cb29fe..09b0368 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -463,7 +463,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
builtin_help_subcommands, builtin_help_usage, 0);
if (show_all) {
- printf("\n usage: %s\n\n", perf_usage_string);
+ printf("\n Usage: %s\n\n", perf_usage_string);
list_commands("perf commands", &main_cmds, &other_cmds);
printf(" %s\n\n", perf_more_info_string);
return 0;
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 494089b..06793d9 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -648,7 +648,7 @@ int usage_with_options_internal(const char * const *usagestr,
if (!usagestr)
return PARSE_OPT_HELP;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
while (*usagestr) {
@@ -691,7 +691,7 @@ int parse_options_usage(const char * const *usagestr,
if (!usagestr)
goto opt;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
while (*usagestr) {
--
1.8.5.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 3/3] perf help: Change the usage's stdout to stderr for consistency
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
2015-10-15 7:39 ` [PATCH v2 1/3] perf help: Add options description to 'perf -h' Yunlong Song
2015-10-15 7:39 ` [PATCH v2 2/3] perf help: Change 'usage' to 'Usage' for consistency Yunlong Song
@ 2015-10-15 7:39 ` Yunlong Song
2 siblings, 0 replies; 18+ messages in thread
From: Yunlong Song @ 2015-10-15 7:39 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme
Cc: linux-kernel, wangnan0, namhyung, artagnon, sriram.r,
adrian.hunter, jolsa, dsahern
The builtins use stderr everywhere to show the usage info when the opts
or cmds are incorrectly used, for consistency, change perf's stdout to
stderr to show its usage info when it is incorrectly (including no
command) used.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
tools/perf/builtin-help.c | 9 +++++----
tools/perf/perf.c | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 09b0368..8cee457 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -287,10 +287,11 @@ void list_common_cmds_help(void)
longest = strlen(common_cmds[i].name);
}
- puts(" The most commonly used perf commands are:");
+ fputs(" The most commonly used perf commands are:\n", stderr);
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
- printf(" %-*s ", longest, common_cmds[i].name);
- puts(common_cmds[i].help);
+ fprintf(stderr, " %-*s ", longest, common_cmds[i].name);
+ fputs(common_cmds[i].help, stderr);
+ fputc('\n', stderr);
}
}
@@ -472,7 +473,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
if (!argv[0]) {
usage_with_options_return(perf_usage, perf_options);
list_common_cmds_help();
- printf("\n %s\n\n", perf_more_info_string);
+ fprintf(stderr, "\n %s\n\n", perf_more_info_string);
return 0;
}
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 3bcaa10d..54ef361 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -584,7 +584,7 @@ int main(int argc, const char **argv)
/* The user didn't specify a command; give them help */
usage_with_options_return(perf_usage, perf_options);
list_common_cmds_help();
- printf("\n %s\n\n", perf_more_info_string);
+ fprintf(stderr, "\n %s\n\n", perf_more_info_string);
goto out;
}
cmd = argv[0];
--
1.8.5.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] perf help: Add options description to 'perf -h'
2015-10-15 7:39 ` [PATCH v2 1/3] perf help: Add options description to 'perf -h' Yunlong Song
@ 2015-10-19 15:29 ` Namhyung Kim
2015-10-20 2:13 ` Yunlong Song
0 siblings, 1 reply; 18+ messages in thread
From: Namhyung Kim @ 2015-10-19 15:29 UTC (permalink / raw)
To: Yunlong Song
Cc: a.p.zijlstra, paulus, mingo, acme, linux-kernel, wangnan0,
artagnon, sriram.r, adrian.hunter, jolsa, dsahern
Hi,
On Thu, Oct 15, 2015 at 03:39:50PM +0800, Yunlong Song wrote:
> Add options description to 'perf -h' to make it consistent with other builtins
> (e.g., 'perf stat -h').
>
> Example:
>
> Before this patch:
>
> # perf -h
>
> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
>
> The most commonly used perf commands are:
> annotate Read perf.data (created by perf record) and display annotated code
> archive Create archive with object files with build-ids found in perf.data file
> bench General framework for benchmark suites
> buildid-cache Manage build-id cache.
> buildid-list List the buildids in a perf.data file
> <SNIP>
> test Runs sanity tests.
> timechart Tool to visualize total system behavior during a workload
> top System profiling tool.
> trace strace inspired tool
> probe Define new dynamic tracepoints
>
> See 'perf help COMMAND' for more information on a specific command.
>
> After this patch:
>
> # perf -h
>
> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
>
> --help help
> --version version
> --exec-path exec-path
> --html-path html-path
> --paginate paginate
> --no-pager no-pager
> --perf-dir perf-dir
> --work-tree work-tree
> --debugfs-dir debugfs-dir
> --buildid-dir buildid-dir
> --list-cmds list-cmds
> --list-opts list-opts
> --debug debug
IMHO this *help* message is not very useful in its current form. Also
please consider updating Documentation/perf.txt too.
Thanks,
Namhyung
>
> The most commonly used perf commands are:
> annotate Read perf.data (created by perf record) and display annotated code
> archive Create archive with object files with build-ids found in perf.data file
> bench General framework for benchmark suites
> buildid-cache Manage build-id cache.
> buildid-list List the buildids in a perf.data file
> <SNIP>
> test Runs sanity tests.
> timechart Tool to visualize total system behavior during a workload
> top System profiling tool.
> trace strace inspired tool
> probe Define new dynamic tracepoints
>
> See 'perf help COMMAND' for more information on a specific command.
>
> As shown above, the options description really appears now.
>
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] perf help: Add options description to 'perf -h'
2015-10-19 15:29 ` Namhyung Kim
@ 2015-10-20 2:13 ` Yunlong Song
2015-10-21 1:57 ` Namhyung Kim
0 siblings, 1 reply; 18+ messages in thread
From: Yunlong Song @ 2015-10-20 2:13 UTC (permalink / raw)
To: Namhyung Kim
Cc: a.p.zijlstra, paulus, mingo, acme, linux-kernel, wangnan0,
artagnon, sriram.r, adrian.hunter, jolsa, dsahern
On 2015/10/19 23:29, Namhyung Kim wrote:
> Hi,
>
> On Thu, Oct 15, 2015 at 03:39:50PM +0800, Yunlong Song wrote:
>> Add options description to 'perf -h' to make it consistent with other builtins
>> (e.g., 'perf stat -h').
>>
>> Example:
>>
>> Before this patch:
>>
>> # perf -h
>>
>> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
>>
>> The most commonly used perf commands are:
>> annotate Read perf.data (created by perf record) and display annotated code
>> archive Create archive with object files with build-ids found in perf.data file
>> bench General framework for benchmark suites
>> buildid-cache Manage build-id cache.
>> buildid-list List the buildids in a perf.data file
>> <SNIP>
>> test Runs sanity tests.
>> timechart Tool to visualize total system behavior during a workload
>> top System profiling tool.
>> trace strace inspired tool
>> probe Define new dynamic tracepoints
>>
>> See 'perf help COMMAND' for more information on a specific command.
>>
>> After this patch:
>>
>> # perf -h
>>
>> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
>>
>> --help help
>> --version version
>> --exec-path exec-path
>> --html-path html-path
>> --paginate paginate
>> --no-pager no-pager
>> --perf-dir perf-dir
>> --work-tree work-tree
>> --debugfs-dir debugfs-dir
>> --buildid-dir buildid-dir
>> --list-cmds list-cmds
>> --list-opts list-opts
>> --debug debug
>
> IMHO this *help* message is not very useful in its current form. Also
> please consider updating Documentation/perf.txt too.
>
> Thanks,
> Namhyung
OK, I will update the struct option of perf to a more interpretative style soon.
>
>>
>> The most commonly used perf commands are:
>> annotate Read perf.data (created by perf record) and display annotated code
>> archive Create archive with object files with build-ids found in perf.data file
>> bench General framework for benchmark suites
>> buildid-cache Manage build-id cache.
>> buildid-list List the buildids in a perf.data file
>> <SNIP>
>> test Runs sanity tests.
>> timechart Tool to visualize total system behavior during a workload
>> top System profiling tool.
>> trace strace inspired tool
>> probe Define new dynamic tracepoints
>>
>> See 'perf help COMMAND' for more information on a specific command.
>>
>> As shown above, the options description really appears now.
>>
>> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
>
> .
>
--
Thanks,
Yunlong Song
^ permalink raw reply [flat|nested] 18+ messages in thread
* [tip:perf/core] perf help: Change 'usage' to 'Usage' for consistency
2015-10-15 7:39 ` [PATCH v2 2/3] perf help: Change 'usage' to 'Usage' for consistency Yunlong Song
@ 2015-10-20 7:48 ` tip-bot for Yunlong Song
0 siblings, 0 replies; 18+ messages in thread
From: tip-bot for Yunlong Song @ 2015-10-20 7:48 UTC (permalink / raw)
To: linux-tip-commits
Cc: sriram.r, jolsa, acme, a.p.zijlstra, yunlong.song, adrian.hunter,
mingo, wangnan0, artagnon, linux-kernel, dsahern, tglx, namhyung,
hpa
Commit-ID: 3a134ae96ca0af06804d343019b85026486e6fe1
Gitweb: http://git.kernel.org/tip/3a134ae96ca0af06804d343019b85026486e6fe1
Author: Yunlong Song <yunlong.song@huawei.com>
AuthorDate: Thu, 15 Oct 2015 15:39:51 +0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 19 Oct 2015 16:51:44 -0300
perf help: Change 'usage' to 'Usage' for consistency
Capitalize 'usage' to make it consistent with all the other 'Usage' in
the codes, e.g., usage_builtin.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Sriram Raghunathan <sriram.r@nokia.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1444894792-2338-3-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-help.c | 2 +-
tools/perf/util/parse-options.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 36486ea..a7d588b 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -463,7 +463,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
builtin_help_subcommands, builtin_help_usage, 0);
if (show_all) {
- printf("\n usage: %s\n\n", perf_usage_string);
+ printf("\n Usage: %s\n\n", perf_usage_string);
list_commands("perf commands", &main_cmds, &other_cmds);
printf(" %s\n\n", perf_more_info_string);
return 0;
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 9a38b05..8aa7922 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -648,7 +648,7 @@ int usage_with_options_internal(const char * const *usagestr,
if (!usagestr)
return PARSE_OPT_HELP;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
while (*usagestr) {
@@ -684,7 +684,7 @@ int parse_options_usage(const char * const *usagestr,
if (!usagestr)
goto opt;
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
while (*usagestr) {
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] perf help: Add options description to 'perf -h'
2015-10-20 2:13 ` Yunlong Song
@ 2015-10-21 1:57 ` Namhyung Kim
0 siblings, 0 replies; 18+ messages in thread
From: Namhyung Kim @ 2015-10-21 1:57 UTC (permalink / raw)
To: Yunlong Song
Cc: a.p.zijlstra, paulus, mingo, acme, linux-kernel, wangnan0,
artagnon, sriram.r, adrian.hunter, jolsa, dsahern
On Tue, Oct 20, 2015 at 10:13:17AM +0800, Yunlong Song wrote:
> On 2015/10/19 23:29, Namhyung Kim wrote:
> > Hi,
> >
> > On Thu, Oct 15, 2015 at 03:39:50PM +0800, Yunlong Song wrote:
> >> Add options description to 'perf -h' to make it consistent with other builtins
> >> (e.g., 'perf stat -h').
> >>
> >> Example:
> >>
> >> Before this patch:
> >>
> >> # perf -h
> >>
> >> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
> >>
> >> The most commonly used perf commands are:
> >> annotate Read perf.data (created by perf record) and display annotated code
> >> archive Create archive with object files with build-ids found in perf.data file
> >> bench General framework for benchmark suites
> >> buildid-cache Manage build-id cache.
> >> buildid-list List the buildids in a perf.data file
> >> <SNIP>
> >> test Runs sanity tests.
> >> timechart Tool to visualize total system behavior during a workload
> >> top System profiling tool.
> >> trace strace inspired tool
> >> probe Define new dynamic tracepoints
> >>
> >> See 'perf help COMMAND' for more information on a specific command.
> >>
> >> After this patch:
> >>
> >> # perf -h
> >>
> >> usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
> >>
> >> --help help
> >> --version version
> >> --exec-path exec-path
> >> --html-path html-path
> >> --paginate paginate
> >> --no-pager no-pager
> >> --perf-dir perf-dir
> >> --work-tree work-tree
> >> --debugfs-dir debugfs-dir
> >> --buildid-dir buildid-dir
> >> --list-cmds list-cmds
> >> --list-opts list-opts
> >> --debug debug
> >
> > IMHO this *help* message is not very useful in its current form. Also
> > please consider updating Documentation/perf.txt too.
> >
> > Thanks,
> > Namhyung
>
> OK, I will update the struct option of perf to a more interpretative style soon.
In addition, --help and --version options are duplicate. And I think
--perf-dir and --work-tree options are never used. Also I doubt
anyone uses html help page with --html-path. Finally I think it'd be
better to hide --list-cmds and --list-opts options as they're only
intended to be used by completion scripts.
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2015-10-21 1:57 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1444282190-13605-1-git-send-email-sriram.r@nokia.com>
2015-10-13 14:57 ` [PATCH 1/1] perf:Adding --list-opts to usage string Arnaldo Carvalho de Melo
2015-10-13 15:24 ` Ramkumar Ramachandra
2015-10-14 2:29 ` Yunlong Song
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
2015-10-14 3:42 ` Namhyung Kim
2015-10-14 13:31 ` Yunlong Song
[not found] ` <CA+JHD92p0QUJGrqKTMYD8FUKj5tS9MUV_njsvoFwaHhsQevn_Q@mail.gmail.com>
2015-10-14 17:10 ` [PATCH 1/1] perf :redirection of usage strings to stdout Sriram Raghunathan
2015-10-15 7:22 ` Sriram Raghunathan
2015-10-15 7:11 ` [PATCH 1/1] perf:Adding --list-opts to usage string Yunlong Song
2015-10-14 13:44 ` [PATCH] perf help: Add options description to 'perf -h' Yunlong Song
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
2015-10-15 7:39 ` [PATCH v2 1/3] perf help: Add options description to 'perf -h' Yunlong Song
2015-10-19 15:29 ` Namhyung Kim
2015-10-20 2:13 ` Yunlong Song
2015-10-21 1:57 ` Namhyung Kim
2015-10-15 7:39 ` [PATCH v2 2/3] perf help: Change 'usage' to 'Usage' for consistency Yunlong Song
2015-10-20 7:48 ` [tip:perf/core] " tip-bot for Yunlong Song
2015-10-15 7:39 ` [PATCH v2 3/3] perf help: Change the usage's stdout to stderr " Yunlong Song
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.