Skip to content

Commit cd0cccb

Browse files
committed
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 <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-5daawc40zhl6gcs600com1ua@git.kernel.org [ Merged fix for NO_SLANG=1 build provided by Jiri Olsa ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent a47e843 commit cd0cccb

8 files changed

Lines changed: 57 additions & 28 deletions

File tree

‎tools/perf/builtin-annotate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static void hists__find_annotations(struct hists *hists,
341341
/* skip missing symbols */
342342
nd = rb_next(nd);
343343
} else if (use_browser == 1) {
344-
key = hist_entry__tui_annotate(he, evsel, NULL);
344+
key = hist_entry__tui_annotate(he, evsel, NULL, &ann->opts);
345345

346346
switch (key) {
347347
case -1:

‎tools/perf/builtin-report.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ static int report__browse_hists(struct report *rep)
561561
ret = perf_evlist__tui_browse_hists(evlist, help, NULL,
562562
rep->min_percent,
563563
&session->header.env,
564-
true);
564+
true, &rep->annotation_opts);
565565
/*
566566
* Usually "ret" is the last pressed key, and we only
567567
* care if the key notifies us to switch data file.

‎tools/perf/builtin-top.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ static void *display_thread_tui(void *arg)
606606
perf_evlist__tui_browse_hists(top->evlist, help, &hbt,
607607
top->min_percent,
608608
&top->session->header.env,
609-
!top->record_opts.overwrite);
609+
!top->record_opts.overwrite,
610+
&top->annotation_opts);
610611

611612
done = 1;
612613
return NULL;

‎tools/perf/ui/browsers/annotate.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct annotate_browser {
2929
struct rb_node *curr_hot;
3030
struct annotation_line *selection;
3131
struct arch *arch;
32+
struct annotation_options *opts;
3233
bool searching_backwards;
3334
char search_bf[128];
3435
};
@@ -418,7 +419,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
418419
}
419420

420421
pthread_mutex_unlock(&notes->lock);
421-
symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt);
422+
symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts);
422423
sym_title(ms->sym, ms->map, title, sizeof(title));
423424
ui_browser__show_title(&browser->b, title);
424425
return true;
@@ -817,24 +818,27 @@ static int annotate_browser__run(struct annotate_browser *browser,
817818
}
818819

819820
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
820-
struct hist_browser_timer *hbt)
821+
struct hist_browser_timer *hbt,
822+
struct annotation_options *opts)
821823
{
822-
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
824+
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, opts);
823825
}
824826

825827
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
826-
struct hist_browser_timer *hbt)
828+
struct hist_browser_timer *hbt,
829+
struct annotation_options *opts)
827830
{
828831
/* reset abort key so that it can get Ctrl-C as a key */
829832
SLang_reset_tty();
830833
SLang_init_tty(0, 0, 0);
831834

832-
return map_symbol__tui_annotate(&he->ms, evsel, hbt);
835+
return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts);
833836
}
834837

835838
int symbol__tui_annotate(struct symbol *sym, struct map *map,
836839
struct perf_evsel *evsel,
837-
struct hist_browser_timer *hbt)
840+
struct hist_browser_timer *hbt,
841+
struct annotation_options *opts)
838842
{
839843
struct annotation *notes = symbol__annotation(sym);
840844
struct map_symbol ms = {
@@ -851,6 +855,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
851855
.priv = &ms,
852856
.use_navkeypressed = true,
853857
},
858+
.opts = opts,
854859
};
855860
int ret = -1, err;
856861

@@ -860,7 +865,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
860865
if (map->dso->annotate_warned)
861866
return -1;
862867

863-
err = symbol__annotate2(sym, map, evsel, &annotation__default_options, &browser.arch);
868+
err = symbol__annotate2(sym, map, evsel, opts, &browser.arch);
864869
if (err) {
865870
char msg[BUFSIZ];
866871
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));

‎tools/perf/ui/browsers/hists.c‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,14 +2175,16 @@ struct hist_browser *hist_browser__new(struct hists *hists)
21752175
static struct hist_browser *
21762176
perf_evsel_browser__new(struct perf_evsel *evsel,
21772177
struct hist_browser_timer *hbt,
2178-
struct perf_env *env)
2178+
struct perf_env *env,
2179+
struct annotation_options *annotation_opts)
21792180
{
21802181
struct hist_browser *browser = hist_browser__new(evsel__hists(evsel));
21812182

21822183
if (browser) {
21832184
browser->hbt = hbt;
21842185
browser->env = env;
21852186
browser->title = hists_browser__scnprintf_title;
2187+
browser->annotation_opts = annotation_opts;
21862188
}
21872189
return browser;
21882190
}
@@ -2344,7 +2346,8 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)
23442346
return 0;
23452347

