Skip to content

Commit 2975489

Browse files
committed
perf annotate: Pass a 'map_symbol' in places receiving a pair of 'map' and 'symbol' pointers
We are already passing things like: symbol__annotate(ms->sym, ms->map, ...) So shorten the signature of such functions to receive the 'map_symbol' pointer. This also paves the way to having the 'struct map_groups' pointer in the 'struct map_symbol' so that we can get rid of 'struct map'->groups. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-23yx8v1t41nzpkpi7rdrozww@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent d3a022c commit 2975489

7 files changed

Lines changed: 66 additions & 75 deletions

File tree

‎tools/perf/builtin-annotate.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
301301
struct perf_annotate *ann)
302302
{
303303
if (!ann->use_stdio2)
304-
return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, &ann->opts);
304+
return symbol__tty_annotate(&he->ms, evsel, &ann->opts);
305305

306-
return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, &ann->opts);
306+
return symbol__tty_annotate2(&he->ms, evsel, &ann->opts);
307307
}
308308

309309
static void hists__find_annotations(struct hists *hists,

‎tools/perf/builtin-report.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ static int hists__resort_cb(struct hist_entry *he, void *arg)
680680
if (rep->symbol_ipc && sym && !sym->annotate2) {
681681
struct evsel *evsel = hists_to_evsel(he->hists);
682682

683-
symbol__annotate2(sym, he->ms.map, evsel,
683+
symbol__annotate2(&he->ms, evsel,
684684
&annotation__default_options, NULL);
685685
}
686686

‎tools/perf/builtin-top.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
143143
return err;
144144
}
145145

146-
err = symbol__annotate(sym, map, evsel, 0, &top->annotation_opts, NULL);
146+
err = symbol__annotate(&he->ms, evsel, 0, &top->annotation_opts, NULL);
147147
if (err == 0) {
148148
top->sym_filter_entry = he;
149149
} else {
150150
char msg[BUFSIZ];
151-
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
151+
symbol__strerror_disassemble(&he->ms, err, msg, sizeof(msg));
152152
pr_err("Couldn't annotate %s: %s\n", sym->name, msg);
153153
}
154154

@@ -257,7 +257,7 @@ static void perf_top__show_details(struct perf_top *top)
257257
printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
258258
printf(" Events Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt);
259259

260-
more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, &top->annotation_opts);
260+
more = symbol__annotate_printf(&he->ms, top->sym_evsel, &top->annotation_opts);
261261

262262
if (top->evlist->enabled) {
263263
if (top->zero)

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
410410
struct evsel *evsel,
411411
struct hist_browser_timer *hbt)
412412
{
413-
struct map_symbol *ms = browser->b.priv;
413+
struct map_symbol *ms = browser->b.priv, target_ms;
414414
struct disasm_line *dl = disasm_line(browser->selection);
415415
struct annotation *notes;
416416
char title[SYM_TITLE_MAX_SIZE];
@@ -430,8 +430,10 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
430430
return true;
431431
}
432432

433+
target_ms.map = ms->map;
434+
target_ms.sym = dl->ops.target.sym;
433435
pthread_mutex_unlock(&notes->lock);
434-
symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts);
436+
symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts);
435437
sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
436438
ui_browser__show_title(&browser->b, title);
437439
return true;
@@ -874,7 +876,7 @@ int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
874876
struct hist_browser_timer *hbt,
875877
struct annotation_options *opts)
876878
{
877-
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, opts);
879+
return symbol__tui_annotate(ms, evsel, hbt, opts);
878880
}
879881

880882
int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
@@ -888,24 +890,20 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
888890
return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts);
889891
}
890892

891-
int symbol__tui_annotate(struct symbol *sym, struct map *map,
892-
struct evsel *evsel,
893+
int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
893894
struct hist_browser_timer *hbt,
894895
struct annotation_options *opts)
895896
{
897+
struct symbol *sym = ms->sym;
896898
struct annotation *notes = symbol__annotation(sym);
897-
struct map_symbol ms = {
898-
.map = map,
899-
.sym = sym,
900-
};
901899
struct annotate_browser browser = {
902900
.b = {
903901
.refresh = annotate_browser__refresh,
904902
.seek = ui_browser__list_head_seek,
905903
.write = annotate_browser__write,
906904
.filter = disasm_line__filter,
907905
.extra_title_lines = 1, /* for hists__scnprintf_title() */
908-
.priv = &ms,
906+
.priv = ms,
909907
.use_navkeypressed = true,
910908
},
911909
.opts = opts,
@@ -915,13 +913,13 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
915913
if (sym == NULL)
916914
return -1;
917915

918-
if (map->dso->annotate_warned)
916+
if (ms->map->dso->annotate_warned)
919917
return -1;
920918

921-
err = symbol__annotate2(sym, map, evsel, opts, &browser.arch);
919+
err = symbol__annotate2(ms, evsel, opts, &browser.arch);
922920
if (err) {
923921
char msg[BUFSIZ];
924-
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
922+
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
925923
ui__error("Couldn't annotate %s:\n%s", sym->name, msg);
926924
goto out_free_offsets;
927925
}

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,
5454
return ret;
5555
}
5656

57-
static int perf_gtk__get_offset(char *buf, size_t size, struct symbol *sym,
58-
struct map *map, struct disasm_line *dl)
57+
static int perf_gtk__get_offset(char *buf, size_t size, struct map_symbol *ms,
58+
struct disasm_line *dl)
5959
{
60-
u64 start = map__rip_2objdump(map, sym->start);
60+
u64 start = map__rip_2objdump(ms->map, ms->sym->start);
6161

6262
strcpy(buf, "");
6363

@@ -91,10 +91,11 @@ static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl)
9191
return ret;
9292
}
9393

