Commit eca0d916 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Frederic Weisbecker

tracing/kprobes: Add argument name support

Add argument name assignment support and remove "alias" lines from format.
This allows user to assign unique name to each argument. For example,

$ echo p do_sys_open dfd=a0 filename=a1 flags=a2 mode=a3 > kprobe_events

This assigns dfd, filename, flags, and mode to 1st - 4th arguments
respectively. Trace buffer shows those names too.

	<...>-1439  [000] 1200885.933147: do_sys_open+0x0/0xdf: dfd=ffffff9c filename=bfa898ac flags=8000 mode=0

This helps users to know what each value means.

Users can filter each events by these names too. Note that you can not
filter by argN anymore.
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20090910235337.22412.77383.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
parent e08d1c65
...@@ -42,7 +42,8 @@ Synopsis of kprobe_events ...@@ -42,7 +42,8 @@ Synopsis of kprobe_events
aN : Fetch function argument. (N >= 0)(*) aN : Fetch function argument. (N >= 0)(*)
rv : Fetch return value.(**) rv : Fetch return value.(**)
ra : Fetch return address.(**) ra : Fetch return address.(**)
+|-offs(FETCHARG) : fetch memory at FETCHARG +|- offs address.(***) +|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(***)
NAME=FETCHARG: Set NAME as the argument name of FETCHARG.
(*) aN may not correct on asmlinkaged functions and at the middle of (*) aN may not correct on asmlinkaged functions and at the middle of
function body. function body.
...@@ -62,12 +63,10 @@ enabled: ...@@ -62,12 +63,10 @@ enabled:
You can enable/disable the probe by writing 1 or 0 on it. You can enable/disable the probe by writing 1 or 0 on it.
format: format:
This shows the format of this probe event. It also shows aliases of arguments This shows the format of this probe event.
which you specified to kprobe_events.
filter: filter:
You can write filtering rules of this event. And you can use both of aliase You can write filtering rules of this event.
names and field names for describing filters.
id: id:
This shows the id of this probe event. This shows the id of this probe event.
...@@ -85,10 +84,11 @@ Usage examples ...@@ -85,10 +84,11 @@ Usage examples
To add a probe as a new event, write a new definition to kprobe_events To add a probe as a new event, write a new definition to kprobe_events
as below. as below.
echo p:myprobe do_sys_open a0 a1 a2 a3 > /sys/kernel/debug/tracing/kprobe_events echo p:myprobe do_sys_open dfd=a0 filename=a1 flags=a2 mode=a3 > /sys/kernel/debug/tracing/kprobe_events
This sets a kprobe on the top of do_sys_open() function with recording This sets a kprobe on the top of do_sys_open() function with recording
1st to 4th arguments as "myprobe" event. 1st to 4th arguments as "myprobe" event. As this example shows, users can
choose more familiar names for each arguments.
echo r:myretprobe do_sys_open rv ra >> /sys/kernel/debug/tracing/kprobe_events echo r:myretprobe do_sys_open rv ra >> /sys/kernel/debug/tracing/kprobe_events
...@@ -99,7 +99,7 @@ recording return value and return address as "myretprobe" event. ...@@ -99,7 +99,7 @@ recording return value and return address as "myretprobe" event.
cat /sys/kernel/debug/tracing/events/kprobes/myprobe/format cat /sys/kernel/debug/tracing/events/kprobes/myprobe/format
name: myprobe name: myprobe
ID: 23 ID: 75
format: format:
field:unsigned short common_type; offset:0; size:2; field:unsigned short common_type; offset:0; size:2;
field:unsigned char common_flags; offset:2; size:1; field:unsigned char common_flags; offset:2; size:1;
...@@ -109,21 +109,15 @@ format: ...@@ -109,21 +109,15 @@ format:
field: unsigned long ip; offset:16;tsize:8; field: unsigned long ip; offset:16;tsize:8;
field: int nargs; offset:24;tsize:4; field: int nargs; offset:24;tsize:4;
field: unsigned long arg0; offset:32;tsize:8; field: unsigned long dfd; offset:32;tsize:8;
field: unsigned long arg1; offset:40;tsize:8; field: unsigned long filename; offset:40;tsize:8;
field: unsigned long arg2; offset:48;tsize:8; field: unsigned long flags; offset:48;tsize:8;
field: unsigned long arg3; offset:56;tsize:8; field: unsigned long mode; offset:56;tsize:8;
alias: a0; original: arg0; print fmt: "%lx: dfd=%lx filename=%lx flags=%lx mode=%lx", ip, REC->dfd, REC->filename, REC->flags, REC->mode
alias: a1; original: arg1;
alias: a2; original: arg2;
alias: a3; original: arg3;
print fmt: "%lx: 0x%lx 0x%lx 0x%lx 0x%lx", ip, arg0, arg1, arg2, arg3
You can see that the event has 4 arguments as in the expressions you specified.
You can see that the event has 4 arguments and alias expressions
corresponding to it.
echo > /sys/kernel/debug/tracing/kprobe_events echo > /sys/kernel/debug/tracing/kprobe_events
...@@ -135,12 +129,12 @@ corresponding to it. ...@@ -135,12 +129,12 @@ corresponding to it.
# #
# TASK-PID CPU# TIMESTAMP FUNCTION # TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | | # | | | | |
<...>-1447 [001] 1038282.286875: do_sys_open+0x0/0xd6: 0x3 0x7fffd1ec4440 0x8000 0x0 <...>-1447 [001] 1038282.286875: do_sys_open+0x0/0xd6: dfd=3 filename=7fffd1ec4440 flags=8000 mode=0
<...>-1447 [001] 1038282.286878: sys_openat+0xc/0xe <- do_sys_open: 0xfffffffffffffffe 0xffffffff81367a3a <...>-1447 [001] 1038282.286878: sys_openat+0xc/0xe <- do_sys_open: rv=fffffffffffffffe ra=ffffffff81367a3a
<...>-1447 [001] 1038282.286885: do_sys_open+0x0/0xd6: 0xffffff9c 0x40413c 0x8000 0x1b6 <...>-1447 [001] 1038282.286885: do_sys_open+0x0/0xd6: dfd=ffffff9c filename=40413c flags=8000 mode=1b6
<...>-1447 [001] 1038282.286915: sys_open+0x1b/0x1d <- do_sys_open: 0x3 0xffffffff81367a3a <...>-1447 [001] 1038282.286915: sys_open+0x1b/0x1d <- do_sys_open: rv=3 ra=ffffffff81367a3a
<...>-1447 [001] 1038282.286969: do_sys_open+0x0/0xd6: 0xffffff9c 0x4041c6 0x98800 0x10 <...>-1447 [001] 1038282.286969: do_sys_open+0x0/0xd6: dfd=ffffff9c filename=4041c6 flags=98800 mode=10
<...>-1447 [001] 1038282.286976: sys_open+0x1b/0x1d <- do_sys_open: 0x3 0xffffffff81367a3a <...>-1447 [001] 1038282.286976: sys_open+0x1b/0x1d <- do_sys_open: rv=3 ra=ffffffff81367a3a
Each line shows when the kernel hits a probe, and <- SYMBOL means kernel Each line shows when the kernel hits a probe, and <- SYMBOL means kernel
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment