Skip to content

Commit

Permalink
perf annotate browser: Read perf config file for settings
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
acmel committed May 30, 2012
1 parent 8dc7c65 commit c323cf0
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/perf/Documentation/perfconfig.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@

# Default, disable using /dev/null
dir = /root/.debug

[annotate]

# Defaults
hide_src_code = false
use_offset = true
jump_arrows = true
show_nr_jumps = false
2 changes: 2 additions & 0 deletions tools/perf/ui/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions tools/perf/ui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
49 changes: 49 additions & 0 deletions tools/perf/ui/browsers/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,3 +900,52 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
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);
}

0 comments on commit c323cf0

Please sign in to comment.