diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-14 17:09:29 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-15 02:50:28 -0500 |
commit | c8829c7a31c7e0156b230fa8d5a14be9881d7677 (patch) | |
tree | c8649f461c5192613de3fe47b728e47a8b5c9e2c | |
parent | f823e441ab4dfaeaf17832fa1931e0dc0fde304d (diff) |
perf util: Remove setup_sorting dups
And it is also needed by 'perf diff'.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260828571-3613-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/builtin-annotate.c | 17 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 17 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 15 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 2 |
4 files changed, 19 insertions, 32 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index fa833f50763e..2e2855a685c6 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -521,21 +521,6 @@ static const struct option options[] = { | |||
521 | OPT_END() | 521 | OPT_END() |
522 | }; | 522 | }; |
523 | 523 | ||
524 | static void setup_sorting(void) | ||
525 | { | ||
526 | char *tmp, *tok, *str = strdup(sort_order); | ||
527 | |||
528 | for (tok = strtok_r(str, ", ", &tmp); | ||
529 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | ||
530 | if (sort_dimension__add(tok) < 0) { | ||
531 | error("Unknown --sort key: `%s'", tok); | ||
532 | usage_with_options(annotate_usage, options); | ||
533 | } | ||
534 | } | ||
535 | |||
536 | free(str); | ||
537 | } | ||
538 | |||
539 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) | 524 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) |
540 | { | 525 | { |
541 | if (symbol__init(&symbol_conf) < 0) | 526 | if (symbol__init(&symbol_conf) < 0) |
@@ -543,7 +528,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used) | |||
543 | 528 | ||
544 | argc = parse_options(argc, argv, options, annotate_usage, 0); | 529 | argc = parse_options(argc, argv, options, annotate_usage, 0); |
545 | 530 | ||
546 | setup_sorting(); | 531 | setup_sorting(annotate_usage, options); |
547 | 532 | ||
548 | if (argc) { | 533 | if (argc) { |
549 | /* | 534 | /* |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index d12ea4ab0d21..beff7c090d2b 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -843,21 +843,6 @@ static const struct option options[] = { | |||
843 | OPT_END() | 843 | OPT_END() |
844 | }; | 844 | }; |
845 | 845 | ||
846 | static void setup_sorting(void) | ||
847 | { | ||
848 | char *tmp, *tok, *str = strdup(sort_order); | ||
849 | |||
850 | for (tok = strtok_r(str, ", ", &tmp); | ||
851 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | ||
852 | if (sort_dimension__add(tok) < 0) { | ||
853 | error("Unknown --sort key: `%s'", tok); | ||
854 | usage_with_options(report_usage, options); | ||
855 | } | ||
856 | } | ||
857 | |||
858 | free(str); | ||
859 | } | ||
860 | |||
861 | static void setup_list(struct strlist **list, const char *list_str, | 846 | static void setup_list(struct strlist **list, const char *list_str, |
862 | struct sort_entry *se, const char *list_name, | 847 | struct sort_entry *se, const char *list_name, |
863 | FILE *fp) | 848 | FILE *fp) |
@@ -884,7 +869,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used) | |||
884 | 869 | ||
885 | argc = parse_options(argc, argv, options, report_usage, 0); | 870 | argc = parse_options(argc, argv, options, report_usage, 0); |
886 | 871 | ||
887 | setup_sorting(); | 872 | setup_sorting(report_usage, options); |
888 | 873 | ||
889 | if (parent_pattern != default_parent_pattern) { | 874 | if (parent_pattern != default_parent_pattern) { |
890 | sort_dimension__add("parent"); | 875 | sort_dimension__add("parent"); |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b490354d1b23..cff1c316fa91 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -288,3 +288,18 @@ int sort_dimension__add(const char *tok) | |||
288 | 288 | ||
289 | return -ESRCH; | 289 | return -ESRCH; |
290 | } | 290 | } |
291 | |||
292 | void setup_sorting(const char * const usagestr[], const struct option *opts) | ||
293 | { | ||
294 | char *tmp, *tok, *str = strdup(sort_order); | ||
295 | |||
296 | for (tok = strtok_r(str, ", ", &tmp); | ||
297 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | ||
298 | if (sort_dimension__add(tok) < 0) { | ||
299 | error("Unknown --sort key: `%s'", tok); | ||
300 | usage_with_options(usagestr, opts); | ||
301 | } | ||
302 | } | ||
303 | |||
304 | free(str); | ||
305 | } | ||
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 333e664ff45f..cb6151c026f2 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -81,6 +81,8 @@ struct sort_entry { | |||
81 | extern struct sort_entry sort_thread; | 81 | extern struct sort_entry sort_thread; |
82 | extern struct list_head hist_entry__sort_list; | 82 | extern struct list_head hist_entry__sort_list; |
83 | 83 | ||
84 | void setup_sorting(const char * const usagestr[], const struct option *opts); | ||
85 | |||
84 | extern int repsep_fprintf(FILE *fp, const char *fmt, ...); | 86 | extern int repsep_fprintf(FILE *fp, const char *fmt, ...); |
85 | extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int); | 87 | extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int); |
86 | extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int); | 88 | extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int); |