Skip to contentSkip to conversation

perf symbols: Provide libtraceevent callback to resolve kernel symbols

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jul 29, 2015 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  c3168b0db93ad5ffeede4ecdf807dab64270f55d
Gitweb:     http://git.kernel.org/tip/c3168b0db93ad5ffeede4ecdf807dab64270f55d
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 22 Jul 2015 16:14:29 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 23 Jul 2015 22:01:37 -0300

perf symbols: Provide libtraceevent callback to resolve kernel symbols

That provides the function signature expected by libtraceevent's pevent_set_function_resolver().

---
 tools/perf/util/machine.c     | 14 ++++++++++++++
 tools/perf/util/machine.h     |  4 ++++
 tools/perf/util/trace-event.c | 45 ++++++++++++++++++++++++++++---------------
 tools/perf/util/trace-event.h |  1 +
 4 files changed, 49 insertions(+), 15 deletions(-)
tools/perf/util/machine.c +14 -0
index d0bf1e5..22006c1 100644
@@ -1993,3 +1993,17 @@ struct dso *machine__findnew_dso(struct machine *machine, const char *filename)
 {
 	return dsos__findnew(&machine->dsos, filename);
 }
+
+char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp)
+{
+	struct machine *machine = vmachine;
+	struct map *map;
+	struct symbol *sym = map_groups__find_symbol(&machine->kmaps, MAP__FUNCTION, *addrp, &map,  NULL);
+
+	if (sym == NULL)
+		return NULL;
+
+	*modp = __map__is_kmodule(map) ? (char *)map->dso->short_name : NULL;
+	*addrp = map->unmap_ip(map, sym->start);
+	return sym->name;
+}
tools/perf/util/machine.h +4 -0
index 887798e..ff5f78c 100644
@@ -237,5 +237,9 @@ int machine__synthesize_threads(struct machine *machine, struct target *target,
 pid_t machine__get_current_tid(struct machine *machine, int cpu);
 int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
 			     pid_t tid);
+/*
+ * For use with libtraceevent's pevent_set_function_resolver()
+ */
+char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp);
 
 #endif /* __PERF_MACHINE_H */
tools/perf/util/trace-event.c +30 -15

69 lines not on this page · raw message

tools/perf/util/trace-event.h +1 -0
index d5168f0..568128c 100644
@@ -18,6 +18,7 @@ struct trace_event {
 
 int trace_event__init(struct trace_event *t);
 void trace_event__cleanup(struct trace_event *t);
+int trace_event__register_resolver(struct machine *machine);
 struct event_format*
 trace_event__tp_format(const char *sys, const char *name);