94-
static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
95-
struct map *map, struct evsel *evsel,
94+
static int perf_gtk__annotate_symbol(GtkWidget *window, struct map_symbol *ms,
95+
struct evsel *evsel,
9696
struct hist_browser_timer *hbt __maybe_unused)
9797
{
98+
struct symbol *sym = ms->sym;
9899
struct disasm_line *pos, *n;
99100
struct annotation *notes;
100101
GType col_types[MAX_ANN_COLS];
@@ -144,7 +145,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
144145

145146
if (ret)
146147
gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1);
147-
if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos))
148+
if (perf_gtk__get_offset(s, sizeof(s), ms, pos))
148149
gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1);
149150
if (perf_gtk__get_line(s, sizeof(s), pos))
150151
gtk_list_store_set(store, &iter, ANN_COL__LINE, s, -1);
@@ -160,23 +161,23 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
160161
return 0;
161162
}
162163

163-
static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
164-
struct evsel *evsel,
164+
static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
165165
struct hist_browser_timer *hbt)
166166
{
167+
struct symbol *sym = ms->sym;
167168
GtkWidget *window;
168169
GtkWidget *notebook;
169170
GtkWidget *scrolled_window;
170171
GtkWidget *tab_label;
171172
int err;
172173

173-
if (map->dso->annotate_warned)
174+
if (ms->map->dso->annotate_warned)
174175
return -1;
175176

176-
err = symbol__annotate(sym, map, evsel, 0, &annotation__default_options, NULL);
177+
err = symbol__annotate(ms, evsel, 0, &annotation__default_options, NULL);
177178
if (err) {
178179
char msg[BUFSIZ];
179-
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
180+
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
180181
ui__error("Couldn't annotate %s: %s\n", sym->name, msg);
181182
return -1;
182183
}
@@ -234,15 +235,15 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
234235
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window,
235236
tab_label);
236237

237-
perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt);
238+
perf_gtk__annotate_symbol(scrolled_window, ms, evsel, hbt);
238239
return 0;
239240
}
240241

241242
int hist_entry__gtk_annotate(struct hist_entry *he,
242243
struct evsel *evsel,
243244
struct hist_browser_timer *hbt)
244245
{
245-
return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt);
246+
return symbol__gtk_annotate(&he->ms, evsel, hbt);
246247
}
247248

248249
void perf_gtk__show_annotations(void)

‎tools/perf/util/annotate.c‎

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,10 +1583,9 @@ static void delete_last_nop(struct symbol *sym)
15831583
}
15841584
}
15851585

1586-
int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map *map,
1587-
int errnum, char *buf, size_t buflen)
1586+
int symbol__strerror_disassemble(struct map_symbol *ms, int errnum, char *buf, size_t buflen)
15881587
{
1589-
struct dso *dso = map->dso;
1588+
struct dso *dso = ms->map->dso;
15901589

15911590
BUG_ON(buflen == 0);
15921591

@@ -2143,11 +2142,10 @@ void symbol__calc_percent(struct symbol *sym, struct evsel *evsel)
21432142
annotation__calc_percent(notes, evsel, symbol__size(sym));
21442143
}
21452144

2146-
int symbol__annotate(struct symbol *sym, struct map *map,
2147-
struct evsel *evsel, size_t privsize,
2148-
struct annotation_options *options,
2149-
struct arch **parch)
2145+
int symbol__annotate(struct map_symbol *ms, struct evsel *evsel, size_t privsize,
2146+
struct annotation_options *options, struct arch **parch)
21502147
{
2148+
struct symbol *sym = ms->sym;
21512149
struct annotation *notes = symbol__annotation(sym);
21522150
struct annotate_args args = {
21532151
.privsize = privsize,
@@ -2177,9 +2175,8 @@ int symbol__annotate(struct symbol *sym, struct map *map,
21772175
}
21782176
}
21792177

2180-
args.ms.map = map;
2181-
args.ms.sym = sym;
2182-
notes->start = map__rip_2objdump(map, sym->start);
2178+
args.ms = *ms;
2179+
notes->start = map__rip_2objdump(ms->map, sym->start);
21832180

21842181
return symbol__disassemble(sym, &args);
21852182
}
@@ -2335,10 +2332,11 @@ static int annotated_source__addr_fmt_width(struct list_head *lines, u64 start)
23352332
return 0;
23362333
}
23372334

