perf annotate browser: Read perf config file for settings
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 30 May 2012 01:06:30 +0000 (22:06 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 30 May 2012 01:06:30 +0000 (22:06 -0300)
The defaults are:

[annotate]

hide_src_code = false
use_offset = true
jump_arrows = true
show_nr_jumps = false

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-q4egci70rjgxh7bogbbfpcyf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perfconfig.example
tools/perf/ui/browser.c
tools/perf/ui/browser.h
tools/perf/ui/browsers/annotate.c

index 42c6fd2ae85d19ac31fa5f0c191dfcf776ca60e9..767ea2436e1cd841a762ee8cdb039ba80a7120b3 100644 (file)
 
        # Default, disable using /dev/null
        dir = /root/.debug
+
+[annotate]
+
+       # Defaults
+       hide_src_code = false
+       use_offset = true
+       jump_arrows = true
+       show_nr_jumps = false
index cde4d0f0ddb99c8de13e581d1595ce948a7afe85..c3a769ad90c52a599fce565f6e127e1843410e98 100644 (file)
@@ -708,4 +708,6 @@ void ui_browser__init(void)
                struct ui_browser__colorset *c = &ui_browser__colorsets[i++];
                sltt_set_color(c->colorset, c->name, c->fg, c->bg);
        }
+
+       annotate_browser__init();
 }
index dd96d82299022c0bb67924752177d3e6c2eaa096..af70314605e54e2468fe774822cdeecd2945cc7c 100644 (file)
@@ -69,4 +69,5 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
 unsigned int ui_browser__list_head_refresh(struct ui_browser *self);
 
 void ui_browser__init(void);
+void annotate_browser__init(void);
 #endif /* _PERF_UI_BROWSER_H_ */
index 02afa036dfa9c411a0744a99fd01ab458ad25779..77b5b12808349b5ebf3f9c59869d1c4b7772f859 100644 (file)
@@ -900,3 +900,52 @@ out_free_offsets:
        free(browser.offsets);
        return ret;
 }
+
+#define ANNOTATE_CFG(n) \
+       { .name = #n, .value = &annotate_browser__opts.n, }
+       
+/*
+ * Keep the entries sorted, they are bsearch'ed
+ */
+static struct annotate__config {
+       const char *name;
+       bool *value;
+} annotate__configs[] = {
+       ANNOTATE_CFG(hide_src_code),
+       ANNOTATE_CFG(jump_arrows),
+       ANNOTATE_CFG(show_nr_jumps),
+       ANNOTATE_CFG(use_offset),
+};
+
+#undef ANNOTATE_CFG
+
+static int annotate_config__cmp(const void *name, const void *cfgp)
+{
+       const struct annotate__config *cfg = cfgp;
+
+       return strcmp(name, cfg->name);
+}
+
+static int annotate__config(const char *var, const char *value, void *data __used)
+{
+       struct annotate__config *cfg;
+       const char *name;
+
+       if (prefixcmp(var, "annotate.") != 0)
+               return 0;
+
+       name = var + 9;
+       cfg = bsearch(name, annotate__configs, ARRAY_SIZE(annotate__configs),
+                     sizeof(struct annotate__config), annotate_config__cmp);
+
+       if (cfg == NULL)
+               return -1;
+
+       *cfg->value = perf_config_bool(name, value);
+       return 0;
+}
+
+void annotate_browser__init(void)
+{
+       perf_config(annotate__config, NULL);
+}