summaryrefslogtreecommitdiff
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c77
1 files changed, 38 insertions, 39 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index cca871959f87..117c4bb78b35 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -168,7 +168,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
if (dso == NULL)
goto out_delete;
- assert(!dso->kernel);
+ assert(!dso__kernel(dso));
map__init(result, start, start + len, pgoff, dso);
if (anon || no_dso) {
@@ -182,10 +182,9 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
if (!(prot & PROT_EXEC))
dso__set_loaded(dso);
}
- mutex_lock(&dso->lock);
- nsinfo__put(dso->nsinfo);
- dso->nsinfo = nsi;
- mutex_unlock(&dso->lock);
+ mutex_lock(dso__lock(dso));
+ dso__set_nsinfo(dso, nsi);
+ mutex_unlock(dso__lock(dso));
if (build_id__is_defined(bid)) {
dso__set_build_id(dso, bid);
@@ -197,9 +196,9 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
* have it missing.
*/
header_bid_dso = dsos__find(&machine->dsos, filename, false);
- if (header_bid_dso && header_bid_dso->header_build_id) {
- dso__set_build_id(dso, &header_bid_dso->bid);
- dso->header_build_id = 1;
+ if (header_bid_dso && dso__header_build_id(header_bid_dso)) {
+ dso__set_build_id(dso, dso__bid(header_bid_dso));
+ dso__set_header_build_id(dso, 1);
}
}
dso__put(dso);
@@ -221,7 +220,7 @@ struct map *map__new2(u64 start, struct dso *dso)
struct map *result;
RC_STRUCT(map) *map;
- map = calloc(1, sizeof(*map) + (dso->kernel ? sizeof(struct kmap) : 0));
+ map = calloc(1, sizeof(*map) + (dso__kernel(dso) ? sizeof(struct kmap) : 0));
if (ADD_RC_CHK(result, map)) {
/*
* ->end will be filled after we load all the symbols
@@ -234,7 +233,7 @@ struct map *map__new2(u64 start, struct dso *dso)
bool __map__is_kernel(const struct map *map)
{
- if (!map__dso(map)->kernel)
+ if (!dso__kernel(map__dso(map)))
return false;
return machine__kernel_map(maps__machine(map__kmaps((struct map *)map))) == map;
}
@@ -251,7 +250,7 @@ bool __map__is_bpf_prog(const struct map *map)
const char *name;
struct dso *dso = map__dso(map);
- if (dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO)
+ if (dso__binary_type(dso) == DSO_BINARY_TYPE__BPF_PROG_INFO)
return true;
/*
@@ -259,7 +258,7 @@ bool __map__is_bpf_prog(const struct map *map)
* type of DSO_BINARY_TYPE__BPF_PROG_INFO. In such cases, we can
* guess the type based on name.
*/
- name = dso->short_name;
+ name = dso__short_name(dso);
return name && (strstr(name, "bpf_prog_") == name);
}
@@ -268,7 +267,7 @@ bool __map__is_bpf_image(const struct map *map)
const char *name;
struct dso *dso = map__dso(map);
- if (dso->binary_type == DSO_BINARY_TYPE__BPF_IMAGE)
+ if (dso__binary_type(dso) == DSO_BINARY_TYPE__BPF_IMAGE)
return true;
/*
@@ -276,7 +275,7 @@ bool __map__is_bpf_image(const struct map *map)
* type of DSO_BINARY_TYPE__BPF_IMAGE. In such cases, we can
* guess the type based on name.
*/
- name = dso->short_name;
+ name = dso__short_name(dso);
return name && is_bpf_image(name);
}
@@ -284,7 +283,7 @@ bool __map__is_ool(const struct map *map)
{
const struct dso *dso = map__dso(map);
- return dso && dso->binary_type == DSO_BINARY_TYPE__OOL;
+ return dso && dso__binary_type(dso) == DSO_BINARY_TYPE__OOL;
}
bool map__has_symbols(const struct map *map)
@@ -315,7 +314,7 @@ void map__put(struct map *map)
void map__fixup_start(struct map *map)
{
struct dso *dso = map__dso(map);
- struct rb_root_cached *symbols = &dso->symbols;
+ struct rb_root_cached *symbols = dso__symbols(dso);
struct rb_node *nd = rb_first_cached(symbols);
if (nd != NULL) {
@@ -328,7 +327,7 @@ void map__fixup_start(struct map *map)
void map__fixup_end(struct map *map)
{
struct dso *dso = map__dso(map);
- struct rb_root_cached *symbols = &dso->symbols;
+ struct rb_root_cached *symbols = dso__symbols(dso);
struct rb_node *nd = rb_last(&symbols->rb_root);
if (nd != NULL) {
@@ -342,7 +341,7 @@ void map__fixup_end(struct map *map)
int map__load(struct map *map)
{
struct dso *dso = map__dso(map);
- const char *name = dso->long_name;
+ const char *name = dso__long_name(dso);
int nr;
if (dso__loaded(dso))
@@ -350,10 +349,10 @@ int map__load(struct map *map)
nr = dso__load(dso, map);
if (nr < 0) {
- if (dso->has_build_id) {
+ if (dso__has_build_id(dso)) {
char sbuild_id[SBUILD_ID_SIZE];
- build_id__sprintf(&dso->bid, sbuild_id);
+ build_id__sprintf(dso__bid(dso), sbuild_id);
pr_debug("%s with build id %s not found", name, sbuild_id);
} else
pr_debug("Failed to open %s", name);
@@ -415,7 +414,7 @@ struct map *map__clone(struct map *from)
size_t size = sizeof(RC_STRUCT(map));
struct dso *dso = map__dso(from);
- if (dso && dso->kernel)
+ if (dso && dso__kernel(dso))
size += sizeof(struct kmap);
map = memdup(RC_CHK_ACCESS(from), size);
@@ -432,14 +431,14 @@ size_t map__fprintf(struct map *map, FILE *fp)
const struct dso *dso = map__dso(map);
return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n",
- map__start(map), map__end(map), map__pgoff(map), dso->name);
+ map__start(map), map__end(map), map__pgoff(map), dso__name(dso));
}
static bool prefer_dso_long_name(const struct dso *dso, bool print_off)
{
- return dso->long_name &&
+ return dso__long_name(dso) &&
(symbol_conf.show_kernel_path ||
- (print_off && (dso->name[0] == '[' || dso__is_kcore(dso))));
+ (print_off && (dso__name(dso)[0] == '[' || dso__is_kcore(dso))));
}
static size_t __map__fprintf_dsoname(struct map *map, bool print_off, FILE *fp)
@@ -450,9 +449,9 @@ static size_t __map__fprintf_dsoname(struct map *map, bool print_off, FILE *fp)
if (dso) {
if (prefer_dso_long_name(dso, print_off))
- dsoname = dso->long_name;
+ dsoname = dso__long_name(dso);
else
- dsoname = dso->name;
+ dsoname = dso__name(dso);
}
if (symbol_conf.pad_output_len_dso) {
@@ -545,14 +544,14 @@ u64 map__rip_2objdump(struct map *map, u64 rip)
}
}
- if (!dso->adjust_symbols)
+ if (!dso__adjust_symbols(dso))
return rip;
- if (dso->rel)
+ if (dso__rel(dso))
return rip - map__pgoff(map);
- if (dso->kernel == DSO_SPACE__USER)
- return rip + dso->text_offset;
+ if (dso__kernel(dso) == DSO_SPACE__USER)
+ return rip + dso__text_offset(dso);
return map__unmap_ip(map, rip) - map__reloc(map);
}
@@ -573,14 +572,14 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
{
const struct dso *dso = map__dso(map);
- if (!dso->adjust_symbols)
+ if (!dso__adjust_symbols(dso))
return map__unmap_ip(map, ip);
- if (dso->rel)
+ if (dso__rel(dso))
return map__unmap_ip(map, ip + map__pgoff(map));
- if (dso->kernel == DSO_SPACE__USER)
- return map__unmap_ip(map, ip - dso->text_offset);
+ if (dso__kernel(dso) == DSO_SPACE__USER)
+ return map__unmap_ip(map, ip - dso__text_offset(dso));
return ip + map__reloc(map);
}
@@ -590,14 +589,14 @@ u64 map__objdump_2rip(struct map *map, u64 ip)
{
const struct dso *dso = map__dso(map);
- if (!dso->adjust_symbols)
+ if (!dso__adjust_symbols(dso))
return ip;
- if (dso->rel)
+ if (dso__rel(dso))
return ip + map__pgoff(map);
- if (dso->kernel == DSO_SPACE__USER)
- return ip - dso->text_offset;
+ if (dso__kernel(dso) == DSO_SPACE__USER)
+ return ip - dso__text_offset(dso);
return map__map_ip(map, ip + map__reloc(map));
}
@@ -613,7 +612,7 @@ struct kmap *__map__kmap(struct map *map)
{
const struct dso *dso = map__dso(map);
- if (!dso || !dso->kernel)
+ if (!dso || !dso__kernel(dso))
return NULL;
return (struct kmap *)(&RC_CHK_ACCESS(map)[1]);
}