aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorDon Zickus <dzickus@redhat.com>2014-04-07 14:55:24 -0400
committerJiri Olsa <jolsa@redhat.com>2014-04-22 11:39:24 -0400
commitcff6bb46d477383092f46682a0d12e323e4b84d2 (patch)
tree88b5217cdee5126642e6f3db587fab1b1050ba65 /tools/perf/builtin-report.c
parent4b6279579c84cca7f162cfbcb98f66418f3062f3 (diff)
perf callchain: Add generic report parse callchain callback function
This takes the parse_callchain_opt function and copies it into the callchain.c file. Now the c2c tool can use it too without duplicating. Update perf-report to use the new routine too. Signed-off-by: Don Zickus <dzickus@redhat.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1396896924-129847-5-git-send-email-dzickus@redhat.com [ Adding missing braces to multiline if condition ] Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c81
1 files changed, 3 insertions, 78 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index af8cb7a2c9b6..76e2bb6cf571 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -589,11 +589,9 @@ static int __cmd_report(struct report *rep)
589} 589}
590 590
591static int 591static int
592parse_callchain_opt(const struct option *opt, const char *arg, int unset) 592report_parse_callchain_opt(const struct option *opt, const char *arg, int unset)
593{ 593{
594 struct report *rep = (struct report *)opt->value; 594 struct report *rep = (struct report *)opt->value;
595 char *tok, *tok2;
596 char *endptr;
597 595
598 /* 596 /*
599 * --no-call-graph 597 * --no-call-graph
@@ -603,80 +601,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
603 return 0; 601 return 0;
604 } 602 }
605 603
606 symbol_conf.use_callchain = true; 604 return parse_callchain_report_opt(arg);
607
608 if (!arg)
609 return 0;
610
611 tok = strtok((char *)arg, ",");
612 if (!tok)
613 return -1;
614
615 /* get the output mode */
616 if (!strncmp(tok, "graph", strlen(arg)))
617 callchain_param.mode = CHAIN_GRAPH_ABS;
618
619 else if (!strncmp(tok, "flat", strlen(arg)))
620 callchain_param.mode = CHAIN_FLAT;
621
622 else if (!strncmp(tok, "fractal", strlen(arg)))
623 callchain_param.mode = CHAIN_GRAPH_REL;
624
625 else if (!strncmp(tok, "none", strlen(arg))) {
626 callchain_param.mode = CHAIN_NONE;
627 symbol_conf.use_callchain = false;
628
629 return 0;
630 }
631
632 else
633 return -1;
634
635 /* get the min percentage */
636 tok = strtok(NULL, ",");
637 if (!tok)
638 goto setup;
639
640 callchain_param.min_percent = strtod(tok, &endptr);
641 if (tok == endptr)
642 return -1;
643
644 /* get the print limit */
645 tok2 = strtok(NULL, ",");
646 if (!tok2)
647 goto setup;
648
649 if (tok2[0] != 'c') {
650 callchain_param.print_limit = strtoul(tok2, &endptr, 0);
651 tok2 = strtok(NULL, ",");
652 if (!tok2)
653 goto setup;
654 }
655
656 /* get the call chain order */
657 if (!strncmp(tok2, "caller", strlen("caller")))
658 callchain_param.order = ORDER_CALLER;
659 else if (!strncmp(tok2, "callee", strlen("callee")))
660 callchain_param.order = ORDER_CALLEE;
661 else
662 return -1;
663
664 /* Get the sort key */
665 tok2 = strtok(NULL, ",");
666 if (!tok2)
667 goto setup;
668 if (!strncmp(tok2, "function", strlen("function")))
669 callchain_param.key = CCKEY_FUNCTION;
670 else if (!strncmp(tok2, "address", strlen("address")))
671 callchain_param.key = CCKEY_ADDRESS;
672 else
673 return -1;
674setup:
675 if (callchain_register_param(&callchain_param) < 0) {
676 pr_err("Can't register callchain params\n");
677 return -1;
678 }
679 return 0;
680} 605}
681 606
682int 607int
@@ -788,7 +713,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
788 "Only display entries with parent-match"), 713 "Only display entries with parent-match"),
789 OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order", 714 OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order",
790 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address). " 715 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address). "
791 "Default: fractal,0.5,callee,function", &parse_callchain_opt, callchain_default_opt), 716 "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
792 OPT_INTEGER(0, "max-stack", &report.max_stack, 717 OPT_INTEGER(0, "max-stack", &report.max_stack,
793 "Set the maximum stack depth when parsing the callchain, " 718 "Set the maximum stack depth when parsing the callchain, "
794 "anything beyond the specified depth will be ignored. " 719 "anything beyond the specified depth will be ignored. "