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: ee756ef749 ("perf dso: Add reference count checking and accessor functions")
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Yunseong Kim <yskelg@gmail.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20240704011745.1021288-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Ian Rogers 2024-07-03 18:17:45 -07:00 committed by Namhyung Kim
parent 14b0fffa25
commit 1553419c3c
9 changed files with 56 additions and 44 deletions

View File

@ -159,9 +159,9 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc)
Dwarf_Addr start = pc;
Dwarf_Addr end = pc;
bool signalp;
const char *exec_file = dso->long_name;
const char *exec_file = dso__long_name(dso);
dwfl = dso->dwfl;
dwfl = RC_CHK_ACCESS(dso)->dwfl;
if (!dwfl) {
dwfl = dwfl_begin(&offline_callbacks);
@ -183,7 +183,7 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc)
dwfl_end(dwfl);
goto out;
}
dso->dwfl = dwfl;
RC_CHK_ACCESS(dso)->dwfl = dwfl;
}
mod = dwfl_addrmodule(dwfl, pc);
@ -267,7 +267,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
rc = check_return_addr(dso, map__start(al.map), ip);
pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n",
dso->long_name, al.sym->name, ip, rc);
dso__long_name(dso), al.sym->name, ip, rc);
if (rc == 0) {
/*

View File

@ -180,13 +180,14 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
GtkWidget *tab_label;
int err;
if (dso->annotate_warned)
if (dso__annotate_warned(dso))
return -1;
err = symbol__annotate(ms, evsel, NULL);
if (err) {
char msg[BUFSIZ];
dso->annotate_warned = true;
dso__set_annotate_warned(dso);
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
ui__error("Couldn't annotate %s: %s\n", sym->name, msg);
return -1;

View File

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

View File

@ -1199,7 +1199,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
int ret;
FILE *s;
if (dso->binary_type != DSO_BINARY_TYPE__BPF_PROG_INFO)
if (dso__binary_type(dso) != DSO_BINARY_TYPE__BPF_PROG_INFO)
return SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE;
pr_debug("%s: handling sym %s addr %" PRIx64 " len %" PRIx64 "\n", __func__,
@ -1226,14 +1226,14 @@ static int symbol__disassemble_bpf(struct symbol *sym,
info.arch = bfd_get_arch(bfdf);
info.mach = bfd_get_mach(bfdf);
info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
dso->bpf_prog.id);
info_node = perf_env__find_bpf_prog_info(dso__bpf_prog(dso)->env,
dso__bpf_prog(dso)->id);
if (!info_node) {
ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
goto out;
}
info_linear = info_node->info_linear;
sub_id = dso->bpf_prog.sub_id;
sub_id = dso__bpf_prog(dso)->sub_id;
info.buffer = (void *)(uintptr_t)(info_linear->info.jited_prog_insns);
info.buffer_length = info_linear->info.jited_prog_len;
@ -1244,7 +1244,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
if (info_linear->info.btf_id) {
struct btf_node *node;
node = perf_env__find_btf(dso->bpf_prog.env,
node = perf_env__find_btf(dso__bpf_prog(dso)->env,
info_linear->info.btf_id);
if (node)
btf = btf__new((__u8 *)(node->data),

View File

@ -280,6 +280,16 @@ static inline void dso__set_annotate_warned(struct dso *dso)
RC_CHK_ACCESS(dso)->annotate_warned = 1;
}
static inline bool dso__auxtrace_warned(const struct dso *dso)
{
return RC_CHK_ACCESS(dso)->auxtrace_warned;
}
static inline void dso__set_auxtrace_warned(struct dso *dso)
{
RC_CHK_ACCESS(dso)->auxtrace_warned = 1;
}
static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso)
{
return RC_CHK_ACCESS(dso)->auxtrace_cache;

View File

@ -288,7 +288,7 @@ static int inline_list__append_dso_a2l(struct dso *dso,
struct inline_node *node,
struct symbol *sym)
{
struct a2l_data *a2l = dso->a2l;
struct a2l_data *a2l = dso__a2l(dso);
struct symbol *inline_sym = new_inline_sym(dso, sym, a2l->funcname);
char *srcline = NULL;
@ -304,11 +304,11 @@ static int addr2line(const char *dso_name, u64 addr,
struct symbol *sym)
{
int ret = 0;
struct a2l_data *a2l = dso->a2l;
struct a2l_data *a2l = dso__a2l(dso);
if (!a2l) {
dso->a2l = addr2line_init(dso_name);
a2l = dso->a2l;
a2l = addr2line_init(dso_name);
dso__set_a2l(dso, a2l);
}
if (a2l == NULL) {
@ -360,14 +360,14 @@ static int addr2line(const char *dso_name, u64 addr,
void dso__free_a2l(struct dso *dso)
{
struct a2l_data *a2l = dso->a2l;
struct a2l_data *a2l = dso__a2l(dso);
if (!a2l)
return;
addr2line_cleanup(a2l);
dso->a2l = NULL;
dso__set_a2l(dso, NULL);
}
#else /* HAVE_LIBBFD_SUPPORT */

View File

@ -1607,7 +1607,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
if (!bfd_check_format(abfd, bfd_object)) {
pr_debug2("%s: cannot read %s bfd file.\n", __func__,
dso->long_name);
dso__long_name(dso));
goto out_close;
}
@ -1640,12 +1640,13 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
}
if (i < symbols_count) {
/* PE symbols can only have 4 bytes, so use .text high bits */
dso->text_offset = section->vma - (u32)section->vma;
dso->text_offset += (u32)bfd_asymbol_value(symbols[i]);
dso->text_end = (section->vma - dso->text_offset) + section->size;
u64 text_offset = (section->vma - (u32)section->vma)
+ (u32)bfd_asymbol_value(symbols[i]);
dso__set_text_offset(dso, text_offset);
dso__set_text_end(dso, (section->vma - text_offset) + section->size);
} else {
dso->text_offset = section->vma - section->filepos;
dso->text_end = section->filepos + section->size;
dso__set_text_offset(dso, section->vma - section->filepos);
dso__set_text_end(dso, section->filepos + section->size);
}
}
@ -1671,7 +1672,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
else
len = section->size - sym->value;
start = bfd_asymbol_value(sym) - dso->text_offset;
start = bfd_asymbol_value(sym) - dso__text_offset(dso);
symbol = symbol__new(start, len, bfd2elf_binding(sym), STT_FUNC,
bfd_asymbol_name(sym));
if (!symbol)

