Commit f0f56b02 authored by Augusto Caringi's avatar Augusto Caringi

Re-enable subset of build warnings and fix some related warnings #316

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