diff options
author | Luke <luke.wilde@live.co.uk> | 2020-08-25 04:33:07 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-25 09:46:06 +0200 |
commit | 694b86a4bf055ce80c2b234b33c73515426fff5e (patch) | |
tree | ccf7896ce5ef7327aa55f258d01e70c18804394d /DevTools/HackStudio | |
parent | b58ca7cf3d73152e8e049df4ddd43912030ab4ea (diff) | |
download | serenity-694b86a4bf055ce80c2b234b33c73515426fff5e.zip |
LibDebug: Move everything into the "Debug" namespace
Diffstat (limited to 'DevTools/HackStudio')
-rw-r--r-- | DevTools/HackStudio/Debugger/BacktraceModel.cpp | 6 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/BacktraceModel.h | 8 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/DebugInfoWidget.cpp | 6 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/DebugInfoWidget.h | 2 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/Debugger.cpp | 28 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/Debugger.h | 14 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/VariablesModel.cpp | 18 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/VariablesModel.h | 4 |
8 files changed, 45 insertions, 41 deletions
diff --git a/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/DevTools/HackStudio/Debugger/BacktraceModel.cpp index 500b1a0747..afcf75ddbf 100644 --- a/DevTools/HackStudio/Debugger/BacktraceModel.cpp +++ b/DevTools/HackStudio/Debugger/BacktraceModel.cpp @@ -30,7 +30,7 @@ namespace HackStudio { -NonnullRefPtr<BacktraceModel> BacktraceModel::create(const DebugSession& debug_session, const PtraceRegisters& regs) +NonnullRefPtr<BacktraceModel> BacktraceModel::create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) { return adopt(*new BacktraceModel(create_backtrace(debug_session, regs))); } @@ -51,7 +51,7 @@ GUI::ModelIndex BacktraceModel::index(int row, int column, const GUI::ModelIndex return create_index(row, column, &m_frames.at(row)); } -Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const DebugSession& debug_session, const PtraceRegisters& regs) +Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) { u32 current_ebp = regs.ebp; u32 current_instruction = regs.eip; @@ -64,7 +64,7 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const DebugSe } frames.append({ name, current_instruction, current_ebp }); - auto frame_info = StackFrameUtils::get_info(*Debugger::the().session(), current_ebp); + auto frame_info = Debug::StackFrameUtils::get_info(*Debugger::the().session(), current_ebp); ASSERT(frame_info.has_value()); current_instruction = frame_info.value().return_address; current_ebp = frame_info.value().next_ebp; diff --git a/DevTools/HackStudio/Debugger/BacktraceModel.h b/DevTools/HackStudio/Debugger/BacktraceModel.h index ff974b57d4..06d697c388 100644 --- a/DevTools/HackStudio/Debugger/BacktraceModel.h +++ b/DevTools/HackStudio/Debugger/BacktraceModel.h @@ -31,13 +31,17 @@ #include <LibGUI/Model.h> #include <sys/arch/i386/regs.h> +namespace Debug { + class DebugSession; +} + namespace HackStudio { class BacktraceModel final : public GUI::Model { public: - static NonnullRefPtr<BacktraceModel> create(const DebugSession&, const PtraceRegisters& regs); + static NonnullRefPtr<BacktraceModel> create(const Debug::DebugSession&, const PtraceRegisters& regs); virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_frames.size(); } virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; } @@ -66,7 +70,7 @@ private: { } - static Vector<FrameInfo> create_backtrace(const DebugSession&, const PtraceRegisters&); + static Vector<FrameInfo> create_backtrace(const Debug::DebugSession&, const PtraceRegisters&); Vector<FrameInfo> m_frames; }; diff --git a/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index c3d7ebda5c..30fb546a74 100644 --- a/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -115,8 +115,8 @@ DebugInfoWidget::DebugInfoWidget() auto is_valid_index = [](auto& index) { if (!index.is_valid()) return false; - auto* variable = static_cast<const DebugInfo::VariableInfo*>(index.internal_data()); - if (variable->location_type != DebugInfo::VariableInfo::LocationType::Address) + auto* variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + if (variable->location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return false; return variable->is_enum_type() || variable->type_name.is_one_of("int", "bool"); }; @@ -139,7 +139,7 @@ DebugInfoWidget::DebugInfoWidget() }; } -void DebugInfoWidget::update_state(const DebugSession& debug_session, const PtraceRegisters& regs) +void DebugInfoWidget::update_state(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) { m_variables_view->set_model(VariablesModel::create(regs)); m_backtrace_view->set_model(BacktraceModel::create(debug_session, regs)); diff --git a/DevTools/HackStudio/Debugger/DebugInfoWidget.h b/DevTools/HackStudio/Debugger/DebugInfoWidget.h index 727c89f912..308ec6c02f 100644 --- a/DevTools/HackStudio/Debugger/DebugInfoWidget.h +++ b/DevTools/HackStudio/Debugger/DebugInfoWidget.h @@ -43,7 +43,7 @@ class DebugInfoWidget final : public GUI::Widget { public: virtual ~DebugInfoWidget() override {} - void update_state(const DebugSession&, const PtraceRegisters&); + void update_state(const Debug::DebugSession&, const PtraceRegisters&); void program_stopped(); void set_debug_actions_enabled(bool enabled); diff --git a/DevTools/HackStudio/Debugger/Debugger.cpp b/DevTools/HackStudio/Debugger/Debugger.cpp index 49280741cd..1938a77630 100644 --- a/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/DevTools/HackStudio/Debugger/Debugger.cpp @@ -69,7 +69,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC if (change_type == BreakpointChange::Added) { Debugger::the().m_breakpoints.append(position); } else { - Debugger::the().m_breakpoints.remove_all_matching([&](DebugInfo::SourcePosition val) { return val == position; }); + Debugger::the().m_breakpoints.remove_all_matching([&](Debug::DebugInfo::SourcePosition val) { return val == position; }); } auto session = Debugger::the().session(); @@ -94,7 +94,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC } } -DebugInfo::SourcePosition Debugger::create_source_position(const String& file, size_t line) +Debug::DebugInfo::SourcePosition Debugger::create_source_position(const String& file, size_t line) { if (!file.starts_with('/') && !file.starts_with("./")) return { String::format("./%s", file.characters()), line + 1 }; @@ -109,7 +109,7 @@ int Debugger::start_static() void Debugger::start() { - m_debug_session = DebugSession::exec_and_attach(m_executable_path); + m_debug_session = Debug::DebugSession::exec_and_attach(m_executable_path); ASSERT(!!m_debug_session); for (const auto& breakpoint : m_breakpoints) { @@ -130,11 +130,11 @@ int Debugger::debugger_loop() { ASSERT(m_debug_session); - m_debug_session->run([&](DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) { - if (reason == DebugSession::DebugBreakReason::Exited) { + m_debug_session->run([&](Debug::DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) { + if (reason == Debug::DebugSession::DebugBreakReason::Exited) { dbg() << "Program exited"; m_on_exit_callback(); - return DebugSession::DebugDecision::Detach; + return Debug::DebugSession::DebugDecision::Detach; } remove_temporary_breakpoints(); ASSERT(optional_regs.has_value()); @@ -146,7 +146,7 @@ int Debugger::debugger_loop() if (m_state.should_stop_single_stepping(source_position.value())) { m_state.set_normal(); } else { - return DebugSession::DebugDecision::SingleStep; + return Debug::DebugSession::DebugDecision::SingleStep; } } @@ -165,18 +165,18 @@ int Debugger::debugger_loop() switch (m_continue_type) { case ContinueType::Continue: m_state.set_normal(); - return DebugSession::DebugDecision::Continue; + return Debug::DebugSession::DebugDecision::Continue; case ContinueType::SourceSingleStep: m_state.set_single_stepping(source_position.value()); - return DebugSession::DebugDecision::SingleStep; + return Debug::DebugSession::DebugDecision::SingleStep; case ContinueType::SourceStepOut: m_state.set_stepping_out(); do_step_out(regs); - return DebugSession::DebugDecision::Continue; + return Debug::DebugSession::DebugDecision::Continue; case ContinueType::SourceStepOver: m_state.set_stepping_over(); do_step_over(regs); - return DebugSession::DebugDecision::Continue; + return Debug::DebugSession::DebugDecision::Continue; } ASSERT_NOT_REACHED(); }); @@ -190,13 +190,13 @@ void Debugger::DebuggingState::set_normal() m_original_source_position.clear(); } -void Debugger::DebuggingState::set_single_stepping(DebugInfo::SourcePosition original_source_position) +void Debugger::DebuggingState::set_single_stepping(Debug::DebugInfo::SourcePosition original_source_position) { m_state = State::SingleStepping; m_original_source_position = original_source_position; } -bool Debugger::DebuggingState::should_stop_single_stepping(const DebugInfo::SourcePosition& current_source_position) const +bool Debugger::DebuggingState::should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const { ASSERT(m_state == State::SingleStepping); return m_original_source_position.value() != current_source_position; @@ -244,7 +244,7 @@ void Debugger::do_step_over(const PtraceRegisters& regs) void Debugger::insert_temporary_breakpoint_at_return_address(const PtraceRegisters& regs) { - auto frame_info = StackFrameUtils::get_info(*m_debug_session, regs.ebp); + auto frame_info = Debug::StackFrameUtils::get_info(*m_debug_session, regs.ebp); ASSERT(frame_info.has_value()); u32 return_address = frame_info.value().return_address; insert_temporary_breakpoint(return_address); diff --git a/DevTools/HackStudio/Debugger/Debugger.h b/DevTools/HackStudio/Debugger/Debugger.h index bcd496dda9..ec7dead40e 100644 --- a/DevTools/HackStudio/Debugger/Debugger.h +++ b/DevTools/HackStudio/Debugger/Debugger.h @@ -55,7 +55,7 @@ public: void set_executable_path(const String& path) { m_executable_path = path; } - DebugSession* session() { return m_debug_session.ptr(); } + Debug::DebugSession* session() { return m_debug_session.ptr(); } // Thread entry point static int start_static(); @@ -85,18 +85,18 @@ private: State get() const { return m_state; } void set_normal(); - void set_single_stepping(DebugInfo::SourcePosition original_source_position); + void set_single_stepping(Debug::DebugInfo::SourcePosition original_source_position); void set_stepping_out() { m_state = State::SteppingOut; } void set_stepping_over() { m_state = State::SteppingOver; } - bool should_stop_single_stepping(const DebugInfo::SourcePosition& current_source_position) const; + bool should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const; void clear_temporary_breakpoints(); void add_temporary_breakpoint(u32 address); const Vector<u32>& temporary_breakpoints() const { return m_addresses_of_temporary_breakpoints; } private: State m_state { Normal }; - Optional<DebugInfo::SourcePosition> m_original_source_position; // The source position at which we started the current single step + Optional<Debug::DebugInfo::SourcePosition> m_original_source_position; // The source position at which we started the current single step Vector<u32> m_addresses_of_temporary_breakpoints; }; @@ -105,7 +105,7 @@ private: Function<void()> on_continue_callback, Function<void()> on_exit_callback); - static DebugInfo::SourcePosition create_source_position(const String& file, size_t line); + static Debug::DebugInfo::SourcePosition create_source_position(const String& file, size_t line); void start(); int debugger_loop(); @@ -116,13 +116,13 @@ private: void insert_temporary_breakpoint(FlatPtr address); void insert_temporary_breakpoint_at_return_address(const PtraceRegisters&); - OwnPtr<DebugSession> m_debug_session; + OwnPtr<Debug::DebugSession> m_debug_session; DebuggingState m_state; pthread_mutex_t m_continue_mutex {}; pthread_cond_t m_continue_cond {}; - Vector<DebugInfo::SourcePosition> m_breakpoints; + Vector<Debug::DebugInfo::SourcePosition> m_breakpoints; String m_executable_path; diff --git a/DevTools/HackStudio/Debugger/VariablesModel.cpp b/DevTools/HackStudio/Debugger/VariablesModel.cpp index 8bc964fa40..6f958d12fd 100644 --- a/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -34,7 +34,7 @@ GUI::ModelIndex VariablesModel::index(int row, int column, const GUI::ModelIndex { if (!parent_index.is_valid()) return create_index(row, column, &m_variables[row]); - auto* parent = static_cast<const DebugInfo::VariableInfo*>(parent_index.internal_data()); + auto* parent = static_cast<const Debug::DebugInfo::VariableInfo*>(parent_index.internal_data()); auto* child = &parent->members[row]; return create_index(row, column, child); } @@ -43,7 +43,7 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* child = static_cast<const DebugInfo::VariableInfo*>(index.internal_data()); + auto* child = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); auto* parent = child->parent; if (parent == nullptr) return {}; @@ -55,7 +55,7 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const ASSERT_NOT_REACHED(); } for (size_t row = 0; row < parent->parent->members.size(); row++) { - DebugInfo::VariableInfo* child_at_row = parent->parent->members.ptr_at(row).ptr(); + Debug::DebugInfo::VariableInfo* child_at_row = parent->parent->members.ptr_at(row).ptr(); if (child_at_row == parent) return create_index(row, 0, parent); } @@ -66,13 +66,13 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_variables.size(); - auto* node = static_cast<const DebugInfo::VariableInfo*>(index.internal_data()); + auto* node = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); return node->members.size(); } -static String variable_value_as_string(const DebugInfo::VariableInfo& variable) +static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& variable) { - if (variable.location_type != DebugInfo::VariableInfo::LocationType::Address) + if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return "N/A"; auto variable_address = variable.location_data.address; @@ -108,7 +108,7 @@ static String variable_value_as_string(const DebugInfo::VariableInfo& variable) return String::format("type: %s @ %08x, ", variable.type_name.characters(), variable_address); } -static Optional<u32> string_to_variable_value(const StringView& string_value, const DebugInfo::VariableInfo& variable) +static Optional<u32> string_to_variable_value(const StringView& string_value, const Debug::DebugInfo::VariableInfo& variable) { if (variable.is_enum_type()) { auto prefix_string = String::format("%s::", variable.type_name.characters()); @@ -145,7 +145,7 @@ static Optional<u32> string_to_variable_value(const StringView& string_value, co void VariablesModel::set_variable_value(const GUI::ModelIndex& index, const StringView& string_value, GUI::Window* parent_window) { - auto variable = static_cast<const DebugInfo::VariableInfo*>(index.internal_data()); + auto variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); auto value = string_to_variable_value(string_value, *variable); @@ -163,7 +163,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, const Stri GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* variable = static_cast<const DebugInfo::VariableInfo*>(index.internal_data()); + auto* variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); switch (role) { case GUI::ModelRole::Display: { auto value_as_string = variable_value_as_string(*variable); diff --git a/DevTools/HackStudio/Debugger/VariablesModel.h b/DevTools/HackStudio/Debugger/VariablesModel.h index bb0e3d5b2f..41ed5e3ec9 100644 --- a/DevTools/HackStudio/Debugger/VariablesModel.h +++ b/DevTools/HackStudio/Debugger/VariablesModel.h @@ -48,13 +48,13 @@ public: virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override; private: - explicit VariablesModel(NonnullOwnPtrVector<DebugInfo::VariableInfo>&& variables, const PtraceRegisters& regs) + explicit VariablesModel(NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, const PtraceRegisters& regs) : m_variables(move(variables)) , m_regs(regs) { m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); } - NonnullOwnPtrVector<DebugInfo::VariableInfo> m_variables; + NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables; PtraceRegisters m_regs; GUI::Icon m_variable_icon; |