View File

@ -29,8 +29,8 @@ static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata,
const struct dso *dso = *userdata;
assert(dso);
if (dso->symsrc_filename && strcmp (file_name, dso->symsrc_filename))
*debuginfo_file_name = strdup(dso->symsrc_filename);
if (dso__symsrc_filename(dso) && strcmp(file_name, dso__symsrc_filename(dso)))
*debuginfo_file_name = strdup(dso__symsrc_filename(dso));
return -1;
}
@ -66,7 +66,7 @@ static int __report_module(struct addr_location *al, u64 ip,
* a different code in another DSO. So just use the map->start
* directly to pick the correct one.
*/
if (!strncmp(dso->long_name, "/tmp/jitted-", 12))
if (!strncmp(dso__long_name(dso), "/tmp/jitted-", 12))
base = map__start(al->map);
else
base = map__start(al->map) - map__pgoff(al->map);
@ -83,15 +83,15 @@ static int __report_module(struct addr_location *al, u64 ip,
if (!mod) {
char filename[PATH_MAX];
__symbol__join_symfs(filename, sizeof(filename), dso->long_name);
mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1,
__symbol__join_symfs(filename, sizeof(filename), dso__long_name(dso));
mod = dwfl_report_elf(ui->dwfl, dso__short_name(dso), filename, -1,
base, false);
}
if (!mod) {
char filename[PATH_MAX];
if (dso__build_id_filename(dso, filename, sizeof(filename), false))
mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1,
mod = dwfl_report_elf(ui->dwfl, dso__short_name(dso), filename, -1,
base, false);
}

View File

@ -363,7 +363,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
struct machine *machine, u64 *offset)
{
int fd;
u64 ofs = dso->data.debug_frame_offset;
u64 ofs = dso__data(dso)->debug_frame_offset;
/* debug_frame can reside in:
* - dso
@ -379,7 +379,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
}
if (ofs <= 0) {
fd = open(dso->symsrc_filename, O_RDONLY);
fd = open(dso__symsrc_filename(dso), O_RDONLY);
if (fd >= 0) {
ofs = elf_section_offset(fd, ".debug_frame");
close(fd);
@ -407,21 +407,21 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
}
}
if (ofs > 0) {
if (dso->symsrc_filename != NULL) {
if (dso__symsrc_filename(dso) != NULL) {
pr_warning(
"%s: overwrite symsrc(%s,%s)\n",
__func__,
dso->symsrc_filename,
dso__symsrc_filename(dso),
debuglink);
zfree(&dso->symsrc_filename);
zfree(&dso__symsrc_filename(dso));
}
dso->symsrc_filename = debuglink;
dso__set_symsrc_filename(dso, debuglink);
} else {
free(debuglink);
}
}
dso->data.debug_frame_offset = ofs;
dso__data(dso)->debug_frame_offset = ofs;
}
*offset = ofs;
@ -486,7 +486,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
if (ret < 0 &&
!read_unwind_spec_debug_frame(dso, ui->machine, &segbase)) {
int fd = dso__data_get_fd(dso, ui->machine);
int is_exec = elf_is_exec(fd, dso->name);
int is_exec = elf_is_exec(fd, dso__name(dso));
u64 start = map__start(map);
unw_word_t base = is_exec ? 0 : start;
const char *symfile;
@ -494,7 +494,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
if (fd >= 0)
dso__data_put_fd(dso);
symfile = dso->symsrc_filename ?: dso->name;
symfile = dso__symsrc_filename(dso) ?: dso__name(dso);
memset(&di, 0, sizeof(di));
if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))