perf map: Add helper for ->map_ip() and ->unmap_ip()
Later changes will add reference count checking for struct map, add a helper function to invoke the map_ip and unmap_ip function pointers. The helper allows the reference count check to be in fewer places. Committer notes: Add missing conversions to: tools/perf/util/map.c tools/perf/util/cs-etm.c tools/perf/util/annotate.c tools/perf/arch/powerpc/util/sym-handling.c tools/perf/arch/s390/annotate/instructions.c Signed-off-by: Ian 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/20230404205954.2245628-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
		
				
					committed by
					
						
						Arnaldo Carvalho de Melo
					
				
			
			
				
	
			
			
			
						parent
						
							0e6aa013bb
						
					
				
				
					commit
					78a1f7cd90
				
			@@ -131,7 +131,7 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
 | 
			
		||||
	for (i = 0; i < ntevs; i++) {
 | 
			
		||||
		tev = &pev->tevs[i];
 | 
			
		||||
		map__for_each_symbol(map, sym, tmp) {
 | 
			
		||||
			if (map->unmap_ip(map, sym->start) == tev->point.address) {
 | 
			
		||||
			if (map__unmap_ip(map, sym->start) == tev->point.address) {
 | 
			
		||||
				arch__fix_tev_from_maps(pev, tev, map, sym);
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
 | 
			
		||||
	target.addr = map__objdump_2mem(map, ops->target.addr);
 | 
			
		||||
 | 
			
		||||
	if (maps__find_ams(ms->maps, &target) == 0 &&
 | 
			
		||||
	    map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
 | 
			
		||||
	    map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
 | 
			
		||||
		ops->target.sym = target.ms.sym;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ static int __cmd_kallsyms(int argc, const char **argv)
 | 
			
		||||
		dso = map__dso(map);
 | 
			
		||||
		printf("%s: %s %s %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n",
 | 
			
		||||
			symbol->name, dso->short_name, dso->long_name,
 | 
			
		||||
			map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end),
 | 
			
		||||
			map__unmap_ip(map, symbol->start), map__unmap_ip(map, symbol->end),
 | 
			
		||||
			symbol->start, symbol->end);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1024,7 +1024,7 @@ static void __print_slab_result(struct rb_root *root,
 | 
			
		||||
 | 
			
		||||
		if (sym != NULL)
 | 
			
		||||
			snprintf(buf, sizeof(buf), "%s+%" PRIx64 "", sym->name,
 | 
			
		||||
				 addr - map->unmap_ip(map, sym->start));
 | 
			
		||||
				 addr - map__unmap_ip(map, sym->start));
 | 
			
		||||
		else
 | 
			
		||||
			snprintf(buf, sizeof(buf), "%#" PRIx64 "", addr);
 | 
			
		||||
		printf(" %-34s |", buf);
 | 
			
		||||
 
 | 
			
		||||
@@ -900,7 +900,7 @@ static int get_symbol_name_offset(struct map *map, struct symbol *sym, u64 ip,
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	offset = map->map_ip(map, ip) - sym->start;
 | 
			
		||||
	offset = map__map_ip(map, ip) - sym->start;
 | 
			
		||||
 | 
			
		||||
	if (offset)
 | 
			
		||||
		return scnprintf(buf, size, "%s+%#lx", sym->name, offset);
 | 
			
		||||
@@ -1070,7 +1070,7 @@ static int report_lock_contention_begin_event(struct evsel *evsel,
 | 
			
		||||
				return -ENOMEM;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			addrs[filters.nr_addrs++] = kmap->unmap_ip(kmap, sym->start);
 | 
			
		||||
			addrs[filters.nr_addrs++] = map__unmap_ip(kmap, sym->start);
 | 
			
		||||
			filters.addrs = addrs;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1088,7 +1088,7 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
 | 
			
		||||
	/* Load maps to ensure dso->is_64_bit has been updated */
 | 
			
		||||
	map__load(al.map);
 | 
			
		||||
 | 
			
		||||
	offset = al.map->map_ip(al.map, start);
 | 
			
		||||
	offset = map__map_ip(al.map, start);
 | 
			
		||||
	len = dso__data_read_offset(dso, machine, offset, (u8 *)buffer,
 | 
			
		||||
				    end - start + MAXINSN);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@
 | 
			
		||||
#include "debug.h"
 | 
			
		||||
#include "machine.h"
 | 
			
		||||
 | 
			
		||||
#define UM(x) kallsyms_map->unmap_ip(kallsyms_map, (x))
 | 
			
		||||
#define UM(x) map__unmap_ip(kallsyms_map, (x))
 | 
			
		||||
 | 
			
		||||
static bool is_ignored_symbol(const char *name, char type)
 | 
			
		||||
{
 | 
			
		||||
@@ -221,8 +221,8 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
 | 
			
		||||
		if (sym->start == sym->end)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		mem_start = vmlinux_map->unmap_ip(vmlinux_map, sym->start);
 | 
			
		||||
		mem_end = vmlinux_map->unmap_ip(vmlinux_map, sym->end);
 | 
			
		||||
		mem_start = map__unmap_ip(vmlinux_map, sym->start);
 | 
			
		||||
		mem_end = map__unmap_ip(vmlinux_map, sym->end);
 | 
			
		||||
 | 
			
		||||
		first_pair = machine__find_kernel_symbol(&kallsyms, mem_start, NULL);
 | 
			
		||||
		pair = first_pair;
 | 
			
		||||
@@ -319,8 +319,8 @@ next_pair:
 | 
			
		||||
	maps__for_each_entry(maps, rb_node) {
 | 
			
		||||
		struct map *pair, *map = rb_node->map;
 | 
			
		||||
 | 
			
		||||
		mem_start = vmlinux_map->unmap_ip(vmlinux_map, map__start(map));
 | 
			
		||||
		mem_end = vmlinux_map->unmap_ip(vmlinux_map, map__end(map));
 | 
			
		||||
		mem_start = map__unmap_ip(vmlinux_map, map__start(map));
 | 
			
		||||
		mem_end = map__unmap_ip(vmlinux_map, map__end(map));
 | 
			
		||||
 | 
			
		||||
		pair = maps__find(kallsyms.kmaps, mem_start);
 | 
			
		||||
		if (pair == NULL || pair->priv)
 | 
			
		||||
 
 | 
			
		||||
@@ -272,7 +272,7 @@ find_target:
 | 
			
		||||
	target.addr = map__objdump_2mem(map, ops->target.addr);
 | 
			
		||||
 | 
			
		||||
	if (maps__find_ams(ms->maps, &target) == 0 &&
 | 
			
		||||
	    map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
 | 
			
		||||
	    map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
 | 
			
		||||
		ops->target.sym = target.ms.sym;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
@@ -376,8 +376,8 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	target.addr = map__objdump_2mem(map, ops->target.addr);
 | 
			
		||||
	start = map->unmap_ip(map, sym->start),
 | 
			
		||||
	end = map->unmap_ip(map, sym->end);
 | 
			
		||||
	start = map__unmap_ip(map, sym->start);
 | 
			
		||||
	end = map__unmap_ip(map, sym->end);
 | 
			
		||||
 | 
			
		||||
	ops->target.outside = target.addr < start || target.addr > end;
 | 
			
		||||
 | 
			
		||||
@@ -400,7 +400,7 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
 | 
			
		||||
	 * the symbol searching and disassembly should be done.
 | 
			
		||||
	 */
 | 
			
		||||
	if (maps__find_ams(ms->maps, &target) == 0 &&
 | 
			
		||||
	    map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
 | 
			
		||||
	    map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
 | 
			
		||||
		ops->target.sym = target.ms.sym;
 | 
			
		||||
 | 
			
		||||
	if (!ops->target.outside) {
 | 
			
		||||
@@ -881,7 +881,7 @@ static int __symbol__inc_addr_samples(struct map_symbol *ms,
 | 
			
		||||
	unsigned offset;
 | 
			
		||||
	struct sym_hist *h;
 | 
			
		||||
 | 
			
		||||
	pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, ms->map->unmap_ip(ms->map, addr));
 | 
			
		||||
	pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map__unmap_ip(ms->map, addr));
 | 
			
		||||
 | 
			
		||||
	if ((addr < sym->start || addr >= sym->end) &&
 | 
			
		||||
	    (addr != sym->end || sym->start != sym->end)) {
 | 
			
		||||
@@ -1977,8 +1977,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 | 
			
		||||
		return err;
 | 
			
		||||
 | 
			
		||||
	pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
 | 
			
		||||
		 symfs_filename, sym->name, map->unmap_ip(map, sym->start),
 | 
			
		||||
		 map->unmap_ip(map, sym->end));
 | 
			
		||||
		 symfs_filename, sym->name, map__unmap_ip(map, sym->start),
 | 
			
		||||
		 map__unmap_ip(map, sym->end));
 | 
			
		||||
 | 
			
		||||
	pr_debug("annotating [%p] %30s : [%p] %30s\n",
 | 
			
		||||
		 dso, dso->long_name, sym, sym->name);
 | 
			
		||||
 
 | 
			
		||||
@@ -74,7 +74,7 @@ int lock_contention_prepare(struct lock_contention *con)
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			addrs[con->filters->nr_addrs++] = kmap->unmap_ip(kmap, sym->start);
 | 
			
		||||
			addrs[con->filters->nr_addrs++] = map__unmap_ip(kmap, sym->start);
 | 
			
		||||
			con->filters->addrs = addrs;
 | 
			
		||||
		}
 | 
			
		||||
		naddrs = con->filters->nr_addrs;
 | 
			
		||||
@@ -233,7 +233,7 @@ static const char *lock_contention_get_name(struct lock_contention *con,
 | 
			
		||||
	if (sym) {
 | 
			
		||||
		unsigned long offset;
 | 
			
		||||
 | 
			
		||||
		offset = kmap->map_ip(kmap, addr) - sym->start;
 | 
			
		||||
		offset = map__map_ip(kmap, addr) - sym->start;
 | 
			
		||||
 | 
			
		||||
		if (offset == 0)
 | 
			
		||||
			return sym->name;
 | 
			
		||||
 
 | 
			
		||||
@@ -893,7 +893,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id,
 | 
			
		||||
	    dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE))
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	offset = al.map->map_ip(al.map, address);
 | 
			
		||||
	offset = map__map_ip(al.map, address);
 | 
			
		||||
 | 
			
		||||
	map__load(al.map);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -278,7 +278,7 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
 | 
			
		||||
 | 
			
		||||
	map = a.map;
 | 
			
		||||
have_map:
 | 
			
		||||
	offset = map->map_ip(map, ip);
 | 
			
		||||
	offset = map__map_ip(map, ip);
 | 
			
		||||
	if (ip + len >= map__end(map))
 | 
			
		||||
		len = map__end(map) - ip;
 | 
			
		||||
	return dso__data_read_offset(map__dso(map), d->machine, offset, buf, len);
 | 
			
		||||
 
 | 
			
		||||
@@ -1122,7 +1122,8 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
 | 
			
		||||
			    struct machine *machine, u64 addr,
 | 
			
		||||
			    u8 *data, ssize_t size)
 | 
			
		||||
{
 | 
			
		||||
	u64 offset = map->map_ip(map, addr);
 | 
			
		||||
	u64 offset = map__map_ip(map, addr);
 | 
			
		||||
 | 
			
		||||
	return dso__data_read_offset(dso, machine, offset, data, size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1162,7 +1163,8 @@ ssize_t dso__data_write_cache_addr(struct dso *dso, struct map *map,
 | 
			
		||||
				   struct machine *machine, u64 addr,
 | 
			
		||||
				   const u8 *data, ssize_t size)
 | 
			
		||||
{
 | 
			
		||||
	u64 offset = map->map_ip(map, addr);
 | 
			
		||||
	u64 offset = map__map_ip(map, addr);
 | 
			
		||||
 | 
			
		||||
	return dso__data_write_cache_offs(dso, machine, offset, data, size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -487,7 +487,7 @@ size_t perf_event__fprintf_text_poke(union perf_event *event, struct machine *ma
 | 
			
		||||
 | 
			
		||||
		al.map = maps__find(machine__kernel_maps(machine), tp->addr);
 | 
			
		||||
		if (al.map && map__load(al.map) >= 0) {
 | 
			
		||||
			al.addr = al.map->map_ip(al.map, tp->addr);
 | 
			
		||||
			al.addr = map__map_ip(al.map, tp->addr);
 | 
			
		||||
			al.sym = map__find_symbol(al.map, al.addr);
 | 
			
		||||
			if (al.sym)
 | 
			
		||||
				ret += symbol__fprintf_symname_offs(al.sym, &al, fp);
 | 
			
		||||
@@ -622,7 +622,7 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
 | 
			
		||||
		 */
 | 
			
		||||
		if (load_map)
 | 
			
		||||
			map__load(al->map);
 | 
			
		||||
		al->addr = al->map->map_ip(al->map, al->addr);
 | 
			
		||||
		al->addr = map__map_ip(al->map, al->addr);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return al->map;
 | 
			
		||||
@@ -743,12 +743,12 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 | 
			
		||||
		}
 | 
			
		||||
		if (!ret && al->sym) {
 | 
			
		||||
			snprintf(al_addr_str, sz, "0x%"PRIx64,
 | 
			
		||||
				al->map->unmap_ip(al->map, al->sym->start));
 | 
			
		||||
				 map__unmap_ip(al->map, al->sym->start));
 | 
			
		||||
			ret = strlist__has_entry(symbol_conf.sym_list,
 | 
			
		||||
						al_addr_str);
 | 
			
		||||
		}
 | 
			
		||||
		if (!ret && symbol_conf.addr_list && al->map) {
 | 
			
		||||
			unsigned long addr = al->map->unmap_ip(al->map, al->addr);
 | 
			
		||||
			unsigned long addr = map__unmap_ip(al->map, al->addr);
 | 
			
		||||
 | 
			
		||||
			ret = intlist__has_entry(symbol_conf.addr_list, addr);
 | 
			
		||||
			if (!ret && symbol_conf.addr_range) {
 | 
			
		||||
 
 | 
			
		||||
@@ -151,7 +151,7 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 | 
			
		||||
				printed += fprintf(fp, " <-");
 | 
			
		||||
 | 
			
		||||
			if (map)
 | 
			
		||||
				addr = map->map_ip(map, node->ip);
 | 
			
		||||
				addr = map__map_ip(map, node->ip);
 | 
			
		||||
 | 
			
		||||
			if (print_ip) {
 | 
			
		||||
				/* Show binary offset for userspace addr */
 | 
			
		||||
 
 | 
			
		||||
@@ -816,7 +816,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
 | 
			
		||||
		    dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE))
 | 
			
		||||
			return -ENOENT;
 | 
			
		||||
 | 
			
		||||
		offset = al.map->map_ip(al.map, *ip);
 | 
			
		||||
		offset = map__map_ip(al.map, *ip);
 | 
			
		||||
 | 
			
		||||
		if (!to_ip && one_map) {
 | 
			
		||||
			struct intel_pt_cache_entry *e;
 | 
			
		||||
@@ -987,7 +987,7 @@ static int __intel_pt_pgd_ip(uint64_t ip, void *data)
 | 
			
		||||
	if (!thread__find_map(thread, cpumode, ip, &al) || !map__dso(al.map))
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	offset = al.map->map_ip(al.map, ip);
 | 
			
		||||
	offset = map__map_ip(al.map, ip);
 | 
			
		||||
 | 
			
		||||
	return intel_pt_match_pgd_ip(ptq->pt, ip, offset, map__dso(al.map)->long_name);
 | 
			
		||||
}
 | 
			
		||||
@@ -2749,7 +2749,7 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)
 | 
			
		||||
	for (sym = start; sym; sym = dso__next_symbol(sym)) {
 | 
			
		||||
		if (sym->binding == STB_GLOBAL &&
 | 
			
		||||
		    !strcmp(sym->name, "__switch_to")) {
 | 
			
		||||
			ip = map->unmap_ip(map, sym->start);
 | 
			
		||||
			ip = map__unmap_ip(map, sym->start);
 | 
			
		||||
			if (ip >= map__start(map) && ip < map__end(map)) {
 | 
			
		||||
				switch_ip = ip;
 | 
			
		||||
				break;
 | 
			
		||||
@@ -2767,7 +2767,7 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)
 | 
			
		||||
 | 
			
		||||
	for (sym = start; sym; sym = dso__next_symbol(sym)) {
 | 
			
		||||
		if (!strcmp(sym->name, ptss)) {
 | 
			
		||||
			ip = map->unmap_ip(map, sym->start);
 | 
			
		||||
			ip = map__unmap_ip(map, sym->start);
 | 
			
		||||
			if (ip >= map__start(map) && ip < map__end(map)) {
 | 
			
		||||
				*ptss_ip = ip;
 | 
			
		||||
				break;
 | 
			
		||||
@@ -3393,7 +3393,7 @@ static int intel_pt_text_poke(struct intel_pt *pt, union perf_event *event)
 | 
			
		||||
		if (!dso || !dso->auxtrace_cache)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		offset = al.map->map_ip(al.map, addr);
 | 
			
		||||
		offset = map__map_ip(al.map, addr);
 | 
			
		||||
 | 
			
		||||
		e = intel_pt_cache_lookup(dso, machine, offset);
 | 
			
		||||
		if (!e)
 | 
			
		||||
 
 | 
			
		||||
@@ -919,7 +919,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
 | 
			
		||||
		dso = map__dso(map);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	sym = symbol__new(map->map_ip(map, map__start(map)),
 | 
			
		||||
	sym = symbol__new(map__map_ip(map, map__start(map)),
 | 
			
		||||
			  event->ksymbol.len,
 | 
			
		||||
			  0, 0, event->ksymbol.name);
 | 
			
		||||
	if (!sym)
 | 
			
		||||
@@ -944,7 +944,7 @@ static int machine__process_ksymbol_unregister(struct machine *machine,
 | 
			
		||||
	else {
 | 
			
		||||
		struct dso *dso = map__dso(map);
 | 
			
		||||
 | 
			
		||||
		sym = dso__find_symbol(dso, map->map_ip(map, map__start(map)));
 | 
			
		||||
		sym = dso__find_symbol(dso, map__map_ip(map, map__start(map)));
 | 
			
		||||
		if (sym)
 | 
			
		||||
			dso__delete_symbol(dso, sym);
 | 
			
		||||
	}
 | 
			
		||||
@@ -1279,7 +1279,7 @@ int machine__map_x86_64_entry_trampolines(struct machine *machine,
 | 
			
		||||
 | 
			
		||||
		dest_map = maps__find(kmaps, map->pgoff);
 | 
			
		||||
		if (dest_map != map)
 | 
			
		||||
			map->pgoff = dest_map->map_ip(dest_map, map->pgoff);
 | 
			
		||||
			map->pgoff = map__map_ip(dest_map, map->pgoff);
 | 
			
		||||
		found = true;
 | 
			
		||||
	}
 | 
			
		||||
	if (found || machine->trampolines_mapped)
 | 
			
		||||
@@ -3345,7 +3345,7 @@ char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, ch
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	*modp = __map__is_kmodule(map) ? (char *)map__dso(map)->short_name : NULL;
 | 
			
		||||
	*addrp = map->unmap_ip(map, sym->start);
 | 
			
		||||
	*addrp = map__unmap_ip(map, sym->start);
 | 
			
		||||
	return sym->name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -3388,17 +3388,17 @@ bool machine__is_lock_function(struct machine *machine, u64 addr)
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		machine->sched.text_start = kmap->unmap_ip(kmap, sym->start);
 | 
			
		||||
		machine->sched.text_start = map__unmap_ip(kmap, sym->start);
 | 
			
		||||
 | 
			
		||||
		/* should not fail from here */
 | 
			
		||||
		sym = machine__find_kernel_symbol_by_name(machine, "__sched_text_end", &kmap);
 | 
			
		||||
		machine->sched.text_end = kmap->unmap_ip(kmap, sym->start);
 | 
			
		||||
		machine->sched.text_end = map__unmap_ip(kmap, sym->start);
 | 
			
		||||
 | 
			
		||||
		sym = machine__find_kernel_symbol_by_name(machine, "__lock_text_start", &kmap);
 | 
			
		||||
		machine->lock.text_start = kmap->unmap_ip(kmap, sym->start);
 | 
			
		||||
		machine->lock.text_start = map__unmap_ip(kmap, sym->start);
 | 
			
		||||
 | 
			
		||||
		sym = machine__find_kernel_symbol_by_name(machine, "__lock_text_end", &kmap);
 | 
			
		||||
		machine->lock.text_end = kmap->unmap_ip(kmap, sym->start);
 | 
			
		||||
		machine->lock.text_end = map__unmap_ip(kmap, sym->start);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* failed to get kernel symbols */
 | 
			
		||||
 
 | 
			
		||||
@@ -519,7 +519,7 @@ u64 map__rip_2objdump(struct map *map, u64 rip)
 | 
			
		||||
	if (dso->kernel == DSO_SPACE__USER)
 | 
			
		||||
		return rip + dso->text_offset;
 | 
			
		||||
 | 
			
		||||
	return map->unmap_ip(map, rip) - map->reloc;
 | 
			
		||||
	return map__unmap_ip(map, rip) - map->reloc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -530,7 +530,7 @@ u64 map__rip_2objdump(struct map *map, u64 rip)
 | 
			
		||||
 * Closely related to map__rip_2objdump(), this function takes an address from
 | 
			
		||||
 * objdump and converts it to a memory address.  Note this assumes that @map
 | 
			
		||||
 * contains the address.  To be sure the result is valid, check it forwards
 | 
			
		||||
 * e.g. map__rip_2objdump(map->map_ip(map, map__objdump_2mem(map, ip))) == ip
 | 
			
		||||
 * e.g. map__rip_2objdump(map__map_ip(map, map__objdump_2mem(map, ip))) == ip
 | 
			
		||||
 *
 | 
			
		||||
 * Return: Memory address.
 | 
			
		||||
 */
 | 
			
		||||
@@ -539,24 +539,24 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
 | 
			
		||||
	const struct dso *dso = map__dso(map);
 | 
			
		||||
 | 
			
		||||
	if (!dso->adjust_symbols)
 | 
			
		||||
		return map->unmap_ip(map, ip);
 | 
			
		||||
		return map__unmap_ip(map, ip);
 | 
			
		||||
 | 
			
		||||
	if (dso->rel)
 | 
			
		||||
		return map->unmap_ip(map, ip + map->pgoff);
 | 
			
		||||
		return map__unmap_ip(map, ip + map->pgoff);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * kernel modules also have DSO_TYPE_USER in dso->kernel,
 | 
			
		||||
	 * but all kernel modules are ET_REL, so won't get here.
 | 
			
		||||
	 */
 | 
			
		||||
	if (dso->kernel == DSO_SPACE__USER)
 | 
			
		||||
		return map->unmap_ip(map, ip - dso->text_offset);
 | 
			
		||||
		return map__unmap_ip(map, ip - dso->text_offset);
 | 
			
		||||
 | 
			
		||||
	return ip + map->reloc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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(map) && ip < map__end(map);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,16 @@ static inline struct dso *map__dso(const struct map *map)
 | 
			
		||||
	return map->dso;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline u64 map__map_ip(const struct map *map, u64 ip)
 | 
			
		||||
{
 | 
			
		||||
	return map->map_ip(map, ip);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline u64 map__unmap_ip(const struct map *map, u64 ip)
 | 
			
		||||
{
 | 
			
		||||
	return map->unmap_ip(map, ip);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline u64 map__start(const struct map *map)
 | 
			
		||||
{
 | 
			
		||||
	return map->start;
 | 
			
		||||
 
 | 
			
		||||
@@ -194,7 +194,7 @@ struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp)
 | 
			
		||||
	if (map != NULL && map__load(map) >= 0) {
 | 
			
		||||
		if (mapp != NULL)
 | 
			
		||||
			*mapp = map;
 | 
			
		||||
		return map__find_symbol(map, map->map_ip(map, addr));
 | 
			
		||||
		return map__find_symbol(map, map__map_ip(map, addr));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
@@ -237,7 +237,7 @@ int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams)
 | 
			
		||||
			return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ams->al_addr = ams->ms.map->map_ip(ams->ms.map, ams->addr);
 | 
			
		||||
	ams->al_addr = map__map_ip(ams->ms.map, ams->addr);
 | 
			
		||||
	ams->ms.sym = map__find_symbol(ams->ms.map, ams->al_addr);
 | 
			
		||||
 | 
			
		||||
	return ams->ms.sym ? 0 : -1;
 | 
			
		||||
@@ -349,8 +349,8 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
 | 
			
		||||
 | 
			
		||||
			after->start = map__end(map);
 | 
			
		||||
			after->pgoff += map__end(map) - map__start(pos->map);
 | 
			
		||||
			assert(pos->map->map_ip(pos->map, map__end(map)) ==
 | 
			
		||||
				after->map_ip(after, map__end(map)));
 | 
			
		||||
			assert(map__map_ip(pos->map, map__end(map)) ==
 | 
			
		||||
				map__map_ip(after, map__end(map)));
 | 
			
		||||
			err = __maps__insert(maps, after);
 | 
			
		||||
			if (err)
 | 
			
		||||
				goto put_map;
 | 
			
		||||
 
 | 
			
		||||
@@ -141,7 +141,7 @@ static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
 | 
			
		||||
		sym = machine__find_kernel_symbol_by_name(host_machine, name, &map);
 | 
			
		||||
		if (!sym)
 | 
			
		||||
			return -ENOENT;
 | 
			
		||||
		*addr = map->unmap_ip(map, sym->start) -
 | 
			
		||||
		*addr = map__unmap_ip(map, sym->start) -
 | 
			
		||||
			((reloc) ? 0 : map->reloc) -
 | 
			
		||||
			((reladdr) ? map__start(map) : 0);
 | 
			
		||||
	}
 | 
			
		||||
@@ -400,7 +400,7 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
 | 
			
		||||
					   "Consider identifying the final function used at run time and set the probe directly on that.\n",
 | 
			
		||||
					   pp->function);
 | 
			
		||||
		} else
 | 
			
		||||
			address = map->unmap_ip(map, sym->start) - map->reloc;
 | 
			
		||||
			address = map__unmap_ip(map, sym->start) - map->reloc;
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	if (!address) {
 | 
			
		||||
@@ -2249,7 +2249,7 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
 | 
			
		||||
		goto out;
 | 
			
		||||
 | 
			
		||||
	pp->retprobe = tp->retprobe;
 | 
			
		||||
	pp->offset = addr - map->unmap_ip(map, sym->start);
 | 
			
		||||
	pp->offset = addr - map__unmap_ip(map, sym->start);
 | 
			
		||||
	pp->function = strdup(sym->name);
 | 
			
		||||
	ret = pp->function ? 0 : -ENOMEM;
 | 
			
		||||
 | 
			
		||||
@@ -3123,7 +3123,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 | 
			
		||||
			goto err_out;
 | 
			
		||||
		}
 | 
			
		||||
		/* Add one probe point */
 | 
			
		||||
		tp->address = map->unmap_ip(map, sym->start) + pp->offset;
 | 
			
		||||
		tp->address = map__unmap_ip(map, sym->start) + pp->offset;
 | 
			
		||||
 | 
			
		||||
		/* Check the kprobe (not in module) is within .text  */
 | 
			
		||||
		if (!pev->uprobes && !pev->target &&
 | 
			
		||||
 
 | 
			
		||||
@@ -471,7 +471,7 @@ static PyObject *python_process_callchain(struct perf_sample *sample,
 | 
			
		||||
				struct addr_location node_al;
 | 
			
		||||
				unsigned long offset;
 | 
			
		||||
 | 
			
		||||
				node_al.addr = map->map_ip(map, node->ip);
 | 
			
		||||
				node_al.addr = map__map_ip(map, node->ip);
 | 
			
		||||
				node_al.map  = map;
 | 
			
		||||
				offset = get_offset(node->ms.sym, &node_al);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -364,7 +364,7 @@ static int _hist_entry__sym_snprintf(struct map_symbol *ms,
 | 
			
		||||
		u64 rip = ip;
 | 
			
		||||
 | 
			
		||||
		if (dso && dso->kernel && dso->adjust_symbols)
 | 
			
		||||
			rip = map->unmap_ip(map, ip);
 | 
			
		||||
			rip = map__unmap_ip(map, ip);
 | 
			
		||||
 | 
			
		||||
		ret += repsep_snprintf(bf, size, "%-#*llx %c ",
 | 
			
		||||
				       BITS_PER_LONG / 4 + 2, rip, o);
 | 
			
		||||
@@ -375,7 +375,7 @@ static int _hist_entry__sym_snprintf(struct map_symbol *ms,
 | 
			
		||||
		if (sym->type == STT_OBJECT) {
 | 
			
		||||
			ret += repsep_snprintf(bf + ret, size - ret, "%s", sym->name);
 | 
			
		||||
			ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx",
 | 
			
		||||
					ip - map->unmap_ip(map, sym->start));
 | 
			
		||||
					ip - map__unmap_ip(map, sym->start));
 | 
			
		||||
		} else {
 | 
			
		||||
			ret += repsep_snprintf(bf + ret, size - ret, "%.*s",
 | 
			
		||||
					       width - ret,
 | 
			
		||||
@@ -1147,7 +1147,7 @@ static int _hist_entry__addr_snprintf(struct map_symbol *ms,
 | 
			
		||||
		if (sym->type == STT_OBJECT) {
 | 
			
		||||
			ret += repsep_snprintf(bf + ret, size - ret, "%s", sym->name);
 | 
			
		||||
			ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx",
 | 
			
		||||
					ip - map->unmap_ip(map, sym->start));
 | 
			
		||||
					ip - map__unmap_ip(map, sym->start));
 | 
			
		||||
		} else {
 | 
			
		||||
			ret += repsep_snprintf(bf + ret, size - ret, "%.*s",
 | 
			
		||||
					       width - ret,
 | 
			
		||||
@@ -2104,9 +2104,9 @@ sort__addr_cmp(struct hist_entry *left, struct hist_entry *right)
 | 
			
		||||
	struct map *right_map = right->ms.map;
 | 
			
		||||
 | 
			
		||||
	if (left_map)
 | 
			
		||||
		left_ip = left_map->unmap_ip(left_map, left_ip);
 | 
			
		||||
		left_ip = map__unmap_ip(left_map, left_ip);
 | 
			
		||||
	if (right_map)
 | 
			
		||||
		right_ip = right_map->unmap_ip(right_map, right_ip);
 | 
			
		||||
		right_ip = map__unmap_ip(right_map, right_ip);
 | 
			
		||||
 | 
			
		||||
	return _sort__addr_cmp(left_ip, right_ip);
 | 
			
		||||
}
 | 
			
		||||
@@ -2118,7 +2118,7 @@ static int hist_entry__addr_snprintf(struct hist_entry *he, char *bf,
 | 
			
		||||
	struct map *map = he->ms.map;
 | 
			
		||||
 | 
			
		||||
	if (map)
 | 
			
		||||
		ip = map->unmap_ip(map, ip);
 | 
			
		||||
		ip = map__unmap_ip(map, ip);
 | 
			
		||||
 | 
			
		||||
	return repsep_snprintf(bf, size, "%-#*llx", width, ip);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -896,8 +896,8 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
 | 
			
		||||
			 * So that we look just like we get from .ko files,
 | 
			
		||||
			 * i.e. not prelinked, relative to initial_map->start.
 | 
			
		||||
			 */
 | 
			
		||||
			pos->start = curr_map->map_ip(curr_map, pos->start);
 | 
			
		||||
			pos->end   = curr_map->map_ip(curr_map, pos->end);
 | 
			
		||||
			pos->start = map__map_ip(curr_map, pos->start);
 | 
			
		||||
			pos->end   = map__map_ip(curr_map, pos->end);
 | 
			
		||||
		} else if (x86_64 && is_entry_trampoline(pos->name)) {
 | 
			
		||||
			/*
 | 
			
		||||
			 * These symbols are not needed anymore since the
 | 
			
		||||
 
 | 
			
		||||
@@ -464,7 +464,7 @@ int thread__memcpy(struct thread *thread, struct machine *machine,
 | 
			
		||||
	if( !dso || dso->data.status == DSO_DATA_STATUS_ERROR || map__load(al.map) < 0)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	offset = al.map->map_ip(al.map, ip);
 | 
			
		||||
	offset = map__map_ip(al.map, ip);
 | 
			
		||||
	if (is64bit)
 | 
			
		||||
		*is64bit = dso->is_64_bit;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ static int entry(u64 ip, struct unwind_info *ui)
 | 
			
		||||
	pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
 | 
			
		||||
		 al.sym ? al.sym->name : "''",
 | 
			
		||||
		 ip,
 | 
			
		||||
		 al.map ? al.map->map_ip(al.map, ip) : (u64) 0);
 | 
			
		||||
		 al.map ? map__map_ip(al.map, ip) : (u64) 0);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -640,7 +640,7 @@ static int entry(u64 ip, struct thread *thread,
 | 
			
		||||
	pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
 | 
			
		||||
		 al.sym ? al.sym->name : "''",
 | 
			
		||||
		 ip,
 | 
			
		||||
		 al.map ? al.map->map_ip(al.map, ip) : (u64) 0);
 | 
			
		||||
		 al.map ? map__map_ip(al.map, ip) : (u64) 0);
 | 
			
		||||
 | 
			
		||||
	return cb(&e, arg);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user