perf hists browser: Pass annotation_options from tool to browser
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: cd0cccbae9f654479a1c5abcd876c7fc4356b882 Gitweb: https://git.kernel.org/tip/cd0cccbae9f654479a1c5abcd876c7fc4356b882 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 28 May 2018 13:54:59 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 4 Jun 2018 10:28:53 -0300
perf hists browser: Pass annotation_options from tool to browser
So that things changed in the command line may percolate to the browser code without using globals.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
[ Merged fix for NO_SLANG=1 build provided by Jiri Olsa ]
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 3 ++- tools/perf/ui/browsers/annotate.c | 19 ++++++++++++------- tools/perf/ui/browsers/hists.c | 29 ++++++++++++++++++++--------- tools/perf/ui/browsers/hists.h | 3 +++ tools/perf/util/annotate.h | 7 ++++--- tools/perf/util/hist.h | 20 ++++++++++++++------ 8 files changed, 57 insertions(+), 28 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -341,7 +341,7 @@ find_next:/* skip missing symbols */ nd =rb_next (nd); }else if (use_browser ==1 ) { - key =hist_entry__tui_annotate (he, evsel,NULL ); + key =hist_entry__tui_annotate (he, evsel,NULL , &ann->opts);switch (key) {case -1 :
tools/perf/builtin-report.c +1 -1
@@ -561,7 +561,7 @@ static int report__browse_hists(struct report *rep) ret =perf_evlist__tui_browse_hists (evlist, help,NULL , rep->min_percent, &session->header.env, - true); + true, &rep->annotation_opts);/* * Usually "ret" is the last pressed key, and we only * care if the key notifies us to switch data file.
tools/perf/builtin-top.c +2 -1
@@ -606,7 +606,8 @@ static void *display_thread_tui(void *arg)perf_evlist__tui_browse_hists (top->evlist, help, &hbt, top->min_percent, &top->session->header.env, - !top->record_opts.overwrite); + !top->record_opts.overwrite, + &top->annotation_opts); done =1 ;return NULL ;
tools/perf/ui/browsers/annotate.c +12 -7
@@ -29,6 +29,7 @@ struct annotate_browser {struct rb_node *curr_hot;struct annotation_line *selection;struct arch *arch; +struct annotation_options *opts;bool searching_backwards;char search_bf[128 ]; };
@@ -418,7 +419,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, }pthread_mutex_unlock (¬es->lock); -symbol__tui_annotate (dl->ops.target.sym, ms->map, evsel, hbt); +symbol__tui_annotate (dl->ops.target.sym, ms->map, evsel, hbt, browser->opts);sym_title (ms->sym, ms->map, title,sizeof (title));ui_browser__show_title (&browser->b, title);return true;
@@ -817,24 +818,27 @@ out: }int map_symbol__tui_annotate (struct map_symbol *ms,struct perf_evsel *evsel, -struct hist_browser_timer *hbt) +struct hist_browser_timer *hbt, +struct annotation_options *opts) { -return symbol__tui_annotate (ms->sym, ms->map, evsel, hbt); +return symbol__tui_annotate (ms->sym, ms->map, evsel, hbt, opts); }int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel, -struct hist_browser_timer *hbt) +struct hist_browser_timer *hbt, +struct annotation_options *opts) {/* reset abort key so that it can get Ctrl-C as a key */ SLang_reset_tty ();SLang_init_tty (0 ,0 ,0 ); -return map_symbol__tui_annotate (&he->ms, evsel, hbt); +return map_symbol__tui_annotate (&he->ms, evsel, hbt, opts); }int symbol__tui_annotate (struct symbol *sym,struct map *map,struct perf_evsel *evsel, -struct hist_browser_timer *hbt) +struct hist_browser_timer *hbt, +struct annotation_options *opts) {struct annotation *notes =symbol__annotation (sym);struct map_symbol ms = {
@@ -851,6 +855,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, .priv = &ms, .use_navkeypressed = true, }, + .opts = opts, };int ret =-1 , err;
@@ -860,7 +865,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,if (map->dso->annotate_warned)return -1 ; - err =symbol__annotate2 (sym, map, evsel, &annotation__default_options, &browser.arch); + err =symbol__annotate2 (sym, map, evsel, opts, &browser.arch);if (err) {char msg[BUFSIZ ];symbol__strerror_disassemble (sym, map, err, msg,sizeof (msg));
tools/perf/ui/browsers/hists.c +20 -9
@@ -2175,7 +2175,8 @@ struct hist_browser *hist_browser__new(struct hists *hists)static struct hist_browser *perf_evsel_browser__new (struct perf_evsel *evsel,struct hist_browser_timer *hbt, -struct perf_env *env) +struct perf_env *env, +struct annotation_options *annotation_opts) {struct hist_browser *browser =hist_browser__new (evsel__hists (evsel));
@@ -2183,6 +2184,7 @@ perf_evsel_browser__new(struct perf_evsel *evsel, browser->hbt = hbt; browser->env = env; browser->title = hists_browser__scnprintf_title; + browser->annotation_opts = annotation_opts; }return browser; }
@@ -2344,7 +2346,8 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)return 0 ; evsel =hists_to_evsel (browser->hists); - err =map_symbol__tui_annotate (&act->ms, evsel, browser->hbt); + err =map_symbol__tui_annotate (&act->ms, evsel, browser->hbt, + browser->annotation_opts); he =hist_browser__selected_entry (browser);/* * offer option to annotate the other branch source or target
@@ -2697,10 +2700,11 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,struct hist_browser_timer *hbt, float min_pcnt, struct perf_env *env, - bool warn_lost_event) + bool warn_lost_event, + struct annotation_options *annotation_opts) { struct hists *hists = evsel__hists(evsel); -struct hist_browser *browser =perf_evsel_browser__new (evsel, hbt, env); +struct hist_browser *browser =perf_evsel_browser__new (evsel, hbt, env, annotation_opts);struct branch_info *bi;#define MAX_OPTIONS 16char *options[MAX_OPTIONS ];
@@ -3062,6 +3066,7 @@ out:struct perf_evsel_menu {struct ui_browser b;struct perf_evsel *selection; +struct annotation_options *annotation_opts;bool lost_events, lost_events_warned;float min_pcnt;struct perf_env *env;
@@ -3163,7 +3168,8 @@ browse_hists: true, hbt, menu->min_pcnt, menu->env, - warn_lost_event); + warn_lost_event, + menu->annotation_opts);ui_browser__show_title (&menu->b, title);switch (key) {case K_TAB :
@@ -3222,7 +3228,8 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,struct hist_browser_timer *hbt, float min_pcnt, struct perf_env *env, - bool warn_lost_event) + bool warn_lost_event, + struct annotation_options *annotation_opts) { struct perf_evsel *pos; struct perf_evsel_menu menu = {
@@ -3237,6 +3244,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, }, .min_pcnt = min_pcnt, .env = env, + .annotation_opts = annotation_opts, };ui_helpline__push ("Press ESC to exit" );
@@ -3257,7 +3265,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,struct hist_browser_timer *hbt, float min_pcnt, struct perf_env *env, - bool warn_lost_event) + bool warn_lost_event, + struct annotation_options *annotation_opts) { int nr_entries = evlist->nr_entries;
@@ -3267,7 +3276,8 @@ single_entry:return perf_evsel__hists_browse (first, nr_entries, help, false, hbt, min_pcnt, - env, warn_lost_event); + env, warn_lost_event, + annotation_opts); }if (symbol_conf.event_group) {
@@ -3285,5 +3295,6 @@ single_entry:return __perf_evlist__tui_browse_hists (evlist, nr_entries, help, hbt, min_pcnt, env, - warn_lost_event); + warn_lost_event, + annotation_opts); }
tools/perf/ui/browsers/hists.h +3 -0
@@ -4,6 +4,8 @@#include "ui/browser.h" +struct annotation_options ; +struct hist_browser {struct ui_browser b;struct hists *hists;
@@ -12,6 +14,7 @@ struct hist_browser {struct hist_browser_timer *hbt;struct pstack *pstack;struct perf_env *env; +struct annotation_options *annotation_opts;int print_seq;bool show_dso;bool show_headers;
tools/perf/util/annotate.h +4 -3
@@ -357,13 +357,14 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map,#ifdef HAVE_SLANG_SUPPORT int symbol__tui_annotate (struct symbol *sym,struct map *map,struct perf_evsel *evsel, -struct hist_browser_timer *hbt); +struct hist_browser_timer *hbt, +struct annotation_options *opts);#else static inline int symbol__tui_annotate (struct symbol *sym__maybe_unused ,struct map *map__maybe_unused ,struct perf_evsel *evsel__maybe_unused , -struct hist_browser_timer *hbt -__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +struct annotation_options *opts__maybe_unused ) {return 0 ; }
tools/perf/util/hist.h +14 -6
@@ -419,19 +419,24 @@ struct hist_browser_timer {int refresh; }; +struct annotation_options ; +#ifdef HAVE_SLANG_SUPPORT #include "../ui/keysyms.h" int map_symbol__tui_annotate (struct map_symbol *ms,struct perf_evsel *evsel, -struct hist_browser_timer *hbt); +struct hist_browser_timer *hbt, +struct annotation_options *annotation_opts);int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel, -struct hist_browser_timer *hbt); +struct hist_browser_timer *hbt, +struct annotation_options *annotation_opts);int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help,struct hist_browser_timer *hbt,float min_pcnt,struct perf_env *env, -bool warn_lost_event); +bool warn_lost_event, +struct annotation_options *annotation_options);int script_browse (const char *script_opt);#else static inline
@@ -440,20 +445,23 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,struct hist_browser_timer *hbt__maybe_unused , float min_pcnt __maybe_unused, struct perf_env *env __maybe_unused, - bool warn_lost_event __maybe_unused) + bool warn_lost_event __maybe_unused, + struct annotation_options *annotation_options __maybe_unused) { return 0; }static inline int map_symbol__tui_annotate (struct map_symbol *ms__maybe_unused ,struct perf_evsel *evsel__maybe_unused , -struct hist_browser_timer *hbt__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +struct annotation_options *annotation_options__maybe_unused ) {return 0 ; }static inline int hist_entry__tui_annotate (struct hist_entry *he__maybe_unused ,struct perf_evsel *evsel__maybe_unused , -struct hist_browser_timer *hbt__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +struct annotation_options *annotation_opts__maybe_unused ) {return 0 ; }