Simplify public headers more
This commit is contained in:
@@ -84,117 +84,14 @@ struct ArenaDebugger {
|
||||
|
||||
private:
|
||||
void scan_arena_pointers() {
|
||||
std::cout << "Scanning all used arena memory for 64-bit aligned pointers..."
|
||||
<< std::endl;
|
||||
|
||||
// Use the arena's comprehensive pointer scanning method
|
||||
auto pointers = arena.find_intra_arena_pointers();
|
||||
|
||||
std::cout << "Arena memory scan complete:" << std::endl;
|
||||
std::cout << "Arena memory analysis:" << std::endl;
|
||||
std::cout << "- Total scanned: " << arena.used_bytes() << " bytes across "
|
||||
<< arena.num_blocks() << " blocks" << std::endl;
|
||||
std::cout << "- Intra-arena pointers found: " << pointers.size()
|
||||
<< std::endl;
|
||||
|
||||
if (pointers.empty()) {
|
||||
std::cout << "No intra-arena pointers detected." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "Detected pointers:" << std::endl;
|
||||
|
||||
for (size_t i = 0; i < pointers.size(); ++i) {
|
||||
const auto &ptr_info = pointers[i];
|
||||
|
||||
std::cout << "Pointer #" << (i + 1) << ":" << std::endl;
|
||||
std::cout << " Source: " << ptr_info.source_addr << " (Block #"
|
||||
<< ptr_info.source_block_number << ", offset +0x" << std::hex
|
||||
<< ptr_info.source_offset << std::dec << ")" << std::endl;
|
||||
std::cout << " Target: " << ptr_info.target_addr << " (Block #"
|
||||
<< ptr_info.target_block_number << ", offset +0x" << std::hex
|
||||
<< ptr_info.target_offset << std::dec << ")" << std::endl;
|
||||
|
||||
// Try to identify what this pointer might be pointing to
|
||||
identify_pointer_target(ptr_info.target_addr);
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void identify_pointer_target(const void *target_addr) {
|
||||
// Check if this target address matches any of our known string data
|
||||
std::cout << " Points to: ";
|
||||
|
||||
bool found_match = false;
|
||||
|
||||
// Check request_id
|
||||
if (commit_request.request_id().has_value()) {
|
||||
const auto &req_id = *commit_request.request_id();
|
||||
if (target_addr >= req_id.data() &&
|
||||
target_addr < req_id.data() + req_id.size()) {
|
||||
std::cout << "request_id string";
|
||||
found_match = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check leader_id
|
||||
if (!found_match) {
|
||||
const auto &leader_id = commit_request.leader_id();
|
||||
if (target_addr >= leader_id.data() &&
|
||||
target_addr < leader_id.data() + leader_id.size()) {
|
||||
std::cout << "leader_id string";
|
||||
found_match = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check preconditions
|
||||
if (!found_match) {
|
||||
for (size_t i = 0; i < commit_request.preconditions().size(); ++i) {
|
||||
const auto &precond = commit_request.preconditions()[i];
|
||||
|
||||
if (!precond.begin.empty() && target_addr >= precond.begin.data() &&
|
||||
target_addr < precond.begin.data() + precond.begin.size()) {
|
||||
std::cout << "precondition[" << i << "].begin string";
|
||||
found_match = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!precond.end.empty() && target_addr >= precond.end.data() &&
|
||||
target_addr < precond.end.data() + precond.end.size()) {
|
||||
std::cout << "precondition[" << i << "].end string";
|
||||
found_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check operations
|
||||
if (!found_match) {
|
||||
for (size_t i = 0; i < commit_request.operations().size(); ++i) {
|
||||
const auto &op = commit_request.operations()[i];
|
||||
|
||||
if (!op.param1.empty() && target_addr >= op.param1.data() &&
|
||||
target_addr < op.param1.data() + op.param1.size()) {
|
||||
std::cout << "operation[" << i << "].param1 string";
|
||||
found_match = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!op.param2.empty() && target_addr >= op.param2.data() &&
|
||||
target_addr < op.param2.data() + op.param2.size()) {
|
||||
std::cout << "operation[" << i << "].param2 string";
|
||||
found_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_match) {
|
||||
std::cout << "unknown arena data";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "- Memory utilization: "
|
||||
<< (arena.total_allocated() > 0
|
||||
? (100.0 * arena.used_bytes() / arena.total_allocated())
|
||||
: 0.0)
|
||||
<< "%" << std::endl;
|
||||
}
|
||||
|
||||
std::string_view find_string_view_for_data(const char *data) {
|
||||
|
||||
Reference in New Issue
Block a user