2338-
int symbol__annotate_printf(struct symbol *sym, struct map *map,
2339-
struct evsel *evsel,
2335+
int symbol__annotate_printf(struct map_symbol *ms, struct evsel *evsel,
23402336
struct annotation_options *opts)
23412337
{
2338+
struct map *map = ms->map;
2339+
struct symbol *sym = ms->sym;
23422340
struct dso *dso = map->dso;
23432341
char *filename;
23442342
const char *d_filename;
@@ -2742,30 +2740,29 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map,
27422740
resort_source_line(root, &tmp_root);
27432741
}
27442742

2745-
static void symbol__calc_lines(struct symbol *sym, struct map *map,
2746-
struct rb_root *root,
2743+
static void symbol__calc_lines(struct map_symbol *ms, struct rb_root *root,
27472744
struct annotation_options *opts)
27482745
{
2749-
struct annotation *notes = symbol__annotation(sym);
2746+
struct annotation *notes = symbol__annotation(ms->sym);
27502747

2751-
annotation__calc_lines(notes, map, root, opts);
2748+
annotation__calc_lines(notes, ms->map, root, opts);
27522749
}
27532750

2754-
int symbol__tty_annotate2(struct symbol *sym, struct map *map,
2755-
struct evsel *evsel,
2751+
int symbol__tty_annotate2(struct map_symbol *ms, struct evsel *evsel,
27562752
struct annotation_options *opts)
27572753
{
2758-
struct dso *dso = map->dso;
2754+
struct dso *dso = ms->map->dso;
2755+
struct symbol *sym = ms->sym;
27592756
struct rb_root source_line = RB_ROOT;
27602757
struct hists *hists = evsel__hists(evsel);
27612758
char buf[1024];
27622759

2763-
if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0)
2760+
if (symbol__annotate2(ms, evsel, opts, NULL) < 0)
27642761
return -1;
27652762

27662763
if (opts->print_lines) {
27672764
srcline_full_filename = opts->full_path;
2768-
symbol__calc_lines(sym, map, &source_line, opts);
2765+
symbol__calc_lines(ms, &source_line, opts);
27692766
print_summary(&source_line, dso->long_name);
27702767
}
27712768

@@ -2779,25 +2776,25 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map,
27792776
return 0;
27802777
}
27812778

2782-
int symbol__tty_annotate(struct symbol *sym, struct map *map,
2783-
struct evsel *evsel,
2779+
int symbol__tty_annotate(struct map_symbol *ms, struct evsel *evsel,
27842780
struct annotation_options *opts)
27852781
{
2786-
struct dso *dso = map->dso;
2782+
struct dso *dso = ms->map->dso;
2783+
struct symbol *sym = ms->sym;
27872784
struct rb_root source_line = RB_ROOT;
27882785

2789-
if (symbol__annotate(sym, map, evsel, 0, opts, NULL) < 0)
2786+
if (symbol__annotate(ms, evsel, 0, opts, NULL) < 0)
27902787
return -1;
27912788

27922789
symbol__calc_percent(sym, evsel);
27932790

27942791
if (opts->print_lines) {
27952792
srcline_full_filename = opts->full_path;
2796-
symbol__calc_lines(sym, map, &source_line, opts);
2793+
symbol__calc_lines(ms, &source_line, opts);
27972794
print_summary(&source_line, dso->long_name);
27982795
}
27992796

2800-
symbol__annotate_printf(sym, map, evsel, opts);
2797+
symbol__annotate_printf(ms, evsel, opts);
28012798

28022799
annotated_source__purge(symbol__annotation(sym)->src);
28032800

@@ -3051,9 +3048,10 @@ void annotation_line__write(struct annotation_line *al, struct annotation *notes
30513048
wops->write_graph);
30523049
}
30533050

3054-
int symbol__annotate2(struct symbol *sym, struct map *map, struct evsel *evsel,
3051+
int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,
30553052
struct annotation_options *options, struct arch **parch)
30563053
{
3054+
struct symbol *sym = ms->sym;
30573055
struct annotation *notes = symbol__annotation(sym);
30583056
size_t size = symbol__size(sym);
30593057
int nr_pcnt = 1, err;
@@ -3065,7 +3063,7 @@ int symbol__annotate2(struct symbol *sym, struct map *map, struct evsel *evsel,
30653063
if (perf_evsel__is_group_event(evsel))
30663064
nr_pcnt = evsel->core.nr_members;
30673065

3068-
err = symbol__annotate(sym, map, evsel, 0, options, parch);
3066+
err = symbol__annotate(ms, evsel, 0, options, parch);
30693067
if (err)
30703068
goto out_free_offsets;
30713069

0 commit comments

Comments
 (0)