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
d9c243e6
Commit
d9c243e6
authored
Jul 08, 2016
by
Sasha Goldshtein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Test new tracepoint support
parent
fab68e3a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
18 deletions
+4
-18
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+2
-2
tests/python/test_tracepoint.py
tests/python/test_tracepoint.py
+2
-16
No files found.
src/python/bcc/__init__.py
View file @
d9c243e6
...
...
@@ -610,10 +610,10 @@ class BPF(object):
def
_trace_autoload
(
self
):
for
i
in
range
(
0
,
lib
.
bpf_num_functions
(
self
.
module
)):
func_name
=
lib
.
bpf_function_name
(
self
.
module
,
i
).
decode
()
if
func_name
.
startswith
(
"kprobe__"
):
if
len
(
open_kprobes
)
==
0
and
func_name
.
startswith
(
"kprobe__"
):
fn
=
self
.
load_func
(
func_name
,
BPF
.
KPROBE
)
self
.
attach_kprobe
(
event
=
fn
.
name
[
8
:],
fn_name
=
fn
.
name
)
elif
func_name
.
startswith
(
"kretprobe__"
):
elif
len
(
open_kprobes
)
==
0
and
func_name
.
startswith
(
"kretprobe__"
):
fn
=
self
.
load_func
(
func_name
,
BPF
.
KPROBE
)
self
.
attach_kretprobe
(
event
=
fn
.
name
[
11
:],
fn_name
=
fn
.
name
)
elif
func_name
.
startswith
(
"tracepoint__"
):
...
...
tests/python/test_tracepoint.py
View file @
d9c243e6
...
...
@@ -22,21 +22,9 @@ def kernel_version_ge(major, minor):
@
unittest
.
skipUnless
(
kernel_version_ge
(
4
,
7
),
"requires kernel >= 4.7"
)
class
TestTracepoint
(
unittest
.
TestCase
):
def
test_tracepoint
(
self
):
text
=
"""#include <linux/ptrace.h>
struct tp_args {
unsigned long long __unused__;
char prev_comm[16];
pid_t prev_pid;
int prev_prio;
long prev_state;
char next_comm[16];
pid_t next_pid;
int next_prio;
};
text
=
"""
BPF_HASH(switches, u32, u64);
int probe_switch(struct tp_args *args) {
if (args == 0)
return 0;
TRACEPOINT_PROBE(sched, sched_switch) {
u64 val = 0;
u32 pid = args->next_pid;
u64 *existing = switches.lookup_or_init(&pid, &val);
...
...
@@ -45,13 +33,11 @@ class TestTracepoint(unittest.TestCase):
}
"""
b
=
bcc
.
BPF
(
text
=
text
)
b
.
attach_tracepoint
(
"sched:sched_switch"
,
"probe_switch"
)
sleep
(
1
)
total_switches
=
0
for
k
,
v
in
b
[
"switches"
].
items
():
total_switches
+=
v
.
value
self
.
assertNotEqual
(
0
,
total_switches
)
b
.
detach_tracepoint
(
"sched:sched_switch"
)
if
__name__
==
"__main__"
:
unittest
.
main
()
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