Commit f9fc748f authored by Alastair Robertson's avatar Alastair Robertson

Rename namespace ::ebpf::bpftrace -> ::bpftrace

parent 978af8b6
#include "ast.h"
#include "parser.tab.hh"
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -56,22 +55,22 @@ void Program::accept(Visitor &v) {
std::string opstr(Binop &binop)
{
switch (binop.op) {
case ebpf::bpftrace::Parser::token::EQ: return "==";
case ebpf::bpftrace::Parser::token::NE: return "!=";
case ebpf::bpftrace::Parser::token::LE: return "<=";
case ebpf::bpftrace::Parser::token::GE: return ">=";
case ebpf::bpftrace::Parser::token::LT: return "<";
case ebpf::bpftrace::Parser::token::GT: return ">";
case ebpf::bpftrace::Parser::token::LAND: return "&&";
case ebpf::bpftrace::Parser::token::LOR: return "||";
case ebpf::bpftrace::Parser::token::PLUS: return "+";
case ebpf::bpftrace::Parser::token::MINUS: return "-";
case ebpf::bpftrace::Parser::token::MUL: return "*";
case ebpf::bpftrace::Parser::token::DIV: return "/";
case ebpf::bpftrace::Parser::token::MOD: return "%";
case ebpf::bpftrace::Parser::token::BAND: return "&";
case ebpf::bpftrace::Parser::token::BOR: return "|";
case ebpf::bpftrace::Parser::token::BXOR: return "^";
case bpftrace::Parser::token::EQ: return "==";
case bpftrace::Parser::token::NE: return "!=";
case bpftrace::Parser::token::LE: return "<=";
case bpftrace::Parser::token::GE: return ">=";
case bpftrace::Parser::token::LT: return "<";
case bpftrace::Parser::token::GT: return ">";
case bpftrace::Parser::token::LAND: return "&&";
case bpftrace::Parser::token::LOR: return "||";
case bpftrace::Parser::token::PLUS: return "+";
case bpftrace::Parser::token::MINUS: return "-";
case bpftrace::Parser::token::MUL: return "*";
case bpftrace::Parser::token::DIV: return "/";
case bpftrace::Parser::token::MOD: return "%";
case bpftrace::Parser::token::BAND: return "&";
case bpftrace::Parser::token::BOR: return "|";
case bpftrace::Parser::token::BXOR: return "^";
default: abort();
}
}
......@@ -79,12 +78,11 @@ std::string opstr(Binop &binop)
std::string opstr(Unop &unop)
{
switch (unop.op) {
case ebpf::bpftrace::Parser::token::LNOT: return "!";
case ebpf::bpftrace::Parser::token::BNOT: return "~";
case bpftrace::Parser::token::LNOT: return "!";
case bpftrace::Parser::token::BNOT: return "~";
default: abort();
}
}
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -3,7 +3,6 @@
#include <string>
#include <vector>
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -158,4 +157,3 @@ std::string opstr(Unop &unop);
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -6,7 +6,6 @@
#include "libbpf.h"
#include "perf_reader.h"
namespace ebpf {
namespace bpftrace {
AttachedProbe::AttachedProbe(Probe &probe, std::tuple<uint8_t *, uintptr_t> &func)
......@@ -102,4 +101,3 @@ void AttachedProbe::attach_kprobe()
}
} // namespace bpftrace
} // namespace ebpf
......@@ -2,7 +2,6 @@
#include "bpftrace.h"
namespace ebpf {
namespace bpftrace {
class AttachedProbe
......@@ -25,4 +24,3 @@ private:
};
} // namespace bpftrace
} // namespace ebpf
......@@ -5,7 +5,6 @@
#include "bpftrace.h"
#include "attached_probe.h"
namespace ebpf {
namespace bpftrace {
int BPFtrace::add_probe(ast::Probe &p)
......@@ -233,4 +232,3 @@ int BPFtrace::print_quantize(std::vector<uint64_t> values)
}
} // namespace bpftrace
} // namespace ebpf
......@@ -8,7 +8,6 @@
#include "map.h"
#include "types.h"
namespace ebpf {
namespace bpftrace {
class BPFtrace
......@@ -30,4 +29,3 @@ private:
};
} // namespace bpftrace
} // namespace ebpf
......@@ -8,7 +8,6 @@
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -73,22 +72,22 @@ void CodegenLLVM::visit(Binop &binop)
rhs = expr_;
switch (binop.op) {
case ebpf::bpftrace::Parser::token::EQ: expr_ = b_.CreateICmpEQ (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::NE: expr_ = b_.CreateICmpNE (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::LE: expr_ = b_.CreateICmpSLE(lhs, rhs); break;
case ebpf::bpftrace::Parser::token::GE: expr_ = b_.CreateICmpSGE(lhs, rhs); break;
case ebpf::bpftrace::Parser::token::LT: expr_ = b_.CreateICmpSLT(lhs, rhs); break;
case ebpf::bpftrace::Parser::token::GT: expr_ = b_.CreateICmpSGT(lhs, rhs); break;
case ebpf::bpftrace::Parser::token::LAND: abort();// TODO
case ebpf::bpftrace::Parser::token::LOR: abort();// TODO
case ebpf::bpftrace::Parser::token::PLUS: expr_ = b_.CreateAdd (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::MINUS: expr_ = b_.CreateSub (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::MUL: expr_ = b_.CreateMul (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::DIV: expr_ = b_.CreateSDiv (lhs, rhs); break; // TODO signed/unsigned
case ebpf::bpftrace::Parser::token::MOD: expr_ = b_.CreateURem (lhs, rhs); break; // TODO signed/unsigned
case ebpf::bpftrace::Parser::token::BAND: expr_ = b_.CreateAnd (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::BOR: expr_ = b_.CreateOr (lhs, rhs); break;
case ebpf::bpftrace::Parser::token::BXOR: expr_ = b_.CreateXor (lhs, rhs); break;
case bpftrace::Parser::token::EQ: expr_ = b_.CreateICmpEQ (lhs, rhs); break;
case bpftrace::Parser::token::NE: expr_ = b_.CreateICmpNE (lhs, rhs); break;
case bpftrace::Parser::token::LE: expr_ = b_.CreateICmpSLE(lhs, rhs); break;
case bpftrace::Parser::token::GE: expr_ = b_.CreateICmpSGE(lhs, rhs); break;
case bpftrace::Parser::token::LT: expr_ = b_.CreateICmpSLT(lhs, rhs); break;
case bpftrace::Parser::token::GT: expr_ = b_.CreateICmpSGT(lhs, rhs); break;
case bpftrace::Parser::token::LAND: abort();// TODO
case bpftrace::Parser::token::LOR: abort();// TODO
case bpftrace::Parser::token::PLUS: expr_ = b_.CreateAdd (lhs, rhs); break;
case bpftrace::Parser::token::MINUS: expr_ = b_.CreateSub (lhs, rhs); break;
case bpftrace::Parser::token::MUL: expr_ = b_.CreateMul (lhs, rhs); break;
case bpftrace::Parser::token::DIV: expr_ = b_.CreateSDiv (lhs, rhs); break; // TODO signed/unsigned
case bpftrace::Parser::token::MOD: expr_ = b_.CreateURem (lhs, rhs); break; // TODO signed/unsigned
case bpftrace::Parser::token::BAND: expr_ = b_.CreateAnd (lhs, rhs); break;
case bpftrace::Parser::token::BOR: expr_ = b_.CreateOr (lhs, rhs); break;
case bpftrace::Parser::token::BXOR: expr_ = b_.CreateXor (lhs, rhs); break;
default: abort();
}
}
......@@ -98,8 +97,8 @@ void CodegenLLVM::visit(Unop &unop)
unop.expr->accept(*this);
switch (unop.op) {
case ebpf::bpftrace::Parser::token::LNOT: expr_ = b_.CreateNot(expr_); break;
case ebpf::bpftrace::Parser::token::BNOT: expr_ = b_.CreateNeg(expr_); break;
case bpftrace::Parser::token::LNOT: expr_ = b_.CreateNot(expr_); break;
case bpftrace::Parser::token::BNOT: expr_ = b_.CreateNeg(expr_); break;
default: abort();
}
}
......@@ -354,4 +353,3 @@ int CodegenLLVM::compile(bool debug)
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -9,7 +9,6 @@
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Module.h>
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -54,4 +53,3 @@ private:
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -5,7 +5,6 @@
extern FILE *yyin;
extern void *yy_scan_string(const char *yystr);
namespace ebpf {
namespace bpftrace {
int Driver::parse_stdin()
......@@ -33,4 +32,3 @@ int Driver::parse_file(const std::string &f)
}
} // namespace bpftrace
} // namespace ebpf
......@@ -3,10 +3,9 @@
#include "ast.h"
#include "parser.tab.hh"
#define YY_DECL ebpf::bpftrace::Parser::symbol_type yylex(ebpf::bpftrace::Driver &driver)
#define YY_DECL bpftrace::Parser::symbol_type yylex(bpftrace::Driver &driver)
YY_DECL;
namespace ebpf {
namespace bpftrace {
class Driver {
......@@ -34,4 +33,3 @@ private:
};
} // namespace bpftrace
} // namespace ebpf
......@@ -3,7 +3,6 @@
#include <llvm/IR/Module.h>
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -146,4 +145,3 @@ CallInst *IRBuilderBPF::CreateGetUidGid()
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -5,7 +5,6 @@
#include <llvm/IR/IRBuilder.h>
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -33,4 +32,3 @@ private:
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -7,12 +7,12 @@
#undef yywrap
#define yywrap() 1
static ebpf::bpftrace::location loc;
static bpftrace::location loc;
#define YY_USER_ACTION loc.columns(yyleng);
#define yyterminate() return ebpf::bpftrace::Parser::make_END(loc)
#define yyterminate() return bpftrace::Parser::make_END(loc)
using namespace ebpf::bpftrace;
using namespace bpftrace;
%}
ident [_a-zA-Z][_a-zA-Z0-9]*
......
......@@ -6,7 +6,7 @@
#include "printer.h"
#include "semantic_analyser.h"
using namespace ebpf::bpftrace;
using namespace bpftrace;
void usage()
{
......@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
if (debug)
{
ast::Printer p = ebpf::bpftrace::ast::Printer(std::cout);
ast::Printer p = bpftrace::ast::Printer(std::cout);
driver.root_->accept(p);
}
......
......@@ -4,7 +4,6 @@
#include "map.h"
#include "libbpf.h"
namespace ebpf {
namespace bpftrace {
Map::Map(std::string &name, Type type, std::vector<Type> &args)
......@@ -50,4 +49,3 @@ Map::~Map()
}
} // namespace bpftrace
} // namespace ebpf
......@@ -6,7 +6,6 @@
#include "types.h"
namespace ebpf {
namespace bpftrace {
class Map {
......@@ -23,4 +22,3 @@ public:
};
} // namespace bpftrace
} // namespace ebpf
%skeleton "lalr1.cc"
%require "3.0.4"
%defines
%define api.namespace { ebpf::bpftrace }
%define api.namespace { bpftrace }
%define parser_class_name { Parser }
%define api.token.constructor
......@@ -10,20 +10,18 @@
%define parse.error verbose
%param { ebpf::bpftrace::Driver &driver }
%param { bpftrace::Driver &driver }
%locations
// Forward declarations of classes referenced in the parser
%code requires
{
namespace ebpf {
namespace bpftrace {
class Driver;
namespace ast {
class Node;
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
#include "ast.h"
}
......@@ -32,7 +30,7 @@ class Node;
#include "driver.h"
void yyerror(ebpf::bpftrace::Driver &driver, const char *s);
void yyerror(bpftrace::Driver &driver, const char *s);
%}
%token
......@@ -159,7 +157,7 @@ vargs : vargs "," expr { $$ = $1; $1->push_back($3); }
%%
void ebpf::bpftrace::Parser::error(const location &l, const std::string &m)
void bpftrace::Parser::error(const location &l, const std::string &m)
{
driver.error(l, m);
}
#include "printer.h"
#include "ast.h"
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -134,4 +133,3 @@ void Printer::visit(Program &program)
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -3,7 +3,6 @@
#include <ostream>
#include "ast.h"
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -32,4 +31,3 @@ private:
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -4,7 +4,6 @@
#include "ast.h"
#include "parser.tab.hh"
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -236,7 +235,7 @@ int SemanticAnalyser::create_maps()
abort();
auto &args = search_args->second;
bpftrace_.maps_[map_name] = std::make_unique<ebpf::bpftrace::Map>(map_name, type, args);
bpftrace_.maps_[map_name] = std::make_unique<bpftrace::Map>(map_name, type, args);
}
return 0;
......@@ -249,4 +248,3 @@ bool SemanticAnalyser::is_final_pass() const
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -7,7 +7,6 @@
#include "map.h"
#include "types.h"
namespace ebpf {
namespace bpftrace {
namespace ast {
......@@ -42,7 +41,7 @@ private:
int pass_;
const int num_passes_ = 10;
using Type = ebpf::bpftrace::Type;
using Type = bpftrace::Type;
Type type_;
bool is_final_pass() const;
......@@ -53,4 +52,3 @@ private:
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
......@@ -2,7 +2,6 @@
#include "types.h"
namespace ebpf {
namespace bpftrace {
std::ostream &operator<<(std::ostream &os, Type type)
......@@ -44,4 +43,3 @@ bpf_prog_type progtype(ProbeType t)
}
} // namespace bpftrace
} // namespace ebpf
......@@ -8,7 +8,6 @@
#include "libbpf.h"
namespace ebpf {
namespace bpftrace {
enum class Type
......@@ -64,4 +63,3 @@ std::string argument_list(const std::vector<T> &items, bool show_empty=false)
}
} // namespace bpftrace
} // namespace ebpf
......@@ -4,7 +4,6 @@
#include "parser.tab.hh"
#include "semantic_analyser.h"
namespace ebpf {
namespace bpftrace {
class MockBPFtrace : public BPFtrace {
......@@ -32,7 +31,7 @@ TEST(semantic_analyser, probe_count)
ProbeList pl = {&p1, &p2};
Program root(&pl);
ebpf::bpftrace::ast::SemanticAnalyser semantics(&root, bpftrace);
bpftrace::ast::SemanticAnalyser semantics(&root, bpftrace);
semantics.analyse();
}
......@@ -45,7 +44,7 @@ TEST(semantic_analyser, undefined_map)
std::string mapstr1 = "mymap1";
Integer myint(123);
Map map1(mapstr1);
Binop binop(&map1, ebpf::bpftrace::Parser::token::EQ, &myint);
Binop binop(&map1, bpftrace::Parser::token::EQ, &myint);
Predicate pred(&binop);
ExprStatement stmt(&myint);
StatementList stmts = {&stmt};
......@@ -54,7 +53,7 @@ TEST(semantic_analyser, undefined_map)
Program root(&pl);
std::ostringstream out1;
ebpf::bpftrace::ast::SemanticAnalyser semantics1(&root, bpftrace, out1);
bpftrace::ast::SemanticAnalyser semantics1(&root, bpftrace, out1);
EXPECT_EQ(semantics1.analyse(), 10);
// kprobe:kprobe / @mymap1 == 123 / { 123; @mymap1 = @mymap2; }
......@@ -64,10 +63,9 @@ TEST(semantic_analyser, undefined_map)
stmts.push_back(&assign);
std::ostringstream out2;
ebpf::bpftrace::ast::SemanticAnalyser semantics2(&root, bpftrace, out2);
bpftrace::ast::SemanticAnalyser semantics2(&root, bpftrace, out2);
EXPECT_EQ(semantics2.analyse(), 10);
}
} // namespace ast
} // namespace bpftrace
} // namespace ebpf
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