diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-12-11 14:16:47 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-12-11 15:21:52 -0500 |
commit | c5ff78c3092d0e7d14c82d2949e16fee063a83f1 (patch) | |
tree | b317450794e7583a585a417c5e8b26a3d1eac6ee /tools | |
parent | c79a439338f3a021f5a5ff6ea165b0d19d2eb0aa (diff) |
perf record: Pass perf_record_opts to the callchain cmdline parsing callback
Its all it uses and makes the parsing callback suitable for use by
'perf top', which will happen in a followup patch.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-wb9eti78bk2jd7wpasro8hsz@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-record.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index fc4f08044632..d035040efe1d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -868,11 +868,9 @@ static int get_stack_size(char *str, unsigned long *_size) | |||
868 | } | 868 | } |
869 | #endif /* LIBUNWIND_SUPPORT */ | 869 | #endif /* LIBUNWIND_SUPPORT */ |
870 | 870 | ||
871 | static int | 871 | static int parse_callchain_opt(const struct option *opt, const char *arg, int unset) |
872 | parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg, | ||
873 | int unset) | ||
874 | { | 872 | { |
875 | struct perf_record *rec = (struct perf_record *)opt->value; | 873 | struct perf_record_opts *opts = opt->value; |
876 | char *tok, *name, *saveptr = NULL; | 874 | char *tok, *name, *saveptr = NULL; |
877 | char *buf; | 875 | char *buf; |
878 | int ret = -1; | 876 | int ret = -1; |
@@ -898,7 +896,7 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg, | |||
898 | /* Framepointer style */ | 896 | /* Framepointer style */ |
899 | if (!strncmp(name, "fp", sizeof("fp"))) { | 897 | if (!strncmp(name, "fp", sizeof("fp"))) { |
900 | if (!strtok_r(NULL, ",", &saveptr)) { | 898 | if (!strtok_r(NULL, ",", &saveptr)) { |
901 | rec->opts.call_graph = CALLCHAIN_FP; | 899 | opts->call_graph = CALLCHAIN_FP; |
902 | ret = 0; | 900 | ret = 0; |
903 | } else | 901 | } else |
904 | pr_err("callchain: No more arguments " | 902 | pr_err("callchain: No more arguments " |
@@ -911,20 +909,20 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg, | |||
911 | const unsigned long default_stack_dump_size = 8192; | 909 | const unsigned long default_stack_dump_size = 8192; |
912 | 910 | ||
913 | ret = 0; | 911 | ret = 0; |
914 | rec->opts.call_graph = CALLCHAIN_DWARF; | 912 | opts->call_graph = CALLCHAIN_DWARF; |
915 | rec->opts.stack_dump_size = default_stack_dump_size; | 913 | opts->stack_dump_size = default_stack_dump_size; |
916 | 914 | ||
917 | tok = strtok_r(NULL, ",", &saveptr); | 915 | tok = strtok_r(NULL, ",", &saveptr); |
918 | if (tok) { | 916 | if (tok) { |
919 | unsigned long size = 0; | 917 | unsigned long size = 0; |
920 | 918 | ||
921 | ret = get_stack_size(tok, &size); | 919 | ret = get_stack_size(tok, &size); |
922 | rec->opts.stack_dump_size = size; | 920 | opts->stack_dump_size = size; |
923 | } | 921 | } |
924 | 922 | ||
925 | if (!ret) | 923 | if (!ret) |
926 | pr_debug("callchain: stack dump size %d\n", | 924 | pr_debug("callchain: stack dump size %d\n", |
927 | rec->opts.stack_dump_size); | 925 | opts->stack_dump_size); |
928 | #endif /* LIBUNWIND_SUPPORT */ | 926 | #endif /* LIBUNWIND_SUPPORT */ |
929 | } else { | 927 | } else { |
930 | pr_err("callchain: Unknown -g option " | 928 | pr_err("callchain: Unknown -g option " |
@@ -937,7 +935,7 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg, | |||
937 | free(buf); | 935 | free(buf); |
938 | 936 | ||
939 | if (!ret) | 937 | if (!ret) |
940 | pr_debug("callchain: type %d\n", rec->opts.call_graph); | 938 | pr_debug("callchain: type %d\n", opts->call_graph); |
941 | 939 | ||
942 | return ret; | 940 | return ret; |
943 | } | 941 | } |
@@ -1021,9 +1019,9 @@ const struct option record_options[] = { | |||
1021 | "number of mmap data pages"), | 1019 | "number of mmap data pages"), |
1022 | OPT_BOOLEAN(0, "group", &record.opts.group, | 1020 | OPT_BOOLEAN(0, "group", &record.opts.group, |
1023 | "put the counters into a counter group"), | 1021 | "put the counters into a counter group"), |
1024 | OPT_CALLBACK_DEFAULT('g', "call-graph", &record, "mode[,dump_size]", | 1022 | OPT_CALLBACK_DEFAULT('g', "call-graph", &record.opts, |
1025 | callchain_help, &parse_callchain_opt, | 1023 | "mode[,dump_size]", callchain_help, |
1026 | "fp"), | 1024 | &parse_callchain_opt, "fp"), |
1027 | OPT_INCR('v', "verbose", &verbose, | 1025 | OPT_INCR('v', "verbose", &verbose, |
1028 | "be more verbose (show counter open errors, etc)"), | 1026 | "be more verbose (show counter open errors, etc)"), |
1029 | OPT_BOOLEAN('q', "quiet", &quiet, "don't print any message"), | 1027 | OPT_BOOLEAN('q', "quiet", &quiet, "don't print any message"), |