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
f0f56b02
Commit
f0f56b02
authored
Feb 06, 2019
by
Augusto Caringi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-enable subset of build warnings and fix some related warnings #316
parent
3a9c9d0f
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
138 additions
and
138 deletions
+138
-138
CMakeLists.txt
CMakeLists.txt
+8
-8
src/ast/codegen_llvm.cpp
src/ast/codegen_llvm.cpp
+4
-4
src/ast/irbuilderbpf.cpp
src/ast/irbuilderbpf.cpp
+1
-1
src/ast/semantic_analyser.cpp
src/ast/semantic_analyser.cpp
+3
-3
src/ast/semantic_analyser.h
src/ast/semantic_analyser.h
+2
-2
src/bpftrace.cpp
src/bpftrace.cpp
+2
-2
src/bpftrace.h
src/bpftrace.h
+1
-1
src/mapkey.cpp
src/mapkey.cpp
+1
-1
src/utils-inl.h
src/utils-inl.h
+1
-1
tests/bpftrace.cpp
tests/bpftrace.cpp
+38
-38
tests/clang_parser.cpp
tests/clang_parser.cpp
+70
-70
tests/codegen/general.cpp
tests/codegen/general.cpp
+7
-7
No files found.
CMakeLists.txt
View file @
f0f56b02
...
...
@@ -7,19 +7,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
add_compile_options
(
"-std=c++14"
)
add_compile_options
(
"-Wno-format-security"
)
#add_compile_options("-Wall")
#
add_compile_options("-Wextra")
#
add_compile_options("-Wundef")
#
add_compile_options("-Wpointer-arith")
#
add_compile_options("-Wcast-align")
#
add_compile_options("-Wwrite-strings")
add_compile_options
(
"-Wextra"
)
add_compile_options
(
"-Wundef"
)
add_compile_options
(
"-Wpointer-arith"
)
add_compile_options
(
"-Wcast-align"
)
add_compile_options
(
"-Wwrite-strings"
)
#add_compile_options("-Wcast-qual")
#add_compile_options("-Wswitch-default")
#add_compile_options("-Wswitch-enum")
#add_compile_options("-Wconversion")
#
add_compile_options("-Wunreachable-code")
add_compile_options
(
"-Wunreachable-code"
)
#add_compile_options("-Wformat=2")
#
add_compile_options("-Wstrict-overflow=5")
#
add_compile_options("-Wdisabled-optimization")
add_compile_options
(
"-Wstrict-overflow=5"
)
add_compile_options
(
"-Wdisabled-optimization"
)
include
(
CTest
)
...
...
src/ast/codegen_llvm.cpp
View file @
f0f56b02
...
...
@@ -496,7 +496,7 @@ void CodegenLLVM::visit(Call &call)
int
struct_size
=
layout_
.
getTypeAllocSize
(
printf_struct
);
auto
*
struct_layout
=
layout_
.
getStructLayout
(
printf_struct
);
for
(
in
t
i
=
0
;
i
<
args
.
size
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
args
.
size
();
i
++
)
{
Field
&
arg
=
args
[
i
];
arg
.
offset
=
struct_layout
->
getElementOffset
(
i
+
1
);
// +1 for the printf_id field
...
...
@@ -506,7 +506,7 @@ void CodegenLLVM::visit(Call &call)
b_
.
CreateMemSet
(
printf_args
,
b_
.
getInt8
(
0
),
struct_size
,
1
);
b_
.
CreateStore
(
b_
.
getInt64
(
printf_id_
),
printf_args
);
for
(
in
t
i
=
1
;
i
<
call
.
vargs
->
size
();
i
++
)
for
(
size_
t
i
=
1
;
i
<
call
.
vargs
->
size
();
i
++
)
{
Expression
&
arg
=
*
call
.
vargs
->
at
(
i
);
expr_deleter_
=
nullptr
;
...
...
@@ -548,7 +548,7 @@ void CodegenLLVM::visit(Call &call)
int
struct_size
=
layout_
.
getTypeAllocSize
(
printf_struct
);
auto
*
struct_layout
=
layout_
.
getStructLayout
(
printf_struct
);
for
(
in
t
i
=
0
;
i
<
args
.
size
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
args
.
size
();
i
++
)
{
Field
&
arg
=
args
[
i
];
arg
.
offset
=
struct_layout
->
getElementOffset
(
i
+
1
);
// +1 for the system_id field
...
...
@@ -559,7 +559,7 @@ void CodegenLLVM::visit(Call &call)
// system_id_ has an offset to avoid be confused with printf
b_
.
CreateStore
(
b_
.
getInt64
(
system_id_
+
asyncactionint
(
AsyncAction
::
syscall
)),
system_args
);
for
(
in
t
i
=
1
;
i
<
call
.
vargs
->
size
();
i
++
)
for
(
size_
t
i
=
1
;
i
<
call
.
vargs
->
size
();
i
++
)
{
Expression
&
arg
=
*
call
.
vargs
->
at
(
i
);
expr_deleter_
=
nullptr
;
...
...
src/ast/irbuilderbpf.cpp
View file @
f0f56b02
...
...
@@ -366,7 +366,7 @@ Value *IRBuilderBPF::CreateStrcmp(Value* val, std::string str, bool inverse) {
CreateStore
(
getInt1
(
inverse
),
store
);
const
char
*
c_str
=
str
.
c_str
();
for
(
in
t
i
=
0
;
i
<
strlen
(
c_str
)
+
1
;
i
++
)
for
(
size_
t
i
=
0
;
i
<
strlen
(
c_str
)
+
1
;
i
++
)
{
BasicBlock
*
char_eq
=
BasicBlock
::
Create
(
module_
.
getContext
(),
"strcmp.loop"
,
parent
);
AllocaInst
*
val_char
=
CreateAllocaBPF
(
getInt8Ty
(),
"strcmp.char"
);
...
...
src/ast/semantic_analyser.cpp
View file @
f0f56b02
...
...
@@ -314,7 +314,7 @@ void SemanticAnalyser::visit(Call &call)
// Promote to 64-bit if it's not an array type
if
(
!
ty
.
IsArray
())
ty
.
size
=
8
;
args
.
push_back
({
.
type
=
ty
});
args
.
push_back
({
.
type
=
ty
,
.
offset
=
0
});
}
err_
<<
verify_format_string
(
fmt
.
str
,
args
);
...
...
@@ -988,7 +988,7 @@ bool SemanticAnalyser::check_assignment(const Call &call, bool want_map, bool wa
return
true
;
}
bool
SemanticAnalyser
::
check_nargs
(
const
Call
&
call
,
in
t
expected_nargs
)
bool
SemanticAnalyser
::
check_nargs
(
const
Call
&
call
,
size_
t
expected_nargs
)
{
std
::
vector
<
Expression
*>::
size_type
nargs
=
0
;
if
(
call
.
vargs
)
...
...
@@ -1003,7 +1003,7 @@ bool SemanticAnalyser::check_nargs(const Call &call, int expected_nargs)
return
true
;
}
bool
SemanticAnalyser
::
check_varargs
(
const
Call
&
call
,
int
min_nargs
,
in
t
max_nargs
)
bool
SemanticAnalyser
::
check_varargs
(
const
Call
&
call
,
size_t
min_nargs
,
size_
t
max_nargs
)
{
std
::
vector
<
Expression
*>::
size_type
nargs
=
0
;
if
(
call
.
vargs
)
...
...
src/ast/semantic_analyser.h
View file @
f0f56b02
...
...
@@ -55,8 +55,8 @@ private:
std
::
string
get_cast_type
(
Expression
*
expr
);
bool
check_assignment
(
const
Call
&
call
,
bool
want_map
,
bool
want_var
);
bool
check_nargs
(
const
Call
&
call
,
in
t
expected_nargs
);
bool
check_varargs
(
const
Call
&
call
,
int
min_nargs
,
in
t
max_nargs
);
bool
check_nargs
(
const
Call
&
call
,
size_
t
expected_nargs
);
bool
check_varargs
(
const
Call
&
call
,
size_t
min_nargs
,
size_
t
max_nargs
);
bool
check_arg
(
const
Call
&
call
,
Type
type
,
int
arg_num
,
bool
want_literal
=
false
);
bool
check_alpha_numeric
(
const
Call
&
call
,
int
arg_num
);
...
...
src/bpftrace.cpp
View file @
f0f56b02
...
...
@@ -466,7 +466,7 @@ void BPFtrace::add_param(const std::string ¶m)
params_
.
emplace_back
(
param
);
}
std
::
string
BPFtrace
::
get_param
(
in
t
i
)
std
::
string
BPFtrace
::
get_param
(
size_
t
i
)
{
if
(
i
>
0
&&
i
<
params_
.
size
()
+
1
)
return
params_
[
i
-
1
];
...
...
@@ -868,7 +868,7 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div)
if
(
div
==
0
)
div
=
1
;
uint32_t
i
=
0
;
in
t
total
=
values_by_key
.
size
();
size_
t
total
=
values_by_key
.
size
();
for
(
auto
&
pair
:
values_by_key
)
{
auto
key
=
pair
.
first
;
...
...
src/bpftrace.h
View file @
f0f56b02
...
...
@@ -70,7 +70,7 @@ public:
std
::
vector
<
std
::
unique_ptr
<
IPrintable
>>
get_arg_values
(
const
std
::
vector
<
Field
>
&
args
,
uint8_t
*
arg_data
);
void
add_param
(
const
std
::
string
&
param
);
bool
is_numeric
(
std
::
string
str
);
std
::
string
get_param
(
in
t
index
);
std
::
string
get_param
(
size_
t
index
);
std
::
string
cmd_
;
int
pid_
{
0
};
...
...
src/mapkey.cpp
View file @
f0f56b02
...
...
@@ -69,8 +69,8 @@ std::string MapKey::argument_value(BPFtrace &bpftrace,
return
std
::
to_string
(
*
(
int32_t
*
)
data
);
case
8
:
return
std
::
to_string
(
*
(
int64_t
*
)
data
);
break
;
}
break
;
case
Type
:
:
kstack
:
return
bpftrace
.
get_stack
(
*
(
uint64_t
*
)
data
,
false
);
case
Type
:
:
ustack
:
...
...
src/utils-inl.h
View file @
f0f56b02
namespace
bpftrace
{
inline
std
::
string
GetProviderFromPath
(
std
::
string
path
)
{
in
t
i
=
path
.
rfind
(
"/"
);
size_
t
i
=
path
.
rfind
(
"/"
);
return
(
i
!=
std
::
string
::
npos
)
?
path
.
substr
(
i
+
1
)
:
path
;
}
...
...
tests/bpftrace.cpp
View file @
f0f56b02
...
...
@@ -107,8 +107,8 @@ TEST(bpftrace, add_begin_probe)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
0
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
1
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_special_probes
().
size
());
check_special_probe
(
bpftrace
.
get_special_probes
().
at
(
0
),
"BEGIN_trigger"
,
"BEGIN"
);
}
...
...
@@ -121,8 +121,8 @@ TEST(bpftrace, add_end_probe)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
0
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
1
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_special_probes
().
size
());
check_special_probe
(
bpftrace
.
get_special_probes
().
at
(
0
),
"END_trigger"
,
"END"
);
}
...
...
@@ -135,8 +135,8 @@ TEST(bpftrace, add_probes_single)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
check_kprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"sys_read"
,
"kprobe:sys_read"
);
}
...
...
@@ -150,8 +150,8 @@ TEST(bpftrace, add_probes_multiple)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
2
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
2
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"kprobe:sys_read,kprobe:sys_write"
;
check_kprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"sys_read"
,
probe_orig_name
);
...
...
@@ -175,8 +175,8 @@ TEST(bpftrace, add_probes_character_class)
.
Times
(
1
);
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
3
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
3
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"kprobe:[Ss]y[Ss]_read,kprobe:sys_write"
;
check_kprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"SyS_read"
,
probe_orig_name
);
...
...
@@ -202,8 +202,8 @@ TEST(bpftrace, add_probes_wildcard)
.
Times
(
1
);
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
4
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
4
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"kprobe:sys_read,kprobe:my_*,kprobe:sys_write"
;
check_kprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"sys_read"
,
probe_orig_name
);
...
...
@@ -230,8 +230,8 @@ TEST(bpftrace, add_probes_wildcard_no_matches)
.
Times
(
1
);
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
2
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
2
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"kprobe:sys_read,kprobe:my_*,kprobe:sys_write"
;
check_kprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"sys_read"
,
probe_orig_name
);
...
...
@@ -247,8 +247,8 @@ TEST(bpftrace, add_probes_uprobe)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
check_uprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"/bin/sh"
,
"foo"
,
"uprobe:/bin/sh:foo"
);
}
...
...
@@ -261,8 +261,8 @@ TEST(bpftrace, add_probes_usdt)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
check_usdt
(
bpftrace
.
get_probes
().
at
(
0
),
"/bin/sh"
,
"foo"
,
"usdt:/bin/sh:foo"
);
}
...
...
@@ -275,8 +275,8 @@ TEST(bpftrace, add_probes_uprobe_wildcard)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
bpftrace
.
add_probe
(
probe
),
0
);
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
}
TEST
(
bpftrace
,
add_probes_uprobe_wildcard_no_matches
)
...
...
@@ -288,8 +288,8 @@ TEST(bpftrace, add_probes_uprobe_wildcard_no_matches)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
bpftrace
.
add_probe
(
probe
),
0
);
EXPECT_EQ
(
0
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
}
TEST
(
bpftrace
,
add_probes_uprobe_string_literal
)
...
...
@@ -301,8 +301,8 @@ TEST(bpftrace, add_probes_uprobe_string_literal)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
check_uprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"/bin/sh"
,
"foo*"
,
"uprobe:/bin/sh:foo*"
);
}
...
...
@@ -315,8 +315,8 @@ TEST(bpftrace, add_probes_tracepoint)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"tracepoint:sched:sched_switch"
;
check_tracepoint
(
bpftrace
.
get_probes
().
at
(
0
),
"sched"
,
"sched_switch"
,
probe_orig_name
);
...
...
@@ -338,8 +338,8 @@ TEST(bpftrace, add_probes_tracepoint_wildcard)
.
Times
(
1
);
EXPECT_EQ
(
bpftrace
.
add_probe
(
probe
),
0
);
EXPECT_EQ
(
2
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
2
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"tracepoint:sched:sched_*"
;
check_tracepoint
(
bpftrace
.
get_probes
().
at
(
0
),
"sched"
,
"sched_one"
,
probe_orig_name
);
...
...
@@ -362,8 +362,8 @@ TEST(bpftrace, add_probes_tracepoint_wildcard_no_matches)
.
Times
(
1
);
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
0
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
}
TEST
(
bpftrace
,
add_probes_profile
)
...
...
@@ -375,8 +375,8 @@ TEST(bpftrace, add_probes_profile)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"profile:ms:997"
;
check_profile
(
bpftrace
.
get_probes
().
at
(
0
),
"ms"
,
997
,
probe_orig_name
);
...
...
@@ -391,8 +391,8 @@ TEST(bpftrace, add_probes_interval)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"interval:s:1"
;
check_interval
(
bpftrace
.
get_probes
().
at
(
0
),
"s"
,
1
,
probe_orig_name
);
...
...
@@ -407,8 +407,8 @@ TEST(bpftrace, add_probes_software)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"software:faults:1000"
;
check_software
(
bpftrace
.
get_probes
().
at
(
0
),
"faults"
,
1000
,
probe_orig_name
);
...
...
@@ -423,8 +423,8 @@ TEST(bpftrace, add_probes_hardware)
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
EXPECT_EQ
(
1
U
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
U
,
bpftrace
.
get_special_probes
().
size
());
std
::
string
probe_orig_name
=
"hardware:cache-references:1000000"
;
check_hardware
(
bpftrace
.
get_probes
().
at
(
0
),
"cache-references"
,
1000000
,
probe_orig_name
);
...
...
tests/clang_parser.cpp
View file @
f0f56b02
This diff is collapsed.
Click to expand it.
tests/codegen/general.cpp
View file @
f0f56b02
...
...
@@ -32,9 +32,9 @@ TEST(codegen, populate_sections)
auto
bpforc
=
codegen
.
compile
();
// Check sections are populated
EXPECT_EQ
(
bpforc
->
sections_
.
size
(),
2
);
EXPECT_EQ
(
bpforc
->
sections_
.
count
(
"s_kprobe:foo_1"
),
1
);
EXPECT_EQ
(
bpforc
->
sections_
.
count
(
"s_kprobe:bar_1"
),
1
);
EXPECT_EQ
(
bpforc
->
sections_
.
size
(),
2
U
);
EXPECT_EQ
(
bpforc
->
sections_
.
count
(
"s_kprobe:foo_1"
),
1
U
);
EXPECT_EQ
(
bpforc
->
sections_
.
count
(
"s_kprobe:bar_1"
),
1
U
);
}
TEST
(
codegen
,
printf_offsets
)
...
...
@@ -53,22 +53,22 @@ TEST(codegen, printf_offsets)
ast
::
CodegenLLVM
codegen
(
driver
.
root_
,
bpftrace
);
auto
bpforc
=
codegen
.
compile
();
EXPECT_EQ
(
bpftrace
.
printf_args_
.
size
(),
1
);
EXPECT_EQ
(
bpftrace
.
printf_args_
.
size
(),
1
U
);
auto
&
fmt
=
std
::
get
<
0
>
(
bpftrace
.
printf_args_
[
0
]);
auto
&
args
=
std
::
get
<
1
>
(
bpftrace
.
printf_args_
[
0
]);
EXPECT_EQ
(
fmt
,
"%c %u
\n
"
);
EXPECT_EQ
(
args
.
size
(),
2
);
EXPECT_EQ
(
args
.
size
(),
2
U
);
// NOTE (mmarchini) type.size is the original arg size, and it might be
// different from the actual size we use to store in memory
EXPECT_EQ
(
args
[
0
].
type
.
type
,
Type
::
integer
);
EXPECT_EQ
(
args
[
0
].
type
.
size
,
8
);
EXPECT_EQ
(
args
[
0
].
type
.
size
,
8
U
);
EXPECT_EQ
(
args
[
0
].
offset
,
8
);
EXPECT_EQ
(
args
[
1
].
type
.
type
,
Type
::
integer
);
EXPECT_EQ
(
args
[
1
].
type
.
size
,
8
);
EXPECT_EQ
(
args
[
1
].
type
.
size
,
8
U
);
EXPECT_EQ
(
args
[
1
].
offset
,
16
);
}
...
...
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