aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2014-06-08 02:24:07 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-06-08 02:24:07 -0400
commita292241cccb7e20e8b997a9a44177e7c98141859 (patch)
treea0b0bb95e7dce3233a2d8b203f9e326cdec7a00e /tools/perf/builtin-record.c
parentd49cb7aeebb974713f9f7ab2991352d3050b095b (diff)
parent68807a0c2015cb40df4869e16651f0ce5cc14d52 (diff)
Merge branch 'next' into for-linus
Prepare input updates for 3.16.
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index af47531b82ec..8ce62ef7f6c3 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -374,7 +374,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
374 374
375 session = perf_session__new(file, false, NULL); 375 session = perf_session__new(file, false, NULL);
376 if (session == NULL) { 376 if (session == NULL) {
377 pr_err("Not enough memory for reading perf file header\n"); 377 pr_err("Perf session creation failed.\n");
378 return -1; 378 return -1;
379 } 379 }
380 380
@@ -649,7 +649,7 @@ error:
649 return ret; 649 return ret;
650} 650}
651 651
652#ifdef HAVE_LIBUNWIND_SUPPORT 652#ifdef HAVE_DWARF_UNWIND_SUPPORT
653static int get_stack_size(char *str, unsigned long *_size) 653static int get_stack_size(char *str, unsigned long *_size)
654{ 654{
655 char *endptr; 655 char *endptr;
@@ -675,7 +675,7 @@ static int get_stack_size(char *str, unsigned long *_size)
675 max_size, str); 675 max_size, str);
676 return -1; 676 return -1;
677} 677}
678#endif /* HAVE_LIBUNWIND_SUPPORT */ 678#endif /* HAVE_DWARF_UNWIND_SUPPORT */
679 679
680int record_parse_callchain(const char *arg, struct record_opts *opts) 680int record_parse_callchain(const char *arg, struct record_opts *opts)
681{ 681{
@@ -704,7 +704,7 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)
704 "needed for -g fp\n"); 704 "needed for -g fp\n");
705 break; 705 break;
706 706
707#ifdef HAVE_LIBUNWIND_SUPPORT 707#ifdef HAVE_DWARF_UNWIND_SUPPORT
708 /* Dwarf style */ 708 /* Dwarf style */
709 } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { 709 } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
710 const unsigned long default_stack_dump_size = 8192; 710 const unsigned long default_stack_dump_size = 8192;
@@ -720,7 +720,7 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)
720 ret = get_stack_size(tok, &size); 720 ret = get_stack_size(tok, &size);
721 opts->stack_dump_size = size; 721 opts->stack_dump_size = size;
722 } 722 }
723#endif /* HAVE_LIBUNWIND_SUPPORT */ 723#endif /* HAVE_DWARF_UNWIND_SUPPORT */
724 } else { 724 } else {
725 pr_err("callchain: Unknown --call-graph option " 725 pr_err("callchain: Unknown --call-graph option "
726 "value: %s\n", arg); 726 "value: %s\n", arg);
@@ -735,7 +735,9 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)
735 735
736static void callchain_debug(struct record_opts *opts) 736static void callchain_debug(struct record_opts *opts)
737{ 737{
738 pr_debug("callchain: type %d\n", opts->call_graph); 738 static const char *str[CALLCHAIN_MAX] = { "NONE", "FP", "DWARF" };
739
740 pr_debug("callchain: type %s\n", str[opts->call_graph]);
739 741
740 if (opts->call_graph == CALLCHAIN_DWARF) 742 if (opts->call_graph == CALLCHAIN_DWARF)
741 pr_debug("callchain: stack dump size %d\n", 743 pr_debug("callchain: stack dump size %d\n",
@@ -749,6 +751,8 @@ int record_parse_callchain_opt(const struct option *opt,
749 struct record_opts *opts = opt->value; 751 struct record_opts *opts = opt->value;
750 int ret; 752 int ret;
751 753
754 opts->call_graph_enabled = !unset;
755
752 /* --no-call-graph */ 756 /* --no-call-graph */
753 if (unset) { 757 if (unset) {
754 opts->call_graph = CALLCHAIN_NONE; 758 opts->call_graph = CALLCHAIN_NONE;
@@ -769,6 +773,8 @@ int record_callchain_opt(const struct option *opt,
769{ 773{
770 struct record_opts *opts = opt->value; 774 struct record_opts *opts = opt->value;
771 775
776 opts->call_graph_enabled = !unset;
777
772 if (opts->call_graph == CALLCHAIN_NONE) 778 if (opts->call_graph == CALLCHAIN_NONE)
773 opts->call_graph = CALLCHAIN_FP; 779 opts->call_graph = CALLCHAIN_FP;
774 780
@@ -776,6 +782,16 @@ int record_callchain_opt(const struct option *opt,
776 return 0; 782 return 0;
777} 783}
778 784
785static int perf_record_config(const char *var, const char *value, void *cb)
786{
787 struct record *rec = cb;
788
789 if (!strcmp(var, "record.call-graph"))
790 return record_parse_callchain(value, &rec->opts);
791
792 return perf_default_config(var, value, cb);
793}
794
779static const char * const record_usage[] = { 795static const char * const record_usage[] = {
780 "perf record [<options>] [<command>]", 796 "perf record [<options>] [<command>]",
781 "perf record [<options>] -- <command> [<options>]", 797 "perf record [<options>] -- <command> [<options>]",
@@ -807,7 +823,7 @@ static struct record record = {
807 823
808#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: " 824#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: "
809 825
810#ifdef HAVE_LIBUNWIND_SUPPORT 826#ifdef HAVE_DWARF_UNWIND_SUPPORT
811const char record_callchain_help[] = CALLCHAIN_HELP "fp dwarf"; 827const char record_callchain_help[] = CALLCHAIN_HELP "fp dwarf";
812#else 828#else
813const char record_callchain_help[] = CALLCHAIN_HELP "fp"; 829const char record_callchain_help[] = CALLCHAIN_HELP "fp";
@@ -907,6 +923,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
907 if (rec->evlist == NULL) 923 if (rec->evlist == NULL)
908 return -ENOMEM; 924 return -ENOMEM;
909 925
926 perf_config(perf_record_config, rec);
927
910 argc = parse_options(argc, argv, record_options, record_usage, 928 argc = parse_options(argc, argv, record_options, record_usage,
911 PARSE_OPT_STOP_AT_NON_OPTION); 929 PARSE_OPT_STOP_AT_NON_OPTION);
912 if (!argc && target__none(&rec->opts.target)) 930 if (!argc && target__none(&rec->opts.target))