All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH tracing/kprobes 0/5] tracing/kprobes, perf: perf kprobe support
@ 2009-09-25 19:14 Masami Hiramatsu
  2009-09-25 19:14 ` [RFC PATCH tracing/kprobes 1/5] tracing/kprobes: Rename special variables syntax Masami Hiramatsu
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Masami Hiramatsu @ 2009-09-25 19:14 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt, Ingo Molnar, lkml
  Cc: Frederic Weisbecker, Ingo Molnar, Thomas Gleixner,
	Arnaldo Carvalho de Melo, Steven Rostedt, Mike Galbraith,
	Paul Mackerras, Peter Zijlstra, Christoph Hellwig,
	Ananth N Mavinakayanahalli, Jim Keniston, Frank Ch. Eigler,
	systemtap, DLE


Hi,

These patches introduce perf kprobe command and update kprobe-tracer.
perf kprobe command allows you to add new probe points by C line number
and local variable names.

Usage
-----
 perf kprobe [<options>] -P PROBEDEF [-P PROBEDEF ...]

    -k, --vmlinux <file>  vmlinux/module pathname
    -r, --release <rel>   kernel release
    -P, --probe <p|r:[GRP/]NAME,FUNC[+OFFS][@SRC]|@SRC:LINE,ARG[,ARG,...]>
                          probe point definition, where
		p:	kprobe probe
		r:	kretprobe probe
		GRP:	Group name (optional)
		NAME:	Event name
		FUNC:	Function name
		OFFS:	Offset from function entry (in byte)
		SRC:	Source code path
		LINE:	Line number
		ARG:	Probe argument (local variable name or
			kprobe-tracer argument format is supported.)

Examples
--------
1) Add a new kprobe probe on a line of C source code.
./perf kprobe -P 'p:myprobe,@fs/bio.c:162,bv,idx'
Adding new event: p:myprobe bvec_free_bs+17 bv=%bx idx=%cx

2) Add a new kretprobe probe on a function return.
./perf kprobe -P 'r:myretprobe,vfs_read,$rv'
Adding new event: r:myretprobe vfs_read+0 $rv

3) Check it in the perf list.
./perf list
...
  rNNN                                       [raw hardware event descriptor]

  kprobes:myprobe                            [Tracepoint event]
  kprobes:myretprobe                         [Tracepoint event]
  skb:kfree_skb                              [Tracepoint event]
...

4) Check its format

$ cat /sys/kernel/debug/tracing/events/kprobes/myprobe/format
name: myprobe
ID: 687
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_lock_depth;	offset:8;	size:4;

	field: unsigned long __probe_ip;	offset:12;	size:4;
	field: int __probe_nargs;	offset:16;	size:4;
	field: unsigned long bv;	offset:20;	size:4;
	field: unsigned long idx;	offset:24;	size:4;


print fmt: "(%lx) bv=%lx idx=%lx", REC->__probe_ip, REC->bv, REC->idx


Syntax Issue
------------
This version picks '-P event-definition' syntax, but I think
'-p event -a arg' is also possible. I'd like to ask you
which you like or support both?


TODO
----
There are still many enhancements required for catching up
'tracing side' of systemtap. I think it should be done one by one.
I hope that systemtap developers cooperate with us on this
development.

 - Support sys_perf_counter_open (non-root)
 - Type support
 - Non-auto static variable
 - Fields of data structure (var->field)
 - Bit fields
 - Array (var[N])
 - Dynamic array indexing (var[var2])
 - String/dynamic arrays (var:string, var[N..M])
 - Force Type casting ((type)var)
 - Non-inline search
 - libdw, libdwfl

Thank you,

---

Masami Hiramatsu (5):
      perf: kprobe command supports without libdwarf
      perf: Support perf kprobe command for kprobe-event setup helper
      tracing/kprobes: Rename fixed field name
      tracing/kprobes: Avoid field name confliction
      tracing/kprobes: Rename special variables syntax


 Documentation/trace/kprobetrace.txt |   10 -
 kernel/trace/trace_kprobe.c         |  124 +++++-
 tools/perf/Makefile                 |   10 +
 tools/perf/builtin-kprobe.c         |  340 +++++++++++++++++
 tools/perf/builtin.h                |    1 
 tools/perf/perf.c                   |    1 
 tools/perf/util/probe-finder.c      |  684 +++++++++++++++++++++++++++++++++++
 tools/perf/util/probe-finder.h      |   70 ++++
 8 files changed, 1200 insertions(+), 40 deletions(-)
 create mode 100644 tools/perf/builtin-kprobe.c
 create mode 100644 tools/perf/util/probe-finder.c
 create mode 100644 tools/perf/util/probe-finder.h

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-09-30 14:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-25 19:14 [RFC PATCH tracing/kprobes 0/5] tracing/kprobes, perf: perf kprobe support Masami Hiramatsu
2009-09-25 19:14 ` [RFC PATCH tracing/kprobes 1/5] tracing/kprobes: Rename special variables syntax Masami Hiramatsu
2009-09-25 19:15 ` [RFC PATCH tracing/kprobes 2/5] tracing/kprobes: Avoid field name confliction Masami Hiramatsu
2009-09-28  2:20   ` Li Zefan
2009-09-28 16:52     ` Masami Hiramatsu
2009-09-25 19:15 ` [RFC PATCH tracing/kprobes 3/5] tracing/kprobes: Rename fixed field name Masami Hiramatsu
2009-09-25 19:15 ` [RFC PATCH tracing/kprobes 4/5] perf: Support perf kprobe command for kprobe-event setup helper Masami Hiramatsu
2009-09-26  8:52   ` Steven Rostedt
2009-09-28 16:51     ` Masami Hiramatsu
2009-09-25 19:16 ` [RFC PATCH tracing/kprobes 5/5] perf: kprobe command supports without libdwarf Masami Hiramatsu
2009-09-30  1:06 ` [RFC PATCH tracing/kprobes 0/5] tracing/kprobes, perf: perf kprobe support Masami Hiramatsu
2009-09-30 12:04   ` Ingo Molnar
2009-09-30 14:57     ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.