Commit c7417dcc authored by Teng Qin's avatar Teng Qin

Add C++ helper to clear BPF tables

parent e5db52bf
......@@ -106,6 +106,12 @@ BPFStackTable::~BPFStackTable() {
bcc_free_symcache(it.second, it.first);
}
void BPFStackTable::clear_table_non_atomic() {
for (int i = 0; i < capacity(); i++) {
remove(&i);
}
}
std::vector<uintptr_t> BPFStackTable::get_stack_addr(int stack_id) {
std::vector<uintptr_t> res;
stacktrace_t stack;
......
......@@ -196,6 +196,20 @@ class BPFHashTable : public BPFTableBase<KeyType, ValueType> {
return res;
}
StatusTuple clear_table_non_atomic() {
KeyType cur;
if (!this->first(&cur))
return StatusTuple(0);
while (true) {
TRY2(remove_value(cur));
if (!this->next(&cur, &cur))
break;
}
return StatusTuple(0);
}
};
// From src/cc/export/helpers.h
......@@ -211,6 +225,7 @@ class BPFStackTable : public BPFTableBase<int, stacktrace_t> {
bool check_debug_file_crc);
~BPFStackTable();
void clear_table_non_atomic();
std::vector<uintptr_t> get_stack_addr(int stack_id);
std::vector<std::string> get_stack_symbol(int stack_id, int pid);
......
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