Commit e5116f46 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf map: Add accessor for start and end

Later changes will add reference count checking for struct map, start
and end are frequently accessed variables. Add an accessor so that the
reference count check is only necessary in one place.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Miaoqian Lin <linmq006@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
Cc: Song Liu <song@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yury Norov <yury.norov@gmail.com>
Link: https://lore.kernel.org/r/20230320212248.1175731-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 63df0e4b
...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1; return -1;
} }
stack_size = map->end - sp; stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size; stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
memcpy(buf, (void *) sp, stack_size); memcpy(buf, (void *) sp, stack_size);
......
...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1; return -1;
} }
stack_size = map->end - sp; stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size; stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
memcpy(buf, (void *) sp, stack_size); memcpy(buf, (void *) sp, stack_size);
......
...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1; return -1;
} }
stack_size = map->end - sp; stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size; stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
memcpy(buf, (void *) sp, stack_size); memcpy(buf, (void *) sp, stack_size);
......
...@@ -262,7 +262,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain) ...@@ -262,7 +262,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
return skip_slot; return skip_slot;
} }
rc = check_return_addr(dso, al.map->start, 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, al.sym->name, ip, rc);
......
...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample, ...@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1; return -1;
} }
stack_size = map->end - sp; stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size; stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
memcpy(buf, (void *) sp, stack_size); memcpy(buf, (void *) sp, stack_size);
......
...@@ -59,8 +59,8 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, ...@@ -59,8 +59,8 @@ int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
event->mmap.header.size = size; event->mmap.header.size = size;
event->mmap.start = map->start; event->mmap.start = map__start(map);
event->mmap.len = map->end - map->start; event->mmap.len = map__size(map);
event->mmap.pgoff = map->pgoff; event->mmap.pgoff = map->pgoff;
event->mmap.pid = machine->pid; event->mmap.pid = machine->pid;
......
...@@ -30,7 +30,7 @@ static int buildid__map_cb(struct map *map, void *arg __maybe_unused) ...@@ -30,7 +30,7 @@ static int buildid__map_cb(struct map *map, void *arg __maybe_unused)
memset(bid_buf, 0, sizeof(bid_buf)); memset(bid_buf, 0, sizeof(bid_buf));
if (dso->has_build_id) if (dso->has_build_id)
build_id__sprintf(&dso->bid, bid_buf); build_id__sprintf(&dso->bid, bid_buf);
printf("%s %16" PRIx64 " %16" PRIx64, bid_buf, map->start, map->end); printf("%s %16" PRIx64 " %16" PRIx64, bid_buf, map__start(map), map__end(map));
if (dso->long_name != NULL) { if (dso->long_name != NULL) {
printf(" %s", dso->long_name); printf(" %s", dso->long_name);
} else if (dso->short_name != NULL) { } else if (dso->short_name != NULL) {
......
...@@ -851,7 +851,7 @@ static size_t maps__fprintf_task(struct maps *maps, int indent, FILE *fp) ...@@ -851,7 +851,7 @@ static size_t maps__fprintf_task(struct maps *maps, int indent, FILE *fp)
const struct dso *dso = map__dso(map); const struct dso *dso = map__dso(map);
printed += fprintf(fp, "%*s %" PRIx64 "-%" PRIx64 " %c%c%c%c %08" PRIx64 " %" PRIu64 " %s\n", printed += fprintf(fp, "%*s %" PRIx64 "-%" PRIx64 " %c%c%c%c %08" PRIx64 " %" PRIu64 " %s\n",
indent, "", map->start, map->end, indent, "", map__start(map), map__end(map),
map->prot & PROT_READ ? 'r' : '-', map->prot & PROT_READ ? 'r' : '-',
map->prot & PROT_WRITE ? 'w' : '-', map->prot & PROT_WRITE ? 'w' : '-',
map->prot & PROT_EXEC ? 'x' : '-', map->prot & PROT_EXEC ? 'x' : '-',
......
...@@ -1209,7 +1209,7 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread, ...@@ -1209,7 +1209,7 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread,
if (al.addr < al.sym->end) if (al.addr < al.sym->end)
off = al.addr - al.sym->start; off = al.addr - al.sym->start;
else else
off = al.addr - al.map->start - al.sym->start; off = al.addr - map__start(al.map) - al.sym->start;
printed += fprintf(fp, "\t%s", al.sym->name); printed += fprintf(fp, "\t%s", al.sym->name);
if (off) if (off)
printed += fprintf(fp, "%+d", off); printed += fprintf(fp, "%+d", off);
......
...@@ -183,7 +183,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip) ...@@ -183,7 +183,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)
"Not all samples will be on the annotation output.\n\n" "Not all samples will be on the annotation output.\n\n"
"Please report to linux-kernel@vger.kernel.org\n", "Please report to linux-kernel@vger.kernel.org\n",
ip, dso->long_name, dso__symtab_origin(dso), ip, dso->long_name, dso__symtab_origin(dso),
map->start, map->end, sym->start, sym->end, map__start(map), map__end(map), sym->start, sym->end,
sym->binding == STB_GLOBAL ? 'g' : sym->binding == STB_GLOBAL ? 'g' :
sym->binding == STB_LOCAL ? 'l' : 'w', sym->name, sym->binding == STB_LOCAL ? 'l' : 'w', sym->name,
err ? "[unknown]" : uts.machine, err ? "[unknown]" : uts.machine,
......
...@@ -265,8 +265,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, ...@@ -265,8 +265,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
len = BUFSZ; len = BUFSZ;
/* Do not go off the map */ /* Do not go off the map */
if (addr + len > al.map->end) if (addr + len > map__end(al.map))
len = al.map->end - addr; len = map__end(al.map) - addr;
/* Read the object code using perf */ /* Read the object code using perf */
ret_len = dso__data_read_offset(dso, maps__machine(thread->maps), ret_len = dso__data_read_offset(dso, maps__machine(thread->maps),
...@@ -291,7 +291,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, ...@@ -291,7 +291,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
size_t d; size_t d;
for (d = 0; d < state->done_cnt; d++) { for (d = 0; d < state->done_cnt; d++) {
if (state->done[d] == al.map->start) { if (state->done[d] == map__start(al.map)) {
pr_debug("kcore map tested already"); pr_debug("kcore map tested already");
pr_debug(" - skipping\n"); pr_debug(" - skipping\n");
goto out; goto out;
...@@ -301,7 +301,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, ...@@ -301,7 +301,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
pr_debug("Too many kcore maps - skipping\n"); pr_debug("Too many kcore maps - skipping\n");
goto out; goto out;
} }
state->done[state->done_cnt++] = al.map->start; state->done[state->done_cnt++] = map__start(al.map);
} }
objdump_name = dso->long_name; objdump_name = dso->long_name;
......
...@@ -24,8 +24,8 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma ...@@ -24,8 +24,8 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma
if (i > 0) if (i > 0)
TEST_ASSERT_VAL("less maps expected", (map && i < size) || (!map && i == size)); TEST_ASSERT_VAL("less maps expected", (map && i < size) || (!map && i == size));
TEST_ASSERT_VAL("wrong map start", map->start == merged[i].start); TEST_ASSERT_VAL("wrong map start", map__start(map) == merged[i].start);
TEST_ASSERT_VAL("wrong map end", map->end == merged[i].end); TEST_ASSERT_VAL("wrong map end", map__end(map) == merged[i].end);
TEST_ASSERT_VAL("wrong map name", !strcmp(map__dso(map)->name, merged[i].name)); TEST_ASSERT_VAL("wrong map name", !strcmp(map__dso(map)->name, merged[i].name));
TEST_ASSERT_VAL("wrong map refcnt", refcount_read(&map->refcnt) == 1); TEST_ASSERT_VAL("wrong map refcnt", refcount_read(&map->refcnt) == 1);
......
...@@ -202,7 +202,7 @@ static int mmap_events(synth_cb synth) ...@@ -202,7 +202,7 @@ static int mmap_events(synth_cb synth)
break; break;
} }
pr_debug("map %p, addr %" PRIx64 "\n", al.map, al.map->start); pr_debug("map %p, addr %" PRIx64 "\n", al.map, map__start(al.map));
} }
machine__delete_threads(machine); machine__delete_threads(machine);
......
...@@ -267,7 +267,7 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused ...@@ -267,7 +267,7 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
continue; continue;
} }
} else if (mem_start == kallsyms.vmlinux_map->end) { } else if (mem_start == map__end(kallsyms.vmlinux_map)) {
/* /*
* Ignore aliases to _etext, i.e. to the end of the kernel text area, * Ignore aliases to _etext, i.e. to the end of the kernel text area,
* such as __indirect_thunk_end. * such as __indirect_thunk_end.
...@@ -319,14 +319,14 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused ...@@ -319,14 +319,14 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
maps__for_each_entry(maps, rb_node) { maps__for_each_entry(maps, rb_node) {
struct map *pair, *map = rb_node->map; struct map *pair, *map = rb_node->map;
mem_start = vmlinux_map->unmap_ip(vmlinux_map, map->start); mem_start = vmlinux_map->unmap_ip(vmlinux_map, map__start(map));
mem_end = vmlinux_map->unmap_ip(vmlinux_map, map->end); mem_end = vmlinux_map->unmap_ip(vmlinux_map, map__end(map));
pair = maps__find(kallsyms.kmaps, mem_start); pair = maps__find(kallsyms.kmaps, mem_start);
if (pair == NULL || pair->priv) if (pair == NULL || pair->priv)
continue; continue;
if (pair->start == mem_start) { if (map__start(pair) == mem_start) {
struct dso *dso = map__dso(map); struct dso *dso = map__dso(map);
if (!header_printed) { if (!header_printed) {
...@@ -335,10 +335,10 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused ...@@ -335,10 +335,10 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
} }
pr_info("WARN: %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as", pr_info("WARN: %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as",
map->start, map->end, map->pgoff, dso->name); map__start(map), map__end(map), map->pgoff, dso->name);
if (mem_end != pair->end) if (mem_end != map__end(pair))
pr_info(":\nWARN: *%" PRIx64 "-%" PRIx64 " %" PRIx64, pr_info(":\nWARN: *%" PRIx64 "-%" PRIx64 " %" PRIx64,
pair->start, pair->end, pair->pgoff); map__start(pair), map__end(pair), pair->pgoff);
pr_info(" %s\n", dso->name); pr_info(" %s\n", dso->name);
pair->priv = 1; pair->priv = 1;
} }
......
...@@ -1008,13 +1008,13 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, ...@@ -1008,13 +1008,13 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
if (start && if (start &&
(start->ms.sym == ams->ms.sym || (start->ms.sym == ams->ms.sym ||
(ams->ms.sym && (ams->ms.sym &&
start->addr == ams->ms.sym->start + ams->ms.map->start))) start->addr == ams->ms.sym->start + map__start(ams->ms.map))))
saddr = start->al_addr; saddr = start->al_addr;
if (saddr == 0) if (saddr == 0)
pr_debug2("BB with bad start: addr %"PRIx64" start %"PRIx64" sym %"PRIx64" saddr %"PRIx64"\n", pr_debug2("BB with bad start: addr %"PRIx64" start %"PRIx64" sym %"PRIx64" saddr %"PRIx64"\n",
ams->addr, ams->addr,
start ? start->addr : 0, start ? start->addr : 0,
ams->ms.sym ? ams->ms.sym->start + ams->ms.map->start : 0, ams->ms.sym ? ams->ms.sym->start + map__start(ams->ms.map) : 0,
saddr); saddr);
err = symbol__account_cycles(ams->al_addr, saddr, ams->ms.sym, cycles); err = symbol__account_cycles(ams->al_addr, saddr, ams->ms.sym, cycles);
if (err) if (err)
......
...@@ -51,7 +51,7 @@ static void al_to_d_al(struct addr_location *al, struct perf_dlfilter_al *d_al) ...@@ -51,7 +51,7 @@ static void al_to_d_al(struct addr_location *al, struct perf_dlfilter_al *d_al)
if (al->addr < sym->end) if (al->addr < sym->end)
d_al->symoff = al->addr - sym->start; d_al->symoff = al->addr - sym->start;
else else
d_al->symoff = al->addr - al->map->start - sym->start; d_al->symoff = al->addr - map__start(al->map) - sym->start;
d_al->sym_binding = sym->binding; d_al->sym_binding = sym->binding;
} else { } else {
d_al->sym = NULL; d_al->sym = NULL;
...@@ -268,7 +268,7 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len) ...@@ -268,7 +268,7 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
map = al->map; map = al->map;
if (map && ip >= map->start && ip < map->end && if (map && ip >= map__start(map) && ip < map__end(map) &&
machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip)) machine__kernel_ip(d->machine, ip) == machine__kernel_ip(d->machine, d->sample->ip))
goto have_map; goto have_map;
...@@ -279,8 +279,8 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len) ...@@ -279,8 +279,8 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
map = a.map; map = a.map;
have_map: have_map:
offset = map->map_ip(map, ip); offset = map->map_ip(map, ip);
if (ip + len >= map->end) if (ip + len >= map__end(map))
len = map->end - ip; len = map__end(map) - ip;
return dso__data_read_offset(map__dso(map), d->machine, offset, buf, len); return dso__data_read_offset(map__dso(map), d->machine, offset, buf, len);
} }
......
...@@ -887,7 +887,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, ...@@ -887,7 +887,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
goto out_no_cache; goto out_no_cache;
} }
if (*ip >= al.map->end) if (*ip >= map__end(al.map))
break; break;
offset += intel_pt_insn->length; offset += intel_pt_insn->length;
...@@ -2750,7 +2750,7 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip) ...@@ -2750,7 +2750,7 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)
if (sym->binding == STB_GLOBAL && if (sym->binding == STB_GLOBAL &&
!strcmp(sym->name, "__switch_to")) { !strcmp(sym->name, "__switch_to")) {
ip = map->unmap_ip(map, sym->start); ip = map->unmap_ip(map, sym->start);
if (ip >= map->start && ip < map->end) { if (ip >= map__start(map) && ip < map__end(map)) {
switch_ip = ip; switch_ip = ip;
break; break;
} }
...@@ -2768,7 +2768,7 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip) ...@@ -2768,7 +2768,7 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)
for (sym = start; sym; sym = dso__next_symbol(sym)) { for (sym = start; sym; sym = dso__next_symbol(sym)) {
if (!strcmp(sym->name, ptss)) { if (!strcmp(sym->name, ptss)) {
ip = map->unmap_ip(map, sym->start); ip = map->unmap_ip(map, sym->start);
if (ip >= map->start && ip < map->end) { if (ip >= map__start(map) && ip < map__end(map)) {
*ptss_ip = ip; *ptss_ip = ip;
break; break;
} }
...@@ -3356,7 +3356,7 @@ static int intel_pt_process_aux_output_hw_id(struct intel_pt *pt, ...@@ -3356,7 +3356,7 @@ static int intel_pt_process_aux_output_hw_id(struct intel_pt *pt,
static int intel_pt_find_map(struct thread *thread, u8 cpumode, u64 addr, static int intel_pt_find_map(struct thread *thread, u8 cpumode, u64 addr,
struct addr_location *al) struct addr_location *al)
{ {
if (!al->map || addr < al->map->start || addr >= al->map->end) { if (!al->map || addr < map__start(al->map) || addr >= map__end(al->map)) {
if (!thread__find_map(thread, cpumode, addr, al)) if (!thread__find_map(thread, cpumode, addr, al))
return -1; return -1;
} }
......
...@@ -903,7 +903,7 @@ static int machine__process_ksymbol_register(struct machine *machine, ...@@ -903,7 +903,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
} }
map->start = event->ksymbol.addr; map->start = event->ksymbol.addr;
map->end = map->start + event->ksymbol.len; map->end = map__start(map) + event->ksymbol.len;
err = maps__insert(machine__kernel_maps(machine), map); err = maps__insert(machine__kernel_maps(machine), map);
map__put(map); map__put(map);
if (err) if (err)
...@@ -919,7 +919,7 @@ static int machine__process_ksymbol_register(struct machine *machine, ...@@ -919,7 +919,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
dso = map__dso(map); dso = map__dso(map);
} }
sym = symbol__new(map->map_ip(map, map->start), sym = symbol__new(map->map_ip(map, map__start(map)),
event->ksymbol.len, event->ksymbol.len,
0, 0, event->ksymbol.name); 0, 0, event->ksymbol.name);
if (!sym) if (!sym)
...@@ -944,7 +944,7 @@ static int machine__process_ksymbol_unregister(struct machine *machine, ...@@ -944,7 +944,7 @@ static int machine__process_ksymbol_unregister(struct machine *machine,
else { else {
struct dso *dso = map__dso(map); struct dso *dso = map__dso(map);
sym = dso__find_symbol(dso, map->map_ip(map, map->start)); sym = dso__find_symbol(dso, map->map_ip(map, map__start(map)));
if (sym) if (sym)
dso__delete_symbol(dso, sym); dso__delete_symbol(dso, sym);
} }
...@@ -1217,7 +1217,7 @@ int machine__create_extra_kernel_map(struct machine *machine, ...@@ -1217,7 +1217,7 @@ int machine__create_extra_kernel_map(struct machine *machine,
if (!err) { if (!err) {
pr_debug2("Added extra kernel map %s %" PRIx64 "-%" PRIx64 "\n", pr_debug2("Added extra kernel map %s %" PRIx64 "-%" PRIx64 "\n",
kmap->name, map->start, map->end); kmap->name, map__start(map), map__end(map));
} }
map__put(map); map__put(map);
...@@ -1722,7 +1722,7 @@ int machine__create_kernel_maps(struct machine *machine) ...@@ -1722,7 +1722,7 @@ int machine__create_kernel_maps(struct machine *machine)
struct map_rb_node *next = map_rb_node__next(rb_node); struct map_rb_node *next = map_rb_node__next(rb_node);
if (next) if (next)
machine__set_kernel_mmap(machine, start, next->map->start); machine__set_kernel_mmap(machine, start, map__start(next->map));
} }
out_put: out_put:
...@@ -1795,7 +1795,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine, ...@@ -1795,7 +1795,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
if (map == NULL) if (map == NULL)
goto out_problem; goto out_problem;
map->end = map->start + xm->end - xm->start; map->end = map__start(map) + xm->end - xm->start;
if (build_id__is_defined(bid)) if (build_id__is_defined(bid))
dso__set_build_id(map__dso(map), bid); dso__set_build_id(map__dso(map), bid);
...@@ -3293,7 +3293,7 @@ int machine__get_kernel_start(struct machine *machine) ...@@ -3293,7 +3293,7 @@ int machine__get_kernel_start(struct machine *machine)
* kernel_start = 1ULL << 63 for x86_64. * kernel_start = 1ULL << 63 for x86_64.
*/ */
if (!err && !machine__is(machine, "x86_64")) if (!err && !machine__is(machine, "x86_64"))
machine->kernel_start = map->start; machine->kernel_start = map__start(map);
} }
return err; return err;
} }
......
...@@ -421,7 +421,7 @@ size_t map__fprintf(struct map *map, FILE *fp) ...@@ -421,7 +421,7 @@ size_t map__fprintf(struct map *map, FILE *fp)
const struct dso *dso = map__dso(map); const struct dso *dso = map__dso(map);
return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n", return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n",
map->start, map->end, map->pgoff, dso->name); map__start(map), map__end(map), map->pgoff, dso->name);
} }
size_t map__fprintf_dsoname(struct map *map, FILE *fp) size_t map__fprintf_dsoname(struct map *map, FILE *fp)
...@@ -558,7 +558,7 @@ bool map__contains_symbol(const struct map *map, const struct symbol *sym) ...@@ -558,7 +558,7 @@ bool map__contains_symbol(const struct map *map, const struct symbol *sym)
{ {
u64 ip = map->unmap_ip(map, sym->start); u64 ip = map->unmap_ip(map, sym->start);
return ip >= map->start && ip < map->end; return ip >= map__start(map) && ip < map__end(map);
} }
struct kmap *__map__kmap(struct map *map) struct kmap *__map__kmap(struct map *map)
...@@ -592,12 +592,12 @@ struct maps *map__kmaps(struct map *map) ...@@ -592,12 +592,12 @@ struct maps *map__kmaps(struct map *map)
u64 map__map_ip(const struct map *map, u64 ip) u64 map__map_ip(const struct map *map, u64 ip)
{ {
return ip - map->start + map->pgoff; return ip - map__start(map) + map->pgoff;
} }
u64 map__unmap_ip(const struct map *map, u64 ip) u64 map__unmap_ip(const struct map *map, u64 ip)
{ {
return ip + map->start - map->pgoff; return ip + map__start(map) - map->pgoff;
} }
u64 identity__map_ip(const struct map *map __maybe_unused, u64 ip) u64 identity__map_ip(const struct map *map __maybe_unused, u64 ip)
......
...@@ -52,9 +52,19 @@ static inline struct dso *map__dso(const struct map *map) ...@@ -52,9 +52,19 @@ static inline struct dso *map__dso(const struct map *map)
return map->dso; return map->dso;
} }
static inline u64 map__start(const struct map *map)
{
return map->start;
}
static inline u64 map__end(const struct map *map)
{
return map->end;
}
static inline size_t map__size(const struct map *map) static inline size_t map__size(const struct map *map)
{ {
return map->end - map->start; return map__end(map) - map__start(map);
} }
/* rip/ip <-> addr suitable for passing to `objdump --start-address=` */ /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */
......
...@@ -34,7 +34,7 @@ static int __maps__insert(struct maps *maps, struct map *map) ...@@ -34,7 +34,7 @@ static int __maps__insert(struct maps *maps, struct map *map)
{ {
struct rb_node **p = &maps__entries(maps)->rb_node; struct rb_node **p = &maps__entries(maps)->rb_node;
struct rb_node *parent = NULL; struct rb_node *parent = NULL;
const u64 ip = map->start; const u64 ip = map__start(map);
struct map_rb_node *m, *new_rb_node; struct map_rb_node *m, *new_rb_node;
new_rb_node = malloc(sizeof(*new_rb_node)); new_rb_node = malloc(sizeof(*new_rb_node));
...@@ -47,7 +47,7 @@ static int __maps__insert(struct maps *maps, struct map *map) ...@@ -47,7 +47,7 @@ static int __maps__insert(struct maps *maps, struct map *map)
while (*p != NULL) { while (*p != NULL) {
parent = *p; parent = *p;
m = rb_entry(parent, struct map_rb_node, rb_node); m = rb_entry(parent, struct map_rb_node, rb_node);
if (ip < m->map->start) if (ip < map__start(m->map))
p = &(*p)->rb_left; p = &(*p)->rb_left;
else else
p = &(*p)->rb_right; p = &(*p)->rb_right;
...@@ -229,7 +229,7 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, st ...@@ -229,7 +229,7 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, st
int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams) int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams)
{ {
if (ams->addr < ams->ms.map->start || ams->addr >= ams->ms.map->end) { if (ams->addr < map__start(ams->ms.map) || ams->addr >= map__end(ams->ms.map)) {
if (maps == NULL) if (maps == NULL)
return -1; return -1;
ams->ms.map = maps__find(maps, ams->addr); ams->ms.map = maps__find(maps, ams->addr);
...@@ -283,9 +283,9 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -283,9 +283,9 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
while (next) { while (next) {
struct map_rb_node *pos = rb_entry(next, struct map_rb_node, rb_node); struct map_rb_node *pos = rb_entry(next, struct map_rb_node, rb_node);
if (pos->map->end > map->start) { if (map__end(pos->map) > map__start(map)) {
first = next; first = next;
if (pos->map->start <= map->start) if (map__start(pos->map) <= map__start(map))
break; break;
next = next->rb_left; next = next->rb_left;
} else } else
...@@ -301,7 +301,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -301,7 +301,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
* Stop if current map starts after map->end. * Stop if current map starts after map->end.
* Maps are ordered by start: next will not overlap for sure. * Maps are ordered by start: next will not overlap for sure.
*/ */
if (pos->map->start >= map->end) if (map__start(pos->map) >= map__end(map))
break; break;
if (verbose >= 2) { if (verbose >= 2) {
...@@ -321,7 +321,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -321,7 +321,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
* Now check if we need to create new maps for areas not * Now check if we need to create new maps for areas not
* overlapped by the new map: * overlapped by the new map:
*/ */
if (map->start > pos->map->start) { if (map__start(map) > map__start(pos->map)) {
struct map *before = map__clone(pos->map); struct map *before = map__clone(pos->map);
if (before == NULL) { if (before == NULL) {
...@@ -329,7 +329,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -329,7 +329,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
goto put_map; goto put_map;
} }
before->end = map->start; before->end = map__start(map);
err = __maps__insert(maps, before); err = __maps__insert(maps, before);
if (err) if (err)
goto put_map; goto put_map;
...@@ -339,7 +339,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -339,7 +339,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
map__put(before); map__put(before);
} }
if (map->end < pos->map->end) { if (map__end(map) < map__end(pos->map)) {
struct map *after = map__clone(pos->map); struct map *after = map__clone(pos->map);
if (after == NULL) { if (after == NULL) {
...@@ -347,10 +347,10 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -347,10 +347,10 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
goto put_map; goto put_map;
} }
after->start = map->end; after->start = map__end(map);
after->pgoff += map->end - pos->map->start; after->pgoff += map__end(map) - map__start(pos->map);
assert(pos->map->map_ip(pos->map, map->end) == assert(pos->map->map_ip(pos->map, map__end(map)) ==
after->map_ip(after, map->end)); after->map_ip(after, map__end(map)));
err = __maps__insert(maps, after); err = __maps__insert(maps, after);
if (err) if (err)
goto put_map; goto put_map;
...@@ -430,9 +430,9 @@ struct map *maps__find(struct maps *maps, u64 ip) ...@@ -430,9 +430,9 @@ struct map *maps__find(struct maps *maps, u64 ip)
p = maps__entries(maps)->rb_node; p = maps__entries(maps)->rb_node;
while (p != NULL) { while (p != NULL) {
m = rb_entry(p, struct map_rb_node, rb_node); m = rb_entry(p, struct map_rb_node, rb_node);
if (ip < m->map->start) if (ip < map__start(m->map))
p = p->rb_left; p = p->rb_left;
else if (ip >= m->map->end) else if (ip >= map__end(m->map))
p = p->rb_right; p = p->rb_right;
else else
goto out; goto out;
......
...@@ -143,7 +143,7 @@ static int kernel_get_symbol_address_by_name(const char *name, u64 *addr, ...@@ -143,7 +143,7 @@ static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
return -ENOENT; return -ENOENT;
*addr = map->unmap_ip(map, sym->start) - *addr = map->unmap_ip(map, sym->start) -
((reloc) ? 0 : map->reloc) - ((reloc) ? 0 : map->reloc) -
((reladdr) ? map->start : 0); ((reladdr) ? map__start(map) : 0);
} }
return 0; return 0;
} }
...@@ -257,7 +257,7 @@ static bool kprobe_warn_out_range(const char *symbol, u64 address) ...@@ -257,7 +257,7 @@ static bool kprobe_warn_out_range(const char *symbol, u64 address)
map = kernel_get_module_map(NULL); map = kernel_get_module_map(NULL);
if (map) { if (map) {
ret = address <= map->start || map->end < address; ret = address <= map__start(map) || map__end(map) < address;
if (ret) if (ret)
pr_warning("%s is out of .text, skip it.\n", symbol); pr_warning("%s is out of .text, skip it.\n", symbol);
map__put(map); map__put(map);
......
...@@ -409,7 +409,7 @@ static unsigned long get_offset(struct symbol *sym, struct addr_location *al) ...@@ -409,7 +409,7 @@ static unsigned long get_offset(struct symbol *sym, struct addr_location *al)
if (al->addr < sym->end) if (al->addr < sym->end)
offset = al->addr - sym->start; offset = al->addr - sym->start;
else else
offset = al->addr - al->map->start - sym->start; offset = al->addr - map__start(al->map) - sym->start;
return offset; return offset;
} }
...@@ -788,9 +788,9 @@ static void set_sym_in_dict(PyObject *dict, struct addr_location *al, ...@@ -788,9 +788,9 @@ static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
pydict_set_item_string_decref(dict, dso_bid_field, pydict_set_item_string_decref(dict, dso_bid_field,
_PyUnicode_FromString(sbuild_id)); _PyUnicode_FromString(sbuild_id));
pydict_set_item_string_decref(dict, dso_map_start, pydict_set_item_string_decref(dict, dso_map_start,
PyLong_FromUnsignedLong(al->map->start)); PyLong_FromUnsignedLong(map__start(al->map)));
pydict_set_item_string_decref(dict, dso_map_end, pydict_set_item_string_decref(dict, dso_map_end,
PyLong_FromUnsignedLong(al->map->end)); PyLong_FromUnsignedLong(map__end(al->map)));
} }
if (al->sym) { if (al->sym) {
pydict_set_item_string_decref(dict, sym_field, pydict_set_item_string_decref(dict, sym_field,
......
...@@ -1355,7 +1355,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map, ...@@ -1355,7 +1355,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
if (*remap_kernel && dso->kernel && !kmodule) { if (*remap_kernel && dso->kernel && !kmodule) {
*remap_kernel = false; *remap_kernel = false;
map->start = shdr->sh_addr + ref_reloc(kmap); map->start = shdr->sh_addr + ref_reloc(kmap);
map->end = map->start + shdr->sh_size; map->end = map__start(map) + shdr->sh_size;
map->pgoff = shdr->sh_offset; map->pgoff = shdr->sh_offset;
map->map_ip = map__map_ip; map->map_ip = map__map_ip;
map->unmap_ip = map__unmap_ip; map->unmap_ip = map__unmap_ip;
...@@ -1397,7 +1397,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map, ...@@ -1397,7 +1397,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
u64 start = sym->st_value; u64 start = sym->st_value;
if (kmodule) if (kmodule)
start += map->start + shdr->sh_offset; start += map__start(map) + shdr->sh_offset;
curr_dso = dso__new(dso_name); curr_dso = dso__new(dso_name);
if (curr_dso == NULL) if (curr_dso == NULL)
...@@ -1415,7 +1415,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map, ...@@ -1415,7 +1415,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
if (adjust_kernel_syms) { if (adjust_kernel_syms) {
curr_map->start = shdr->sh_addr + ref_reloc(kmap); curr_map->start = shdr->sh_addr + ref_reloc(kmap);
curr_map->end = curr_map->start + shdr->sh_size; curr_map->end = map__start(curr_map) + shdr->sh_size;
curr_map->pgoff = shdr->sh_offset; curr_map->pgoff = shdr->sh_offset;
} else { } else {
curr_map->map_ip = curr_map->unmap_ip = identity__map_ip; curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
...@@ -1536,7 +1536,7 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, ...@@ -1536,7 +1536,7 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
* attempted to prelink vdso to its virtual address. * attempted to prelink vdso to its virtual address.
*/ */
if (dso__is_vdso(dso)) if (dso__is_vdso(dso))
map->reloc = map->start - dso->text_offset; map->reloc = map__start(map) - dso->text_offset;
dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap); dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap);
/* /*
......
...@@ -278,8 +278,8 @@ void maps__fixup_end(struct maps *maps) ...@@ -278,8 +278,8 @@ void maps__fixup_end(struct maps *maps)
down_write(maps__lock(maps)); down_write(maps__lock(maps));
maps__for_each_entry(maps, curr) { maps__for_each_entry(maps, curr) {
if (prev != NULL && !prev->map->end) if (prev != NULL && !map__end(prev->map))
prev->map->end = curr->map->start; prev->map->end = map__start(curr->map);
prev = curr; prev = curr;
} }
...@@ -288,7 +288,7 @@ void maps__fixup_end(struct maps *maps) ...@@ -288,7 +288,7 @@ void maps__fixup_end(struct maps *maps)
* We still haven't the actual symbols, so guess the * We still haven't the actual symbols, so guess the
* last map final address. * last map final address.
*/ */
if (curr && !curr->map->end) if (curr && !map__end(curr->map))
curr->map->end = ~0ULL; curr->map->end = ~0ULL;
up_write(maps__lock(maps)); up_write(maps__lock(maps));
...@@ -810,11 +810,11 @@ static int maps__split_kallsyms_for_kcore(struct maps *kmaps, struct dso *dso) ...@@ -810,11 +810,11 @@ static int maps__split_kallsyms_for_kcore(struct maps *kmaps, struct dso *dso)
continue; continue;
} }
curr_map_dso = map__dso(curr_map); curr_map_dso = map__dso(curr_map);
pos->start -= curr_map->start - curr_map->pgoff; pos->start -= map__start(curr_map) - curr_map->pgoff;
if (pos->end > curr_map->end) if (pos->end > map__end(curr_map))
pos->end = curr_map->end; pos->end = map__end(curr_map);
if (pos->end) if (pos->end)
pos->end -= curr_map->start - curr_map->pgoff; pos->end -= map__start(curr_map) - curr_map->pgoff;
symbols__insert(&curr_map_dso->symbols, pos); symbols__insert(&curr_map_dso->symbols, pos);
++count; ++count;
} }
...@@ -1156,7 +1156,7 @@ static int do_validate_kcore_modules(const char *filename, struct maps *kmaps) ...@@ -1156,7 +1156,7 @@ static int do_validate_kcore_modules(const char *filename, struct maps *kmaps)
dso = map__dso(old_map); dso = map__dso(old_map);
/* Module must be in memory at the same address */ /* Module must be in memory at the same address */
mi = find_module(dso->short_name, &modules); mi = find_module(dso->short_name, &modules);
if (!mi || mi->start != old_map->start) { if (!mi || mi->start != map__start(old_map)) {
err = -EINVAL; err = -EINVAL;
goto out; goto out;
} }
...@@ -1250,7 +1250,7 @@ static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data) ...@@ -1250,7 +1250,7 @@ static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data)
return -ENOMEM; return -ENOMEM;
} }
list_node->map->end = list_node->map->start + len; list_node->map->end = map__start(list_node->map) + len;
list_node->map->pgoff = pgoff; list_node->map->pgoff = pgoff;
list_add(&list_node->node, &md->maps); list_add(&list_node->node, &md->maps);
...@@ -1272,21 +1272,21 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map) ...@@ -1272,21 +1272,21 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map)
struct map *old_map = rb_node->map; struct map *old_map = rb_node->map;
/* no overload with this one */ /* no overload with this one */
if (new_map->end < old_map->start || if (map__end(new_map) < map__start(old_map) ||
new_map->start >= old_map->end) map__start(new_map) >= map__end(old_map))
continue; continue;
if (new_map->start < old_map->start) { if (map__start(new_map) < map__start(old_map)) {
/* /*
* |new...... * |new......
* |old.... * |old....
*/ */
if (new_map->end < old_map->end) { if (map__end(new_map) < map__end(old_map)) {
/* /*
* |new......| -> |new..| * |new......| -> |new..|
* |old....| -> |old....| * |old....| -> |old....|
*/ */
new_map->end = old_map->start; new_map->end = map__start(old_map);
} else { } else {
/* /*
* |new.............| -> |new..| |new..| * |new.............| -> |new..| |new..|
...@@ -1306,17 +1306,17 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map) ...@@ -1306,17 +1306,17 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map)
goto out; goto out;
} }
m->map->end = old_map->start; m->map->end = map__start(old_map);
list_add_tail(&m->node, &merged); list_add_tail(&m->node, &merged);
new_map->pgoff += old_map->end - new_map->start; new_map->pgoff += map__end(old_map) - map__start(new_map);
new_map->start = old_map->end; new_map->start = map__end(old_map);
} }
} else { } else {
/* /*
* |new...... * |new......
* |old.... * |old....
*/ */
if (new_map->end < old_map->end) { if (map__end(new_map) < map__end(old_map)) {
/* /*
* |new..| -> x * |new..| -> x
* |old.........| -> |old.........| * |old.........| -> |old.........|
...@@ -1329,8 +1329,8 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map) ...@@ -1329,8 +1329,8 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map)
* |new......| -> |new...| * |new......| -> |new...|
* |old....| -> |old....| * |old....| -> |old....|
*/ */
new_map->pgoff += old_map->end - new_map->start; new_map->pgoff += map__end(old_map) - map__start(new_map);
new_map->start = old_map->end; new_map->start = map__end(old_map);
} }
} }
} }
...@@ -1428,9 +1428,9 @@ static int dso__load_kcore(struct dso *dso, struct map *map, ...@@ -1428,9 +1428,9 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
list_for_each_entry(new_node, &md.maps, node) { list_for_each_entry(new_node, &md.maps, node) {
struct map *new_map = new_node->map; struct map *new_map = new_node->map;
u64 new_size = new_map->end - new_map->start; u64 new_size = map__size(new_map);
if (!(stext >= new_map->start && stext < new_map->end)) if (!(stext >= map__start(new_map) && stext < map__end(new_map)))
continue; continue;
/* /*
...@@ -1457,8 +1457,8 @@ static int dso__load_kcore(struct dso *dso, struct map *map, ...@@ -1457,8 +1457,8 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
list_del_init(&new_node->node); list_del_init(&new_node->node);
if (new_map == replacement_map) { if (new_map == replacement_map) {
map->start = new_map->start; map->start = map__start(new_map);
map->end = new_map->end; map->end = map__end(new_map);
map->pgoff = new_map->pgoff; map->pgoff = new_map->pgoff;
map->map_ip = new_map->map_ip; map->map_ip = new_map->map_ip;
map->unmap_ip = new_map->unmap_ip; map->unmap_ip = new_map->unmap_ip;
......
...@@ -30,7 +30,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym, ...@@ -30,7 +30,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
if (al->addr < sym->end) if (al->addr < sym->end)
offset = al->addr - sym->start; offset = al->addr - sym->start;
else else
offset = al->addr - al->map->start - sym->start; offset = al->addr - map__start(al->map) - sym->start;
length += fprintf(fp, "+0x%lx", offset); length += fprintf(fp, "+0x%lx", offset);
} }
return length; return length;
......
...@@ -706,8 +706,8 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t ...@@ -706,8 +706,8 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
(sizeof(event->mmap2.filename) - size)); (sizeof(event->mmap2.filename) - size));
memset(event->mmap2.filename + size, 0, machine->id_hdr_size); memset(event->mmap2.filename + size, 0, machine->id_hdr_size);
event->mmap2.header.size += machine->id_hdr_size; event->mmap2.header.size += machine->id_hdr_size;
event->mmap2.start = map->start; event->mmap2.start = map__start(map);
event->mmap2.len = map->end - map->start; event->mmap2.len = map__size(map);
event->mmap2.pid = machine->pid; event->mmap2.pid = machine->pid;
memcpy(event->mmap2.filename, dso->long_name, dso->long_name_len + 1); memcpy(event->mmap2.filename, dso->long_name, dso->long_name_len + 1);
...@@ -720,8 +720,8 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t ...@@ -720,8 +720,8 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
(sizeof(event->mmap.filename) - size)); (sizeof(event->mmap.filename) - size));
memset(event->mmap.filename + size, 0, machine->id_hdr_size); memset(event->mmap.filename + size, 0, machine->id_hdr_size);
event->mmap.header.size += machine->id_hdr_size; event->mmap.header.size += machine->id_hdr_size;
event->mmap.start = map->start; event->mmap.start = map__start(map);
event->mmap.len = map->end - map->start; event->mmap.len = map__size(map);
event->mmap.pid = machine->pid; event->mmap.pid = machine->pid;
memcpy(event->mmap.filename, dso->long_name, dso->long_name_len + 1); memcpy(event->mmap.filename, dso->long_name, dso->long_name_len + 1);
...@@ -1143,8 +1143,8 @@ static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool, ...@@ -1143,8 +1143,8 @@ static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
event->mmap2.header.size = (sizeof(event->mmap2) - event->mmap2.header.size = (sizeof(event->mmap2) -
(sizeof(event->mmap2.filename) - size) + machine->id_hdr_size); (sizeof(event->mmap2.filename) - size) + machine->id_hdr_size);
event->mmap2.pgoff = kmap->ref_reloc_sym->addr; event->mmap2.pgoff = kmap->ref_reloc_sym->addr;
event->mmap2.start = map->start; event->mmap2.start = map__start(map);
event->mmap2.len = map->end - event->mmap.start; event->mmap2.len = map__end(map) - event->mmap.start;
event->mmap2.pid = machine->pid; event->mmap2.pid = machine->pid;
perf_record_mmap2__read_build_id(&event->mmap2, machine, true); perf_record_mmap2__read_build_id(&event->mmap2, machine, true);
...@@ -1156,8 +1156,8 @@ static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool, ...@@ -1156,8 +1156,8 @@ static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
event->mmap.header.size = (sizeof(event->mmap) - event->mmap.header.size = (sizeof(event->mmap) -
(sizeof(event->mmap.filename) - size) + machine->id_hdr_size); (sizeof(event->mmap.filename) - size) + machine->id_hdr_size);
event->mmap.pgoff = kmap->ref_reloc_sym->addr; event->mmap.pgoff = kmap->ref_reloc_sym->addr;
event->mmap.start = map->start; event->mmap.start = map__start(map);
event->mmap.len = map->end - event->mmap.start; event->mmap.len = map__end(map) - event->mmap.start;
event->mmap.pid = machine->pid; event->mmap.pid = machine->pid;
} }
......
...@@ -62,19 +62,19 @@ static int __report_module(struct addr_location *al, u64 ip, ...@@ -62,19 +62,19 @@ static int __report_module(struct addr_location *al, u64 ip,
Dwarf_Addr s; Dwarf_Addr s;
dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL); dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL);
if (s != al->map->start - al->map->pgoff) if (s != map__start(al->map) - al->map->pgoff)
mod = 0; mod = 0;
} }
if (!mod) if (!mod)
mod = dwfl_report_elf(ui->dwfl, dso->short_name, dso->long_name, -1, mod = dwfl_report_elf(ui->dwfl, dso->short_name, dso->long_name, -1,
al->map->start - al->map->pgoff, false); map__start(al->map) - al->map->pgoff, 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, filename, -1,
al->map->start - al->map->pgoff, false); map__start(al->map) - al->map->pgoff, false);
} }
if (mod) { if (mod) {
......
...@@ -327,9 +327,10 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui, ...@@ -327,9 +327,10 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui,
maps__for_each_entry(ui->thread->maps, map_node) { maps__for_each_entry(ui->thread->maps, map_node) {
struct map *map = map_node->map; struct map *map = map_node->map;
u64 start = map__start(map);
if (map__dso(map) == dso && map->start < base_addr) if (map__dso(map) == dso && start < base_addr)
base_addr = map->start; base_addr = start;
} }
base_addr -= dso->data.elf_base_addr; base_addr -= dso->data.elf_base_addr;
/* Address of .eh_frame_hdr */ /* Address of .eh_frame_hdr */
...@@ -443,8 +444,8 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, ...@@ -443,8 +444,8 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
if (!read_unwind_spec_eh_frame(dso, ui, &table_data, &segbase, &fde_count)) { if (!read_unwind_spec_eh_frame(dso, ui, &table_data, &segbase, &fde_count)) {
memset(&di, 0, sizeof(di)); memset(&di, 0, sizeof(di));
di.format = UNW_INFO_FORMAT_REMOTE_TABLE; di.format = UNW_INFO_FORMAT_REMOTE_TABLE;
di.start_ip = map->start; di.start_ip = map__start(map);
di.end_ip = map->end; di.end_ip = map__end(map);
di.u.rti.segbase = segbase; di.u.rti.segbase = segbase;
di.u.rti.table_data = table_data; di.u.rti.table_data = table_data;
di.u.rti.table_len = fde_count * sizeof(struct table_entry) di.u.rti.table_len = fde_count * sizeof(struct table_entry)
...@@ -459,7 +460,8 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, ...@@ -459,7 +460,8 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
!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);
unw_word_t base = is_exec ? 0 : map->start; u64 start = map__start(map);
unw_word_t base = is_exec ? 0 : start;
const char *symfile; const char *symfile;
if (fd >= 0) if (fd >= 0)
...@@ -468,8 +470,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, ...@@ -468,8 +470,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
symfile = dso->symsrc_filename ?: dso->name; symfile = dso->symsrc_filename ?: dso->name;
memset(&di, 0, sizeof(di)); memset(&di, 0, sizeof(di));
if (dwarf_find_debug_frame(0, &di, ip, base, symfile, if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))
map->start, map->end))
return dwarf_search_unwind_table(as, ip, &di, pi, return dwarf_search_unwind_table(as, ip, &di, pi,
need_unwind_info, arg); need_unwind_info, arg);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment