forked from joelagnel/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Brenden Blanco <[email protected]>
- Loading branch information
Brenden Blanco
committed
Jun 5, 2015
1 parent
6c0311e
commit 41d10e2
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) PLUMgrid, Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License") | ||
|
||
# run in project directory with: | ||
# sudo bash -c "PYTHONPATH=$PWD/src LD_LIBRARY_PATH=$PWD/build/src/cc examples/hello_world.py" | ||
|
||
from bpf import BPF | ||
from subprocess import call | ||
|
||
prog = """ | ||
#include "src/cc/bpf_helpers.h" | ||
BPF_EXPORT(hello) | ||
int hello(void *ctx) { | ||
char fmt[] = "Hello, World!\\n"; | ||
bpf_trace_printk(fmt, sizeof(fmt)); | ||
return 0; | ||
}; | ||
""" | ||
b = BPF(text=prog) | ||
fn = b.load_func("hello", BPF.KPROBE) | ||
BPF.attach_kprobe(fn, "sys_clone") | ||
call(["cat", "/sys/kernel/debug/tracing/trace_pipe"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters