diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-29 21:06:30 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-29 21:06:30 -0400 |
commit | c323cf0400c1fed853738e6d81e83c6ac7ff5105 (patch) | |
tree | d66f12ac74bf798ca9e7a9b52b29c11ff890f353 /tools/perf/ui/browsers/annotate.c | |
parent | 8dc7c651dd7d95b548adef8cd56908392d3ba432 (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>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 49 |
1 files changed, 49 insertions, 0 deletions
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 | */ | ||
910 | static 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 | |||
922 | static 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 | |||
929 | static 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 | |||
948 | void annotate_browser__init(void) | ||
949 | { | ||
950 | perf_config(annotate__config, NULL); | ||
951 | } | ||