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
c7edcd5e
Commit
c7edcd5e
authored
Sep 10, 2015
by
4ast
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #201 from iovisor/bblanco_dev
Always autoload k[ret]probe__ prefixed functions
parents
ed85df7d
32097d90
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
examples/bitehist.c
examples/bitehist.c
+1
-1
examples/bitehist.py
examples/bitehist.py
+0
-1
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+10
-5
No files found.
examples/bitehist.c
View file @
c7edcd5e
...
...
@@ -38,7 +38,7 @@ static unsigned int log2l(unsigned long v)
return
log2
(
v
)
+
1
;
}
int
do
_request
(
struct
pt_regs
*
ctx
,
struct
request
*
req
)
int
kprobe__blk_start
_request
(
struct
pt_regs
*
ctx
,
struct
request
*
req
)
{
int
index
=
log2l
(
req
->
__data_len
/
1024
);
u64
*
leaf
=
dist
.
lookup
(
&
index
);
...
...
examples/bitehist.py
View file @
c7edcd5e
...
...
@@ -18,7 +18,6 @@ from time import sleep
# load BPF program
b
=
BPF
(
src_file
=
"bitehist.c"
)
b
.
attach_kprobe
(
event
=
"blk_start_request"
,
fn_name
=
"do_request"
)
# header
print
(
"Tracing... Hit Ctrl-C to end."
)
...
...
src/python/bcc/__init__.py
View file @
c7edcd5e
...
...
@@ -348,6 +348,10 @@ class BPF(object):
if
self
.
module
==
None
:
raise
Exception
(
"Failed to compile BPF module %s"
%
src_file
)
# If any "kprobe__" prefixed functions were defined, they will be
# loaded and attached here.
self
.
_trace_autoload
()
def
load_funcs
(
self
,
prog_type
=
KPROBE
):
"""load_funcs(prog_type=KPROBE)
...
...
@@ -552,11 +556,13 @@ class BPF(object):
# Cater to one-liner case where attach_kprobe is omitted and C function
# name matches that of the kprobe.
if
len
(
open_kprobes
)
==
0
:
fns
=
self
.
load_funcs
(
BPF
.
KPROBE
)
for
fn
in
fns
:
if
fn
.
name
.
startswith
(
"kprobe__"
):
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__"
):
fn
=
self
.
load_func
(
func_name
,
BPF
.
KPROBE
)
self
.
attach_kprobe
(
event
=
fn
.
name
[
8
:],
fn_name
=
fn
.
name
)
elif
fn
.
name
.
startswith
(
"kretprobe__"
):
elif
func_name
.
startswith
(
"kretprobe__"
):
fn
=
self
.
load_func
(
func_name
,
BPF
.
KPROBE
)
self
.
attach_kretprobe
(
event
=
fn
.
name
[
11
:],
fn_name
=
fn
.
name
)
def
trace_open
(
self
,
nonblocking
=
False
):
...
...
@@ -564,7 +570,6 @@ class BPF(object):
Open the trace_pipe if not already open
"""
self
.
_trace_autoload
()
global
tracefile
if
not
tracefile
:
tracefile
=
open
(
"%s/trace_pipe"
%
TRACEFS
)
...
...
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