aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2013-11-01 17:54:00 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-04 12:36:49 -0500
commit6d862b8c14ba539c7c87ffc77f2e1d6dc9630c4d (patch)
treea8acb87cf151aed23aa0f64d2f78567b6eaffc75 /tools
parentc6c2b960b7a4105f096499fba3df65d6c0272a20 (diff)
tools lib traceevent: Add pevent_print_func_field() helper function
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> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20131101215501.869542711@goodmis.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/traceevent/event-parse.c42
-rw-r--r--tools/lib/traceevent/event-parse.h4
2 files changed, 46 insertions, 0 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index fc6f35f591f6..8f450adaa9c2 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,
5367 return -1; 5367 return -1;
5368} 5368}
5369 5369
5370/**
5371 * pevent_print_func_field - print a field and a format for function pointers
5372 * @s: The seq to print to
5373 * @fmt: The printf format to print the field with.
5374 * @event: the event that the field is for
5375 * @name: The name of the field
5376 * @record: The record with the field name.
5377 * @err: print default error if failed.
5378 *
5379 * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
5380 */
5381int pevent_print_func_field(struct trace_seq *s, const char *fmt,
5382 struct event_format *event, const char *name,
5383 struct pevent_record *record, int err)
5384{
5385 struct format_field *field = pevent_find_field(event, name);
5386 struct pevent *pevent = event->pevent;
5387 unsigned long long val;
5388 struct func_map *func;
5389 char tmp[128];
5390
5391 if (!field)
5392 goto failed;
5393
5394 if (pevent_read_number_field(field, record->data, &val))
5395 goto failed;
5396
5397 func = find_func(pevent, val);
5398
5399 if (func)
5400 snprintf(tmp, 128, "%s/0x%llx", func->func, func->addr - val);
5401 else
5402 sprintf(tmp, "0x%08llx", val);
5403
5404 return trace_seq_printf(s, fmt, tmp);
5405
5406 failed:
5407 if (err)
5408 trace_seq_printf(s, "CAN'T FIND FIELD \"%s\"", name);
5409 return -1;
5410}
5411
5370static void free_func_handle(struct pevent_function_handler *func) 5412static void free_func_handle(struct pevent_function_handler *func)
5371{ 5413{
5372 struct pevent_func_params *params; 5414 struct pevent_func_params *params;
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index dc8539ee9485..8d73d2594f65 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,
569 struct event_format *event, const char *name, 569 struct event_format *event, const char *name,
570 struct pevent_record *record, int err); 570 struct pevent_record *record, int err);
571 571
572int pevent_print_func_field(struct trace_seq *s, const char *fmt,
573 struct event_format *event, const char *name,
574 struct pevent_record *record, int err);
575
572int pevent_register_event_handler(struct pevent *pevent, int id, 576int pevent_register_event_handler(struct pevent *pevent, int id,
573 const char *sys_name, const char *event_name, 577 const char *sys_name, const char *event_name,
574 pevent_event_handler_func func, void *context); 578 pevent_event_handler_func func, void *context);