Commit c3a6a8c4 authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo

perf tools: Refine parse/config callchain functions

Pass global callchain_param into parse_callchain_record_opt and
perf_evsel__config_callgraph as parameter. So we can reuse these
functions to parse/config local param for callchain.
Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1438677022-34296-3-git-send-email-kan.liang@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 32067712
...@@ -779,7 +779,7 @@ int record_parse_callchain_opt(const struct option *opt, ...@@ -779,7 +779,7 @@ int record_parse_callchain_opt(const struct option *opt,
return 0; return 0;
} }
ret = parse_callchain_record_opt(arg); ret = parse_callchain_record_opt(arg, &callchain_param);
if (!ret) if (!ret)
callchain_debug(); callchain_debug();
......
...@@ -53,7 +53,7 @@ static int get_stack_size(const char *str, unsigned long *_size) ...@@ -53,7 +53,7 @@ static int get_stack_size(const char *str, unsigned long *_size)
} }
#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* HAVE_DWARF_UNWIND_SUPPORT */
int parse_callchain_record_opt(const char *arg) int parse_callchain_record_opt(const char *arg, struct callchain_param *param)
{ {
char *tok, *name, *saveptr = NULL; char *tok, *name, *saveptr = NULL;
char *buf; char *buf;
...@@ -73,7 +73,7 @@ int parse_callchain_record_opt(const char *arg) ...@@ -73,7 +73,7 @@ int parse_callchain_record_opt(const char *arg)
/* Framepointer style */ /* Framepointer style */
if (!strncmp(name, "fp", sizeof("fp"))) { if (!strncmp(name, "fp", sizeof("fp"))) {
if (!strtok_r(NULL, ",", &saveptr)) { if (!strtok_r(NULL, ",", &saveptr)) {
callchain_param.record_mode = CALLCHAIN_FP; param->record_mode = CALLCHAIN_FP;
ret = 0; ret = 0;
} else } else
pr_err("callchain: No more arguments " pr_err("callchain: No more arguments "
...@@ -86,20 +86,20 @@ int parse_callchain_record_opt(const char *arg) ...@@ -86,20 +86,20 @@ int parse_callchain_record_opt(const char *arg)
const unsigned long default_stack_dump_size = 8192; const unsigned long default_stack_dump_size = 8192;
ret = 0; ret = 0;
callchain_param.record_mode = CALLCHAIN_DWARF; param->record_mode = CALLCHAIN_DWARF;
callchain_param.dump_size = default_stack_dump_size; param->dump_size = default_stack_dump_size;
tok = strtok_r(NULL, ",", &saveptr); tok = strtok_r(NULL, ",", &saveptr);
if (tok) { if (tok) {
unsigned long size = 0; unsigned long size = 0;
ret = get_stack_size(tok, &size); ret = get_stack_size(tok, &size);
callchain_param.dump_size = size; param->dump_size = size;
} }
#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* HAVE_DWARF_UNWIND_SUPPORT */
} else if (!strncmp(name, "lbr", sizeof("lbr"))) { } else if (!strncmp(name, "lbr", sizeof("lbr"))) {
if (!strtok_r(NULL, ",", &saveptr)) { if (!strtok_r(NULL, ",", &saveptr)) {
callchain_param.record_mode = CALLCHAIN_LBR; param->record_mode = CALLCHAIN_LBR;
ret = 0; ret = 0;
} else } else
pr_err("callchain: No more arguments " pr_err("callchain: No more arguments "
...@@ -219,7 +219,7 @@ int perf_callchain_config(const char *var, const char *value) ...@@ -219,7 +219,7 @@ int perf_callchain_config(const char *var, const char *value)
var += sizeof("call-graph.") - 1; var += sizeof("call-graph.") - 1;
if (!strcmp(var, "record-mode")) if (!strcmp(var, "record-mode"))
return parse_callchain_record_opt(value); return parse_callchain_record_opt(value, &callchain_param);
#ifdef HAVE_DWARF_UNWIND_SUPPORT #ifdef HAVE_DWARF_UNWIND_SUPPORT
if (!strcmp(var, "dump-size")) { if (!strcmp(var, "dump-size")) {
unsigned long size = 0; unsigned long size = 0;
......
...@@ -177,7 +177,7 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node * ...@@ -177,7 +177,7 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *
bool hide_unresolved); bool hide_unresolved);
extern const char record_callchain_help[]; extern const char record_callchain_help[];
int parse_callchain_record_opt(const char *arg); int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
int parse_callchain_report_opt(const char *arg); int parse_callchain_report_opt(const char *arg);
int perf_callchain_config(const char *var, const char *value); int perf_callchain_config(const char *var, const char *value);
......
...@@ -545,14 +545,15 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size) ...@@ -545,14 +545,15 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)
static void static void
perf_evsel__config_callgraph(struct perf_evsel *evsel, perf_evsel__config_callgraph(struct perf_evsel *evsel,
struct record_opts *opts) struct record_opts *opts,
struct callchain_param *param)
{ {
bool function = perf_evsel__is_function_event(evsel); bool function = perf_evsel__is_function_event(evsel);
struct perf_event_attr *attr = &evsel->attr; struct perf_event_attr *attr = &evsel->attr;
perf_evsel__set_sample_bit(evsel, CALLCHAIN); perf_evsel__set_sample_bit(evsel, CALLCHAIN);
if (callchain_param.record_mode == CALLCHAIN_LBR) { if (param->record_mode == CALLCHAIN_LBR) {
if (!opts->branch_stack) { if (!opts->branch_stack) {
if (attr->exclude_user) { if (attr->exclude_user) {
pr_warning("LBR callstack option is only available " pr_warning("LBR callstack option is only available "
...@@ -568,12 +569,12 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel, ...@@ -568,12 +569,12 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel,
"Falling back to framepointers.\n"); "Falling back to framepointers.\n");
} }
if (callchain_param.record_mode == CALLCHAIN_DWARF) { if (param->record_mode == CALLCHAIN_DWARF) {
if (!function) { if (!function) {
perf_evsel__set_sample_bit(evsel, REGS_USER); perf_evsel__set_sample_bit(evsel, REGS_USER);
perf_evsel__set_sample_bit(evsel, STACK_USER); perf_evsel__set_sample_bit(evsel, STACK_USER);
attr->sample_regs_user = PERF_REGS_MASK; attr->sample_regs_user = PERF_REGS_MASK;
attr->sample_stack_user = callchain_param.dump_size; attr->sample_stack_user = param->dump_size;
attr->exclude_callchain_user = 1; attr->exclude_callchain_user = 1;
} else { } else {
pr_info("Cannot use DWARF unwind for function trace event," pr_info("Cannot use DWARF unwind for function trace event,"
...@@ -714,7 +715,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) ...@@ -714,7 +715,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
evsel->attr.exclude_callchain_user = 1; evsel->attr.exclude_callchain_user = 1;
if (callchain_param.enabled && !evsel->no_aux_samples) if (callchain_param.enabled && !evsel->no_aux_samples)
perf_evsel__config_callgraph(evsel, opts); perf_evsel__config_callgraph(evsel, opts, &callchain_param);
if (opts->sample_intr_regs) { if (opts->sample_intr_regs) {
attr->sample_regs_intr = PERF_REGS_MASK; attr->sample_regs_intr = PERF_REGS_MASK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment