Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Steven Rostedt and committed by
Arnaldo Carvalho de Melo
6d862b8c c6c2b960

+46
+42
tools/lib/traceevent/event-parse.c
··· 5367 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 + */ 5381 + int 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 + 5370 5412 static void free_func_handle(struct pevent_function_handler *func) 5371 5413 { 5372 5414 struct pevent_func_params *params;
+4
tools/lib/traceevent/event-parse.h
··· 569 569 struct event_format *event, const char *name, 570 570 struct pevent_record *record, int err); 571 571 572 + int 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 + 572 576 int pevent_register_event_handler(struct pevent *pevent, int id, 573 577 const char *sys_name, const char *event_name, 574 578 pevent_event_handler_func func, void *context);