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
a1ac4bc1
Commit
a1ac4bc1
authored
Jan 30, 2018
by
yonghong-song
Committed by
GitHub
Jan 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1561 from joelagnel/bcc-misc-1
Miscellaneous BCC patches
parents
df55284e
8e099585
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
25 deletions
+22
-25
src/cc/frontends/clang/CMakeLists.txt
src/cc/frontends/clang/CMakeLists.txt
+1
-0
src/python/bcc/table.py
src/python/bcc/table.py
+18
-22
tools/opensnoop.py
tools/opensnoop.py
+3
-3
No files found.
src/cc/frontends/clang/CMakeLists.txt
View file @
a1ac4bc1
...
...
@@ -10,3 +10,4 @@ if(DEFINED BCC_BACKUP_COMPILE)
endif
()
add_library
(
clang_frontend STATIC loader.cc b_frontend_action.cc tp_frontend_action.cc kbuild_helper.cc ../../common.cc
)
target_link_libraries
(
clang_frontend bcc-static
)
src/python/bcc/table.py
View file @
a1ac4bc1
...
...
@@ -205,6 +205,11 @@ class TableBase(MutableMapping):
errstr
=
os
.
strerror
(
ct
.
get_errno
())
raise
Exception
(
"Could not update table: %s"
%
errstr
)
def
__delitem__
(
self
,
key
):
res
=
lib
.
bpf_delete_elem
(
self
.
map_fd
,
ct
.
byref
(
key
))
if
res
<
0
:
raise
KeyError
# override the MutableMapping's implementation of these since they
# don't handle KeyError nicely
def
itervalues
(
self
):
...
...
@@ -391,11 +396,6 @@ class HashTable(TableBase):
for
k
in
self
:
i
+=
1
return
i
def
__delitem__
(
self
,
key
):
res
=
lib
.
bpf_delete_elem
(
self
.
map_fd
,
ct
.
byref
(
key
))
if
res
<
0
:
raise
KeyError
class
LruHash
(
HashTable
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
LruHash
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -430,11 +430,12 @@ class ArrayBase(TableBase):
def
__delitem__
(
self
,
key
):
key
=
self
.
_normalize_key
(
key
)
# Deleting from array type maps does not have an effect, so
# zero out the entry instead.
super
(
ArrayBase
,
self
).
__delitem__
(
key
)
def
clearitem
(
self
,
key
):
key
=
self
.
_normalize_key
(
key
)
leaf
=
self
.
Leaf
()
res
=
lib
.
bpf_update_elem
(
self
.
map_fd
,
ct
.
byref
(
key
),
ct
.
byref
(
leaf
),
0
)
res
=
lib
.
bpf_update_elem
(
self
.
map_fd
,
ct
.
byref
(
key
),
ct
.
byref
(
leaf
),
0
)
if
res
<
0
:
raise
Exception
(
"Could not clear item"
)
...
...
@@ -461,6 +462,9 @@ class Array(ArrayBase):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Array
,
self
).
__init__
(
*
args
,
**
kwargs
)
def
__delitem__
(
self
,
key
):
# Delete in Array type does not have an effect, so zero out instead
self
.
clearitem
(
key
)
class
ProgArray
(
ArrayBase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -473,12 +477,6 @@ class ProgArray(ArrayBase):
leaf
=
self
.
Leaf
(
leaf
.
fd
)
super
(
ProgArray
,
self
).
__setitem__
(
key
,
leaf
)
def
__delitem__
(
self
,
key
):
key
=
self
.
_normalize_key
(
key
)
res
=
lib
.
bpf_delete_elem
(
self
.
map_fd
,
ct
.
byref
(
key
))
if
res
<
0
:
raise
Exception
(
"Could not delete item"
)
class
PerfEventArray
(
ArrayBase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -494,8 +492,7 @@ class PerfEventArray(ArrayBase):
if
key
not
in
self
.
_open_key_fds
:
return
# Delete entry from the array
c_key
=
self
.
_normalize_key
(
key
)
lib
.
bpf_delete_elem
(
self
.
map_fd
,
ct
.
byref
(
c_key
))
super
(
PerfEventArray
,
self
).
__delitem__
(
key
)
key_id
=
(
id
(
self
),
key
)
if
key_id
in
self
.
bpf
.
open_kprobes
:
# The key is opened for perf ring buffer
...
...
@@ -665,6 +662,10 @@ class PerCpuArray(ArrayBase):
def
__setitem__
(
self
,
key
,
leaf
):
super
(
PerCpuArray
,
self
).
__setitem__
(
key
,
leaf
)
def
__delitem__
(
self
,
key
):
# Delete in this type does not have an effect, so zero out instead
self
.
clearitem
(
key
)
def
sum
(
self
,
key
):
if
isinstance
(
self
.
Leaf
(),
ct
.
Structure
):
raise
IndexError
(
"Leaf must be an integer type for default sum functions"
)
...
...
@@ -728,10 +729,5 @@ class StackTrace(TableBase):
for
k
in
self
:
i
+=
1
return
i
def
__delitem__
(
self
,
key
):
res
=
lib
.
bpf_delete_elem
(
self
.
map_fd
,
ct
.
byref
(
key
))
if
res
<
0
:
raise
KeyError
def
clear
(
self
):
pass
tools/opensnoop.py
View file @
a1ac4bc1
...
...
@@ -68,7 +68,7 @@ struct data_t {
BPF_HASH(infotmp, u64, struct val_t);
BPF_PERF_OUTPUT(events);
int trace_entry(struct pt_regs *ctx, const char __user *filename)
int trace_entry(struct pt_regs *ctx,
int dfd,
const char __user *filename)
{
struct val_t val = {};
u64 id = bpf_get_current_pid_tgid();
...
...
@@ -124,8 +124,8 @@ if debug:
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event
=
"sys_open"
,
fn_name
=
"trace_entry"
)
b
.
attach_kretprobe
(
event
=
"sys_open"
,
fn_name
=
"trace_return"
)
b
.
attach_kprobe
(
event
=
"
do_
sys_open"
,
fn_name
=
"trace_entry"
)
b
.
attach_kretprobe
(
event
=
"
do_
sys_open"
,
fn_name
=
"trace_return"
)
TASK_COMM_LEN
=
16
# linux/sched.h
NAME_MAX
=
255
# linux/limits.h
...
...
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