Skip to content

Commit 1553419

Browse files
captain5050namhyung
authored andcommitted
perf dso: Fix address sanitizer build
Various files had been missed from having accessor functions added for the sake of dso reference count checking. Add the function calls and missing dso accessor functions. Fixes: ee756ef ("perf dso: Add reference count checking and accessor functions") Signed-off-by: Ian Rogers <[email protected]> Cc: James Clark <[email protected]> Cc: Suzuki K Poulose <[email protected]> Cc: Yunseong Kim <[email protected]> Cc: Will Deacon <[email protected]> Cc: Mike Leach <[email protected]> Cc: Leo Yan <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 14b0fff commit 1553419

File tree

9 files changed

+56
-44
lines changed

9 files changed

+56
-44
lines changed

tools/perf/arch/powerpc/util/skip-callchain-idx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc)
159159
Dwarf_Addr start = pc;
160160
Dwarf_Addr end = pc;
161161
bool signalp;
162-
const char *exec_file = dso->long_name;
162+
const char *exec_file = dso__long_name(dso);
163163

164-
dwfl = dso->dwfl;
164+
dwfl = RC_CHK_ACCESS(dso)->dwfl;
165165

166166
if (!dwfl) {
167167
dwfl = dwfl_begin(&offline_callbacks);
@@ -183,7 +183,7 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc)
183183
dwfl_end(dwfl);
184184
goto out;
185185
}
186-
dso->dwfl = dwfl;
186+
RC_CHK_ACCESS(dso)->dwfl = dwfl;
187187
}
188188

189189
mod = dwfl_addrmodule(dwfl, pc);
@@ -267,7 +267,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
267267
rc = check_return_addr(dso, map__start(al.map), ip);
268268

269269
pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n",
270-
dso->long_name, al.sym->name, ip, rc);
270+
dso__long_name(dso), al.sym->name, ip, rc);
271271

