public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Borislav Petkov <bp@suse.de>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Ingo Molnar <mingo@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH] tools lib traceevent: Allow setting an alternative symbol resolver
Date: Thu, 23 Jul 2015 12:04:33 -0300	[thread overview]
Message-ID: <20150723150433.GA3154@kernel.org> (raw)

Hi Steven,

	Can you take a look if this is ok with you? This is the part
that touches tools/lib/traceevent/, the rest of the patchset that then
uses it is at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tmp.perf/core

Best regards,

- Arnaldo

commit be524761540b0a65224ebc60b03a02989ebee8bd
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Jul 22 12:36:55 2015 -0300

    tools lib traceevent: Allow setting an alternative symbol resolver
    
    The perf tools have a symbol resolver that includes solving kernel
    symbols using either kallsyms or ELF symtabs, and it also is using
    libtraceevent to format the trace events fields, including via
    subsystem specific plugins, like the "timer" one.
    
    To solve fields like "timer:hrtimer_start"'s "function", libtraceevent
    needs a way to map from its value to a function name and addr.
    
    This patch provides a way for tools that already have symbol resolving
    facilities to ask libtraceevent to use it when needing to resolve
    kernel symbols.
    
    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-sbs6l5vu9vt94lukcorqfgtj@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index cc25f059ab3d..98c0e56447c9 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -418,7 +418,7 @@ static int func_map_init(struct pevent *pevent)
 }
 
 static struct func_map *
-find_func(struct pevent *pevent, unsigned long long addr)
+__find_func(struct pevent *pevent, unsigned long long addr)
 {
 	struct func_map *func;
 	struct func_map key;
@@ -434,6 +434,42 @@ find_func(struct pevent *pevent, unsigned long long addr)
 	return func;
 }
 
+static struct {
+	pevent_function_resolver_t *function;
+	void 			   *priv;
+} function_resolver;
+
+/**
+ * pevent_set_function_resolver - set an alternative function resolver
+ * @resolver - function to be used
+ * @priv - resolver function private state.
+ *
+ * Some tools may have already a way to resolve kernel functions, allow them
+ * to keep using it instead of duplicating all the entries inside pevent->funclist.
+ */
+void pevent_set_function_resolver(pevent_function_resolver_t *resolver, void *priv)
+{
+	function_resolver.function = resolver;
+	function_resolver.priv	  = priv;
+}
+
+static struct func_map *
+find_func(struct pevent *pevent, unsigned long long addr)
+{
+	static struct func_map map;
+
+	if (!function_resolver.function)
+		return __find_func(pevent, addr);
+
+	map.mod	 = NULL;
+	map.addr = addr;
+	map.func = function_resolver.function(function_resolver.priv, &map.addr, &map.mod);
+	if (map.func == NULL)
+		return NULL;
+
+	return &map;
+}
+
 /**
  * pevent_find_function - find a function by a given address
  * @pevent: handle for the pevent
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 063b1971eb35..978703a34143 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -611,6 +611,10 @@ enum trace_flag_type {
 	TRACE_FLAG_SOFTIRQ		= 0x10,
 };
 
+typedef char *(pevent_function_resolver_t)(void *priv, unsigned long long *addrp, char **modp);
+
+void pevent_set_function_resolver(pevent_function_resolver_t *resolver, void *priv);
+
 int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
 int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock);
 int pevent_register_function(struct pevent *pevent, char *name,

             reply	other threads:[~2015-07-23 15:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23 15:04 Arnaldo Carvalho de Melo [this message]
2015-07-23 16:21 ` [RFC PATCH] tools lib traceevent: Allow setting an alternative symbol resolver Steven Rostedt
2015-07-23 17:25   ` Arnaldo Carvalho de Melo
2015-07-23 18:10     ` Steven Rostedt
2015-07-23 18:11       ` Steven Rostedt
2015-07-23 18:17         ` Arnaldo Carvalho de Melo
2015-07-23 21:25         ` Arnaldo Carvalho de Melo
2015-07-23 21:35           ` Steven Rostedt
2015-07-23 21:52             ` Arnaldo Carvalho de Melo
2015-07-23 21:58               ` Arnaldo Carvalho de Melo
2015-07-23 22:07                 ` Steven Rostedt
2015-07-24  1:34                   ` Arnaldo Carvalho de Melo
2015-07-24  1:46                     ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150723150433.GA3154@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=bp@suse.de \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox