summaryrefslogtreecommitdiff
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c261
1 files changed, 125 insertions, 136 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 9ebdb8e13c0b..9e5940b5bc59 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -27,6 +27,7 @@
#include "symbol.h"
#include "map_symbol.h"
#include "mem-events.h"
+#include "mem-info.h"
#include "symsrc.h"
#include "strlist.h"
#include "intlist.h"
@@ -532,52 +533,52 @@ static struct symbol *symbols__find_by_name(struct symbol *symbols[],
void dso__reset_find_symbol_cache(struct dso *dso)
{
- dso->last_find_result.addr = 0;
- dso->last_find_result.symbol = NULL;
+ dso__set_last_find_result_addr(dso, 0);
+ dso__set_last_find_result_symbol(dso, NULL);
}
void dso__insert_symbol(struct dso *dso, struct symbol *sym)
{
- __symbols__insert(&dso->symbols, sym, dso->kernel);
+ __symbols__insert(dso__symbols(dso), sym, dso__kernel(dso));
/* update the symbol cache if necessary */
- if (dso->last_find_result.addr >= sym->start &&
- (dso->last_find_result.addr < sym->end ||
+ if (dso__last_find_result_addr(dso) >= sym->start &&
+ (dso__last_find_result_addr(dso) < sym->end ||
sym->start == sym->end)) {
- dso->last_find_result.symbol = sym;
+ dso__set_last_find_result_symbol(dso, sym);
}
}
void dso__delete_symbol(struct dso *dso, struct symbol *sym)
{
- rb_erase_cached(&sym->rb_node, &dso->symbols);
+ rb_erase_cached(&sym->rb_node, dso__symbols(dso));
symbol__delete(sym);
dso__reset_find_symbol_cache(dso);
}
struct symbol *dso__find_symbol(struct dso *dso, u64 addr)
{
- if (dso->last_find_result.addr != addr || dso->last_find_result.symbol == NULL) {
- dso->last_find_result.addr = addr;
- dso->last_find_result.symbol = symbols__find(&dso->symbols, addr);
+ if (dso__last_find_result_addr(dso) != addr || dso__last_find_result_symbol(dso) == NULL) {
+ dso__set_last_find_result_addr(dso, addr);
+ dso__set_last_find_result_symbol(dso, symbols__find(dso__symbols(dso), addr));
}
- return dso->last_find_result.symbol;
+ return dso__last_find_result_symbol(dso);
}
struct symbol *dso__find_symbol_nocache(struct dso *dso, u64 addr)
{
- return symbols__find(&dso->symbols, addr);
+ return symbols__find(dso__symbols(dso), addr);
}
struct symbol *dso__first_symbol(struct dso *dso)
{
- return symbols__first(&dso->symbols);
+ return symbols__first(dso__symbols(dso));
}
struct symbol *dso__last_symbol(struct dso *dso)
{
- return symbols__last(&dso->symbols);
+ return symbols__last(dso__symbols(dso));
}
struct symbol *dso__next_symbol(struct symbol *sym)
@@ -587,11 +588,11 @@ struct symbol *dso__next_symbol(struct symbol *sym)
struct symbol *dso__next_symbol_by_name(struct dso *dso, size_t *idx)
{
- if (*idx + 1 >= dso->symbol_names_len)
+ if (*idx + 1 >= dso__symbol_names_len(dso))
return NULL;
++*idx;
- return dso->symbol_names[*idx];
+ return dso__symbol_names(dso)[*idx];
}
/*
@@ -599,27 +600,29 @@ struct symbol *dso__next_symbol_by_name(struct dso *dso, size_t *idx)
*/
struct symbol *dso__find_symbol_by_name(struct dso *dso, const char *name, size_t *idx)
{
- struct symbol *s = symbols__find_by_name(dso->symbol_names, dso->symbol_names_len,
- name, SYMBOL_TAG_INCLUDE__NONE, idx);
- if (!s)
- s = symbols__find_by_name(dso->symbol_names, dso->symbol_names_len,
- name, SYMBOL_TAG_INCLUDE__DEFAULT_ONLY, idx);
+ struct symbol *s = symbols__find_by_name(dso__symbol_names(dso),
+ dso__symbol_names_len(dso),
+ name, SYMBOL_TAG_INCLUDE__NONE, idx);
+ if (!s) {
+ s = symbols__find_by_name(dso__symbol_names(dso), dso__symbol_names_len(dso),
+ name, SYMBOL_TAG_INCLUDE__DEFAULT_ONLY, idx);
+ }
return s;
}
void dso__sort_by_name(struct dso *dso)
{
- mutex_lock(&dso->lock);
+ mutex_lock(dso__lock(dso));
if (!dso__sorted_by_name(dso)) {
size_t len;
- dso->symbol_names = symbols__sort_by_name(&dso->symbols, &len);
- if (dso->symbol_names) {
- dso->symbol_names_len = len;
+ dso__set_symbol_names(dso, symbols__sort_by_name(dso__symbols(dso), &len));
+ if (dso__symbol_names(dso)) {
+ dso__set_symbol_names_len(dso, len);
dso__set_sorted_by_name(dso);
}
}
- mutex_unlock(&dso->lock);
+ mutex_unlock(dso__lock(dso));
}
/*
@@ -746,7 +749,7 @@ static int map__process_kallsym_symbol(void *arg, const char *name,
{
struct symbol *sym;
struct dso *dso = arg;
- struct rb_root_cached *root = &dso->symbols;
+ struct rb_root_cached *root = dso__symbols(dso);
if (!symbol_type__filter(type))
return 0;
@@ -786,8 +789,8 @@ static int maps__split_kallsyms_for_kcore(struct maps *kmaps, struct dso *dso)
{
struct symbol *pos;
int count = 0;
- struct rb_root_cached old_root = dso->symbols;
- struct rb_root_cached *root = &dso->symbols;
+ struct rb_root_cached *root = dso__symbols(dso);
+ struct rb_root_cached old_root = *root;
struct rb_node *next = rb_first_cached(root);
if (!kmaps)
@@ -821,13 +824,13 @@ static int maps__split_kallsyms_for_kcore(struct maps *kmaps, struct dso *dso)
pos->end = map__end(curr_map);
if (pos->end)
pos->end -= map__start(curr_map) - map__pgoff(curr_map);
- symbols__insert(&curr_map_dso->symbols, pos);
+ symbols__insert(dso__symbols(curr_map_dso), pos);
++count;
map__put(curr_map);
}
/* Symbols have been adjusted */
- dso->adjust_symbols = 1;
+ dso__set_adjust_symbols(dso, true);
return count;
}
@@ -844,7 +847,7 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
struct map *curr_map = map__get(initial_map);
struct symbol *pos;
int count = 0, moved = 0;
- struct rb_root_cached *root = &dso->symbols;
+ struct rb_root_cached *root = dso__symbols(dso);
struct rb_node *next = rb_first_cached(root);
int kernel_range = 0;
bool x86_64;
@@ -871,9 +874,9 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
*module++ = '\0';
curr_map_dso = map__dso(curr_map);
- if (strcmp(curr_map_dso->short_name, module)) {
+ if (strcmp(dso__short_name(curr_map_dso), module)) {
if (!RC_CHK_EQUAL(curr_map, initial_map) &&
- dso->kernel == DSO_SPACE__KERNEL_GUEST &&
+ dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST &&
machine__is_default_guest(machine)) {
/*
* We assume all symbols of a module are
@@ -896,7 +899,7 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
goto discard_symbol;
}
curr_map_dso = map__dso(curr_map);
- if (curr_map_dso->loaded &&
+ if (dso__loaded(curr_map_dso) &&
!machine__is_default_guest(machine))
goto discard_symbol;
}
@@ -932,7 +935,7 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
goto add_symbol;
}
- if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
+ if (dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST)
snprintf(dso_name, sizeof(dso_name),
"[guest.kernel].%d",
kernel_range++);
@@ -946,7 +949,7 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
if (ndso == NULL)
return -1;
- ndso->kernel = dso->kernel;
+ dso__set_kernel(ndso, dso__kernel(dso));
curr_map = map__new2(pos->start, ndso);
if (curr_map == NULL) {
@@ -971,7 +974,7 @@ add_symbol:
struct dso *curr_map_dso = map__dso(curr_map);
rb_erase_cached(&pos->rb_node, root);
- symbols__insert(&curr_map_dso->symbols, pos);
+ symbols__insert(dso__symbols(curr_map_dso), pos);
++moved;
} else
++count;
@@ -983,7 +986,7 @@ discard_symbol:
}
if (!RC_CHK_EQUAL(curr_map, initial_map) &&
- dso->kernel == DSO_SPACE__KERNEL_GUEST &&
+ dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST &&
machine__is_default_guest(maps__machine(kmaps))) {
dso__set_loaded(map__dso(curr_map));
}
@@ -1157,7 +1160,7 @@ static int do_validate_kcore_modules_cb(struct map *old_map, void *data)
dso = map__dso(old_map);
/* Module must be in memory at the same address */
- mi = find_module(dso->short_name, modules);
+ mi = find_module(dso__short_name(dso), modules);
if (!mi || mi->start != map__start(old_map))
return -EINVAL;
@@ -1287,7 +1290,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
{
struct maps *kmaps = map__kmaps(map);
struct kcore_mapfn_data md;
- struct map *replacement_map = NULL;
+ struct map *map_ref, *replacement_map = NULL;
struct machine *machine;
bool is_64_bit;
int err, fd;
@@ -1326,7 +1329,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
&is_64_bit);
if (err)
goto out_err;
- dso->is_64_bit = is_64_bit;
+ dso__set_is_64_bit(dso, is_64_bit);
if (list_empty(&md.maps)) {
err = -EINVAL;
@@ -1365,6 +1368,24 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
if (!replacement_map)
replacement_map = list_entry(md.maps.next, struct map_list_node, node)->map;
+ /*
+ * Update addresses of vmlinux map. Re-insert it to ensure maps are
+ * correctly ordered. Do this before using maps__merge_in() for the
+ * remaining maps so vmlinux gets split if necessary.
+ */
+ map_ref = map__get(map);
+ maps__remove(kmaps, map_ref);
+
+ map__set_start(map_ref, map__start(replacement_map));
+ map__set_end(map_ref, map__end(replacement_map));
+ map__set_pgoff(map_ref, map__pgoff(replacement_map));
+ map__set_mapping_type(map_ref, map__mapping_type(replacement_map));
+
+ err = maps__insert(kmaps, map_ref);
+ map__put(map_ref);
+ if (err)
+ goto out_err;
+
/* Add new maps */
while (!list_empty(&md.maps)) {
struct map_list_node *new_node = list_entry(md.maps.next, struct map_list_node, node);
@@ -1372,22 +1393,8 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
list_del_init(&new_node->node);
- if (RC_CHK_EQUAL(new_map, replacement_map)) {
- struct map *map_ref;
-
- map__set_start(map, map__start(new_map));
- map__set_end(map, map__end(new_map));
- map__set_pgoff(map, map__pgoff(new_map));
- map__set_mapping_type(map, map__mapping_type(new_map));
- /* Ensure maps are correctly ordered */
- map_ref = map__get(map);
- maps__remove(kmaps, map_ref);
- err = maps__insert(kmaps, map_ref);
- map__put(map_ref);
- map__put(new_map);
- if (err)
- goto out_err;
- } else {
+ /* skip if replacement_map, already inserted above */
+ if (!RC_CHK_EQUAL(new_map, replacement_map)) {
/*
* Merge kcore map into existing maps,
* and ensure that current maps (eBPF)
@@ -1418,10 +1425,10 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
* Set the data type and long name so that kcore can be read via
* dso__data_read_addr().
*/
- if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
- dso->binary_type = DSO_BINARY_TYPE__GUEST_KCORE;
+ if (dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST)
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__GUEST_KCORE);
else
- dso->binary_type = DSO_BINARY_TYPE__KCORE;
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__KCORE);
dso__set_long_name(dso, strdup(kcore_filename), true);
close(fd);
@@ -1482,13 +1489,13 @@ int __dso__load_kallsyms(struct dso *dso, const char *filename,
if (kallsyms__delta(kmap, filename, &delta))
return -1;
- symbols__fixup_end(&dso->symbols, true);
- symbols__fixup_duplicate(&dso->symbols);
+ symbols__fixup_end(dso__symbols(dso), true);
+ symbols__fixup_duplicate(dso__symbols(dso));
- if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
- dso->symtab_type = DSO_BINARY_TYPE__GUEST_KALLSYMS;
+ if (dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST)
+ dso__set_symtab_type(dso, DSO_BINARY_TYPE__GUEST_KALLSYMS);
else
- dso->symtab_type = DSO_BINARY_TYPE__KALLSYMS;
+ dso__set_symtab_type(dso, DSO_BINARY_TYPE__KALLSYMS);
if (!no_kcore && !dso__load_kcore(dso, map, filename))
return maps__split_kallsyms_for_kcore(kmap->kmaps, dso);
@@ -1544,7 +1551,7 @@ static int dso__load_perf_map(const char *map_path, struct dso *dso)
if (sym == NULL)
goto out_delete_line;
- symbols__insert(&dso->symbols, sym);
+ symbols__insert(dso__symbols(dso), sym);
nr_syms++;
}
@@ -1670,15 +1677,15 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
if (!symbol)
goto out_free;
- symbols__insert(&dso->symbols, symbol);
+ symbols__insert(dso__symbols(dso), symbol);
}
#ifdef bfd_get_section
#undef bfd_asymbol_section
#endif
- symbols__fixup_end(&dso->symbols, false);
- symbols__fixup_duplicate(&dso->symbols);
- dso->adjust_symbols = 1;
+ symbols__fixup_end(dso__symbols(dso), false);
+ symbols__fixup_duplicate(dso__symbols(dso));
+ dso__set_adjust_symbols(dso, true);
err = 0;
out_free:
@@ -1701,17 +1708,17 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO:
case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
- return !kmod && dso->kernel == DSO_SPACE__USER;
+ return !kmod && dso__kernel(dso) == DSO_SPACE__USER;
case DSO_BINARY_TYPE__KALLSYMS:
case DSO_BINARY_TYPE__VMLINUX:
case DSO_BINARY_TYPE__KCORE:
- return dso->kernel == DSO_SPACE__KERNEL;
+ return dso__kernel(dso) == DSO_SPACE__KERNEL;
case DSO_BINARY_TYPE__GUEST_KALLSYMS:
case DSO_BINARY_TYPE__GUEST_VMLINUX:
case DSO_BINARY_TYPE__GUEST_KCORE:
- return dso->kernel == DSO_SPACE__KERNEL_GUEST;
+ return dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST;
case DSO_BINARY_TYPE__GUEST_KMODULE:
case DSO_BINARY_TYPE__GUEST_KMODULE_COMP:
@@ -1721,7 +1728,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
* kernel modules know their symtab type - it's set when
* creating a module dso in machine__addnew_module_map().
*/
- return kmod && dso->symtab_type == type;
+ return kmod && dso__symtab_type(dso) == type;
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
@@ -1789,18 +1796,19 @@ int dso__load(struct dso *dso, struct map *map)
struct build_id bid;
struct nscookie nsc;
char newmapname[PATH_MAX];
- const char *map_path = dso->long_name;
+ const char *map_path = dso__long_name(dso);
- mutex_lock(&dso->lock);
- perfmap = strncmp(dso->name, "/tmp/perf-", 10) == 0;
+ mutex_lock(dso__lock(dso));
+ perfmap = strncmp(dso__name(dso), "/tmp/perf-", 10) == 0;
if (perfmap) {
- if (dso->nsinfo && (dso__find_perf_map(newmapname,
- sizeof(newmapname), &dso->nsinfo) == 0)) {
+ if (dso__nsinfo(dso) &&
+ (dso__find_perf_map(newmapname, sizeof(newmapname),
+ dso__nsinfo_ptr(dso)) == 0)) {
map_path = newmapname;
}
}
- nsinfo__mountns_enter(dso->nsinfo, &nsc);
+ nsinfo__mountns_enter(dso__nsinfo(dso), &nsc);
/* check again under the dso->lock */
if (dso__loaded(dso)) {
@@ -1808,15 +1816,15 @@ int dso__load(struct dso *dso, struct map *map)
goto out;
}
- kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
- dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
- dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE ||
- dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
+ kmod = dso__symtab_type(dso) == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
+ dso__symtab_type(dso) == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
+ dso__symtab_type(dso) == DSO_BINARY_TYPE__GUEST_KMODULE ||
+ dso__symtab_type(dso) == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
- if (dso->kernel && !kmod) {
- if (dso->kernel == DSO_SPACE__KERNEL)
+ if (dso__kernel(dso) && !kmod) {
+ if (dso__kernel(dso) == DSO_SPACE__KERNEL)
ret = dso__load_kernel_sym(dso, map);
- else if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
+ else if (dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST)
ret = dso__load_guest_kernel_sym(dso, map);
machine = maps__machine(map__kmaps(map));
@@ -1825,12 +1833,13 @@ int dso__load(struct dso *dso, struct map *map)
goto out;
}
- dso->adjust_symbols = 0;
+ dso__set_adjust_symbols(dso, false);
if (perfmap) {
ret = dso__load_perf_map(map_path, dso);
- dso->symtab_type = ret > 0 ? DSO_BINARY_TYPE__JAVA_JIT :
- DSO_BINARY_TYPE__NOT_FOUND;
+ dso__set_symtab_type(dso, ret > 0
+ ? DSO_BINARY_TYPE__JAVA_JIT
+ : DSO_BINARY_TYPE__NOT_FOUND);
goto out;
}
@@ -1845,9 +1854,9 @@ int dso__load(struct dso *dso, struct map *map)
* Read the build id if possible. This is required for
* DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
*/
- if (!dso->has_build_id &&
- is_regular_file(dso->long_name)) {
- __symbol__join_symfs(name, PATH_MAX, dso->long_name);
+ if (!dso__has_build_id(dso) &&
+ is_regular_file(dso__long_name(dso))) {
+ __symbol__join_symfs(name, PATH_MAX, dso__long_name(dso));
if (filename__read_build_id(name, &bid) > 0)
dso__set_build_id(dso, &bid);
}
@@ -1881,7 +1890,7 @@ int dso__load(struct dso *dso, struct map *map)
nsinfo__mountns_exit(&nsc);
is_reg = is_regular_file(name);
- if (!is_reg && errno == ENOENT && dso->nsinfo) {
+ if (!is_reg && errno == ENOENT && dso__nsinfo(dso)) {
char *new_name = dso__filename_with_chroot(dso, name);
if (new_name) {
is_reg = is_regular_file(new_name);
@@ -1898,7 +1907,7 @@ int dso__load(struct dso *dso, struct map *map)
sirc = symsrc__init(ss, dso, name, symtab_type);
if (nsexit)
- nsinfo__mountns_enter(dso->nsinfo, &nsc);
+ nsinfo__mountns_enter(dso__nsinfo(dso), &nsc);
if (bfdrc == 0) {
ret = 0;
@@ -1911,8 +1920,8 @@ int dso__load(struct dso *dso, struct map *map)
if (!syms_ss && symsrc__has_symtab(ss)) {
syms_ss = ss;
next_slot = true;
- if (!dso->symsrc_filename)
- dso->symsrc_filename = strdup(name);
+ if (!dso__symsrc_filename(dso))
+ dso__set_symsrc_filename(dso, strdup(name));
}
if (!runtime_ss && symsrc__possibly_runtime(ss)) {
@@ -1959,16 +1968,20 @@ int dso__load(struct dso *dso, struct map *map)
symsrc__destroy(&ss_[ss_pos - 1]);
out_free:
free(name);
- if (ret < 0 && strstr(dso->name, " (deleted)") != NULL)
+ if (ret < 0 && strstr(dso__name(dso), " (deleted)") != NULL)
ret = 0;
out:
dso__set_loaded(dso);
- mutex_unlock(&dso->lock);
+ mutex_unlock(dso__lock(dso));
nsinfo__mountns_exit(&nsc);
return ret;
}
+/*
+ * Always takes ownership of vmlinux when vmlinux_allocated == true, even if
+ * it returns an error.
+ */
int dso__load_vmlinux(struct dso *dso, struct map *map,
const char *vmlinux, bool vmlinux_allocated)
{
@@ -1982,23 +1995,26 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
else
symbol__join_symfs(symfs_vmlinux, vmlinux);
- if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
+ if (dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST)
symtab_type = DSO_BINARY_TYPE__GUEST_VMLINUX;
else
symtab_type = DSO_BINARY_TYPE__VMLINUX;
- if (symsrc__init(&ss, dso, symfs_vmlinux, symtab_type))
+ if (symsrc__init(&ss, dso, symfs_vmlinux, symtab_type)) {
+ if (vmlinux_allocated)
+ free((char *) vmlinux);
return -1;
+ }
/*
* dso__load_sym() may copy 'dso' which will result in the copies having
* an incorrect long name unless we set it here first.
*/
dso__set_long_name(dso, vmlinux, vmlinux_allocated);
- if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
- dso->binary_type = DSO_BINARY_TYPE__GUEST_VMLINUX;
+ if (dso__kernel(dso) == DSO_SPACE__KERNEL_GUEST)
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__GUEST_VMLINUX);
else
- dso->binary_type = DSO_BINARY_TYPE__VMLINUX;
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__VMLINUX);
err = dso__load_sym(dso, map, &ss, &ss, 0);
symsrc__destroy(&ss);
@@ -2031,7 +2047,6 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map)
err = dso__load_vmlinux(dso, map, filename, true);
if (err > 0)
goto out;
- free(filename);
}
out:
return err;
@@ -2091,7 +2106,7 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
bool is_host = false;
char path[PATH_MAX];
- if (!dso->has_build_id) {
+ if (!dso__has_build_id(dso)) {
/*
* Last resort, if we don't have a build-id and couldn't find
* any vmlinux file, try the running kernel kallsyms table.
@@ -2116,7 +2131,7 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
goto proc_kallsyms;
}
- build_id__sprintf(&dso->bid, sbuild_id);
+ build_id__sprintf(dso__bid(dso), sbuild_id);
/* Find kallsyms in build-id cache with kcore */
scnprintf(path, sizeof(path), "%s/%s/%s",
@@ -2183,7 +2198,6 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map)
err = dso__load_vmlinux(dso, map, filename, true);
if (err > 0)
return err;
- free(filename);
}
if (!symbol_conf.ignore_vmlinux && vmlinux_path != NULL) {
@@ -2209,7 +2223,7 @@ do_kallsyms:
free(kallsyms_allocated_filename);
if (err > 0 && !dso__is_kcore(dso)) {
- dso->binary_type = DSO_BINARY_TYPE__KALLSYMS;
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__KALLSYMS);
dso__set_long_name(dso, DSO__NAME_KALLSYMS, false);
map__fixup_start(map);
map__fixup_end(map);
@@ -2252,7 +2266,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map)
if (err > 0)
pr_debug("Using %s for symbols\n", kallsyms_filename);
if (err > 0 && !dso__is_kcore(dso)) {
- dso->binary_type = DSO_BINARY_TYPE__GUEST_KALLSYMS;
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__GUEST_KALLSYMS);
dso__set_long_name(dso, machine->mmap_name, false);
map__fixup_start(map);
map__fixup_end(map);
@@ -2566,31 +2580,6 @@ int symbol__config_symfs(const struct option *opt __maybe_unused,
return 0;
}
-struct mem_info *mem_info__get(struct mem_info *mi)
-{
- if (mi)
- refcount_inc(&mi->refcnt);
- return mi;
-}
-
-void mem_info__put(struct mem_info *mi)
-{
- if (mi && refcount_dec_and_test(&mi->refcnt)) {
- addr_map_symbol__exit(&mi->iaddr);
- addr_map_symbol__exit(&mi->daddr);
- free(mi);
- }
-}
-
-struct mem_info *mem_info__new(void)
-{
- struct mem_info *mi = zalloc(sizeof(*mi));
-
- if (mi)
- refcount_set(&mi->refcnt, 1);
- return mi;
-}
-
/*
* Checks that user supplied symbol kernel files are accessible because
* the default mechanism for accessing elf files fails silently. i.e. if