272272
if (rc == 0) {
273273
/*

tools/perf/ui/gtk/annotate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,14 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
180180
GtkWidget *tab_label;
181181
int err;
182182

183-
if (dso->annotate_warned)
183+
if (dso__annotate_warned(dso))
184184
return -1;
185185

186186
err = symbol__annotate(ms, evsel, NULL);
187187
if (err) {
188188
char msg[BUFSIZ];
189-
dso->annotate_warned = true;
189+
190+
dso__set_annotate_warned(dso);
190191
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
191192
ui__error("Couldn't annotate %s: %s\n", sym->name, msg);
192193
return -1;

tools/perf/util/cs-etm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id,
10131013
if (!dso)
10141014
goto out;
10151015

1016-
if (dso->data.status == DSO_DATA_STATUS_ERROR &&
1016+
if (dso__data(dso)->status == DSO_DATA_STATUS_ERROR &&
10171017
dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE))
10181018
goto out;
10191019

@@ -1027,11 +1027,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id,
10271027
if (len <= 0) {
10281028
ui__warning_once("CS ETM Trace: Missing DSO. Use 'perf archive' or debuginfod to export data from the traced system.\n"
10291029
" Enable CONFIG_PROC_KCORE or use option '-k /path/to/vmlinux' for kernel symbols.\n");
1030-
if (!dso->auxtrace_warned) {
1030+
if (!dso__auxtrace_warned(dso)) {
10311031
pr_err("CS ETM Trace: Debug data not found for address %#"PRIx64" in %s\n",
1032-
address,
1033-
dso->long_name ? dso->long_name : "Unknown");
1034-
dso->auxtrace_warned = true;
1032+
address,
1033+
dso__long_name(dso) ? dso__long_name(dso) : "Unknown");
1034+
dso__set_auxtrace_warned(dso);
10351035
}
10361036
goto out;
10371037
}

tools/perf/util/disasm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
11991199
int ret;
12001200
FILE *s;
12011201

1202-
if (dso->binary_type != DSO_BINARY_TYPE__BPF_PROG_INFO)
1202+
if (dso__binary_type(dso) != DSO_BINARY_TYPE__BPF_PROG_INFO)
12031203
return SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE;
12041204

12051205
pr_debug("%s: handling sym %s addr %" PRIx64 " len %" PRIx64 "\n", __func__,
@@ -1226,14 +1226,14 @@ static int symbol__disassemble_bpf(struct symbol *sym,
12261226
info.arch = bfd_get_arch(bfdf);
12271227
info.mach = bfd_get_mach(bfdf);
12281228

1229-
info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
1230-
dso->bpf_prog.id);
1229+
info_node = perf_env__find_bpf_prog_info(dso__bpf_prog(dso)->env,
1230+
dso__bpf_prog(dso)->id);
12311231
if (!info_node) {
12321232
ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
12331233
goto out;
12341234
}
12351235
info_linear = info_node->info_linear;
1236-
sub_id = dso->bpf_prog.sub_id;
1236+
sub_id = dso__bpf_prog(dso)->sub_id;
12371237

12381238
info.buffer = (void *)(uintptr_t)(info_linear->info.jited_prog_insns);
12391239
info.buffer_length = info_linear->info.jited_prog_len;
@@ -1244,7 +1244,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
12441244
if (info_linear->info.btf_id) {
12451245
struct btf_node *node;
12461246

1247-
node = perf_env__find_btf(dso->bpf_prog.env,
1247+
node = perf_env__find_btf(dso__bpf_prog(dso)->env,
12481248
info_linear->info.btf_id);
12491249
if (node)
12501250
btf = btf__new((__u8 *)(node->data),

tools/perf/util/dso.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ static inline void dso__set_annotate_warned(struct dso *dso)
280280
RC_CHK_ACCESS(dso)->annotate_warned = 1;
281281
}
282282

283+
static inline bool dso__auxtrace_warned(const struct dso *dso)
284+
{
285+
return RC_CHK_ACCESS(dso)->auxtrace_warned;
286+
}
287+
288+
static inline void dso__set_auxtrace_warned(struct dso *dso)
289+
{
290+
RC_CHK_ACCESS(dso)->auxtrace_warned = 1;
291+
}
292+
283293
static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso)
284294
{
285295
return RC_CHK_ACCESS(dso)->auxtrace_cache;

tools/perf/util/srcline.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static int inline_list__append_dso_a2l(struct dso *dso,
288288
struct inline_node *node,
289289
struct symbol *sym)
290290
{
291-
struct a2l_data *a2l = dso->a2l;
291+
struct a2l_data *a2l = dso__a2l(dso);
292292
struct symbol *inline_sym = new_inline_sym(dso, sym, a2l->funcname);
293293
char *srcline = NULL;
294294

@@ -304,11 +304,11 @@ static int addr2line(const char *dso_name, u64 addr,
304304
struct symbol *sym)
305305
{
306306
int ret = 0;
307-
struct a2l_data *a2l = dso->a2l;
307+
struct a2l_data *a2l = dso__a2l(dso);
308308

309309
if (!a2l) {
310-
dso->a2l = addr2line_init(dso_name);
311-
a2l = dso->a2l;
310+
a2l = addr2line_init(dso_name);
311+
dso__set_a2l(dso, a2l);
312312
}
313313

314314
if (a2l == NULL) {
@@ -360,14 +360,14 @@ static int addr2line(const char *dso_name, u64 addr,
360360

361361
void dso__free_a2l(struct dso *dso)
362362
{
363-
struct a2l_data *a2l = dso->a2l;
363+
struct a2l_data *a2l = dso__a2l(dso);
364364

365365
if (!a2l)
366366
return;
367367

368368
addr2line_cleanup(a2l);
369369

370-
dso->a2l = NULL;
370+
dso__set_a2l(dso, NULL);
371371
}
372372

373373
#else /* HAVE_LIBBFD_SUPPORT */

tools/perf/util/symbol.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
16071607

16081608
if (!bfd_check_format(abfd, bfd_object)) {
16091609
pr_debug2("%s: cannot read %s bfd file.\n", __func__,
1610-
dso->long_name);
1610+
dso__long_name(dso));
16111611
goto out_close;
16121612
}
16131613

@@ -1640,12 +1640,13 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
16401640
}
16411641
if (i < symbols_count) {
16421642
/* PE symbols can only have 4 bytes, so use .text high bits */
1643-
dso->text_offset = section->vma - (u32)section->vma;
1644-
dso->text_offset += (u32)bfd_asymbol_value(symbols[i]);
1645-
dso->text_end = (section->vma - dso->text_offset) + section->size;
1643+
u64 text_offset = (section->vma - (u32)section->vma)
1644+
+ (u32)bfd_asymbol_value(symbols[i]);
1645+
dso__set_text_offset(dso, text_offset);
1646+
dso__set_text_end(dso, (section->vma - text_offset) + section->size);
16461647
} else {
1647-
dso->text_offset = section->vma - section->filepos;
1648-
dso->text_end = section->filepos + section->size;
1648+
dso__set_text_offset(dso, section->vma - section->filepos);
1649+
dso__set_text_end(dso, section->filepos + section->size);
16491650
}
16501651
}
16511652

@@ -1671,7 +1672,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
16711672
else
16721673
len = section->size - sym->value;
16731674

