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
81990c32
Commit
81990c32
authored
Mar 30, 2016
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpf.lua: Implement `dump_func`
parent
72d7aa3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
src/lua/bcc/bpf.lua
src/lua/bcc/bpf.lua
+10
-1
tests/lua/test_dump.lua
tests/lua/test_dump.lua
+9
-0
No files found.
src/lua/bcc/bpf.lua
View file @
81990c32
...
...
@@ -157,7 +157,8 @@ function Bpf:load_func(fn_name, prog_type)
return
self
.
funcs
[
fn_name
]
end
assert
(
libbcc
.
bpf_function_start
(
self
.
module
,
fn_name
),
"unknown program: "
..
fn_name
)
assert
(
libbcc
.
bpf_function_start
(
self
.
module
,
fn_name
)
~=
nil
,
"unknown program: "
..
fn_name
)
local
fd
=
libbcc
.
bpf_prog_load
(
prog_type
,
libbcc
.
bpf_function_start
(
self
.
module
,
fn_name
),
...
...
@@ -173,6 +174,14 @@ function Bpf:load_func(fn_name, prog_type)
return
fn
end
function
Bpf
:
dump_func
(
fn_name
)
local
start
=
libbcc
.
bpf_function_start
(
self
.
module
,
fn_name
)
assert
(
start
~=
nil
,
"unknown program"
)
local
len
=
libbcc
.
bpf_function_size
(
self
.
module
,
fn_name
)
return
ffi
.
string
(
start
,
tonumber
(
len
))
end
function
Bpf
:
attach_uprobe
(
args
)
Bpf
.
check_probe_quota
(
1
)
...
...
tests/lua/test_dump.lua
0 → 100644
View file @
81990c32
require
(
"test_helper"
)
function
test_dump_func
()
local
raw
=
"\xb7\x00\x00\x00\x01\x00\x00\x00\x95\x00\x00\x00\x00\x00\x00\x00"
local
b
=
BPF
:
new
{
text
=
[[int entry(void) { return 1; }]]
}
assert_equals
(
b
:
dump_func
(
"entry"
),
raw
)
end
os.exit
(
LuaUnit
.
run
())
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