Skip to content

Commit c323cf0

Browse files
committed
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 <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 8dc7c65 commit c323cf0

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

tools/perf/Documentation/perfconfig.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@
1919

2020
# Default, disable using /dev/null
2121
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

tools/perf/ui/browser.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,4 +708,6 @@ void ui_browser__init(void)
708708
struct ui_browser__colorset *c = &ui_browser__colorsets[i++];
709709
sltt_set_color(c->colorset, c->name, c->fg, c->bg);
710710
}
711+
712+
annotate_browser__init();
711713
}

tools/perf/ui/browser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
6969
unsigned int ui_browser__list_head_refresh(struct ui_browser *self);
7070

7171
void ui_browser__init(void);
72+
void annotate_browser__init(void);
7273
#endif /* _PERF_UI_BROWSER_H_ */

tools/perf/ui/browsers/annotate.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,52 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
900900
free(browser.offsets);
901901
return ret;
902902
}
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+
}

0 commit comments

Comments
 (0)