23462348
evsel = hists_to_evsel(browser->hists);
2347-
err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt);
2349+
err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt,
2350+
browser->annotation_opts);
23482351
he = hist_browser__selected_entry(browser);
23492352
/*
23502353
* 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,
26972700
struct hist_browser_timer *hbt,
26982701
float min_pcnt,
26992702
struct perf_env *env,
2700-
bool warn_lost_event)
2703+
bool warn_lost_event,
2704+
struct annotation_options *annotation_opts)
27012705
{
27022706
struct hists *hists = evsel__hists(evsel);
2703-
struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env);
2707+
struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env, annotation_opts);
27042708
struct branch_info *bi;
27052709
#define MAX_OPTIONS 16
27062710
char *options[MAX_OPTIONS];
@@ -3062,6 +3066,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
30623066
struct perf_evsel_menu {
30633067
struct ui_browser b;
30643068
struct perf_evsel *selection;
3069+
struct annotation_options *annotation_opts;
30653070
bool lost_events, lost_events_warned;
30663071
float min_pcnt;
30673072
struct perf_env *env;
@@ -3163,7 +3168,8 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu,
31633168
true, hbt,
31643169
menu->min_pcnt,
31653170
menu->env,
3166-
warn_lost_event);
3171+
warn_lost_event,
3172+
menu->annotation_opts);
31673173
ui_browser__show_title(&menu->b, title);
31683174
switch (key) {
31693175
case K_TAB:
@@ -3222,7 +3228,8 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
32223228
struct hist_browser_timer *hbt,
32233229
float min_pcnt,
32243230
struct perf_env *env,
3225-
bool warn_lost_event)
3231+
bool warn_lost_event,
3232+
struct annotation_options *annotation_opts)
32263233
{
32273234
struct perf_evsel *pos;
32283235
struct perf_evsel_menu menu = {
@@ -3237,6 +3244,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
32373244
},
32383245
.min_pcnt = min_pcnt,
32393246
.env = env,
3247+
.annotation_opts = annotation_opts,
32403248
};
32413249

32423250
ui_helpline__push("Press ESC to exit");
@@ -3257,7 +3265,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
32573265
struct hist_browser_timer *hbt,
32583266
float min_pcnt,
32593267
struct perf_env *env,
3260-
bool warn_lost_event)
3268+
bool warn_lost_event,
3269+
struct annotation_options *annotation_opts)
32613270
{
32623271
int nr_entries = evlist->nr_entries;
32633272

@@ -3267,7 +3276,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
32673276

32683277
return perf_evsel__hists_browse(first, nr_entries, help,
32693278
false, hbt, min_pcnt,
3270-
env, warn_lost_event);
3279+
env, warn_lost_event,
3280+
annotation_opts);
32713281
}
32723282

32733283
if (symbol_conf.event_group) {
@@ -3285,5 +3295,6 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
32853295

32863296
return __perf_evlist__tui_browse_hists(evlist, nr_entries, help,
32873297
hbt, min_pcnt, env,
3288-
warn_lost_event);
3298+
warn_lost_event,
3299+
annotation_opts);
32893300
}

‎tools/perf/ui/browsers/hists.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "ui/browser.h"
66

7+
struct annotation_options;
8+
79
struct hist_browser {
810
struct ui_browser b;
911
struct hists *hists;
@@ -12,6 +14,7 @@ struct hist_browser {
1214
struct hist_browser_timer *hbt;
1315
struct pstack *pstack;
1416
struct perf_env *env;
17+
struct annotation_options *annotation_opts;
1518
int print_seq;
1619
bool show_dso;
1720
bool show_headers;

‎tools/perf/util/annotate.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,14 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map,
357357
#ifdef HAVE_SLANG_SUPPORT
358358
int symbol__tui_annotate(struct symbol *sym, struct map *map,
359359
struct perf_evsel *evsel,
360-
struct hist_browser_timer *hbt);
360+
struct hist_browser_timer *hbt,
361+
struct annotation_options *opts);
361362
#else
362363
static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
363364
struct map *map __maybe_unused,
364365
struct perf_evsel *evsel __maybe_unused,
365-
struct hist_browser_timer *hbt
366-
__maybe_unused)
366+
struct hist_browser_timer *hbt __maybe_unused,
367+
struct annotation_options *opts __maybe_unused)
367368
{
368369
return 0;
369370
}

‎tools/perf/util/hist.h‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,19 +419,24 @@ struct hist_browser_timer {
419419
int refresh;
420420
};
421421

422+
struct annotation_options;
423+
422424
#ifdef HAVE_SLANG_SUPPORT
423425
#include "../ui/keysyms.h"
424426
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
425-
struct hist_browser_timer *hbt);
427+
struct hist_browser_timer *hbt,
428+
struct annotation_options *annotation_opts);
426429

427430
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
428-
struct hist_browser_timer *hbt);
431+
struct hist_browser_timer *hbt,
432+
struct annotation_options *annotation_opts);
429433

430434
int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
431435
struct hist_browser_timer *hbt,
432436
float min_pcnt,
433437
struct perf_env *env,
434-
bool warn_lost_event);
438+
bool warn_lost_event,
439+
struct annotation_options *annotation_options);
435440
int script_browse(const char *script_opt);
436441
#else
437442
static inline
@@ -440,20 +445,23 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
440445
struct hist_browser_timer *hbt __maybe_unused,
441446
float min_pcnt __maybe_unused,
442447
struct perf_env *env __maybe_unused,
443-
bool warn_lost_event __maybe_unused)
448+
bool warn_lost_event __maybe_unused,
449+
struct annotation_options *annotation_options __maybe_unused)
444450
{
445451
return 0;
446452
}
447453
static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
448454
struct perf_evsel *evsel __maybe_unused,
449-
struct hist_browser_timer *hbt __maybe_unused)
455+
struct hist_browser_timer *hbt __maybe_unused,
456+
struct annotation_options *annotation_options __maybe_unused)
450457
{
451458
return 0;
452459
}
453460

454461
static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
455462
struct perf_evsel *evsel __maybe_unused,
456-
struct hist_browser_timer *hbt __maybe_unused)
463+
struct hist_browser_timer *hbt __maybe_unused,
464+
struct annotation_options *annotation_opts __maybe_unused)
457465
{
458466
return 0;
459467
}

0 commit comments

Comments
 (0)