Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9de89fe7 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar
Browse files

perf symbols: Remove perf_session usage in symbols layer



I noticed while writing the first test in 'perf regtest' that to
just test the symbol handling routines one needs to create a
perf session, that is a layer centered on a perf.data file,
events, etc, so I untied these layers.

This reduces the complexity for the users as the number of
parameters to most of the symbols and session APIs now was
reduced while not adding more state to all the map instances by
only having data that is needed to split the kernel (kallsyms
and ELF symtab sections) maps and do vmlinux relocation on the
main kernel map.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1265223128-11786-1-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent b8f46c5a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
		if (is_caller) {
			addr = data->call_site;
			if (!raw_ip)
				sym = map_groups__find_function(&session->kmaps, session, addr, NULL);
				sym = map_groups__find_function(&session->kmaps, addr, NULL);
		} else
			addr = data->ptr;

+2 −3
Original line number Diff line number Diff line
@@ -122,8 +122,7 @@ static int opt_del_probe_event(const struct option *opt __used,
static void evaluate_probe_point(struct probe_point *pp)
{
	struct symbol *sym;
	sym = map__find_symbol_by_name(session.kmap, pp->function,
				       session.psession, NULL);
	sym = map__find_symbol_by_name(session.kmap, pp->function, NULL);
	if (!sym)
		die("Kernel symbol \'%s\' not found - probe not added.",
		    pp->function);
@@ -132,7 +131,7 @@ static void evaluate_probe_point(struct probe_point *pp)
#ifndef NO_LIBDWARF
static int open_vmlinux(void)
{
	if (map__load(session.kmap, session.psession, NULL) < 0) {
	if (map__load(session.kmap, NULL) < 0) {
		pr_debug("Failed to load kernel map.\n");
		return -EINVAL;
	}
+2 −4
Original line number Diff line number Diff line
@@ -374,9 +374,7 @@ int event__process_mmap(event_t *self, struct perf_session *session)
				goto out_problem;

			kernel->kernel = 1;
			if (__map_groups__create_kernel_maps(&session->kmaps,
							     session->vmlinux_maps,
							     kernel) < 0)
			if (__perf_session__create_kernel_maps(session, kernel) < 0)
				goto out_problem;

			session->vmlinux_maps[MAP__FUNCTION]->start = self->mmap.start;
@@ -476,7 +474,7 @@ void thread__find_addr_location(struct thread *self,
{
	thread__find_addr_map(self, session, cpumode, type, addr, al);
	if (al->map != NULL)
		al->sym = map__find_symbol(al->map, session, al->addr, filter);
		al->sym = map__find_symbol(al->map, al->addr, filter);
	else
		al->sym = NULL;
}
+12 −8
Original line number Diff line number Diff line
@@ -104,8 +104,7 @@ void map__fixup_end(struct map *self)

#define DSO__DELETED "(deleted)"

int map__load(struct map *self, struct perf_session *session,
	      symbol_filter_t filter)
int map__load(struct map *self, symbol_filter_t filter)
{
	const char *name = self->dso->long_name;
	int nr;
@@ -113,7 +112,7 @@ int map__load(struct map *self, struct perf_session *session,
	if (dso__loaded(self->dso, self->type))
		return 0;

	nr = dso__load(self->dso, self, session, filter);
	nr = dso__load(self->dso, self, filter);
	if (nr < 0) {
		if (self->dso->has_build_id) {
			char sbuild_id[BUILD_ID_SIZE * 2 + 1];
@@ -144,24 +143,29 @@ int map__load(struct map *self, struct perf_session *session,

		return -1;
	}
	/*
	 * Only applies to the kernel, as its symtabs aren't relative like the
	 * module ones.
	 */
	if (self->dso->kernel)
		map__reloc_vmlinux(self);

	return 0;
}

struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
				u64 addr, symbol_filter_t filter)
struct symbol *map__find_symbol(struct map *self, u64 addr,
				symbol_filter_t filter)
{
	if (map__load(self, session, filter) < 0)
	if (map__load(self, filter) < 0)
		return NULL;

	return dso__find_symbol(self->dso, self->type, addr);
}

struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
					struct perf_session *session,
					symbol_filter_t filter)
{
	if (map__load(self, session, filter) < 0)
	if (map__load(self, filter) < 0)
		return NULL;

	if (!dso__sorted_by_name(self->dso, self->type))
+16 −6
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ enum map_type {
#define MAP__NR_TYPES (MAP__VARIABLE + 1)

struct dso;
struct ref_reloc_sym;
struct map_groups;

struct map {
	union {
@@ -29,6 +31,16 @@ struct map {
	struct dso		*dso;
};

struct kmap {
	struct ref_reloc_sym	*ref_reloc_sym;
	struct map_groups	*kmaps;
};

static inline struct kmap *map__kmap(struct map *self)
{
	return (struct kmap *)(self + 1);
}

static inline u64 map__map_ip(struct map *map, u64 ip)
{
	return ip - map->start + map->pgoff;
@@ -58,16 +70,14 @@ struct map *map__clone(struct map *self);
int map__overlap(struct map *l, struct map *r);
size_t map__fprintf(struct map *self, FILE *fp);

struct perf_session;

int map__load(struct map *self, struct perf_session *session,
	      symbol_filter_t filter);
struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
int map__load(struct map *self, symbol_filter_t filter);
struct symbol *map__find_symbol(struct map *self,
				u64 addr, symbol_filter_t filter);
struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
					struct perf_session *session,
					symbol_filter_t filter);
void map__fixup_start(struct map *self);
void map__fixup_end(struct map *self);

void map__reloc_vmlinux(struct map *self);

#endif /* __PERF_MAP_H */
Loading