Commit 19d92a2a authored by Alastair Robertson's avatar Alastair Robertson

Store map name in map class

parent aa05dca0
......@@ -28,7 +28,7 @@ void CodegenLLVM::visit(Map &map)
{
int mapfd;
if (bpftrace_.maps_.find(map.ident) == bpftrace_.maps_.end()) {
bpftrace_.maps_[map.ident] = std::make_unique<ebpf::bpftrace::Map>();
bpftrace_.maps_[map.ident] = std::make_unique<ebpf::bpftrace::Map>(map.ident);
}
mapfd = bpftrace_.maps_[map.ident]->mapfd_;
......@@ -104,7 +104,7 @@ void CodegenLLVM::visit(AssignMapStatement &assignment)
Map &map = *assignment.map;
int mapfd;
if (bpftrace_.maps_.find(map.ident) == bpftrace_.maps_.end()) {
bpftrace_.maps_[map.ident] = std::make_unique<ebpf::bpftrace::Map>();
bpftrace_.maps_[map.ident] = std::make_unique<ebpf::bpftrace::Map>(map.ident);
}
mapfd = bpftrace_.maps_[map.ident]->mapfd_;
......
......@@ -7,11 +7,11 @@
namespace ebpf {
namespace bpftrace {
Map::Map() {
Map::Map(std::string &name) : name_(name) {
mapfd_ = bpf_create_map(BPF_MAP_TYPE_HASH, 8, 8, 128, 0);
if (mapfd_ < 0)
{
std::cerr << "Error creating map" << std::endl;;
std::cerr << "Error creating map: '" << name_ << "'" << std::endl;
}
}
......
......@@ -8,10 +8,11 @@ namespace bpftrace {
class Map {
public:
Map();
explicit Map(std::string &);
~Map();
int mapfd_;
std::string name_;
};
} // namespace bpftrace
......
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