This program converts probe point in C expression to kprobe event format for kprobe-based event tracer. This helps to define kprobes events by C source line number or function name, and local variable name. Currently, this supports only x86(32/64) kernels. Compile -------- Before compilation, please install libelf and libdwarf development packages. (e.g. elfutils-libelf-devel and libdwarf-devel on Fedora) $ gcc -Wall -lelf -ldwarf c2kpe.c -o c2kpe Synopsis -------- $ c2kpe [options] FUNCTION[+OFFS][@SRC] [VAR [VAR ...]] or $ c2kpe [options] @SRC:LINE [VAR [VAR ...]] FUNCTION: Probing function name. OFFS: Offset in bytes. SRC: Source file path. LINE: Line number VAR: Local variable name. options: -r KREL Kernel release version (e.g. 2.6.31-rc5) -m DEBUGINFO Dwarf-format binary file (vmlinux or kmodule) Example ------- $ c2kpe sys_read fd buf count sys_read+0 %di %si %dx $ c2kpe @mm/filemap.c:339 inode pos sync_page_range+125 -48(%bp) %r14 Example with kprobe-tracer -------------------------- Since C expression may be converted multiple results, I recommend to use readline. $ c2kpe sys_read fd buf count | while read i; do \ echo "p $i" > $DEBUGFS/tracing/kprobe_events ;\ done Note ---- - This requires a kernel compiled with CONFIG_DEBUG_INFO. - Specifying @SRC speeds up c2kpe, because we can skip CUs which don't include specified SRC file. - c2kpe doesn't check whether the offset byte is correctly on the instruction boundary. I recommend you to use @SRC:LINE expression for tracing function body. - This tool doesn't search kmodule file. You need to specify kmodule file if you want to probe it. TODO ---- - Fix bugs. - Support multiple probepoints from stdin. - Better kmodule support. - Use elfutils-libdw? - Merge into trace-cmd or perf-tools? -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America), Inc. Software Solutions Division e-mail: mhiramat@redhat.com