Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
e845c520
Commit
e845c520
authored
Sep 07, 2015
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shorten hello world example
parent
08af9e47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
examples/hello_world.py
examples/hello_world.py
+3
-8
examples/trace_fields.py
examples/trace_fields.py
+20
-0
No files found.
examples/hello_world.py
View file @
e845c520
...
...
@@ -4,15 +4,10 @@
# run in project examples directory with:
# sudo ./hello_world.py"
# see trace_fields.py for a longer example
from
bcc
import
BPF
prog
=
"""
int hello(void *ctx) {
bpf_trace_printk("Hello, World!
\
\
n");
return 0;
}
"""
b
=
BPF
(
text
=
prog
)
b
=
BPF
(
text
=
'void hello(void *ctx) { bpf_trace_printk("Hello, World!
\
\
n"); }'
)
b
.
attach_kprobe
(
event
=
"sys_clone"
,
fn_name
=
"hello"
)
b
.
trace_print
(
fmt
=
"{1} {5}"
)
b
.
trace_print
()
examples/trace_fields.py
0 → 100755
View file @
e845c520
#!/usr/bin/env python
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# This is an example of tracing an event and printing custom fields.
# run in project examples directory with:
# sudo ./trace_fields.py"
from
bcc
import
BPF
prog
=
"""
int hello(void *ctx) {
bpf_trace_printk("Hello, World!
\
\
n");
return 0;
}
"""
b
=
BPF
(
text
=
prog
)
b
.
attach_kprobe
(
event
=
"sys_clone"
,
fn_name
=
"hello"
)
print
"PID MESSAGE"
b
.
trace_print
(
fmt
=
"{1} {5}"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment