diff options
-rw-r--r-- | DevTools/HackStudio/Debugger/BreakpointCallback.h (renamed from DevTools/HackStudio/BreakpointCallback.h) | 0 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/DebugInfoWidget.cpp | 52 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/DebugInfoWidget.h | 48 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/Debugger.cpp (renamed from DevTools/HackStudio/Debugger.cpp) | 0 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/Debugger.h (renamed from DevTools/HackStudio/Debugger.h) | 0 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/VariablesModel.cpp (renamed from DevTools/HackStudio/DebugInfoWidget.cpp) | 38 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/VariablesModel.h (renamed from DevTools/HackStudio/DebugInfoWidget.h) | 32 | ||||
-rw-r--r-- | DevTools/HackStudio/Editor.h | 2 | ||||
-rw-r--r-- | DevTools/HackStudio/EditorWrapper.h | 2 | ||||
-rw-r--r-- | DevTools/HackStudio/Makefile | 7 | ||||
-rw-r--r-- | DevTools/HackStudio/main.cpp | 8 |
11 files changed, 127 insertions, 62 deletions
diff --git a/DevTools/HackStudio/BreakpointCallback.h b/DevTools/HackStudio/Debugger/BreakpointCallback.h index 80d1f9495d..80d1f9495d 100644 --- a/DevTools/HackStudio/BreakpointCallback.h +++ b/DevTools/HackStudio/Debugger/BreakpointCallback.h diff --git a/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp new file mode 100644 index 0000000000..6eaf539763 --- /dev/null +++ b/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "DebugInfoWidget.h" +#include "Debugger.h" +#include "VariablesModel.h" +#include <AK/StringBuilder.h> +#include <LibGUI/BoxLayout.h> +#include <LibGUI/Model.h> +#include <LibGUI/TableView.h> +#include <LibGUI/TreeView.h> + +DebugInfoWidget::DebugInfoWidget() +{ + set_layout<GUI::HorizontalBoxLayout>(); + m_info_view = add<GUI::TreeView>(); + m_backtrace_view = add<GUI::TableView>(); +} + +void DebugInfoWidget::update_state(const PtraceRegisters& regs) +{ + auto model = VariablesModel::create(regs); + m_info_view->set_model(model); +} + +void DebugInfoWidget::program_stopped() +{ + m_info_view->set_model({}); +} diff --git a/DevTools/HackStudio/Debugger/DebugInfoWidget.h b/DevTools/HackStudio/Debugger/DebugInfoWidget.h new file mode 100644 index 0000000000..a7d49542ed --- /dev/null +++ b/DevTools/HackStudio/Debugger/DebugInfoWidget.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "Debugger.h" +#include <AK/NonnullOwnPtr.h> +#include <LibGUI/Model.h> +#include <LibGUI/Widget.h> +#include <sys/arch/i386/regs.h> + +class DebugInfoWidget final : public GUI::Widget { + C_OBJECT(DebugInfoWidget) +public: + virtual ~DebugInfoWidget() override {} + + void update_state(const PtraceRegisters&); + void program_stopped(); + +private: + explicit DebugInfoWidget(); + + RefPtr<GUI::TreeView> m_info_view; + RefPtr<GUI::TableView> m_backtrace_view; +}; diff --git a/DevTools/HackStudio/Debugger.cpp b/DevTools/HackStudio/Debugger/Debugger.cpp index cb325e2b27..cb325e2b27 100644 --- a/DevTools/HackStudio/Debugger.cpp +++ b/DevTools/HackStudio/Debugger/Debugger.cpp diff --git a/DevTools/HackStudio/Debugger.h b/DevTools/HackStudio/Debugger/Debugger.h index 90a3318d72..90a3318d72 100644 --- a/DevTools/HackStudio/Debugger.h +++ b/DevTools/HackStudio/Debugger/Debugger.h diff --git a/DevTools/HackStudio/DebugInfoWidget.cpp b/DevTools/HackStudio/Debugger/VariablesModel.cpp index 6e73b1a0ec..482622554a 100644 --- a/DevTools/HackStudio/DebugInfoWidget.cpp +++ b/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -24,14 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "DebugInfoWidget.h" -#include "Debugger.h" -#include <AK/StringBuilder.h> -#include <LibGUI/BoxLayout.h> -#include <LibGUI/Model.h> -#include <LibGUI/TreeView.h> +#include "VariablesModel.h" -GUI::ModelIndex DebugInfoModel::index(int row, int column, const GUI::ModelIndex& parent_index) const +GUI::ModelIndex VariablesModel::index(int row, int column, const GUI::ModelIndex& parent_index) const { if (!parent_index.is_valid()) return create_index(row, column, &m_variables[row]); @@ -40,7 +35,7 @@ GUI::ModelIndex DebugInfoModel::index(int row, int column, const GUI::ModelIndex return create_index(row, column, child); } -GUI::ModelIndex DebugInfoModel::parent_index(const GUI::ModelIndex& index) const +GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; @@ -63,7 +58,7 @@ GUI::ModelIndex DebugInfoModel::parent_index(const GUI::ModelIndex& index) const ASSERT_NOT_REACHED(); } -int DebugInfoModel::row_count(const GUI::ModelIndex& index) const +int VariablesModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_variables.size(); @@ -93,7 +88,7 @@ String variable_value_as_string(const DebugInfo::VariableInfo& variable) return String::format("type: %s @ %08x, ", variable.type.characters(), variable_address); } -GUI::Variant DebugInfoModel::data(const GUI::ModelIndex& index, Role role) const +GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, Role role) const { auto* variable = static_cast<const DebugInfo::VariableInfo*>(index.internal_data()); switch (role) { @@ -108,30 +103,13 @@ GUI::Variant DebugInfoModel::data(const GUI::ModelIndex& index, Role role) const } } -void DebugInfoModel::update() +void VariablesModel::update() { did_update(); } -static RefPtr<DebugInfoModel> create_model(const PtraceRegisters& regs) +RefPtr<VariablesModel> VariablesModel::create(const PtraceRegisters& regs) { auto variables = Debugger::the().session()->debug_info().get_variables_in_current_scope(regs); - return adopt(*new DebugInfoModel(move(variables), regs)); -} - -DebugInfoWidget::DebugInfoWidget() -{ - set_layout<GUI::VerticalBoxLayout>(); - m_info_view = add<GUI::TreeView>(); -} - -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({}); + return adopt(*new VariablesModel(move(variables), regs)); } diff --git a/DevTools/HackStudio/DebugInfoWidget.h b/DevTools/HackStudio/Debugger/VariablesModel.h index ca3c7e65b0..85f18c7564 100644 --- a/DevTools/HackStudio/DebugInfoWidget.h +++ b/DevTools/HackStudio/Debugger/VariablesModel.h @@ -25,21 +25,15 @@ */ #pragma once - #include "Debugger.h" #include <AK/NonnullOwnPtr.h> #include <LibGUI/Model.h> -#include <LibGUI/Widget.h> +#include <LibGUI/TreeView.h> #include <sys/arch/i386/regs.h> -class DebugInfoModel final : public GUI::Model { +class VariablesModel final : public GUI::Model { public: - explicit DebugInfoModel(NonnullOwnPtrVector<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")); - } + static RefPtr<VariablesModel> create(const PtraceRegisters& regs); virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; } @@ -49,22 +43,14 @@ 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) + : 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; PtraceRegisters m_regs; GUI::Icon m_variable_icon; }; - -class DebugInfoWidget final : public GUI::Widget { - C_OBJECT(DebugInfoWidget) -public: - virtual ~DebugInfoWidget() override {} - - void update_variables(const PtraceRegisters&); - void program_stopped(); - -private: - explicit DebugInfoWidget(); - - RefPtr<GUI::TreeView> m_info_view; -}; diff --git a/DevTools/HackStudio/Editor.h b/DevTools/HackStudio/Editor.h index e4197da613..b1b986d18f 100644 --- a/DevTools/HackStudio/Editor.h +++ b/DevTools/HackStudio/Editor.h @@ -26,7 +26,7 @@ #pragma once -#include "BreakpointCallback.h" +#include "Debugger/BreakpointCallback.h" #include <AK/Optional.h> #include <LibGUI/TextEditor.h> #include <LibWeb/Forward.h> diff --git a/DevTools/HackStudio/EditorWrapper.h b/DevTools/HackStudio/EditorWrapper.h index 31aa679590..00c2143c3c 100644 --- a/DevTools/HackStudio/EditorWrapper.h +++ b/DevTools/HackStudio/EditorWrapper.h @@ -26,7 +26,7 @@ #pragma once -#include "BreakpointCallback.h" +#include "Debugger/BreakpointCallback.h" #include <AK/Function.h> #include <AK/Vector.h> #include <LibGUI/Widget.h> diff --git a/DevTools/HackStudio/Makefile b/DevTools/HackStudio/Makefile index 89bd7b610c..d00b45b610 100644 --- a/DevTools/HackStudio/Makefile +++ b/DevTools/HackStudio/Makefile @@ -6,7 +6,6 @@ OBJS = \ ProcessStateWidget.o \ FormEditorWidget.o \ FormWidget.o \ - DebugInfoWidget.o \ Editor.o \ EditorWrapper.o \ Locator.o \ @@ -14,8 +13,10 @@ OBJS = \ CursorTool.o \ WidgetTool.o \ WidgetTreeModel.o \ - Debugger.o \ - main.o + main.o \ + Debugger/DebugInfoWidget.o \ + Debugger/Debugger.o \ + Debugger/VariablesModel.o PROGRAM = HackStudio diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 7d44a12ad4..3c5eceefae 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -25,8 +25,8 @@ */ #include "CursorTool.h" -#include "DebugInfoWidget.h" -#include "Debugger.h" +#include "Debugger/DebugInfoWidget.h" +#include "Debugger/Debugger.h" #include "Editor.h" #include "EditorWrapper.h" #include "FindInFilesWidget.h" @@ -48,9 +48,9 @@ #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> -#include <LibGUI/INISyntaxHighlighter.h> #include <LibGUI/CppSyntaxHighlighter.h> #include <LibGUI/FilePicker.h> +#include <LibGUI/INISyntaxHighlighter.h> #include <LibGUI/InputBox.h> #include <LibGUI/JSSyntaxHighlighter.h> #include <LibGUI/Label.h> @@ -615,7 +615,7 @@ int main(int argc, char** argv) } current_editor_in_execution = get_editor_of_file(source_position.value().file_path); current_editor_in_execution->editor().set_execution_position(source_position.value().line_number - 1); - debug_info_widget.update_variables(regs); + debug_info_widget.update_state(regs); continue_action->set_enabled(true); single_step_action->set_enabled(true); reveal_action_tab(debug_info_widget); |