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
de258bac
Commit
de258bac
authored
7 years ago
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add flag to enable verifier log_level 2
parent
2d33f352
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
src/cc/api/BPF.cc
src/cc/api/BPF.cc
+7
-1
src/cc/common.h
src/cc/common.h
+7
-1
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+15
-5
No files found.
src/cc/api/BPF.cc
View file @
de258bac
...
@@ -480,11 +480,17 @@ StatusTuple BPF::load_func(const std::string& func_name,
...
@@ -480,11 +480,17 @@ StatusTuple BPF::load_func(const std::string& func_name,
func_name
.
c_str
());
func_name
.
c_str
());
size_t
func_size
=
bpf_module_
->
function_size
(
func_name
);
size_t
func_size
=
bpf_module_
->
function_size
(
func_name
);
int
log_level
=
0
;
if
(
flag_
&
DEBUG_BPF_REGISTER_STATE
)
log_level
=
2
;
else
if
(
flag_
&
DEBUG_BPF
)
log_level
=
1
;
fd
=
bpf_prog_load
(
type
,
func_name
.
c_str
(),
fd
=
bpf_prog_load
(
type
,
func_name
.
c_str
(),
reinterpret_cast
<
struct
bpf_insn
*>
(
func_start
),
reinterpret_cast
<
struct
bpf_insn
*>
(
func_start
),
func_size
,
bpf_module_
->
license
(),
func_size
,
bpf_module_
->
license
(),
bpf_module_
->
kern_version
(),
bpf_module_
->
kern_version
(),
flag_
&
DEBUG_BPF
?
1
:
0
,
nullptr
,
0
);
log_level
,
nullptr
,
0
);
if
(
fd
<
0
)
if
(
fd
<
0
)
return
StatusTuple
(
-
1
,
"Failed to load %s: %d"
,
func_name
.
c_str
(),
fd
);
return
StatusTuple
(
-
1
,
"Failed to load %s: %d"
,
func_name
.
c_str
(),
fd
);
...
...
This diff is collapsed.
Click to expand it.
src/cc/common.h
View file @
de258bac
...
@@ -25,10 +25,16 @@ namespace ebpf {
...
@@ -25,10 +25,16 @@ namespace ebpf {
// debug flags
// debug flags
enum
{
enum
{
// Debug output compiled LLVM IR.
DEBUG_LLVM_IR
=
0x1
,
DEBUG_LLVM_IR
=
0x1
,
// Debug output loaded BPF bytecode and register state on branches.
DEBUG_BPF
=
0x2
,
DEBUG_BPF
=
0x2
,
// Debug output pre-processor result.
DEBUG_PREPROCESSOR
=
0x4
,
DEBUG_PREPROCESSOR
=
0x4
,
DEBUG_SOURCE
=
0x8
// Debug output ASM instructions embedded with source.
DEBUG_SOURCE
=
0x8
,
// Debug output register state on all instructions in addition to DEBUG_BPF.
DEBUG_BPF_REGISTER_STATE
=
0x16
,
};
};
template
<
class
T
,
class
...
Args
>
template
<
class
T
,
class
...
Args
>
...
...
This diff is collapsed.
Click to expand it.
src/python/bcc/__init__.py
View file @
de258bac
...
@@ -39,11 +39,18 @@ def _get_num_open_probes():
...
@@ -39,11 +39,18 @@ def _get_num_open_probes():
TRACEFS
=
"/sys/kernel/debug/tracing"
TRACEFS
=
"/sys/kernel/debug/tracing"
# Debug flags
# Debug output compiled LLVM IR.
DEBUG_LLVM_IR
=
0x1
DEBUG_LLVM_IR
=
0x1
# Debug output loaded BPF bytecode and register state on branches.
DEBUG_BPF
=
0x2
DEBUG_BPF
=
0x2
# Debug output pre-processor result.
DEBUG_PREPROCESSOR
=
0x4
DEBUG_PREPROCESSOR
=
0x4
# Debug output ASM instructions embedded with source.
DEBUG_SOURCE
=
0x8
DEBUG_SOURCE
=
0x8
LOG_BUFFER_SIZE
=
65536
#Debug output register state on all instructions in addition to DEBUG_BPF.
DEBUG_BPF_REGISTER_STATE
=
0x16
class
SymbolCache
(
object
):
class
SymbolCache
(
object
):
def
__init__
(
self
,
pid
):
def
__init__
(
self
,
pid
):
...
@@ -249,9 +256,7 @@ class BPF(object):
...
@@ -249,9 +256,7 @@ class BPF(object):
hdr_file (Optional[str]): Path to a helper header file for the `src_file`
hdr_file (Optional[str]): Path to a helper header file for the `src_file`
text (Optional[str]): Contents of a source file for the module
text (Optional[str]): Contents of a source file for the module
debug (Optional[int]): Flags used for debug prints, can be |'d together
debug (Optional[int]): Flags used for debug prints, can be |'d together
DEBUG_LLVM_IR: print LLVM IR to stderr
See "Debug flags" for explanation
DEBUG_BPF: print BPF bytecode to stderr
DEBUG_PREPROCESSOR: print Preprocessed C file to stderr
"""
"""
self
.
open_kprobes
=
{}
self
.
open_kprobes
=
{}
...
@@ -320,13 +325,18 @@ class BPF(object):
...
@@ -320,13 +325,18 @@ class BPF(object):
return
self
.
funcs
[
func_name
]
return
self
.
funcs
[
func_name
]
if
not
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)):
if
not
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)):
raise
Exception
(
"Unknown program %s"
%
func_name
)
raise
Exception
(
"Unknown program %s"
%
func_name
)
log_level
=
0
if
(
self
.
debug
&
DEBUG_BPF_REGISTER_STATE
):
log_level
=
2
elif
(
self
.
debug
&
DEBUG_BPF
):
log_level
=
1
fd
=
lib
.
bpf_prog_load
(
prog_type
,
fd
=
lib
.
bpf_prog_load
(
prog_type
,
func_name
.
encode
(
"ascii"
),
func_name
.
encode
(
"ascii"
),
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_function_start
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_function_size
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_function_size
(
self
.
module
,
func_name
.
encode
(
"ascii"
)),
lib
.
bpf_module_license
(
self
.
module
),
lib
.
bpf_module_license
(
self
.
module
),
lib
.
bpf_module_kern_version
(
self
.
module
),
lib
.
bpf_module_kern_version
(
self
.
module
),
1
if
(
self
.
debug
&
DEBUG_BPF
)
else
0
,
None
,
0
);
log_level
,
None
,
0
);
if
fd
<
0
:
if
fd
<
0
:
atexit
.
register
(
self
.
donothing
)
atexit
.
register
(
self
.
donothing
)
...
...
This diff is collapsed.
Click to expand it.
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