perf tools: Search for more options when passing args to -h
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: f4efcce33d2e5224a905369f9906f3931f5d907c Gitweb: http://git.kernel.org/tip/f4efcce33d2e5224a905369f9906f3931f5d907c Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Tue, 27 Oct 2015 17:35:58 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 27 Oct 2015 17:35:58 -0300
perf tools: Search for more options when passing args to -h
Recently 'perf <tool> -h' was made aware of arguments and would show just the help for the arguments specified, but that required a strict form, i.e.:
$ perf -h --tui
worked, but:
$ perf -h tui
didn't.
Make it support both cases and also look at the option help when neither matches, so that he following examples works:
$ perf report -h interface
Usage: perf report [<options>]
--gtk Use the GTK2 interface
--stdio Use the stdio interface
--tui Use the TUI interface$ perf report -h stack
Usage: perf report [<options>]
-g, --call-graph <print_type,threshold[,print_limit],order,
sort_key[,branch]>
Display call graph (stack chain/backtrace):
print_type: call graph printing style (graph|flat|fractal|none)
threshold: minimum call graph inclusion threshold (<percent>)
print_limit: maximum number of call graph entry (<number>)
order: call graph order (caller|callee)
sort_key: call graph sort key (function|address)
branch: include last branch info to call graph (branch)
Default: graph,0.5,caller,function
--max-stack <n> Set the maximum stack depth when parsing the
callchain, anything beyond the specified depth will be ignored. Default: 127
$
--- tools/perf/util/parse-options.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
tools/perf/util/parse-options.c +14 -1
@@ -695,8 +695,21 @@ static bool option__in_argv(const struct option *opt, const struct parse_opt_ctxfor (i =1 ; i < ctx->argc; ++i) {const char *arg = ctx->argv[i]; -if (arg[0 ] !='-' ) +if (arg[0 ] !='-' ) { +if (arg[1 ] =='\0' ) { +if (arg[0 ] == opt->short_name) +return true; +continue ; + } + +if (opt->long_name &&strcmp (opt->long_name, arg) ==0 ) +return true; + +if (opt->help &&strcasestr (opt->help, arg) !=NULL ) +return true; +continue ; + }if (arg[1 ] == opt->short_name || (arg[1 ] =='-' && opt->long_name &&strcmp (opt->long_name, arg +2 ) ==0 ))