diff options
| author | Srikar Dronamraju <srikar@linux.vnet.ibm.com> | 2012-04-11 06:30:43 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2012-05-07 08:30:17 -0400 |
| commit | f3f096cfedf8113380c56fc855275cc75cd8cf55 (patch) | |
| tree | b8d0553afc8cebf6dd320d094206e93df5d95794 /Documentation/trace | |
| parent | 8ab83f56475ec9151645a888dfe1941f4a92091d (diff) | |
tracing: Provide trace events interface for uprobes
Implements trace_event support for uprobes. In its current form
it can be used to put probes at a specified offset in a file and
dump the required registers when the code flow reaches the
probed address.
The following example shows how to dump the instruction pointer
and %ax a register at the probed text address. Here we are
trying to probe zfree in /bin/zsh:
# cd /sys/kernel/debug/tracing/
# cat /proc/`pgrep zsh`/maps | grep /bin/zsh | grep r-xp
00400000-0048a000 r-xp 00000000 08:03 130904 /bin/zsh
# objdump -T /bin/zsh | grep -w zfree
0000000000446420 g DF .text 0000000000000012 Base
zfree # echo 'p /bin/zsh:0x46420 %ip %ax' > uprobe_events
# cat uprobe_events
p:uprobes/p_zsh_0x46420 /bin/zsh:0x0000000000046420
# echo 1 > events/uprobes/enable
# sleep 20
# echo 0 > events/uprobes/enable
# cat trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
zsh-24842 [006] 258544.995456: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
zsh-24842 [007] 258545.000270: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
zsh-24842 [002] 258545.043929: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
zsh-24842 [004] 258547.046129: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com>
Cc: Linux-mm <linux-mm@kvack.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Anton Arapov <anton@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120411103043.GB29437@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'Documentation/trace')
| -rw-r--r-- | Documentation/trace/uprobetracer.txt | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/Documentation/trace/uprobetracer.txt b/Documentation/trace/uprobetracer.txt new file mode 100644 index 000000000000..eae40a003eec --- /dev/null +++ b/Documentation/trace/uprobetracer.txt | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | Uprobe-tracer: Uprobe-based Event Tracing | ||
| 2 | ========================================= | ||
| 3 | Documentation written by Srikar Dronamraju | ||
| 4 | |||
| 5 | Overview | ||
| 6 | -------- | ||
| 7 | Uprobe based trace events are similar to kprobe based trace events. | ||
| 8 | To enable this feature, build your kernel with CONFIG_UPROBE_EVENTS=y. | ||
| 9 | |||
| 10 | Similar to the kprobe-event tracer, this doesn't need to be activated via | ||
| 11 | current_tracer. Instead of that, add probe points via | ||
| 12 | /sys/kernel/debug/tracing/uprobe_events, and enable it via | ||
| 13 | /sys/kernel/debug/tracing/events/uprobes/<EVENT>/enabled. | ||
| 14 | |||
| 15 | However unlike kprobe-event tracer, the uprobe event interface expects the | ||
| 16 | user to calculate the offset of the probepoint in the object | ||
| 17 | |||
| 18 | Synopsis of uprobe_tracer | ||
| 19 | ------------------------- | ||
| 20 | p[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS] : Set a probe | ||
| 21 | |||
| 22 | GRP : Group name. If omitted, use "uprobes" for it. | ||
| 23 | EVENT : Event name. If omitted, the event name is generated | ||
| 24 | based on SYMBOL+offs. | ||
| 25 | PATH : path to an executable or a library. | ||
| 26 | SYMBOL[+offs] : Symbol+offset where the probe is inserted. | ||
| 27 | |||
| 28 | FETCHARGS : Arguments. Each probe can have up to 128 args. | ||
| 29 | %REG : Fetch register REG | ||
| 30 | |||
| 31 | Event Profiling | ||
| 32 | --------------- | ||
| 33 | You can check the total number of probe hits and probe miss-hits via | ||
| 34 | /sys/kernel/debug/tracing/uprobe_profile. | ||
| 35 | The first column is event name, the second is the number of probe hits, | ||
| 36 | the third is the number of probe miss-hits. | ||
| 37 | |||
| 38 | Usage examples | ||
| 39 | -------------- | ||
| 40 | To add a probe as a new event, write a new definition to uprobe_events | ||
| 41 | as below. | ||
| 42 | |||
| 43 | echo 'p: /bin/bash:0x4245c0' > /sys/kernel/debug/tracing/uprobe_events | ||
| 44 | |||
| 45 | This sets a uprobe at an offset of 0x4245c0 in the executable /bin/bash | ||
| 46 | |||
| 47 | echo > /sys/kernel/debug/tracing/uprobe_events | ||
| 48 | |||
| 49 | This clears all probe points. | ||
| 50 | |||
| 51 | The following example shows how to dump the instruction pointer and %ax | ||
| 52 | a register at the probed text address. Here we are trying to probe | ||
| 53 | function zfree in /bin/zsh | ||
| 54 | |||
| 55 | # cd /sys/kernel/debug/tracing/ | ||
| 56 | # cat /proc/`pgrep zsh`/maps | grep /bin/zsh | grep r-xp | ||
| 57 | 00400000-0048a000 r-xp 00000000 08:03 130904 /bin/zsh | ||
| 58 | # objdump -T /bin/zsh | grep -w zfree | ||
| 59 | 0000000000446420 g DF .text 0000000000000012 Base zfree | ||
| 60 | |||
| 61 | 0x46420 is the offset of zfree in object /bin/zsh that is loaded at | ||
| 62 | 0x00400000. Hence the command to probe would be : | ||
| 63 | |||
| 64 | # echo 'p /bin/zsh:0x46420 %ip %ax' > uprobe_events | ||
| 65 | |||
| 66 | Please note: User has to explicitly calculate the offset of the probepoint | ||
| 67 | in the object. We can see the events that are registered by looking at the | ||
| 68 | uprobe_events file. | ||
| 69 | |||
| 70 | # cat uprobe_events | ||
| 71 | p:uprobes/p_zsh_0x46420 /bin/zsh:0x0000000000046420 | ||
| 72 | |||
| 73 | Right after definition, each event is disabled by default. For tracing these | ||
| 74 | events, you need to enable it by: | ||
| 75 | |||
| 76 | # echo 1 > events/uprobes/enable | ||
| 77 | |||
| 78 | Lets disable the event after sleeping for some time. | ||
| 79 | # sleep 20 | ||
| 80 | # echo 0 > events/uprobes/enable | ||
| 81 | |||
| 82 | And you can see the traced information via /sys/kernel/debug/tracing/trace. | ||
| 83 | |||
| 84 | # cat trace | ||
| 85 | # tracer: nop | ||
| 86 | # | ||
| 87 | # TASK-PID CPU# TIMESTAMP FUNCTION | ||
| 88 | # | | | | | | ||
| 89 | zsh-24842 [006] 258544.995456: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79 | ||
| 90 | zsh-24842 [007] 258545.000270: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79 | ||
| 91 | zsh-24842 [002] 258545.043929: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79 | ||
| 92 | zsh-24842 [004] 258547.046129: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79 | ||
| 93 | |||
| 94 | Each line shows us probes were triggered for a pid 24842 with ip being | ||
| 95 | 0x446421 and contents of ax register being 79. | ||
