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
416613aa
Commit
416613aa
authored
Sep 25, 2015
by
Suchakra Sharma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Helper to get open k[ret]probes. Fixes #236
parent
aa91d3b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+9
-0
tests/cc/CMakeLists.txt
tests/cc/CMakeLists.txt
+2
-0
tests/cc/test_probe_count.py
tests/cc/test_probe_count.py
+29
-0
No files found.
src/python/bcc/__init__.py
View file @
416613aa
...
...
@@ -708,3 +708,12 @@ class BPF(object):
return
"[unknown]"
offset
=
int
(
addr
-
ksym_addrs
[
idx
])
return
ksym_names
[
idx
]
+
hex
(
offset
)
@
staticmethod
def
get_open_kprobes
():
""" get_open_kprobes()
Get the number of open K[ret]probes. Can be useful for scenarios where
event_re is used while attaching and detaching probes
"""
return
len
(
open_kprobes
)
tests/cc/CMakeLists.txt
View file @
416613aa
...
...
@@ -32,6 +32,8 @@ add_test(NAME py_test_trace3_c WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND
${
TEST_WRAPPER
}
py_trace3_c sudo
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_trace3.py test_trace3.c
)
add_test
(
NAME py_test_trace4 WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
COMMAND
${
TEST_WRAPPER
}
py_trace4 sudo
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_trace4.py
)
add_test
(
NAME py_test_probe_count WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
COMMAND
${
TEST_WRAPPER
}
py_probe_count sudo
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_probe_count.py
)
add_test
(
NAME py_test_brb WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
COMMAND
${
TEST_WRAPPER
}
py_brb_c sudo
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_brb.py test_brb.c
)
add_test
(
NAME py_test_brb2 WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
...
...
tests/cc/test_probe_count.py
0 → 100755
View file @
416613aa
#!/usr/bin/env python
# Copyright (c) Suchakra Sharma <suchakrapani.sharma@polymtl.ca>
# Licensed under the Apache License, Version 2.0 (the "License")
from
bcc
import
BPF
import
os
import
sys
from
unittest
import
main
,
TestCase
class
TestKprobeCnt
(
TestCase
):
def
setUp
(
self
):
self
.
b
=
BPF
(
text
=
"""
int wololo(void *ctx) {
return 0;
}
"""
)
self
.
b
.
attach_kprobe
(
event_re
=
"^vfs_.*"
,
fn_name
=
"wololo"
)
def
test_attach1
(
self
):
actual_cnt
=
0
with
open
(
"/sys/kernel/debug/tracing/available_filter_functions"
)
as
f
:
for
line
in
f
:
if
str
(
line
).
startswith
(
"vfs_"
):
actual_cnt
+=
1
open_cnt
=
self
.
b
.
get_open_kprobes
()
self
.
assertEqual
(
actual_cnt
,
open_cnt
)
if
__name__
==
"__main__"
:
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