summaryrefslogtreecommitdiff
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-03-16 20:33:38 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-03-21 18:53:40 +0300
commit7f0b6fde3111aec82487662ccef5a4ebecb93381 (patch)
tree9e5f7fa74e15a4cd42eb68c91d90b678b7c45c0c /tools/perf/util/annotate.c
parentbefd2a38a632b1f27ad652fea67c8cf97ce59409 (diff)
downloadlinux-7f0b6fde3111aec82487662ccef5a4ebecb93381.tar.xz
perf annotate: Move the default annotate options to the library
One more thing that goes from the TUI code to be used more widely, for instance it'll affect the default options used by: perf annotate --stdio2 Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-0nsz0dm0akdbo30vgja2a10e@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 98cf3e5380bc..cfa641bc1df6 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -14,6 +14,7 @@
#include "sort.h"
#include "build-id.h"
#include "color.h"
+#include "config.h"
#include "cache.h"
#include "symbol.h"
#include "debug.h"
@@ -41,6 +42,11 @@
#include "sane_ctype.h"
+struct annotation_options annotation__default_options = {
+ .use_offset = true,
+ .jump_arrows = true,
+};
+
const char *disassembler_style;
const char *objdump_path;
static regex_t file_lineno;
@@ -2500,3 +2506,59 @@ out_free_offsets:
zfree(&notes->offsets);
return -1;
}
+
+#define ANNOTATION__CFG(n) \
+ { .name = #n, .value = &annotation__default_options.n, }
+
+/*
+ * Keep the entries sorted, they are bsearch'ed
+ */
+static struct annotation_config {
+ const char *name;
+ bool *value;
+} annotation__configs[] = {
+ ANNOTATION__CFG(hide_src_code),
+ ANNOTATION__CFG(jump_arrows),
+ ANNOTATION__CFG(show_linenr),
+ ANNOTATION__CFG(show_nr_jumps),
+ ANNOTATION__CFG(show_nr_samples),
+ ANNOTATION__CFG(show_total_period),
+ ANNOTATION__CFG(use_offset),
+};
+
+#undef ANNOTATION__CFG
+
+static int annotation_config__cmp(const void *name, const void *cfgp)
+{
+ const struct annotation_config *cfg = cfgp;
+
+ return strcmp(name, cfg->name);
+}
+
+static int annotation__config(const char *var, const char *value,
+ void *data __maybe_unused)
+{
+ struct annotation_config *cfg;
+ const char *name;
+
+ if (!strstarts(var, "annotate."))
+ return 0;
+
+ name = var + 9;
+ cfg = bsearch(name, annotation__configs, ARRAY_SIZE(annotation__configs),
+ sizeof(struct annotation_config), annotation_config__cmp);
+
+ if (cfg == NULL)
+ pr_debug("%s variable unknown, ignoring...", var);
+ else
+ *cfg->value = perf_config_bool(name, value);
+ return 0;
+}
+
+void annotation_config__init(void)
+{
+ perf_config(annotation__config, NULL);
+
+ annotation__default_options.show_total_period = symbol_conf.show_total_period;
+ annotation__default_options.show_nr_samples = symbol_conf.show_nr_samples;
+}