mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
HackStudio: Support variable inspection in nested scopes
This commit is contained in:
parent
f0cbaf453c
commit
14ee090f25
3 changed files with 10 additions and 22 deletions
|
@ -90,7 +90,7 @@ String variable_value_as_string(const DebugInfo::VariableInfo& variable)
|
||||||
return String::format("'%c' (%d)", static_cast<char>(value.value()), static_cast<char>(value.value()));
|
return String::format("'%c' (%d)", static_cast<char>(value.value()), static_cast<char>(value.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return String::format("address: %08x, ", variable_address);
|
return String::format("type: %s @ %08x, ", variable.type.characters(), variable_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::Variant DebugInfoModel::data(const GUI::ModelIndex& index, Role role) const
|
GUI::Variant DebugInfoModel::data(const GUI::ModelIndex& index, Role role) const
|
||||||
|
@ -130,3 +130,8 @@ void DebugInfoWidget::update_variables(const PtraceRegisters& regs)
|
||||||
auto model = create_model(regs);
|
auto model = create_model(regs);
|
||||||
m_info_view->set_model(model);
|
m_info_view->set_model(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugInfoWidget::program_stopped()
|
||||||
|
{
|
||||||
|
m_info_view->set_model({});
|
||||||
|
}
|
||||||
|
|
|
@ -140,34 +140,18 @@ Optional<u32> DebugInfo::get_instruction_from_source(const String& file, size_t
|
||||||
|
|
||||||
NonnullOwnPtrVector<DebugInfo::VariableInfo> DebugInfo::get_variables_in_current_scope(const PtraceRegisters& regs) const
|
NonnullOwnPtrVector<DebugInfo::VariableInfo> DebugInfo::get_variables_in_current_scope(const PtraceRegisters& regs) const
|
||||||
{
|
{
|
||||||
auto scope = get_scope(regs.eip);
|
|
||||||
if (!scope.has_value())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
NonnullOwnPtrVector<DebugInfo::VariableInfo> variables;
|
NonnullOwnPtrVector<DebugInfo::VariableInfo> variables;
|
||||||
for (const auto& die_entry : scope.value().dies_of_variables) {
|
|
||||||
variables.append(create_variable_info(die_entry, regs));
|
|
||||||
}
|
|
||||||
return variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<DebugInfo::VariablesScope> DebugInfo::get_scope(u32 instruction_pointer) const
|
|
||||||
{
|
|
||||||
Optional<VariablesScope> best_matching_scope;
|
|
||||||
|
|
||||||
// TODO: We can store the scopes in a better data strucutre
|
// TODO: We can store the scopes in a better data strucutre
|
||||||
for (const auto& scope : m_scopes) {
|
for (const auto& scope : m_scopes) {
|
||||||
if (instruction_pointer < scope.address_low || instruction_pointer >= scope.address_high)
|
if (regs.eip < scope.address_low || regs.eip >= scope.address_high)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!best_matching_scope.has_value()) {
|
for (const auto& die_entry : scope.dies_of_variables) {
|
||||||
best_matching_scope = scope;
|
variables.append(create_variable_info(die_entry, regs));
|
||||||
|
|
||||||
} else if (scope.address_low > best_matching_scope.value().address_low || scope.address_high < best_matching_scope.value().address_high) {
|
|
||||||
best_matching_scope = scope;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return best_matching_scope;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullOwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs) const
|
NonnullOwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs) const
|
||||||
|
|
|
@ -97,7 +97,6 @@ private:
|
||||||
void prepare_variable_scopes();
|
void prepare_variable_scopes();
|
||||||
void prepare_lines();
|
void prepare_lines();
|
||||||
void parse_scopes_impl(const Dwarf::DIE& die);
|
void parse_scopes_impl(const Dwarf::DIE& die);
|
||||||
Optional<VariablesScope> get_scope(u32 instruction_pointer) const;
|
|
||||||
NonnullOwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&) const;
|
NonnullOwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&) const;
|
||||||
|
|
||||||
NonnullRefPtr<const ELF::Loader> m_elf;
|
NonnullRefPtr<const ELF::Loader> m_elf;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue