Skip to content

Commit d46a4cd

Browse files
committed
pref tools: Make 'struct addr_map_symbol' contain 'struct map_symbol'
So that we pass that substructure around and with it consolidate lots of functions that receive a (map, symbol) pair and now can receive just a 'struct map_symbol' pointer. This further paves the way to add 'struct map_groups' to 'struct map_symbol' so that we can have all we need for annotation so that we can ditch 'struct map'->groups, i.e. have the map_groups pointer in a more central place, avoiding the pointer in the 'struct map' that have tons of instances. 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-fs90ttd9q12l7989fo7pw81q@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 5f0fef8 commit d46a4cd

10 files changed

Lines changed: 114 additions & 125 deletions

File tree

‎tools/perf/arch/s390/annotate/instructions.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
77
char *endptr, *tok, *name;
88
struct map *map = ms->map;
99
struct addr_map_symbol target = {
10-
.map = map,
10+
.ms = { .map = map, },
1111
};
1212

1313
tok = strchr(ops->raw, ',');
@@ -39,8 +39,8 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
3939
target.addr = map__objdump_2mem(map, ops->target.addr);
4040

4141
if (map_groups__find_ams(map->groups, &target) == 0 &&
42-
map__rip_2objdump(target.map, map->map_ip(target.map, target.addr)) == ops->target.addr)
43-
ops->target.sym = target.sym;
42+
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
43+
ops->target.sym = target.ms.sym;
4444

4545
return 0;
4646
}

