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
840712bc
Commit
840712bc
authored
Jan 17, 2019
by
williangaspar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests added
parent
e8b99cd2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
2 deletions
+55
-2
src/ast/ast.h
src/ast/ast.h
+1
-1
tests/codegen/builtin_kstack.cpp
tests/codegen/builtin_kstack.cpp
+46
-0
tests/parser.cpp
tests/parser.cpp
+2
-1
tests/runtime/builtin
tests/runtime/builtin
+6
-0
No files found.
src/ast/ast.h
View file @
840712bc
...
...
@@ -59,7 +59,7 @@ class Builtin : public Expression {
public:
explicit
Builtin
(
std
::
string
ident
)
:
ident
(
ident
)
{
if
(
ident
==
"stack"
)
{
std
::
cout
<<
"
\033
[33m
warning:
\033
[0m"
;
std
::
cout
<<
"
\033
[33mwarning:
\033
[0m"
;
std
::
cout
<<
"stack is deprecated and will be removed in the future. Use kstack instead"
<<
std
::
endl
;
this
->
ident
=
"kstack"
;
}
...
...
tests/codegen/builtin_kstack.cpp
0 → 100644
View file @
840712bc
#include "common.h"
namespace
bpftrace
{
namespace
test
{
namespace
codegen
{
TEST
(
codegen
,
builtin_stack
)
{
test
(
"kprobe:f { @x = kstack }"
,
R"EXPECTED(; Function Attrs: nounwind
declare i64 @llvm.bpf.pseudo(i64, i64) #0
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
define i64 @"kprobe:f"(i8*) local_unnamed_addr section "s_kprobe:f_1" {
entry:
%"@x_val" = alloca i64, align 8
%"@x_key" = alloca i64, align 8
%pseudo = tail call i64 @llvm.bpf.pseudo(i64 1, i64 2)
%get_stackid = tail call i64 inttoptr (i64 27 to i64 (i8*, i8*, i64)*)(i8* %0, i64 %pseudo, i64 0)
%1 = bitcast i64* %"@x_key" to i8*
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %1)
store i64 0, i64* %"@x_key", align 8
%2 = bitcast i64* %"@x_val" to i8*
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2)
store i64 %get_stackid, i64* %"@x_val", align 8
%pseudo1 = tail call i64 @llvm.bpf.pseudo(i64 1, i64 1)
%update_elem = call i64 inttoptr (i64 2 to i64 (i8*, i8*, i8*, i64)*)(i64 %pseudo1, i64* nonnull %"@x_key", i64* nonnull %"@x_val", i64 0)
call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %1)
call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %2)
ret i64 0
}
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
attributes #0 = { nounwind }
attributes #1 = { argmemonly nounwind }
)EXPECTED"
);
}
}
// namespace codegen
}
// namespace test
}
// namespace bpftrace
tests/parser.cpp
View file @
840712bc
...
...
@@ -35,7 +35,8 @@ TEST(Parser, builtin_variables)
test
(
"kprobe:f { rand }"
,
"Program
\n
kprobe:f
\n
builtin: rand
\n
"
);
test
(
"kprobe:f { ctx }"
,
"Program
\n
kprobe:f
\n
builtin: ctx
\n
"
);
test
(
"kprobe:f { comm }"
,
"Program
\n
kprobe:f
\n
builtin: comm
\n
"
);
test
(
"kprobe:f { stack }"
,
"Program
\n
kprobe:f
\n
builtin: stack
\n
"
);
test
(
"kprobe:f { stack }"
,
"Program
\n
kprobe:f
\n
builtin: kstack
\n
"
);
test
(
"kprobe:f { kstack }"
,
"Program
\n
kprobe:f
\n
builtin: kstack
\n
"
);
test
(
"kprobe:f { ustack }"
,
"Program
\n
kprobe:f
\n
builtin: ustack
\n
"
);
test
(
"kprobe:f { arg0 }"
,
"Program
\n
kprobe:f
\n
builtin: arg0
\n
"
);
test
(
"kprobe:f { retval }"
,
"Program
\n
kprobe:f
\n
builtin: retval
\n
"
);
...
...
tests/runtime/builtin
View file @
840712bc
...
...
@@ -41,6 +41,12 @@ EXPECT SUCCESS stack
TIMEOUT 5
BEFORE sleep 1 && sleep 1 &
NAME kstack
RUN bpftrace -e 'k:do_nanosleep { printf("SUCCESS '$test' %s\n", kstack); exit(); }'
EXPECT SUCCESS kstack
TIMEOUT 5
BEFORE sleep 1 && sleep 1 &
NAME ustack
RUN bpftrace -e 'k:do_nanosleep { printf("SUCCESS '$test' %s\n", ustack); exit(); }'
EXPECT SUCCESS ustack
...
...
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