Commit 4c5509fc authored by Teng Qin's avatar Teng Qin Committed by yonghong-song

Add free_bcc_memory to BPFModule (#2147)

Some users uses `BPFModule` directly instead of C++ / Python API, and
they would like to have similar interface of free BCC `.text` memory
parent b0bf04ac
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "common.h" #include "common.h"
#include "bcc_debug.h" #include "bcc_debug.h"
#include "bcc_elf.h"
#include "frontends/b/loader.h" #include "frontends/b/loader.h"
#include "frontends/clang/loader.h" #include "frontends/clang/loader.h"
#include "frontends/clang/b_frontend_action.h" #include "frontends/clang/b_frontend_action.h"
...@@ -141,6 +142,10 @@ BPFModule::~BPFModule() { ...@@ -141,6 +142,10 @@ BPFModule::~BPFModule() {
ts_->DeletePrefix(Path({id_})); ts_->DeletePrefix(Path({id_}));
} }
int BPFModule::free_bcc_memory() {
return bcc_free_memory();
}
// load an entire c file as a module // load an entire c file as a module
int BPFModule::load_cfile(const string &file, bool in_memory, const char *cflags[], int ncflags) { int BPFModule::load_cfile(const string &file, bool in_memory, const char *cflags[], int ncflags) {
ClangLoader clang_loader(&*ctx_, flags_); ClangLoader clang_loader(&*ctx_, flags_);
......
...@@ -83,6 +83,7 @@ class BPFModule { ...@@ -83,6 +83,7 @@ class BPFModule {
BPFModule(unsigned flags, TableStorage *ts = nullptr, bool rw_engine_enabled = true, BPFModule(unsigned flags, TableStorage *ts = nullptr, bool rw_engine_enabled = true,
const std::string &maps_ns = ""); const std::string &maps_ns = "");
~BPFModule(); ~BPFModule();
int free_bcc_memory();
int load_b(const std::string &filename, const std::string &proto_filename); int load_b(const std::string &filename, const std::string &proto_filename);
int load_c(const std::string &filename, const char *cflags[], int ncflags); int load_c(const std::string &filename, const char *cflags[], int ncflags);
int load_string(const std::string &text, const char *cflags[], int ncflags); int load_string(const std::string &text, const char *cflags[], int ncflags);
......
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