‎tools/perf/builtin-annotate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void process_basic_block(struct addr_map_symbol *start,
8383
struct addr_map_symbol *end,
8484
struct branch_flags *flags)
8585
{
86-
struct symbol *sym = start->sym;
86+
struct symbol *sym = start->ms.sym;
8787
struct annotation *notes = sym ? symbol__annotation(sym) : NULL;
8888
struct block_range_iter iter;
8989
struct block_range *entry;

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,16 +2405,15 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)
24052405
static int
24062406
add_annotate_opt(struct hist_browser *browser __maybe_unused,
24072407
struct popup_action *act, char **optstr,
2408-
struct map *map, struct symbol *sym)
2408+
struct map_symbol *ms)
24092409
{
2410-
if (sym == NULL || map->dso->annotate_warned)
2410+
if (ms->sym == NULL || ms->map->dso->annotate_warned)
24112411
return 0;
24122412

2413-
if (asprintf(optstr, "Annotate %s", sym->name) < 0)
2413+
if (asprintf(optstr, "Annotate %s", ms->sym->name) < 0)
24142414
return 0;
24152415

2416-
act->ms.map = map;
2417-
act->ms.sym = sym;
2416+
act->ms = *ms;
24182417
act->fn = do_annotate;
24192418
return 1;
24202419
}
@@ -3115,20 +3114,17 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
31153114
nr_options += add_annotate_opt(browser,
31163115
&actions[nr_options],
31173116
&options[nr_options],
3118-
bi->from.map,
3119-
bi->from.sym);
3120-
if (bi->to.sym != bi->from.sym)
3117+
&bi->from.ms);
3118+
if (bi->to.ms.sym != bi->from.ms.sym)
31213119
nr_options += add_annotate_opt(browser,
31223120
&actions[nr_options],
31233121
&options[nr_options],
3124-
bi->to.map,
3125-
bi->to.sym);
3122+
&bi->to.ms);
31263123
} else {
31273124
nr_options += add_annotate_opt(browser,
31283125
&actions[nr_options],
31293126
&options[nr_options],
3130-
browser->selection->map,
3131-
browser->selection->sym);
3127+
browser->selection);
31323128
}
31333129
skip_annotation:
31343130
nr_options += add_thread_opt(browser, &actions[nr_options],

‎tools/perf/util/annotate.c‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_s
243243
char *endptr, *tok, *name;
244244
struct map *map = ms->map;
245245
struct addr_map_symbol target = {
246-
.map = map,
246+
.ms = { .map = map, },
247247
};
248248

249249
ops->target.addr = strtoull(ops->raw, &endptr, 16);
@@ -272,8 +272,8 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_s
272272
target.addr = map__objdump_2mem(map, ops->target.addr);
273273

274274
if (map_groups__find_ams(map->groups, &target) == 0 &&
275-
map__rip_2objdump(target.map, map->map_ip(target.map, target.addr)) == ops->target.addr)
276-
ops->target.sym = target.sym;
275+
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
276+
ops->target.sym = target.ms.sym;
277277

278278
return 0;
279279

@@ -332,7 +332,7 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
332332
struct map *map = ms->map;
333333
struct symbol *sym = ms->sym;
334334
struct addr_map_symbol target = {
335-
.map = map,
335+
.ms = { .map = map, },
336336
};
337337
const char *c = strchr(ops->raw, ',');
338338
u64 start, end;
@@ -392,8 +392,8 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
392392
* the symbol searching and disassembly should be done.
393393
*/
394394
if (map_groups__find_ams(map->groups, &target) == 0 &&
395-
map__rip_2objdump(target.map, map->map_ip(target.map, target.addr)) == ops->target.addr)
396-
ops->target.sym = target.sym;
395+
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
396+
ops->target.sym = target.ms.sym;
397397

398398
if (!ops->target.outside) {
399399
ops->target.offset = target.addr - start;
@@ -865,14 +865,15 @@ static int __symbol__account_cycles(struct cyc_hist *ch,
865865
return 0;
866866
}
867867

868-
static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
868+
static int __symbol__inc_addr_samples(struct map_symbol *ms,
869869
struct annotated_source *src, int evidx, u64 addr,
870870
struct perf_sample *sample)
871871
{
872+
struct symbol *sym = ms->sym;
872873
unsigned offset;
873874
struct sym_hist *h;
874875

875-
pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
876+
pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, ms->map->unmap_ip(ms->map, addr));
876877

877878
if ((addr < sym->start || addr >= sym->end) &&
878879
(addr != sym->end || sym->start != sym->end)) {
@@ -939,17 +940,17 @@ struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists)
939940
return notes->src;
940941
}
941942

942-
static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
943+
static int symbol__inc_addr_samples(struct map_symbol *ms,
943944
struct evsel *evsel, u64 addr,
944945
struct perf_sample *sample)
945946
{
947+
struct symbol *sym = ms->sym;
946948
struct annotated_source *src;
947949

948950
if (sym == NULL)
949951
return 0;
950952
src = symbol__hists(sym, evsel->evlist->core.nr_entries);
951-
return (src) ? __symbol__inc_addr_samples(sym, map, src, evsel->idx,
952-
addr, sample) : 0;
953+
return src ? __symbol__inc_addr_samples(ms, src, evsel->idx, addr, sample) : 0;
953954
}
954955

955956
static int symbol__account_cycles(u64 addr, u64 start,
@@ -997,17 +998,17 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
997998
* it starts on the function start.
998999
*/
9991000
if (start &&
1000-
(start->sym == ams->sym ||
1001-
(ams->sym &&
1002-
start->addr == ams->sym->start + ams->map->start)))
1001+
(start->ms.sym == ams->ms.sym ||
1002+
(ams->ms.sym &&
1003+
start->addr == ams->ms.sym->start + ams->ms.map->start)))
10031004
saddr = start->al_addr;
10041005
if (saddr == 0)
10051006
pr_debug2("BB with bad start: addr %"PRIx64" start %"PRIx64" sym %"PRIx64" saddr %"PRIx64"\n",
10061007
ams->addr,
10071008
start ? start->addr : 0,
1008-
ams->sym ? ams->sym->start + ams->map->start : 0,
1009+
ams->ms.sym ? ams->ms.sym->start + ams->ms.map->start : 0,
10091010
saddr);
1010-
err = symbol__account_cycles(ams->al_addr, saddr, ams->sym, cycles);
1011+
err = symbol__account_cycles(ams->al_addr, saddr, ams->ms.sym, cycles);
10111012
if (err)
10121013
pr_debug2("account_cycles failed %d\n", err);
10131014
return err;
@@ -1093,13 +1094,13 @@ void annotation__compute_ipc(struct annotation *notes, size_t size)
10931094
int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
10941095
struct evsel *evsel)
10951096
{
1096-
return symbol__inc_addr_samples(ams->sym, ams->map, evsel, ams->al_addr, sample);
1097+
return symbol__inc_addr_samples(&ams->ms, evsel, ams->al_addr, sample);
10971098
}
10981099

