remove unused list_global_integer_vars function

This commit is contained in:
Gabriel Ionita 2025-10-26 20:05:00 +01:00
parent dfb69f8e28
commit abdb39abba
Signed by: gabi
SSH Key Fingerprint: SHA256:mrbYmB/SGtDvT3etRoS6pDrMYWxR0/B5GSF6rR3qhhc
2 changed files with 0 additions and 68 deletions

View File

@ -290,70 +290,3 @@ std::optional<VarInfo> Symbol::find_global_var(Dwarf_Debug dbg, const std::strin
return std::nullopt;
}
void Symbol::list_global_integer_vars(Dwarf_Debug dbg) {
Dwarf_Error err;
Dwarf_Unsigned cu_hdr_len, abbr_offset, next_cu_hdr;
Dwarf_Half ver_stamp, addr_sz;
Dwarf_Half length_size, extension_size;
Dwarf_Sig8 type_signature;
Dwarf_Unsigned typeoffset;
Dwarf_Half header_cu_type;
std::cout << "Global integer variables:" << std::endl;
std::cout << std::string(50, '-') << std::endl;
// Iterate through all compilation units
while (dwarf_next_cu_header_d(dbg, true, &cu_hdr_len, &ver_stamp, &abbr_offset,
&addr_sz, &length_size, &extension_size,
&type_signature, &typeoffset, &next_cu_hdr,
&header_cu_type, &err) == DW_DLV_OK) {
Dwarf_Die cu_die = nullptr;
// Get the compilation unit DIE
if (dwarf_siblingof_b(dbg, nullptr, true, &cu_die, &err) != DW_DLV_OK)
continue;
// Get the first child DIE
Dwarf_Die child_die = nullptr;
if (dwarf_child(cu_die, &child_die, &err) != DW_DLV_OK) {
dwarf_dealloc(dbg, cu_die, DW_DLA_DIE);
continue;
}
// Iterate through all child DIEs
while (child_die != nullptr) {
Dwarf_Half tag;
if (dwarf_tag(child_die, &tag, &err) == DW_DLV_OK && tag == DW_TAG_variable) {
// Top-level variables are globals (excludes namespace/function-scoped vars)
// Check if it's an integer type
if (is_integer_type(dbg, child_die)) {
char *var_name = nullptr;
if (dwarf_diename(child_die, &var_name, &err) == DW_DLV_OK && var_name) {
Dwarf_Addr addr = get_global_var_addr(dbg, child_die);
std::cout << std::format("Variable: {:<30} Address: 0x{:x}",
var_name, addr) << std::endl;
dwarf_dealloc(dbg, var_name, DW_DLA_STRING);
}
}
}
// Move to the next sibling
Dwarf_Die next_die = nullptr;
int rc = dwarf_siblingof_c(child_die, &next_die, &err);
dwarf_dealloc(dbg, child_die, DW_DLA_DIE);
child_die = next_die;
if (rc != DW_DLV_OK)
break;
}
dwarf_dealloc(dbg, cu_die, DW_DLA_DIE);
}
}

View File

@ -20,7 +20,6 @@ public:
bool is_integer_type(Dwarf_Debug dbg, Dwarf_Die die);
Dwarf_Addr get_global_var_addr(Dwarf_Debug dbg, Dwarf_Die die);
size_t get_var_size(Dwarf_Debug dbg, Dwarf_Die die);
void list_global_integer_vars(Dwarf_Debug dbg);
std::optional<VarInfo> find_global_var(Dwarf_Debug dbg, const std::string &var_name);
};