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
60b082e0
Commit
60b082e0
authored
Jul 27, 2016
by
Brenden Blanco
Committed by
GitHub
Jul 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #632 from markdrayton/probe-strings
Probe registration fixes
parents
5938394e
7c148427
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+16
-11
No files found.
src/python/bcc/__init__.py
View file @
60b082e0
...
...
@@ -334,11 +334,12 @@ class BPF(object):
fn
.
sock
=
sock
def
_get_kprobe_functions
(
self
,
event_re
):
blacklist
=
set
([
line
.
rstrip
().
split
()[
1
]
for
line
in
open
(
"%s/../kprobes/blacklist"
%
TRACEFS
)])
with
open
(
"%s/../kprobes/blacklist"
%
TRACEFS
)
as
blacklist_file
:
blacklist
=
set
([
line
.
rstrip
().
split
()[
1
]
for
line
in
blacklist_file
])
fns
=
[]
with
open
(
"%s/available_filter_functions"
%
TRACEFS
)
as
f
:
for
line
in
f
:
with
open
(
"%s/available_filter_functions"
%
TRACEFS
)
as
avail_file
:
for
line
in
avail_file
:
fn
=
line
.
rstrip
().
split
()[
0
]
if
re
.
match
(
event_re
,
fn
)
and
fn
not
in
blacklist
:
fns
.
append
(
fn
)
...
...
@@ -363,7 +364,6 @@ class BPF(object):
def
attach_kprobe
(
self
,
event
=
""
,
fn_name
=
""
,
event_re
=
""
,
pid
=-
1
,
cpu
=
0
,
group_fd
=-
1
):
assert
isinstance
(
event
,
str
),
"event must be a string"
# allow the caller to glob multiple functions together
if
event_re
:
for
line
in
self
.
_get_kprobe_functions
(
event_re
):
...
...
@@ -374,6 +374,7 @@ class BPF(object):
pass
return
event
=
str
(
event
)
self
.
_check_probe_quota
(
1
)
fn
=
self
.
load_func
(
fn_name
,
BPF
.
KPROBE
)
ev_name
=
"p_"
+
event
.
replace
(
"+"
,
"_"
).
replace
(
"."
,
"_"
)
...
...
@@ -388,7 +389,7 @@ class BPF(object):
return
self
def
detach_kprobe
(
self
,
event
):
assert
isinstance
(
event
,
str
),
"event must be a string"
event
=
str
(
event
)
ev_name
=
"p_"
+
event
.
replace
(
"+"
,
"_"
).
replace
(
"."
,
"_"
)
if
ev_name
not
in
self
.
open_kprobes
:
raise
Exception
(
"Kprobe %s is not attached"
%
event
)
...
...
@@ -402,7 +403,6 @@ class BPF(object):
def
attach_kretprobe
(
self
,
event
=
""
,
fn_name
=
""
,
event_re
=
""
,
pid
=-
1
,
cpu
=
0
,
group_fd
=-
1
):
assert
isinstance
(
event
,
str
),
"event must be a string"
# allow the caller to glob multiple functions together
if
event_re
:
for
line
in
self
.
_get_kprobe_functions
(
event_re
):
...
...
@@ -413,6 +413,7 @@ class BPF(object):
pass
return
event
=
str
(
event
)
self
.
_check_probe_quota
(
1
)
fn
=
self
.
load_func
(
fn_name
,
BPF
.
KPROBE
)
ev_name
=
"r_"
+
event
.
replace
(
"+"
,
"_"
).
replace
(
"."
,
"_"
)
...
...
@@ -427,7 +428,7 @@ class BPF(object):
return
self
def
detach_kretprobe
(
self
,
event
):
assert
isinstance
(
event
,
str
),
"event must be a string"
event
=
str
(
event
)
ev_name
=
"r_"
+
event
.
replace
(
"+"
,
"_"
).
replace
(
"."
,
"_"
)
if
ev_name
not
in
self
.
open_kprobes
:
raise
Exception
(
"Kretprobe %s is not attached"
%
event
)
...
...
@@ -526,6 +527,7 @@ class BPF(object):
BPF(text).attach_uprobe("/usr/bin/python", "main")
"""
name
=
str
(
name
)
(
path
,
addr
)
=
BPF
.
_check_path_symbol
(
name
,
sym
,
addr
)
self
.
_check_probe_quota
(
1
)
...
...
@@ -548,6 +550,7 @@ class BPF(object):
or binary 'name'.
"""
name
=
str
(
name
)
(
path
,
addr
)
=
BPF
.
_check_path_symbol
(
name
,
sym
,
addr
)
ev_name
=
"p_%s_0x%x"
%
(
self
.
_probe_repl
.
sub
(
"_"
,
path
),
addr
)
if
ev_name
not
in
self
.
open_uprobes
:
...
...
@@ -569,6 +572,7 @@ class BPF(object):
meaning of additional parameters.
"""
name
=
str
(
name
)
(
path
,
addr
)
=
BPF
.
_check_path_symbol
(
name
,
sym
,
addr
)
self
.
_check_probe_quota
(
1
)
...
...
@@ -591,6 +595,7 @@ class BPF(object):
or binary 'name'.
"""
name
=
str
(
name
)
(
path
,
addr
)
=
BPF
.
_check_path_symbol
(
name
,
sym
,
addr
)
ev_name
=
"r_%s_0x%x"
%
(
self
.
_probe_repl
.
sub
(
"_"
,
path
),
addr
)
if
ev_name
not
in
self
.
open_uprobes
:
...
...
@@ -604,7 +609,7 @@ 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
)
func_name
=
str
(
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
)
...
...
@@ -768,14 +773,14 @@ class BPF(object):
exit
()
def
cleanup
(
self
):
for
k
,
v
in
self
.
open_kprobes
.
items
(
):
for
k
,
v
in
list
(
self
.
open_kprobes
.
items
()
):
lib
.
perf_reader_free
(
v
)
# non-string keys here include the perf_events reader
if
isinstance
(
k
,
str
):
desc
=
"-:kprobes/%s"
%
k
lib
.
bpf_detach_kprobe
(
desc
.
encode
(
"ascii"
))
self
.
_del_kprobe
(
k
)
for
k
,
v
in
self
.
open_uprobes
.
items
(
):
for
k
,
v
in
list
(
self
.
open_uprobes
.
items
()
):
lib
.
perf_reader_free
(
v
)
desc
=
"-:uprobes/%s"
%
k
lib
.
bpf_detach_uprobe
(
desc
.
encode
(
"ascii"
))
...
...
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