10991100
int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
11001101
struct evsel *evsel, u64 ip)
11011102
{
1102-
return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evsel, ip, sample);
1103+
return symbol__inc_addr_samples(&he->ms, evsel, ip, sample);
11031104
}
11041105

11051106
static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map_symbol *ms)
@@ -1540,13 +1541,13 @@ static int symbol__parse_objdump_line(struct symbol *sym,
15401541
/* kcore has no symbols, so add the call target symbol */
15411542
if (dl->ins.ops && ins__is_call(&dl->ins) && !dl->ops.target.sym) {
15421543
struct addr_map_symbol target = {
1543-
.map = map,
15441544
.addr = dl->ops.target.addr,
1545+
.ms = { .map = map, },
15451546
};
15461547

15471548
if (!map_groups__find_ams(map->groups, &target) &&
1548-
target.sym->start == target.al_addr)
1549-
dl->ops.target.sym = target.sym;
1549+
target.ms.sym->start == target.al_addr)
1550+
dl->ops.target.sym = target.ms.sym;
15501551
}
15511552

15521553
annotation_line__add(&dl->al, &notes->src->source);

‎tools/perf/util/hist.c‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,27 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
112112
hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen);
113113

114114
if (h->branch_info) {
115-
if (h->branch_info->from.sym) {
116-
symlen = (int)h->branch_info->from.sym->namelen + 4;
115+
if (h->branch_info->from.ms.sym) {
116+
symlen = (int)h->branch_info->from.ms.sym->namelen + 4;
117117
if (verbose > 0)
118118
symlen += BITS_PER_LONG / 4 + 2 + 3;
119119
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
120120

121-
symlen = dso__name_len(h->branch_info->from.map->dso);
121+
symlen = dso__name_len(h->branch_info->from.ms.map->dso);
122122
hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
123123
} else {
124124
symlen = unresolved_col_width + 4 + 2;
125125
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
126126
hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
127127
}
128128

129-
if (h->branch_info->to.sym) {
130-
symlen = (int)h->branch_info->to.sym->namelen + 4;
129+
if (h->branch_info->to.ms.sym) {
130+
symlen = (int)h->branch_info->to.ms.sym->namelen + 4;
131131
if (verbose > 0)
132132
symlen += BITS_PER_LONG / 4 + 2 + 3;
133133
hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
134134

135-
symlen = dso__name_len(h->branch_info->to.map->dso);
135+
symlen = dso__name_len(h->branch_info->to.ms.map->dso);
136136
hists__new_col_len(hists, HISTC_DSO_TO, symlen);
137137
} else {
138138
symlen = unresolved_col_width + 4 + 2;
@@ -149,8 +149,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
149149
}
150150

151151
if (h->mem_info) {
152-
if (h->mem_info->daddr.sym) {
153-
symlen = (int)h->mem_info->daddr.sym->namelen + 4
152+
if (h->mem_info->daddr.ms.sym) {
153+
symlen = (int)h->mem_info->daddr.ms.sym->namelen + 4
154154
+ unresolved_col_width + 2;
155155
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
156156
symlen);
@@ -164,8 +164,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
164164
symlen);
165165
}
166166

167-
if (h->mem_info->iaddr.sym) {
168-
symlen = (int)h->mem_info->iaddr.sym->namelen + 4
167+
if (h->mem_info->iaddr.ms.sym) {
168+
symlen = (int)h->mem_info->iaddr.ms.sym->namelen + 4
169169
+ unresolved_col_width + 2;
170170
hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
171171
symlen);
@@ -175,8 +175,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
175175
symlen);
176176
}
177177

178-
if (h->mem_info->daddr.map) {
179-
symlen = dso__name_len(h->mem_info->daddr.map->dso);
178+
if (h->mem_info->daddr.ms.map) {
179+
symlen = dso__name_len(h->mem_info->daddr.ms.map->dso);
180180
hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
181181
symlen);
182182
} else {
@@ -443,13 +443,13 @@ static int hist_entry__init(struct hist_entry *he,
443443
memcpy(he->branch_info, template->branch_info,
444444
sizeof(*he->branch_info));
445445

446-
map__get(he->branch_info->from.map);
447-
map__get(he->branch_info->to.map);
446+
map__get(he->branch_info->from.ms.map);
447+
map__get(he->branch_info->to.ms.map);
448448
}
449449

450450
if (he->mem_info) {
451-
map__get(he->mem_info->iaddr.map);
452-
map__get(he->mem_info->daddr.map);
451+
map__get(he->mem_info->iaddr.ms.map);
452+
map__get(he->mem_info->daddr.ms.map);
453453
}
454454

455455
if (hist_entry__has_callchains(he) && symbol_conf.use_callchain)
@@ -492,13 +492,13 @@ static int hist_entry__init(struct hist_entry *he,
492492

493493
err_infos:
494494
if (he->branch_info) {
495-
map__put(he->branch_info->from.map);
496-
map__put(he->branch_info->to.map);
495+
map__put(he->branch_info->from.ms.map);
496+
map__put(he->branch_info->to.ms.map);
497497
zfree(&he->branch_info);
498498
}
499499
if (he->mem_info) {
500-
map__put(he->mem_info->iaddr.map);
501-
map__put(he->mem_info->daddr.map);
500+
map__put(he->mem_info->iaddr.ms.map);
501+
map__put(he->mem_info->daddr.ms.map);
502502
}
503503
err:
504504
map__zput(he->ms.map);
@@ -893,8 +893,8 @@ iter_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *al)
893893
if (iter->curr >= iter->total)
894894
return 0;
895895

896-
al->map = bi[i].to.map;
897-
al->sym = bi[i].to.sym;
896+
al->map = bi[i].to.ms.map;
897+
al->sym = bi[i].to.ms.sym;
898898
al->addr = bi[i].to.addr;
899899
return 1;
900900
}
@@ -912,7 +912,7 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a
912912

913913
bi = iter->priv;
914914

915-
if (iter->hide_unresolved && !(bi[i].from.sym && bi[i].to.sym))
915+
if (iter->hide_unresolved && !(bi[i].from.ms.sym && bi[i].to.ms.sym))
916916
goto out;
917917

918918
/*
@@ -1251,16 +1251,16 @@ void hist_entry__delete(struct hist_entry *he)
12511251
map__zput(he->ms.map);
12521252

12531253
if (he->branch_info) {
1254-
map__zput(he->branch_info->from.map);
1255-
map__zput(he->branch_info->to.map);
1254+
map__zput(he->branch_info->from.ms.map);
1255+
map__zput(he->branch_info->to.ms.map);
12561256
free_srcline(he->branch_info->srcline_from);
12571257
free_srcline(he->branch_info->srcline_to);
12581258
zfree(&he->branch_info);
12591259
}
12601260

12611261
if (he->mem_info) {
1262-
map__zput(he->mem_info->iaddr.map);
1263-
map__zput(he->mem_info->daddr.map);
1262+
map__zput(he->mem_info->iaddr.ms.map);
1263+
map__zput(he->mem_info->daddr.ms.map);
12641264
mem_info__zput(he->mem_info);
12651265
}
12661266

‎tools/perf/util/machine.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,8 +1968,8 @@ static void ip__resolve_ams(struct thread *thread,
19681968

19691969
ams->addr = ip;
19701970
ams->al_addr = al.addr;
1971-
ams->sym = al.sym;
1972-
ams->map = al.map;
1971+
ams->ms.sym = al.sym;
1972+
ams->ms.map = al.map;
19731973
ams->phys_addr = 0;
19741974
}
19751975

@@ -1985,8 +1985,8 @@ static void ip__resolve_data(struct thread *thread,
19851985

19861986
ams->addr = addr;
19871987
ams->al_addr = al.addr;
1988-
ams->sym = al.sym;
1989-
ams->map = al.map;
1988+
ams->ms.sym = al.sym;
1989+
ams->ms.map = al.map;
19901990
ams->phys_addr = phys_addr;
19911991
}
19921992

0 commit comments

Comments
 (0)