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
17117141
Commit
17117141
authored
Jun 24, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add retval builtin
parent
fb4c1733
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
README.md
README.md
+1
-0
src/codegen_llvm.cpp
src/codegen_llvm.cpp
+8
-0
src/semantic_analyser.cpp
src/semantic_analyser.cpp
+2
-1
No files found.
README.md
View file @
17117141
...
...
@@ -61,6 +61,7 @@ Variables:
-
`nsecs`
- Nanosecond timestamp
-
`stack`
- Kernel stack trace
-
`arg0`
,
`arg1`
, ... etc. - Arguments to the function being traced
-
`retval`
- Return value from function being traced
Functions:
-
`quantize(int n)`
- produce a log2 histogram of values of
`n`
...
...
src/codegen_llvm.cpp
View file @
17117141
...
...
@@ -62,6 +62,14 @@ void CodegenLLVM::visit(Builtin &builtin)
b_
.
CreateProbeRead
(
dst
,
b_
.
getInt64
(
8
),
src
);
expr_
=
b_
.
CreateLoad
(
dst
);
}
else
if
(
builtin
.
ident
==
"retval"
)
{
AllocaInst
*
dst
=
b_
.
CreateAllocaBPF
();
int
offset
=
arch
::
ret_offset
()
*
sizeof
(
uintptr_t
);
Value
*
src
=
b_
.
CreateGEP
(
ctx_
,
b_
.
getInt64
(
offset
));
b_
.
CreateProbeRead
(
dst
,
b_
.
getInt64
(
8
),
src
);
expr_
=
b_
.
CreateLoad
(
dst
);
}
else
{
abort
();
...
...
src/semantic_analyser.cpp
View file @
17117141
...
...
@@ -19,7 +19,8 @@ void SemanticAnalyser::visit(Builtin &builtin)
builtin
.
ident
==
"pid"
||
builtin
.
ident
==
"tid"
||
builtin
.
ident
==
"uid"
||
builtin
.
ident
==
"gid"
)
{
builtin
.
ident
==
"gid"
||
builtin
.
ident
==
"retval"
)
{
type_
=
Type
::
integer
;
}
else
if
(
builtin
.
ident
==
"stack"
)
...
...
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