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
d5853448
Commit
d5853448
authored
Sep 13, 2018
by
Brendan Gregg
Committed by
GitHub
Sep 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #93 from iovisor/bug
fix printf with name on multiple events
parents
759c786f
6fead65d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
src/ast/codegen_llvm.cpp
src/ast/codegen_llvm.cpp
+12
-4
src/ast/codegen_llvm.h
src/ast/codegen_llvm.h
+1
-0
No files found.
src/ast/codegen_llvm.cpp
View file @
d5853448
...
...
@@ -520,10 +520,9 @@ void CodegenLLVM::visit(Call &call)
ArrayType
*
perfdata_type
=
ArrayType
::
get
(
b_
.
getInt8Ty
(),
sizeof
(
uint64_t
)
*
2
);
AllocaInst
*
perfdata
=
b_
.
CreateAllocaBPF
(
perfdata_type
,
"perfdata"
);
b_
.
CreateStore
(
b_
.
getInt64
(
asyncactionint
(
AsyncAction
::
time
)),
perfdata
);
static
int
time_id
=
0
;
b_
.
CreateStore
(
b_
.
getInt64
(
time_id
),
b_
.
CreateGEP
(
perfdata
,
{
b_
.
getInt64
(
0
),
b_
.
getInt64
(
sizeof
(
uint64_t
))}));
b_
.
CreateStore
(
b_
.
getInt64
(
time_id_
),
b_
.
CreateGEP
(
perfdata
,
{
b_
.
getInt64
(
0
),
b_
.
getInt64
(
sizeof
(
uint64_t
))}));
time_id
++
;
time_id
_
++
;
b_
.
CreatePerfEventOutput
(
ctx_
,
perfdata
,
sizeof
(
uint64_t
)
*
2
);
b_
.
CreateLifetimeEnd
(
perfdata
);
expr_
=
nullptr
;
...
...
@@ -899,7 +898,14 @@ void CodegenLLVM::visit(Probe &probe)
b_
.
CreateRet
(
ConstantInt
::
get
(
module_
->
getContext
(),
APInt
(
64
,
0
)));
}
else
{
// build a separate BPF programs for each wildcard match
/*
* Build a separate BPF program for each wildcard match.
* We begin by saving state that gets changed by the codegen pass, so we
* can restore it for the next pass (printf_id_, time_id_).
*/
int
starting_printf_id_
=
printf_id_
;
int
starting_time_id_
=
time_id_
;
for
(
auto
&
attach_point
:
*
probe
.
attach_points
)
{
std
::
string
file_name
;
switch
(
probetype
(
attach_point
->
provider
))
...
...
@@ -918,6 +924,8 @@ void CodegenLLVM::visit(Probe &probe)
}
auto
matches
=
bpftrace_
.
find_wildcard_matches
(
attach_point
->
target
,
attach_point
->
func
,
file_name
);
for
(
auto
&
match
:
matches
)
{
printf_id_
=
starting_printf_id_
;
time_id_
=
starting_time_id_
;
probefull_
=
attach_point
->
name
(
match
);
Function
*
func
=
Function
::
Create
(
func_type
,
Function
::
ExternalLinkage
,
attach_point
->
name
(
match
),
module_
.
get
());
func
->
setSection
(
"s_"
+
attach_point
->
name
(
match
));
...
...
src/ast/codegen_llvm.h
View file @
d5853448
...
...
@@ -70,6 +70,7 @@ private:
std
::
map
<
std
::
string
,
Value
*>
variables_
;
int
printf_id_
=
0
;
int
time_id_
=
0
;
};
}
// namespace ast
...
...
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