tracing/syscalls: Add fields format for exit events
authorLi Zefan <lizf@cn.fujitsu.com>
Wed, 19 Aug 2009 07:53:05 +0000 (15:53 +0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 19 Aug 2009 13:02:23 +0000 (15:02 +0200)
Add "format" file for syscall exit events:

 # cat events/syscalls/sys_exit_open/format
 name: sys_exit_open
 ID: 344
 format:
         field:unsigned short common_type;       offset:0;       size:2;
         field:unsigned char common_flags;       offset:2;       size:1;
         field:unsigned char common_preempt_count;       offset:3;       size:1;
         field:int common_pid;   offset:4;       size:4;
         field:int common_tgid;  offset:8;       size:4;

         field:int nr;   offset:12;      size:4;
         field:unsigned long ret;        offset:16;      size:4;

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A8BAF61.3060307@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/syscalls.h
include/trace/syscall.h
kernel/trace/trace_syscalls.c

index 87d06c173ddc017ddbf1c4fb3efa97367aa2368f..8d57f77794eed30fabdeac6f364286f7f8626750 100644 (file)
@@ -189,7 +189,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
                .system                 = "syscalls",                   \
                .event                  = &event_syscall_enter,         \
                .raw_init               = init_enter_##sname,           \
-               .show_format            = ftrace_format_syscall,        \
+               .show_format            = syscall_enter_format,         \
                .regfunc                = reg_event_syscall_enter,      \
                .unregfunc              = unreg_event_syscall_enter,    \
                .data                   = "sys"#sname,                  \
@@ -225,6 +225,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
                .system                 = "syscalls",                   \
                .event                  = &event_syscall_exit,          \
                .raw_init               = init_exit_##sname,            \
+               .show_format            = syscall_exit_format,          \
                .regfunc                = reg_event_syscall_exit,       \
                .unregfunc              = unreg_event_syscall_exit,     \
                .data                   = "sys"#sname,                  \
index 0cb03625edd94fa75c3d35992ed84b17b89f8416..5ce85d75d31b00937770c2aefc0cc0d7c8828598 100644 (file)
@@ -55,8 +55,10 @@ extern int reg_event_syscall_enter(void *ptr);
 extern void unreg_event_syscall_enter(void *ptr);
 extern int reg_event_syscall_exit(void *ptr);
 extern void unreg_event_syscall_exit(void *ptr);
-extern int
-ftrace_format_syscall(struct ftrace_event_call *call, struct trace_seq *s);
+extern int syscall_enter_format(struct ftrace_event_call *call,
+                               struct trace_seq *s);
+extern int syscall_exit_format(struct ftrace_event_call *call,
+                               struct trace_seq *s);
 enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags);
 enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags);
 #endif
index d10daf0922b5e309ec1cea8444ac40b200ec19b8..7336b6c265d7380ed40af8b7132990dbee935ebf 100644 (file)
@@ -97,7 +97,7 @@ extern char *__bad_type_size(void);
                __bad_type_size() :                                     \
                #type, #name, offsetof(typeof(trace), name), sizeof(trace.name)
 
-int ftrace_format_syscall(struct ftrace_event_call *call, struct trace_seq *s)
+int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s)
 {
        int i;
        int nr;
@@ -149,6 +149,22 @@ int ftrace_format_syscall(struct ftrace_event_call *call, struct trace_seq *s)
        return ret;
 }
 
+int syscall_exit_format(struct ftrace_event_call *call, struct trace_seq *s)
+{
+       int ret;
+       struct syscall_trace_exit trace;
+
+       ret = trace_seq_printf(s,
+                              "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
+                              "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n",
+                              SYSCALL_FIELD(int, nr),
+                              SYSCALL_FIELD(unsigned long, ret));
+       if (!ret)
+               return 0;
+
+       return trace_seq_printf(s, "\nprint fmt: \"0x%%lx\", REC->ret\n");
+}
+
 void ftrace_syscall_enter(struct pt_regs *regs, long id)
 {
        struct syscall_trace_enter *entry;