aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2013-10-29 06:23:32 -0400
committerIngo Molnar <mingo@kernel.org>2013-10-29 06:23:32 -0400
commitaac898548d04c7bff179b79f805874b0d6f87571 (patch)
treee8de975fd5de6c95bf4329861a872dbcfe0c7ead /tools/perf/builtin-record.c
parent2f5e98802350627ad6f2e3cee4d177059fc0c2f2 (diff)
parentcd65718712469ad844467250e8fad20a5838baae (diff)
Merge branch 'perf/urgent' into perf/core
Conflicts: tools/perf/builtin-record.c tools/perf/builtin-top.c tools/perf/util/hist.h
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c73
1 files changed, 51 insertions, 22 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index ab8d15e6e8cc..8b45fcead5f6 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -678,21 +678,12 @@ static int get_stack_size(char *str, unsigned long *_size)
678} 678}
679#endif /* HAVE_LIBUNWIND_SUPPORT */ 679#endif /* HAVE_LIBUNWIND_SUPPORT */
680 680
681int record_parse_callchain_opt(const struct option *opt, 681int record_parse_callchain(const char *arg, struct perf_record_opts *opts)
682 const char *arg, int unset)
683{ 682{
684 struct perf_record_opts *opts = opt->value;
685 char *tok, *name, *saveptr = NULL; 683 char *tok, *name, *saveptr = NULL;
686 char *buf; 684 char *buf;
687 int ret = -1; 685 int ret = -1;
688 686
689 /* --no-call-graph */
690 if (unset)
691 return 0;
692
693 /* We specified default option if none is provided. */
694 BUG_ON(!arg);
695
696 /* We need buffer that we know we can write to. */ 687 /* We need buffer that we know we can write to. */
697 buf = malloc(strlen(arg) + 1); 688 buf = malloc(strlen(arg) + 1);
698 if (!buf) 689 if (!buf)
@@ -730,13 +721,9 @@ int record_parse_callchain_opt(const struct option *opt,
730 ret = get_stack_size(tok, &size); 721 ret = get_stack_size(tok, &size);
731 opts->stack_dump_size = size; 722 opts->stack_dump_size = size;
732 } 723 }
733
734 if (!ret)
735 pr_debug("callchain: stack dump size %d\n",
736 opts->stack_dump_size);
737#endif /* HAVE_LIBUNWIND_SUPPORT */ 724#endif /* HAVE_LIBUNWIND_SUPPORT */
738 } else { 725 } else {
739 pr_err("callchain: Unknown -g option " 726 pr_err("callchain: Unknown --call-graph option "
740 "value: %s\n", arg); 727 "value: %s\n", arg);
741 break; 728 break;
742 } 729 }
@@ -744,13 +731,52 @@ int record_parse_callchain_opt(const struct option *opt,
744 } while (0); 731 } while (0);
745 732
746 free(buf); 733 free(buf);
734 return ret;
735}
736
737static void callchain_debug(struct perf_record_opts *opts)
738{
739 pr_debug("callchain: type %d\n", opts->call_graph);
747 740
741 if (opts->call_graph == CALLCHAIN_DWARF)
742 pr_debug("callchain: stack dump size %d\n",
743 opts->stack_dump_size);
744}
745
746int record_parse_callchain_opt(const struct option *opt,
747 const char *arg,
748 int unset)
749{
750 struct perf_record_opts *opts = opt->value;
751 int ret;
752
753 /* --no-call-graph */
754 if (unset) {
755 opts->call_graph = CALLCHAIN_NONE;
756 pr_debug("callchain: disabled\n");
757 return 0;
758 }
759
760 ret = record_parse_callchain(arg, opts);
748 if (!ret) 761 if (!ret)
749 pr_debug("callchain: type %d\n", opts->call_graph); 762 callchain_debug(opts);
750 763
751 return ret; 764 return ret;
752} 765}
753 766
767int record_callchain_opt(const struct option *opt,
768 const char *arg __maybe_unused,
769 int unset __maybe_unused)
770{
771 struct perf_record_opts *opts = opt->value;
772
773 if (opts->call_graph == CALLCHAIN_NONE)
774 opts->call_graph = CALLCHAIN_FP;
775
776 callchain_debug(opts);
777 return 0;
778}
779
754static const char * const record_usage[] = { 780static const char * const record_usage[] = {
755 "perf record [<options>] [<command>]", 781 "perf record [<options>] [<command>]",
756 "perf record [<options>] -- <command> [<options>]", 782 "perf record [<options>] -- <command> [<options>]",
@@ -779,12 +805,12 @@ static struct perf_record record = {
779 }, 805 },
780}; 806};
781 807
782#define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " 808#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: "
783 809
784#ifdef HAVE_LIBUNWIND_SUPPORT 810#ifdef HAVE_LIBUNWIND_SUPPORT
785const char record_callchain_help[] = CALLCHAIN_HELP "[fp] dwarf"; 811const char record_callchain_help[] = CALLCHAIN_HELP "fp dwarf";
786#else 812#else
787const char record_callchain_help[] = CALLCHAIN_HELP "[fp]"; 813const char record_callchain_help[] = CALLCHAIN_HELP "fp";
788#endif 814#endif
789 815
790/* 816/*
@@ -825,9 +851,12 @@ const struct option record_options[] = {
825 perf_evlist__parse_mmap_pages), 851 perf_evlist__parse_mmap_pages),
826 OPT_BOOLEAN(0, "group", &record.opts.group, 852 OPT_BOOLEAN(0, "group", &record.opts.group,
827 "put the counters into a counter group"), 853 "put the counters into a counter group"),
828 OPT_CALLBACK_DEFAULT('g', "call-graph", &record.opts, 854 OPT_CALLBACK_NOOPT('g', NULL, &record.opts,
829 "mode[,dump_size]", record_callchain_help, 855 NULL, "enables call-graph recording" ,
830 &record_parse_callchain_opt, "fp"), 856 &record_callchain_opt),
857 OPT_CALLBACK(0, "call-graph", &record.opts,
858 "mode[,dump_size]", record_callchain_help,
859 &record_parse_callchain_opt),
831 OPT_INCR('v', "verbose", &verbose, 860 OPT_INCR('v', "verbose", &verbose,
832 "be more verbose (show counter open errors, etc)"), 861 "be more verbose (show counter open errors, etc)"),
833 OPT_BOOLEAN('q', "quiet", &quiet, "don't print any message"), 862 OPT_BOOLEAN('q', "quiet", &quiet, "don't print any message"),