Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932517AbbEHT31 (ORCPT ); Fri, 8 May 2015 15:29:27 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:35546 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932336AbbEHT3V (ORCPT ); Fri, 8 May 2015 15:29:21 -0400 From: Josef Bacik To: , , Subject: [PATCH 3/5] trace-cmd: lookup syscall names in profile Date: Fri, 8 May 2015 15:29:02 -0400 Message-ID: <1431113344-22579-4-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431113344-22579-1-git-send-email-jbacik@fb.com> References: <1431113344-22579-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.52.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-05-08_07:2015-05-08,2015-05-08,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2645 Lines: 79 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. Signed-off-by: Josef Bacik --- Makefile | 2 +- trace-profile.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 63f7e79..402f711 100644 --- a/Makefile +++ b/Makefile @@ -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 eee026e..0b84c11 100644 --- a/trace-profile.c +++ b/trace-profile.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "trace-local.h" #include "trace-hash.h" @@ -916,8 +917,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); } @@ -1425,8 +1438,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); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/