Skip to content

Commit

Permalink
perf_counter: Improve perf stat and perf record option parsing
Browse files Browse the repository at this point in the history
perf stat and perf record currently look for all options on the command
line. This can lead to some confusion:

# perf stat ls -l
  Error: unknown switch `l'

While we can work around this by adding '--' before the command, the git
option parsing code can stop at the first non option:

# perf stat ls -l
 Performance counter stats for 'ls -l':
....

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090722130412.GD9029@kryten>
  • Loading branch information
antonblanchard authored and Peter Zijlstra committed Jul 22, 2009
1 parent 7f453c2 commit a054123
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tools/perf/builtin-record.c
Expand Up @@ -664,7 +664,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
{
int counter;

argc = parse_options(argc, argv, options, record_usage, 0);
argc = parse_options(argc, argv, options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && target_pid == -1 && !system_wide)
usage_with_options(record_usage, options);

Expand Down
3 changes: 2 additions & 1 deletion tools/perf/builtin-stat.c
Expand Up @@ -511,7 +511,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
{
int status;

argc = parse_options(argc, argv, options, stat_usage, 0);
argc = parse_options(argc, argv, options, stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc)
usage_with_options(stat_usage, options);
if (run_count <= 0 || run_count > MAX_RUN)
Expand Down

0 comments on commit a054123

Please sign in to comment.