diff options
author | Josef Bacik <jbacik@fb.com> | 2015-05-08 15:29:02 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-06-10 15:11:46 -0400 |
commit | db4e8c9be31437a5cdda8231b5de13597da161f9 (patch) | |
tree | cfce83718bc91a245a5e842c3a4b514960addc58 | |
parent | f3b07cf9bb6e9ab405ea7a81678769bca03347e0 (diff) | |
download | trace-cmd-db4e8c9be31437a5cdda8231b5de13597da161f9.tar.gz |
trace-cmd: Lookup syscall names in profile
When we profile syscall times we're just given the syscall number, not the name.
This isn't helpful for human beings, so lookup the syscall names when we are
printing out the information. This uses the audit library to get this
information, I'm not married to it, but it seems that any app that does this
mapping has to scrape /usr/include/asm/unistd*.h to pull out the names, so might
as well just use somebody elses work.
Link: http://lkml.kernel.org/r/1431113344-22579-4-git-send-email-jbacik@fb.com
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | trace-profile.c | 19 |
2 files changed, 17 insertions, 4 deletions
@@ -160,7 +160,7 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) python_dir_SQ = $(subst ','\'',$(python_dir)) -LIBS = -L. -ltracecmd -ldl +LIBS = -L. -ltracecmd -ldl -laudit LIB_FILE = libtracecmd.a PACKAGES= gtk+-2.0 libxml-2.0 gthread-2.0 diff --git a/trace-profile.c b/trace-profile.c index f71a7c68..24f98971 100644 --- a/trace-profile.c +++ b/trace-profile.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <libaudit.h> #include "trace-local.h" #include "trace-hash.h" @@ -845,8 +846,20 @@ static void func_print(struct trace_seq *s, struct event_hash *event_hash) trace_seq_printf(s, "func: 0x%llx", event_hash->val); } -static void print_int(struct trace_seq *s, struct event_hash *event_hash) +static void syscall_print(struct trace_seq *s, struct event_hash *event_hash) { + const char *name = NULL; + int machine; + + machine = audit_detect_machine(); + if (machine < 0) + goto fail; + name = audit_syscall_to_name(event_hash->val, machine); + if (!name) + goto fail; + trace_seq_printf(s, "syscall:%s", name); + return; +fail: trace_seq_printf(s, "%s:%d", event_hash->event_data->event->name, (int)event_hash->val); } @@ -1339,8 +1352,8 @@ void trace_init_profile(struct tracecmd_input *handle, struct hook_list *hook, if (syscall_enter && syscall_exit) { mate_events(h, syscall_enter, NULL, "id", syscall_exit, "id", 1, 0); - syscall_enter->print_func = print_int; - syscall_exit->print_func = print_int; + syscall_enter->print_func = syscall_print; + syscall_exit->print_func = syscall_print; } events = pevent_list_events(pevent, EVENT_SORT_ID); |