aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 21:06:30 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 21:06:30 -0400
commitc323cf0400c1fed853738e6d81e83c6ac7ff5105 (patch)
treed66f12ac74bf798ca9e7a9b52b29c11ff890f353
parent8dc7c651dd7d95b548adef8cd56908392d3ba432 (diff)
perf annotate browser: Read perf config file for settings
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>
-rw-r--r--tools/perf/Documentation/perfconfig.example8
-rw-r--r--tools/perf/ui/browser.c2
-rw-r--r--tools/perf/ui/browser.h1
-rw-r--r--tools/perf/ui/browsers/annotate.c49
4 files changed, 60 insertions, 0 deletions
diff --git a/tools/perf/Documentation/perfconfig.example b/tools/perf/Documentation/perfconfig.example
index 42c6fd2ae85d..767ea2436e1c 100644
--- a/tools/perf/Documentation/perfconfig.example
+++ b/tools/perf/Documentation/perfconfig.example
@@ -19,3 +19,11 @@
19 19
20 # Default, disable using /dev/null 20 # Default, disable using /dev/null
21 dir = /root/.debug 21 dir = /root/.debug
22
23[annotate]
24
25 # Defaults
26 hide_src_code = false
27 use_offset = true
28 jump_arrows = true
29 show_nr_jumps = false
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index cde4d0f0ddb9..c3a769ad90c5 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -708,4 +708,6 @@ void ui_browser__init(void)
708 struct ui_browser__colorset *c = &ui_browser__colorsets[i++]; 708 struct ui_browser__colorset *c = &ui_browser__colorsets[i++];
709 sltt_set_color(c->colorset, c->name, c->fg, c->bg); 709 sltt_set_color(c->colorset, c->name, c->fg, c->bg);
710 } 710 }
711
712 annotate_browser__init();
711} 713}
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index dd96d8229902..af70314605e5 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -69,4 +69,5 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
69unsigned int ui_browser__list_head_refresh(struct ui_browser *self); 69unsigned int ui_browser__list_head_refresh(struct ui_browser *self);
70 70
71void ui_browser__init(void); 71void ui_browser__init(void);
72void annotate_browser__init(void);
72#endif /* _PERF_UI_BROWSER_H_ */ 73#endif /* _PERF_UI_BROWSER_H_ */
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 02afa036dfa9..77b5b1280834 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -900,3 +900,52 @@ out_free_offsets:
900 free(browser.offsets); 900 free(browser.offsets);
901 return ret; 901 return ret;
902} 902}
903
904#define ANNOTATE_CFG(n) \
905 { .name = #n, .value = &annotate_browser__opts.n, }
906
907/*
908 * Keep the entries sorted, they are bsearch'ed
909 */
910static struct annotate__config {
911 const char *name;
912 bool *value;
913} annotate__configs[] = {
914 ANNOTATE_CFG(hide_src_code),
915 ANNOTATE_CFG(jump_arrows),
916 ANNOTATE_CFG(show_nr_jumps),
917 ANNOTATE_CFG(use_offset),
918};
919
920#undef ANNOTATE_CFG
921
922static int annotate_config__cmp(const void *name, const void *cfgp)
923{
924 const struct annotate__config *cfg = cfgp;
925
926 return strcmp(name, cfg->name);
927}
928
929static int annotate__config(const char *var, const char *value, void *data __used)
930{
931 struct annotate__config *cfg;
932 const char *name;
933
934 if (prefixcmp(var, "annotate.") != 0)
935 return 0;
936
937 name = var + 9;
938 cfg = bsearch(name, annotate__configs, ARRAY_SIZE(annotate__configs),
939 sizeof(struct annotate__config), annotate_config__cmp);
940
941 if (cfg == NULL)
942 return -1;
943
944 *cfg->value = perf_config_bool(name, value);
945 return 0;
946}
947
948void annotate_browser__init(void)
949{
950 perf_config(annotate__config, NULL);
951}