1674-
start = bfd_asymbol_value(sym) - dso->text_offset;
1675+
start = bfd_asymbol_value(sym) - dso__text_offset(dso);
16751676
symbol = symbol__new(start, len, bfd2elf_binding(sym), STT_FUNC,
16761677
bfd_asymbol_name(sym));
16771678
if (!symbol)

tools/perf/util/unwind-libdw.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata,
2929
const struct dso *dso = *userdata;
3030

3131
assert(dso);
32-
if (dso->symsrc_filename && strcmp (file_name, dso->symsrc_filename))
33-
*debuginfo_file_name = strdup(dso->symsrc_filename);
32+
if (dso__symsrc_filename(dso) && strcmp(file_name, dso__symsrc_filename(dso)))
33+
*debuginfo_file_name = strdup(dso__symsrc_filename(dso));
3434
return -1;
3535
}
3636

@@ -66,7 +66,7 @@ static int __report_module(struct addr_location *al, u64 ip,
6666
* a different code in another DSO. So just use the map->start
6767
* directly to pick the correct one.
6868
*/
69-
if (!strncmp(dso->long_name, "/tmp/jitted-", 12))
69+
if (!strncmp(dso__long_name(dso), "/tmp/jitted-", 12))
7070
base = map__start(al->map);
7171
else
7272
base = map__start(al->map) - map__pgoff(al->map);
@@ -83,15 +83,15 @@ static int __report_module(struct addr_location *al, u64 ip,
8383
if (!mod) {
8484
char filename[PATH_MAX];
8585

86-
__symbol__join_symfs(filename, sizeof(filename), dso->long_name);
87-
mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1,
86+
__symbol__join_symfs(filename, sizeof(filename), dso__long_name(dso));
87+
mod = dwfl_report_elf(ui->dwfl, dso__short_name(dso), filename, -1,
8888
base, false);
8989
}
9090
if (!mod) {
9191
char filename[PATH_MAX];
9292

9393
if (dso__build_id_filename(dso, filename, sizeof(filename), false))
94-
mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1,
94+
mod = dwfl_report_elf(ui->dwfl, dso__short_name(dso), filename, -1,
9595
base, false);
9696
}
9797

tools/perf/util/unwind-libunwind-local.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
363363
struct machine *machine, u64 *offset)
364364
{
365365
int fd;
366-
u64 ofs = dso->data.debug_frame_offset;
366+
u64 ofs = dso__data(dso)->debug_frame_offset;
367367

368368
/* debug_frame can reside in:
369369
* - dso
@@ -379,7 +379,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
379379
}
380380

381381
if (ofs <= 0) {
382-
fd = open(dso->symsrc_filename, O_RDONLY);
382+
fd = open(dso__symsrc_filename(dso), O_RDONLY);
383383
if (fd >= 0) {
384384
ofs = elf_section_offset(fd, ".debug_frame");
385385
close(fd);
@@ -407,21 +407,21 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
407407
}
408408
}
409409
if (ofs > 0) {
410-
if (dso->symsrc_filename != NULL) {
410+
if (dso__symsrc_filename(dso) != NULL) {
411411
pr_warning(
412412
"%s: overwrite symsrc(%s,%s)\n",
413413
__func__,
414-
dso->symsrc_filename,
414+
dso__symsrc_filename(dso),
415415
debuglink);
416-
zfree(&dso->symsrc_filename);
416+
zfree(&dso__symsrc_filename(dso));
417417
}
418-
dso->symsrc_filename = debuglink;
418+
dso__set_symsrc_filename(dso, debuglink);
419419
} else {
420420
free(debuglink);
421421
}
422422
}
423423

424-
dso->data.debug_frame_offset = ofs;
424+
dso__data(dso)->debug_frame_offset = ofs;
425425
}
426426

427427
*offset = ofs;
@@ -486,15 +486,15 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
486486
if (ret < 0 &&
487487
!read_unwind_spec_debug_frame(dso, ui->machine, &segbase)) {
488488
int fd = dso__data_get_fd(dso, ui->machine);
489-
int is_exec = elf_is_exec(fd, dso->name);
489+
int is_exec = elf_is_exec(fd, dso__name(dso));
490490
u64 start = map__start(map);
491491
unw_word_t base = is_exec ? 0 : start;
492492
const char *symfile;
493493

494494
if (fd >= 0)
495495
dso__data_put_fd(dso);
496496

497-
symfile = dso->symsrc_filename ?: dso->name;
497+
symfile = dso__symsrc_filename(dso) ?: dso__name(dso);
498498

499499
memset(&di, 0, sizeof(di));
500500
if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))

0 commit comments

Comments
 (0)