Skip to content

Commit

Permalink
Denote auto-loading with k[ret]probe__ prefix
Browse files Browse the repository at this point in the history
Since kprobe functions will have a different prototype than the kernel
symbols they are attaching to, require that the user prefix the trace
function with a kprobe__ name to denote intent. kretprobe__ prefix is
also supported.

Signed-off-by: Brenden Blanco <[email protected]>
  • Loading branch information
Brenden Blanco committed Sep 9, 2015
1 parent afea5ed commit e12a95d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

from bcc import BPF

BPF(text='void sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\\n"); }').trace_print()
BPF(text='void kprobe__sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\\n"); }').trace_print()
5 changes: 4 additions & 1 deletion src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,10 @@ def trace_print(self, fmt=None):
if len(open_kprobes) == 0:
fns = self.load_funcs(BPF.KPROBE)
for fn in fns:
self.attach_kprobe(event=fn.name, fn_name=fn.name)
if fn.name.startswith("kprobe__"):
self.attach_kprobe(event=fn.name[8:], fn_name=fn.name)
elif fn.name.startswith("kretprobe__"):
self.attach_kprobe(event=fn.name[11:], fn_name=fn.name)

while True:
if fmt:
Expand Down

0 comments on commit e12a95d

Please sign in to comment.