mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibDebug+HackStudio: Fix crashes relating to debugger variable preview
For one, viewing a variable who's type contained a subprogram will no longer crash HackStudio. Additionally, the variable view will handle invalid enum values gracefully now, fixing another crash. Finally, deeply nested (nest count > 1) structures will have their memory addresses properly set, fixing the final crash I found.
This commit is contained in:
parent
c778164f64
commit
d295095993
3 changed files with 10 additions and 9 deletions
|
@ -83,7 +83,8 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var
|
|||
auto it = variable.type->members.find_if([&enumerator_value = value.value()](const auto& enumerator) {
|
||||
return enumerator->constant_data.as_u32 == enumerator_value;
|
||||
});
|
||||
VERIFY(!it.is_end());
|
||||
if (it.is_end())
|
||||
return String::formatted("Unknown ({})", value.value());
|
||||
return String::formatted("{}::{}", variable.type_name, (*it)->name);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V
|
|||
}
|
||||
}
|
||||
|
||||
OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs) const
|
||||
OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs, u32 address_offset) const
|
||||
{
|
||||
VERIFY(variable_die.tag() == Dwarf::EntryTag::Variable
|
||||
|| variable_die.tag() == Dwarf::EntryTag::Member
|
||||
|
@ -290,6 +290,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
|
|||
}
|
||||
} else {
|
||||
parse_variable_location(variable_die, *variable_info, regs);
|
||||
variable_info->location_data.address += address_offset;
|
||||
}
|
||||
|
||||
if (type_die.has_value()) {
|
||||
|
@ -301,21 +302,20 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
|
|||
type_die.value().for_each_child([&](const Dwarf::DIE& member) {
|
||||
if (member.is_null())
|
||||
return;
|
||||
auto member_variable = create_variable_info(member, regs);
|
||||
if (member.tag() == Dwarf::EntryTag::SubProgram)
|
||||
return;
|
||||
|
||||
auto member_variable = create_variable_info(member, regs, variable_info->location_data.address);
|
||||
VERIFY(member_variable);
|
||||
|
||||
if (type_die.value().tag() == Dwarf::EntryTag::EnumerationType) {
|
||||
member_variable->parent = type_info.ptr();
|
||||
type_info->members.append(member_variable.release_nonnull());
|
||||
} else {
|
||||
if (variable_info->location_type == DebugInfo::VariableInfo::LocationType::None) {
|
||||
if (variable_info->location_type == DebugInfo::VariableInfo::LocationType::None)
|
||||
return;
|
||||
}
|
||||
VERIFY(variable_info->location_type == DebugInfo::VariableInfo::LocationType::Address);
|
||||
|
||||
if (member_variable->location_type == DebugInfo::VariableInfo::LocationType::Address)
|
||||
member_variable->location_data.address += variable_info->location_data.address;
|
||||
|
||||
member_variable->parent = variable_info.ptr();
|
||||
variable_info->members.append(member_variable.release_nonnull());
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ private:
|
|||
void prepare_variable_scopes();
|
||||
void prepare_lines();
|
||||
void parse_scopes_impl(const Dwarf::DIE& die);
|
||||
OwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&) const;
|
||||
OwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&, u32 address_offset = 0) const;
|
||||
|
||||
NonnullOwnPtr<const ELF::Image> m_elf;
|
||||
String m_source_root;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue