int parse_callchain_report_opt(const char *arg) { char *tok; char *endptr; bool minpcnt_set = false; symbol_conf.use_callchain = true; if (!arg) return 0; while ((tok = strtok((char *)arg, ",")) != NULL) { if (!strncmp(tok, "none", strlen(tok))) { callchain_param.mode = CHAIN_NONE; symbol_conf.use_callchain = false; return 0; } if (!parse_callchain_mode(tok) || !parse_callchain_order(tok) || !parse_callchain_sort_key(tok)) { /* parsing ok - move on to the next */ } else if (!minpcnt_set) { /* try to get the min percent */ callchain_param.min_percent = strtod(tok, &endptr); if (tok == endptr) return -1; minpcnt_set = true; } else { /* try print limit at last */ callchain_param.print_limit = strtoul(tok, &endptr, 0); if (tok == endptr) return -1; } arg = NULL; } if (callchain_register_param(&callchain_param) < 0) { pr_err("Can't register callchain params\n"); return -1; } return 0; }
int perf_callchain_config(const char *var, const char *value) { char *endptr; if (prefixcmp(var, "call-graph.")) return 0; var += sizeof("call-graph.") - 1; if (!strcmp(var, "record-mode")) return parse_callchain_record_opt(value, &callchain_param); if (!strcmp(var, "dump-size")) { unsigned long size = 0; int ret; ret = get_stack_size(value, &size); callchain_param.dump_size = size; return ret; } if (!strcmp(var, "print-type")) return parse_callchain_mode(value); if (!strcmp(var, "order")) return parse_callchain_order(value); if (!strcmp(var, "sort-key")) return parse_callchain_sort_key(value); if (!strcmp(var, "threshold")) { callchain_param.min_percent = strtod(value, &endptr); if (value == endptr) { pr_err("Invalid callchain threshold: %s\n", value); return -1; } } if (!strcmp(var, "print-limit")) { callchain_param.print_limit = strtod(value, &endptr); if (value == endptr) { pr_err("Invalid callchain print limit: %s\n", value); return -1; } } return 0; }
int perf_callchain_config(const char *var, const char *value) { char *endptr; if (prefixcmp(var, "call-graph.")) return 0; var += sizeof("call-graph.") - 1; if (!strcmp(var, "record-mode")) return parse_callchain_record_opt(value, &callchain_param); #ifdef HAVE_DWARF_UNWIND_SUPPORT if (!strcmp(var, "dump-size")) { unsigned long size = 0; int ret; ret = get_stack_size(value, &size); callchain_param.dump_size = size; return ret; } #endif if (!strcmp(var, "print-type")) return parse_callchain_mode(value); if (!strcmp(var, "order")) return parse_callchain_order(value); if (!strcmp(var, "sort-key")) return parse_callchain_sort_key(value); if (!strcmp(var, "threshold")) { callchain_param.min_percent = strtod(value, &endptr); if (value == endptr) return -1; } if (!strcmp(var, "print-limit")) { callchain_param.print_limit = strtod(value, &endptr); if (value == endptr) return -1; } return 0; }
static int __parse_callchain_report_opt(const char *arg, bool allow_record_opt) { char *tok; char *endptr, *saveptr = NULL; bool minpcnt_set = false; bool record_opt_set = false; bool try_stack_size = false; callchain_param.enabled = true; symbol_conf.use_callchain = true; if (!arg) return 0; while ((tok = strtok_r((char *)arg, ",", &saveptr)) != NULL) { if (!strncmp(tok, "none", strlen(tok))) { callchain_param.mode = CHAIN_NONE; callchain_param.enabled = false; symbol_conf.use_callchain = false; return 0; } if (!parse_callchain_mode(tok) || !parse_callchain_order(tok) || !parse_callchain_sort_key(tok) || !parse_callchain_value(tok)) { /* parsing ok - move on to the next */ try_stack_size = false; goto next; } else if (allow_record_opt && !record_opt_set) { if (parse_callchain_record(tok, &callchain_param)) goto try_numbers; /* assume that number followed by 'dwarf' is stack size */ if (callchain_param.record_mode == CALLCHAIN_DWARF) try_stack_size = true; record_opt_set = true; goto next; } try_numbers: if (try_stack_size) { unsigned long size = 0; if (get_stack_size(tok, &size) < 0) return -1; callchain_param.dump_size = size; try_stack_size = false; } else if (!minpcnt_set) { /* try to get the min percent */ callchain_param.min_percent = strtod(tok, &endptr); if (tok == endptr) return -1; minpcnt_set = true; } else { /* try print limit at last */ callchain_param.print_limit = strtoul(tok, &endptr, 0); if (tok == endptr) return -1; } next: arg = NULL; } if (callchain_register_param(&callchain_param) < 0) { pr_err("Can't register callchain params\n"); return -1; } return 0; }