Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
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
bpftrace
Commits
298f2928
Commit
298f2928
authored
May 09, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Codegen: Fix calls to bpf_map_update_elem
parent
130b26ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
6 deletions
+24
-6
src/attached_probe.cpp
src/attached_probe.cpp
+1
-1
src/bpftrace.cpp
src/bpftrace.cpp
+16
-0
src/bpftrace.h
src/bpftrace.h
+1
-0
src/codegen_llvm.cpp
src/codegen_llvm.cpp
+3
-4
src/main.cpp
src/main.cpp
+3
-1
No files found.
src/attached_probe.cpp
View file @
298f2928
...
...
@@ -26,8 +26,8 @@ AttachedProbe::AttachedProbe(Probe &probe, std::tuple<uint8_t *, uintptr_t> &fun
AttachedProbe
::~
AttachedProbe
()
{
perf_reader_free
(
perf_reader_
);
close
(
progfd_
);
perf_reader_free
(
perf_reader_
);
int
err
=
0
;
switch
(
probe_
.
type
)
{
...
...
src/bpftrace.cpp
View file @
298f2928
...
...
@@ -81,5 +81,21 @@ int BPFtrace::run()
return
0
;
}
int
BPFtrace
::
print_maps
()
{
for
(
auto
&
mapmap
:
maps_
)
{
Map
&
map
=
*
mapmap
.
second
.
get
();
uint64_t
key
=
0
;
uint64_t
next_key
=
99
;
uint64_t
value
;
int
ret
;
ret
=
bpf_get_next_key
(
map
.
mapfd_
,
&
key
,
&
next_key
);
std
::
cout
<<
ret
<<
map
.
name_
<<
":"
<<
key
<<
":"
<<
next_key
<<
std
::
endl
;
ret
=
bpf_lookup_elem
(
map
.
mapfd_
,
&
key
,
&
value
);
std
::
cout
<<
ret
<<
map
.
name_
<<
":"
<<
key
<<
":"
<<
value
<<
std
::
endl
;
}
}
}
// namespace bpftrace
}
// namespace ebpf
src/bpftrace.h
View file @
298f2928
...
...
@@ -43,6 +43,7 @@ public:
virtual
~
BPFtrace
()
{
}
virtual
int
add_probe
(
ast
::
Probe
&
p
);
int
run
();
int
print_maps
();
std
::
map
<
std
::
string
,
Type
>
map_val_
;
std
::
map
<
std
::
string
,
std
::
vector
<
Type
>>
map_args_
;
...
...
src/codegen_llvm.cpp
View file @
298f2928
...
...
@@ -113,14 +113,13 @@ void CodegenLLVM::visit(AssignMapStatement &assignment)
Function
*
pseudo_func
=
module_
->
getFunction
(
"llvm.bpf.pseudo"
);
Value
*
map_ptr
=
b_
.
CreateCall
(
pseudo_func
,
{
b_
.
getInt64
(
BPF_PSEUDO_MAP_FD
),
b_
.
getInt64
(
mapfd
)});
AllocaInst
*
key
=
createAllocaBPF
(
b_
.
getInt
8Ptr
Ty
());
AllocaInst
*
val
=
createAllocaBPF
(
b_
.
getInt
8Ptr
Ty
());
AllocaInst
*
flags
=
createAllocaBPF
(
b_
.
getInt8PtrTy
()
);
AllocaInst
*
key
=
createAllocaBPF
(
b_
.
getInt
64
Ty
());
AllocaInst
*
val
=
createAllocaBPF
(
b_
.
getInt
64
Ty
());
Value
*
flags
=
b_
.
getInt64
(
0
);
b_
.
CreateStore
(
b_
.
getInt64
(
0
),
key
);
// TODO variable key
assignment
.
expr
->
accept
(
*
this
);
b_
.
CreateStore
(
expr_
,
val
);
b_
.
CreateStore
(
b_
.
getInt64
(
0
),
flags
);
// TODO set flags
// int map_update_elem(&map, &key, &value, flags)
FunctionType
*
update_func_type
=
FunctionType
::
get
(
...
...
src/main.cpp
View file @
298f2928
...
...
@@ -89,7 +89,9 @@ int main(int argc, char *argv[])
if
(
err
)
return
err
;
// TODO print results
err
=
bpftrace
.
print_maps
();
if
(
err
)
return
err
;
return
0
;
}
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