Skip to content

Commit

Permalink
Drop MapManager and all related classes
Browse files Browse the repository at this point in the history
Now that map management has been completely moved to BpfBytecode, using
BpfMap objects, we can remove the legacy MapManager and all of the
related classes: IMap, Map, FakeMap.

One problem that popped up is that after the cleanup, RequiredResources
has only 3 methods which are all used by AOT only. This caused linker
error b/c we expect required_resources.cpp to be linked in libruntime.a,
however, since no method was called from the runtime library, the linker
skipped it. This is fixed by adding an explicit definition of a
constructor in required_resources.cpp.
  • Loading branch information
viktormalik committed Feb 9, 2024
1 parent cec253d commit 5118ac7
Show file tree
Hide file tree
Showing 23 changed files with 11 additions and 733 deletions.
3 changes: 0 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ add_library(runtime
config.cpp
disasm.cpp
dwarf_parser.cpp
fake_map.cpp
format_string.cpp
imap.cpp
log.cpp
map.cpp
mapkey.cpp
output.cpp
probe_matcher.cpp
Expand Down
1 change: 0 additions & 1 deletion src/ast/passes/codegen_llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "bpftrace.h"
#include "format_string.h"
#include "location.hh"
#include "map.h"
#include "required_resources.h"

namespace bpftrace {
Expand Down
1 change: 0 additions & 1 deletion src/ast/passes/config_analyser.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "bpffeature.h"
#include "bpftrace.h"
#include "config.h"
#include "map.h"
#include "types.h"

namespace bpftrace {
Expand Down
5 changes: 0 additions & 5 deletions src/ast/passes/resource_analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ Pass CreateResourcePass()
return PassResult::Error("Resource", 1);
ctx.b.resources = pass_result.value();

// Create fake maps so that codegen has access to map IDs
//
// At runtime we will replace the fake maps with real maps
ctx.b.resources.create_maps(ctx.b, true);

return PassResult::Success();
};

Expand Down
1 change: 0 additions & 1 deletion src/ast/passes/semantic_analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "ast/ast.h"
#include "ast/signal_bt.h"
#include "config.h"
#include "fake_map.h"
#include "log.h"
#include "printf.h"
#include "probe_matcher.h"
Expand Down
1 change: 0 additions & 1 deletion src/ast/passes/semantic_analyser.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "bpffeature.h"
#include "bpftrace.h"
#include "config.h"
#include "map.h"
#include "types.h"

namespace bpftrace {
Expand Down
2 changes: 1 addition & 1 deletion src/bpfbytecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "bpffeature.h"
#include "bpfmap.h"
#include "mapmanager.h"
#include "types.h"

#include <bpf/libbpf.h>
#include <cereal/access.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/bpfprogram.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "bpfbytecode.h"
#include "mapmanager.h"

#include <cstdint>
#include <optional>
Expand Down
11 changes: 0 additions & 11 deletions src/bpftrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,17 +1128,6 @@ int BPFtrace::run(BpfBytecode bytecode)
if (bytecode.create_maps())
return 1;

// Clear fake maps and replace with real maps
maps = {};
if (resources.create_maps(*this, false))
return 1;
// BPF maps are now created by BpfBytecode::create_maps and therefore
// we copy FDs to MapManager for compatibility. This code will go away once
// we get rid of MapManager.
for (auto &map : maps) {
map->mapfd_ = bytecode.getMap(map->name_).fd;
}

if (bytecode.hasMap(MapType::MappedPrintfData)) {
auto map = bytecode.getMap(MapType::MappedPrintfData);
uint32_t idx = 0;
Expand Down
3 changes: 0 additions & 3 deletions src/bpftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "child.h"
#include "config.h"
#include "dwarf_parser.h"
#include "map.h"
#include "mapmanager.h"
#include "output.h"
#include "pcap_writer.h"
#include "printf.h"
Expand Down Expand Up @@ -174,7 +172,6 @@ class BPFtrace {
static volatile sig_atomic_t sigusr1_recv;

RequiredResources resources;
MapManager maps;
BpfBytecode bytecode_;
StructManager structs;
std::map<std::string, std::string> macros_;
Expand Down
39 changes: 0 additions & 39 deletions src/fake_map.cpp

This file was deleted.

32 changes: 0 additions & 32 deletions src/fake_map.h

This file was deleted.

52 changes: 0 additions & 52 deletions src/imap.cpp

This file was deleted.

77 changes: 0 additions & 77 deletions src/imap.h

This file was deleted.

0 comments on commit 5118ac7

Please sign in to comment.