This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder
- From: Masami Hiramatsu <mhiramat at redhat dot com>
- To: Christoph Hellwig <hch at infradead dot org>
- Cc: Ingo Molnar <mingo at elte dot hu>, Steven Rostedt <rostedt at goodmis dot org>, lkml <linux-kernel at vger dot kernel dot org>, Avi Kivity <avi at redhat dot com>, "H. Peter Anvin" <hpa at zytor dot com>, Frederic Weisbecker <fweisbec at gmail dot com>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, Andrew Morton <akpm at linux-foundation dot org>, Andi Kleen <andi at firstfloor dot org>, Jim Keniston <jkenisto at us dot ibm dot com>, "K.Prasad" <prasad at linux dot vnet dot ibm dot com>, Przemys??awPawe??czyk <przemyslaw at pawelczyk dot it>, Vegard Nossum <vegard dot nossum at gmail dot com>, "Frank Ch. Eigler" <fche at redhat dot com>, Tom Zanussi <tzanussi at gmail dot com>, systemtap <systemtap at sources dot redhat dot com>, kvm <kvm at vger dot kernel dot org>, DLE <dle-develop at lists dot sourceforge dot net>
- Date: Sun, 31 May 2009 09:43:36 -0400
- Subject: Re: [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder
- References: <20090529000326.17532.70868.stgit@localhost.localdomain> <20090530080503.GA15755@infradead.org>
Christoph Hellwig wrote:
> Small question to start with: What's your (or Hitachi s/Red Hat's) use case
> for this? It's obviously really cool technology, but I fear without
> some good user space side to make it easy to use it will most likely
> bit-rot which would be sad.
Good question,
Frankly to say, this was started just for the in-kernel user of kprobes.
However, now I think this can be used for some ideas,
- Quick debugging (checking variables, execution path, etc.) in asm level.
(elfutils might help us to make it source level debugging)
- Prototyping new tracepoints.
- Stress test of kprobes to find functions which should be __kprobes.
- Vehicle of tracing facilities which will be ported from systemtap runtime.
- As Frank said, we can make systemtap to control this for simple scripts.
Even now, it's not hard to use systemtap for finding variables in
stack/registers. Key options are -v and -p2,
e.g.
$ stap -v -p2 -e 'probe kernel.statement("*@fs/open.c:1024")\
{printf("%d", $files)}'
Then, you'll get below output,
------
# functions
_dwarf_tvar_get_files_0:long ()
%{{
{
uint64_t addr;
{ // DWARF expression: 0x5c
{ uint64_t value = fetch_register (12);addr = value; }
}
THIS->__retvalue = addr;
}
goto out;
if (0) goto deref_fault;
deref_fault:
goto out;
}
/* pure */%}
# probes
kernel.statement("fd_install@/home/mhiramat/ksrc/linux-2.6-tip/fs/open.c:1024")
/* pc=_stext+0xd1f72 */ /* <- kernel.statement("*@fs/open.c:1024") */
printf("%d", _dwarf_tvar_get_files_0())
------
This shows that 'fs/open.c:1024' is located at _stext+0xd1f72, and
'files' is mapped to %r12 (note, pt_regs mapping is different from
dwarf register mapping.) So, below command adds probe at
fs/open.c:1024 and trace 'files' variable :-)
$ echo p _stext+0xd1f72 %r12 > /debug/tracing/kprobe_events
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com