summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DevTools/HackStudio/DebugInfoWidget.cpp7
-rw-r--r--Libraries/LibDebug/DebugInfo.cpp24
-rw-r--r--Libraries/LibDebug/DebugInfo.h1
3 files changed, 10 insertions, 22 deletions
diff --git a/DevTools/HackStudio/DebugInfoWidget.cpp b/DevTools/HackStudio/DebugInfoWidget.cpp
index c84bd8325e..6e73b1a0ec 100644
--- a/DevTools/HackStudio/DebugInfoWidget.cpp
+++ b/DevTools/HackStudio/DebugInfoWidget.cpp
@@ -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("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
@@ -130,3 +130,8 @@ void DebugInfoWidget::update_variables(const PtraceRegisters& regs)
auto model = create_model(regs);
m_info_view->set_model(model);
}
+
+void DebugInfoWidget::program_stopped()
+{
+ m_info_view->set_model({});
+}
diff --git a/Libraries/LibDebug/DebugInfo.cpp b/Libraries/LibDebug/DebugInfo.cpp
index 14ee1cf0e4..a541e6de74 100644
--- a/Libraries/LibDebug/DebugInfo.cpp
+++ b/Libraries/LibDebug/DebugInfo.cpp
@@ -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
{
- auto scope = get_scope(regs.eip);
- if (!scope.has_value())
- return {};
-
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
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;
- if (!best_matching_scope.has_value()) {
- best_matching_scope = scope;
-
- } else if (scope.address_low > best_matching_scope.value().address_low || scope.address_high < best_matching_scope.value().address_high) {
- best_matching_scope = scope;
+ for (const auto& die_entry : scope.dies_of_variables) {
+ variables.append(create_variable_info(die_entry, regs));
}
}
- return best_matching_scope;
+ return variables;
}
NonnullOwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs) const
diff --git a/Libraries/LibDebug/DebugInfo.h b/Libraries/LibDebug/DebugInfo.h
index 06289c76e7..af928b6a97 100644
--- a/Libraries/LibDebug/DebugInfo.h
+++ b/Libraries/LibDebug/DebugInfo.h
@@ -97,7 +97,6 @@ private:
void prepare_variable_scopes();
void prepare_lines();
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;
NonnullRefPtr<const ELF::Loader> m_elf;