Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1191448
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 09/18] perf symbols: Provide libtraceevent callback to resolve kernel symbols |
| Date | 2015-07-24 04:10 +0200 |
| Message-ID | <pPAAX-8ws-35@gated-at.bofh.it> (permalink) |
| References | <pPArf-85G-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Arnaldo Carvalho de Melo <acme@redhat.com>
That provides the function signature expected by libtraceevent's
pevent_set_function_resolver().
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-ie6hvlb6u15y4ulg9j1612zg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d0bf1e590479..22006c15edf4 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -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;
+}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 887798e511e9..ff5f78c886e0 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -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 */
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index 6322d37164c5..667bd109d16f 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <traceevent/event-parse.h>
#include "trace-event.h"
+#include "machine.h"
#include "util.h"
/*
@@ -19,6 +20,7 @@
* there.
*/
static struct trace_event tevent;
+static bool tevent_initialized;
int trace_event__init(struct trace_event *t)
{
@@ -32,6 +34,32 @@ int trace_event__init(struct trace_event *t)
return pevent ? 0 : -1;
}
+static int trace_event__init2(void)
+{
+ int be = traceevent_host_bigendian();
+ struct pevent *pevent;
+
+ if (trace_event__init(&tevent))
+ return -1;
+
+ pevent = tevent.pevent;
+ pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
+ pevent_set_file_bigendian(pevent, be);
+ pevent_set_host_bigendian(pevent, be);
+ tevent_initialized = true;
+ return 0;
+}
+
+int trace_event__register_resolver(struct machine *machine)
+{
+ if (!tevent_initialized && trace_event__init2())
+ return -1;
+
+ return pevent_set_function_resolver(tevent.pevent,
+ machine__resolve_kernel_addr,
+ machine);
+}
+
void trace_event__cleanup(struct trace_event *t)
{
traceevent_unload_plugins(t->plugin_list, t->pevent);
@@ -62,21 +90,8 @@ tp_format(const char *sys, const char *name)
struct event_format*
trace_event__tp_format(const char *sys, const char *name)
{
- static bool initialized;
-
- if (!initialized) {
- int be = traceevent_host_bigendian();
- struct pevent *pevent;
-
- if (trace_event__init(&tevent))
- return NULL;
-
- pevent = tevent.pevent;
- pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
- pevent_set_file_bigendian(pevent, be);
- pevent_set_host_bigendian(pevent, be);
- initialized = true;
- }
+ if (!tevent_initialized && trace_event__init2())
+ return NULL;
return tp_format(sys, name);
}
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index d5168f0be4ec..568128c3284a 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -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);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:00 +0200
[PATCH 01/18] perf test: Check for refcnt in thread_map test Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:00 +0200
[PATCH 06/18] perf symbols: Add front end cache for DSO symbol lookup Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 12/18] perf tools: Stop reading the kallsyms data from perf.data Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Jiri Olsa <jolsa@redhat.com> - 2015-08-03 19:50 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 21:10 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 21:30 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Jiri Olsa <jolsa@redhat.com> - 2015-08-03 22:20 +0200
[PATCH 03/18] perf evlist: Use bool instead of target argument in propagate_maps() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 18/18] perf script: Add option --show-switch-events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 16/18] perf record: Add option --switch-events to select PERF_RECORD_SWITCH events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 07/18] perf symbols: Introduce map__is_(kernel,kmodule)() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 08/18] tools lib traceevent: Allow setting an alternative symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 13/18] perf tools: Stop copying kallsyms into the perf.data file header Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 15/18] perf tools: Add new PERF_RECORD_SWITCH event Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 17/18] perf script: Don't assume evsel position of tracking events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 09/18] perf symbols: Provide libtraceevent callback to resolve kernel symbols Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 14/18] perf: Add PERF_RECORD_SWITCH to indicate context switches Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 05/18] perf header: Use argv style storage for cmdline feature data Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
csiph-web