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: ee756ef7491e ("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:
parent
14b0fffa25
commit
1553419c3c
@ -159,9 +159,9 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc)
|
|||||||
Dwarf_Addr start = pc;
|
Dwarf_Addr start = pc;
|
||||||
Dwarf_Addr end = pc;
|
Dwarf_Addr end = pc;
|
||||||
bool signalp;
|
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) {
|
if (!dwfl) {
|
||||||
dwfl = dwfl_begin(&offline_callbacks);
|
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);
|
dwfl_end(dwfl);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
dso->dwfl = dwfl;
|
RC_CHK_ACCESS(dso)->dwfl = dwfl;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = dwfl_addrmodule(dwfl, pc);
|
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);
|
rc = check_return_addr(dso, map__start(al.map), ip);
|
||||||
|
|
||||||
pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n",
|
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) {
|
if (rc == 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -180,13 +180,14 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
|
|||||||
GtkWidget *tab_label;
|
GtkWidget *tab_label;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (dso->annotate_warned)
|
if (dso__annotate_warned(dso))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
err = symbol__annotate(ms, evsel, NULL);
|
err = symbol__annotate(ms, evsel, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
char msg[BUFSIZ];
|
char msg[BUFSIZ];
|
||||||
dso->annotate_warned = true;
|
|
||||||
|
dso__set_annotate_warned(dso);
|
||||||
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
|
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
|
||||||
ui__error("Couldn't annotate %s: %s\n", sym->name, msg);
|
ui__error("Couldn't annotate %s: %s\n", sym->name, msg);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1013,7 +1013,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id,
|
|||||||
if (!dso)
|
if (!dso)
|
||||||
goto out;
|
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))
|
dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1027,11 +1027,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id,
|
|||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
ui__warning_once("CS ETM Trace: Missing DSO. Use 'perf archive' or debuginfod to export data from the traced system.\n"
|
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");
|
" 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",
|
pr_err("CS ETM Trace: Debug data not found for address %#"PRIx64" in %s\n",
|
||||||
address,
|
address,
|
||||||
dso->long_name ? dso->long_name : "Unknown");
|
dso__long_name(dso) ? dso__long_name(dso) : "Unknown");
|
||||||
dso->auxtrace_warned = true;
|
dso__set_auxtrace_warned(dso);
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1199,7 +1199,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
|
|||||||
int ret;
|
int ret;
|
||||||
FILE *s;
|
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;
|
return SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE;
|
||||||
|
|
||||||
pr_debug("%s: handling sym %s addr %" PRIx64 " len %" PRIx64 "\n", __func__,
|
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.arch = bfd_get_arch(bfdf);
|
||||||
info.mach = bfd_get_mach(bfdf);
|
info.mach = bfd_get_mach(bfdf);
|
||||||
|
|
||||||
info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
|
info_node = perf_env__find_bpf_prog_info(dso__bpf_prog(dso)->env,
|
||||||
dso->bpf_prog.id);
|
dso__bpf_prog(dso)->id);
|
||||||
if (!info_node) {
|
if (!info_node) {
|
||||||
ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
|
ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
info_linear = info_node->info_linear;
|
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 = (void *)(uintptr_t)(info_linear->info.jited_prog_insns);
|
||||||
info.buffer_length = info_linear->info.jited_prog_len;
|
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) {
|
if (info_linear->info.btf_id) {
|
||||||
struct btf_node *node;
|
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);
|
info_linear->info.btf_id);
|
||||||
if (node)
|
if (node)
|
||||||
btf = btf__new((__u8 *)(node->data),
|
btf = btf__new((__u8 *)(node->data),
|
||||||
|
@ -280,6 +280,16 @@ static inline void dso__set_annotate_warned(struct dso *dso)
|
|||||||
RC_CHK_ACCESS(dso)->annotate_warned = 1;
|
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)
|
static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso)
|
||||||
{
|
{
|
||||||
return RC_CHK_ACCESS(dso)->auxtrace_cache;
|
return RC_CHK_ACCESS(dso)->auxtrace_cache;
|
||||||
|
@ -288,7 +288,7 @@ static int inline_list__append_dso_a2l(struct dso *dso,
|
|||||||
struct inline_node *node,
|
struct inline_node *node,
|
||||||
struct symbol *sym)
|
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);
|
struct symbol *inline_sym = new_inline_sym(dso, sym, a2l->funcname);
|
||||||
char *srcline = NULL;
|
char *srcline = NULL;
|
||||||
|
|
||||||
@ -304,11 +304,11 @@ static int addr2line(const char *dso_name, u64 addr,
|
|||||||
struct symbol *sym)
|
struct symbol *sym)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct a2l_data *a2l = dso->a2l;
|
struct a2l_data *a2l = dso__a2l(dso);
|
||||||
|
|
||||||
if (!a2l) {
|
if (!a2l) {
|
||||||
dso->a2l = addr2line_init(dso_name);
|
a2l = addr2line_init(dso_name);
|
||||||
a2l = dso->a2l;
|
dso__set_a2l(dso, a2l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a2l == NULL) {
|
if (a2l == NULL) {
|
||||||
@ -360,14 +360,14 @@ static int addr2line(const char *dso_name, u64 addr,
|
|||||||
|
|
||||||
void dso__free_a2l(struct dso *dso)
|
void dso__free_a2l(struct dso *dso)
|
||||||
{
|
{
|
||||||
struct a2l_data *a2l = dso->a2l;
|
struct a2l_data *a2l = dso__a2l(dso);
|
||||||
|
|
||||||
if (!a2l)
|
if (!a2l)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
addr2line_cleanup(a2l);
|
addr2line_cleanup(a2l);
|
||||||
|
|
||||||
dso->a2l = NULL;
|
dso__set_a2l(dso, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* HAVE_LIBBFD_SUPPORT */
|
#else /* HAVE_LIBBFD_SUPPORT */
|
||||||
|
@ -1607,7 +1607,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
|
|||||||
|
|
||||||
if (!bfd_check_format(abfd, bfd_object)) {
|
if (!bfd_check_format(abfd, bfd_object)) {
|
||||||
pr_debug2("%s: cannot read %s bfd file.\n", __func__,
|
pr_debug2("%s: cannot read %s bfd file.\n", __func__,
|
||||||
dso->long_name);
|
dso__long_name(dso));
|
||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1640,12 +1640,13 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
|
|||||||
}
|
}
|
||||||
if (i < symbols_count) {
|
if (i < symbols_count) {
|
||||||
/* PE symbols can only have 4 bytes, so use .text high bits */
|
/* PE symbols can only have 4 bytes, so use .text high bits */
|
||||||
dso->text_offset = section->vma - (u32)section->vma;
|
u64 text_offset = (section->vma - (u32)section->vma)
|
||||||
dso->text_offset += (u32)bfd_asymbol_value(symbols[i]);
|
+ (u32)bfd_asymbol_value(symbols[i]);
|
||||||
dso->text_end = (section->vma - dso->text_offset) + section->size;
|
dso__set_text_offset(dso, text_offset);
|
||||||
|
dso__set_text_end(dso, (section->vma - text_offset) + section->size);
|
||||||
} else {
|
} else {
|
||||||
dso->text_offset = section->vma - section->filepos;
|
dso__set_text_offset(dso, section->vma - section->filepos);
|
||||||
dso->text_end = section->filepos + section->size;
|
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
|
else
|
||||||
len = section->size - sym->value;
|
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,
|
symbol = symbol__new(start, len, bfd2elf_binding(sym), STT_FUNC,
|
||||||
bfd_asymbol_name(sym));
|
bfd_asymbol_name(sym));
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
|
@ -29,8 +29,8 @@ static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata,
|
|||||||
const struct dso *dso = *userdata;
|
const struct dso *dso = *userdata;
|
||||||
|
|
||||||
assert(dso);
|
assert(dso);
|
||||||
if (dso->symsrc_filename && strcmp (file_name, dso->symsrc_filename))
|
if (dso__symsrc_filename(dso) && strcmp(file_name, dso__symsrc_filename(dso)))
|
||||||
*debuginfo_file_name = strdup(dso->symsrc_filename);
|
*debuginfo_file_name = strdup(dso__symsrc_filename(dso));
|
||||||
return -1;
|
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
|
* a different code in another DSO. So just use the map->start
|
||||||
* directly to pick the correct one.
|
* 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);
|
base = map__start(al->map);
|
||||||
else
|
else
|
||||||
base = map__start(al->map) - map__pgoff(al->map);
|
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) {
|
if (!mod) {
|
||||||
char filename[PATH_MAX];
|
char filename[PATH_MAX];
|
||||||
|
|
||||||
__symbol__join_symfs(filename, sizeof(filename), dso->long_name);
|
__symbol__join_symfs(filename, sizeof(filename), dso__long_name(dso));
|
||||||
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);
|
base, false);
|
||||||
}
|
}
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
char filename[PATH_MAX];
|
char filename[PATH_MAX];
|
||||||
|
|
||||||
if (dso__build_id_filename(dso, filename, sizeof(filename), false))
|
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);
|
base, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
|
|||||||
struct machine *machine, u64 *offset)
|
struct machine *machine, u64 *offset)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
u64 ofs = dso->data.debug_frame_offset;
|
u64 ofs = dso__data(dso)->debug_frame_offset;
|
||||||
|
|
||||||
/* debug_frame can reside in:
|
/* debug_frame can reside in:
|
||||||
* - dso
|
* - dso
|
||||||
@ -379,7 +379,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ofs <= 0) {
|
if (ofs <= 0) {
|
||||||
fd = open(dso->symsrc_filename, O_RDONLY);
|
fd = open(dso__symsrc_filename(dso), O_RDONLY);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
ofs = elf_section_offset(fd, ".debug_frame");
|
ofs = elf_section_offset(fd, ".debug_frame");
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -407,21 +407,21 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ofs > 0) {
|
if (ofs > 0) {
|
||||||
if (dso->symsrc_filename != NULL) {
|
if (dso__symsrc_filename(dso) != NULL) {
|
||||||
pr_warning(
|
pr_warning(
|
||||||
"%s: overwrite symsrc(%s,%s)\n",
|
"%s: overwrite symsrc(%s,%s)\n",
|
||||||
__func__,
|
__func__,
|
||||||
dso->symsrc_filename,
|
dso__symsrc_filename(dso),
|
||||||
debuglink);
|
debuglink);
|
||||||
zfree(&dso->symsrc_filename);
|
zfree(&dso__symsrc_filename(dso));
|
||||||
}
|
}
|
||||||
dso->symsrc_filename = debuglink;
|
dso__set_symsrc_filename(dso, debuglink);
|
||||||
} else {
|
} else {
|
||||||
free(debuglink);
|
free(debuglink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dso->data.debug_frame_offset = ofs;
|
dso__data(dso)->debug_frame_offset = ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
*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 &&
|
if (ret < 0 &&
|
||||||
!read_unwind_spec_debug_frame(dso, ui->machine, &segbase)) {
|
!read_unwind_spec_debug_frame(dso, ui->machine, &segbase)) {
|
||||||
int fd = dso__data_get_fd(dso, ui->machine);
|
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);
|
u64 start = map__start(map);
|
||||||
unw_word_t base = is_exec ? 0 : start;
|
unw_word_t base = is_exec ? 0 : start;
|
||||||
const char *symfile;
|
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)
|
if (fd >= 0)
|
||||||
dso__data_put_fd(dso);
|
dso__data_put_fd(dso);
|
||||||
|
|
||||||
symfile = dso->symsrc_filename ?: dso->name;
|
symfile = dso__symsrc_filename(dso) ?: dso__name(dso);
|
||||||
|
|
||||||
memset(&di, 0, sizeof(di));
|
memset(&di, 0, sizeof(di));
|
||||||
if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))
|
if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user