From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH 8/8] tools lib traceevent: Add pevent_print_func_field() helper function
Date: Fri, 01 Nov 2013 17:54:00 -0400 [thread overview]
Message-ID: <20131101215501.869542711@goodmis.org> (raw)
In-Reply-To: 20131101215352.875376844@goodmis.org
[-- Attachment #1: 0008-tools-lib-traceevent-Add-pevent_print_func_field-hel.patch --]
[-- Type: text/plain, Size: 2759 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Add the pevent_print_func_field() that will look up a field that
is expected to be a function pointer, and it will print the function
name and offset of the address given by the field.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/lib/traceevent/event-parse.c | 42 ++++++++++++++++++++++++++++++++++++++
tools/lib/traceevent/event-parse.h | 4 ++++
2 files changed, 46 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index fc6f35f..8f450ad 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5367,6 +5367,48 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt,
return -1;
}
+/**
+ * pevent_print_func_field - print a field and a format for function pointers
+ * @s: The seq to print to
+ * @fmt: The printf format to print the field with.
+ * @event: the event that the field is for
+ * @name: The name of the field
+ * @record: The record with the field name.
+ * @err: print default error if failed.
+ *
+ * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
+ */
+int pevent_print_func_field(struct trace_seq *s, const char *fmt,
+ struct event_format *event, const char *name,
+ struct pevent_record *record, int err)
+{
+ struct format_field *field = pevent_find_field(event, name);
+ struct pevent *pevent = event->pevent;
+ unsigned long long val;
+ struct func_map *func;
+ char tmp[128];
+
+ if (!field)
+ goto failed;
+
+ if (pevent_read_number_field(field, record->data, &val))
+ goto failed;
+
+ func = find_func(pevent, val);
+
+ if (func)
+ snprintf(tmp, 128, "%s/0x%llx", func->func, func->addr - val);
+ else
+ sprintf(tmp, "0x%08llx", val);
+
+ return trace_seq_printf(s, fmt, tmp);
+
+ failed:
+ if (err)
+ trace_seq_printf(s, "CAN'T FIND FIELD \"%s\"", name);
+ return -1;
+}
+
static void free_func_handle(struct pevent_function_handler *func)
{
struct pevent_func_params *params;
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index dc8539e..8d73d25 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -569,6 +569,10 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt,
struct event_format *event, const char *name,
struct pevent_record *record, int err);
+int pevent_print_func_field(struct trace_seq *s, const char *fmt,
+ struct event_format *event, const char *name,
+ struct pevent_record *record, int err);
+
int pevent_register_event_handler(struct pevent *pevent, int id,
const char *sys_name, const char *event_name,
pevent_event_handler_func func, void *context);
--
1.8.4.rc3
next prev parent reply other threads:[~2013-11-01 21:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-01 21:53 [PATCH 0/8] tools lib traceevent: Add changes from trace-cmd repo Steven Rostedt
2013-11-01 21:53 ` [PATCH 1/8] tools lib traceevent: Add support for extracting trace_clock in report Steven Rostedt
2013-11-01 21:53 ` [PATCH 2/8] tools lib traceevent: Update printk formats when entered Steven Rostedt
2013-11-04 20:22 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2013-11-01 21:53 ` [PATCH 3/8] tools lib traceevent: If %s is a pointer, check printk formats Steven Rostedt
2013-11-04 20:22 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2013-11-01 21:53 ` [PATCH 4/8] tools lib traceevent: Handle __print_hex(__get_dynamic_array(fieldname), len) Steven Rostedt
2013-11-01 21:53 ` [PATCH 5/8] tools lib traceevent: Have bprintk output the same as the kernel does Steven Rostedt
2013-11-04 20:23 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2013-11-01 21:53 ` [PATCH 6/8] tools lib traceevent: Check for spaces in character array Steven Rostedt
2013-11-04 20:23 ` [tip:perf/core] " tip-bot for Steven Rostedt (Red Hat)
2013-11-01 21:53 ` [PATCH 7/8] tools lib traceevent: Add flags NOHANDLE and PRINTRAW to individual events Steven Rostedt
2013-11-04 20:23 ` [tip:perf/core] " tip-bot for Steven Rostedt
2013-11-01 21:54 ` Steven Rostedt [this message]
2013-11-04 20:23 ` [tip:perf/core] tools lib traceevent: Add pevent_print_func_field () helper function tip-bot for 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=20131101215501.869542711@goodmis.org \
--to=rostedt@goodmis.org \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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