mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2026-02-12 16:11:00 +00:00
Rename BpfPerfBuffer to PerfEventArray, add struct_parser to BpfObject as a shared_ptr
This commit is contained in:
@ -2,11 +2,12 @@
|
||||
#include "bpf_exception.h"
|
||||
#include "bpf_map.h"
|
||||
#include "bpf_program.h"
|
||||
#include "utils/struct_parser.h"
|
||||
#include <cerrno>
|
||||
|
||||
BpfObject::BpfObject(std::string object_path, py::dict structs)
|
||||
: obj_(nullptr), object_path_(std::move(object_path)), loaded_(false),
|
||||
struct_defs_(structs) {}
|
||||
struct_defs_(structs), struct_parser_(nullptr) {}
|
||||
|
||||
BpfObject::~BpfObject() {
|
||||
// Clear caches first (order matters!)
|
||||
@ -256,3 +257,11 @@ py::dict BpfObject::get_cached_maps() const {
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
std::shared_ptr<StructParser> BpfObject::get_struct_parser() const {
|
||||
if (!struct_parser_ && !struct_defs_.empty()) {
|
||||
// Create parser on first access
|
||||
struct_parser_ = std::make_shared<StructParser>(struct_defs_);
|
||||
}
|
||||
return struct_parser_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user