diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-06-03 04:07:39 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-03 04:07:39 -0400 |
commit | 5352f35d6ae7b8b981d77137fb268bc54d10624f (patch) | |
tree | 61d966a613ec2c6508656203a62ce7a9b668cc33 /Documentation/perf_counter/builtin-report.c | |
parent | 3502973d005ed89cc2b3f39780813a341ddba97f (diff) |
perf report: Improve sort key recognition
- allow case-insensitive tokens - such as --sort Comm,Symbol
- allow substring shortcuts: --sort sym
- detect invalid tokens and bail out
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-report.c')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index 6207a3147fcb..a8d390596d8d 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -453,28 +453,18 @@ static int sort_dimension__add(char *tok) | |||
453 | if (sd->taken) | 453 | if (sd->taken) |
454 | continue; | 454 | continue; |
455 | 455 | ||
456 | if (strcmp(tok, sd->name)) | 456 | if (strncasecmp(tok, sd->name, strlen(tok))) |
457 | continue; | 457 | continue; |
458 | 458 | ||
459 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); | 459 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); |
460 | sd->taken = 1; | 460 | sd->taken = 1; |
461 | |||
461 | return 0; | 462 | return 0; |
462 | } | 463 | } |
463 | 464 | ||
464 | return -ESRCH; | 465 | return -ESRCH; |
465 | } | 466 | } |
466 | 467 | ||
467 | static void setup_sorting(void) | ||
468 | { | ||
469 | char *tmp, *tok, *str = strdup(sort_order); | ||
470 | |||
471 | for (tok = strtok_r(str, ", ", &tmp); | ||
472 | tok; tok = strtok_r(NULL, ", ", &tmp)) | ||
473 | sort_dimension__add(tok); | ||
474 | |||
475 | free(str); | ||
476 | } | ||
477 | |||
478 | static int64_t | 468 | static int64_t |
479 | hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) | 469 | hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) |
480 | { | 470 | { |
@@ -880,6 +870,21 @@ static const struct option options[] = { | |||
880 | OPT_END() | 870 | OPT_END() |
881 | }; | 871 | }; |
882 | 872 | ||
873 | static void setup_sorting(void) | ||
874 | { | ||
875 | char *tmp, *tok, *str = strdup(sort_order); | ||
876 | |||
877 | for (tok = strtok_r(str, ", ", &tmp); | ||
878 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | ||
879 | if (sort_dimension__add(tok) < 0) { | ||
880 | error("Unknown --sort key: `%s'", tok); | ||
881 | usage_with_options(report_usage, options); | ||
882 | } | ||
883 | } | ||
884 | |||
885 | free(str); | ||
886 | } | ||
887 | |||
883 | int cmd_report(int argc, const char **argv, const char *prefix) | 888 | int cmd_report(int argc, const char **argv, const char *prefix) |
884 | { | 889 | { |
885 | symbol__init(); | 890 | symbol__init(); |