mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:07:34 +00:00
HackStudio: Reorganize debugger-related files
The debugger's files are now placed under HackStudio/Debugger
This commit is contained in:
parent
ce36071447
commit
b9f0f402f4
11 changed files with 127 additions and 62 deletions
52
DevTools/HackStudio/Debugger/DebugInfoWidget.cpp
Normal file
52
DevTools/HackStudio/Debugger/DebugInfoWidget.cpp
Normal file
|
@ -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({});
|
||||||
|
}
|
48
DevTools/HackStudio/Debugger/DebugInfoWidget.h
Normal file
48
DevTools/HackStudio/Debugger/DebugInfoWidget.h
Normal file
|
@ -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;
|
||||||
|
};
|
|
@ -24,14 +24,9 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DebugInfoWidget.h"
|
#include "VariablesModel.h"
|
||||||
#include "Debugger.h"
|
|
||||||
#include <AK/StringBuilder.h>
|
|
||||||
#include <LibGUI/BoxLayout.h>
|
|
||||||
#include <LibGUI/Model.h>
|
|
||||||
#include <LibGUI/TreeView.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())
|
if (!parent_index.is_valid())
|
||||||
return create_index(row, column, &m_variables[row]);
|
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);
|
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())
|
if (!index.is_valid())
|
||||||
return {};
|
return {};
|
||||||
|
@ -63,7 +58,7 @@ GUI::ModelIndex DebugInfoModel::parent_index(const GUI::ModelIndex& index) const
|
||||||
ASSERT_NOT_REACHED();
|
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())
|
if (!index.is_valid())
|
||||||
return m_variables.size();
|
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);
|
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());
|
auto* variable = static_cast<const DebugInfo::VariableInfo*>(index.internal_data());
|
||||||
switch (role) {
|
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();
|
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);
|
auto variables = Debugger::the().session()->debug_info().get_variables_in_current_scope(regs);
|
||||||
return adopt(*new DebugInfoModel(move(variables), regs));
|
return adopt(*new VariablesModel(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({});
|
|
||||||
}
|
}
|
|
@ -25,21 +25,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Debugger.h"
|
#include "Debugger.h"
|
||||||
#include <AK/NonnullOwnPtr.h>
|
#include <AK/NonnullOwnPtr.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/TreeView.h>
|
||||||
#include <sys/arch/i386/regs.h>
|
#include <sys/arch/i386/regs.h>
|
||||||
|
|
||||||
class DebugInfoModel final : public GUI::Model {
|
class VariablesModel final : public GUI::Model {
|
||||||
public:
|
public:
|
||||||
explicit DebugInfoModel(NonnullOwnPtrVector<DebugInfo::VariableInfo>&& variables, const PtraceRegisters& regs)
|
static RefPtr<VariablesModel> create(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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
|
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;
|
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||||
|
|
||||||
private:
|
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;
|
NonnullOwnPtrVector<DebugInfo::VariableInfo> m_variables;
|
||||||
PtraceRegisters m_regs;
|
PtraceRegisters m_regs;
|
||||||
|
|
||||||
GUI::Icon m_variable_icon;
|
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;
|
|
||||||
};
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BreakpointCallback.h"
|
#include "Debugger/BreakpointCallback.h"
|
||||||
#include <AK/Optional.h>
|
#include <AK/Optional.h>
|
||||||
#include <LibGUI/TextEditor.h>
|
#include <LibGUI/TextEditor.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BreakpointCallback.h"
|
#include "Debugger/BreakpointCallback.h"
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
|
|
|
@ -6,7 +6,6 @@ OBJS = \
|
||||||
ProcessStateWidget.o \
|
ProcessStateWidget.o \
|
||||||
FormEditorWidget.o \
|
FormEditorWidget.o \
|
||||||
FormWidget.o \
|
FormWidget.o \
|
||||||
DebugInfoWidget.o \
|
|
||||||
Editor.o \
|
Editor.o \
|
||||||
EditorWrapper.o \
|
EditorWrapper.o \
|
||||||
Locator.o \
|
Locator.o \
|
||||||
|
@ -14,8 +13,10 @@ OBJS = \
|
||||||
CursorTool.o \
|
CursorTool.o \
|
||||||
WidgetTool.o \
|
WidgetTool.o \
|
||||||
WidgetTreeModel.o \
|
WidgetTreeModel.o \
|
||||||
Debugger.o \
|
main.o \
|
||||||
main.o
|
Debugger/DebugInfoWidget.o \
|
||||||
|
Debugger/Debugger.o \
|
||||||
|
Debugger/VariablesModel.o
|
||||||
|
|
||||||
PROGRAM = HackStudio
|
PROGRAM = HackStudio
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CursorTool.h"
|
#include "CursorTool.h"
|
||||||
#include "DebugInfoWidget.h"
|
#include "Debugger/DebugInfoWidget.h"
|
||||||
#include "Debugger.h"
|
#include "Debugger/Debugger.h"
|
||||||
#include "Editor.h"
|
#include "Editor.h"
|
||||||
#include "EditorWrapper.h"
|
#include "EditorWrapper.h"
|
||||||
#include "FindInFilesWidget.h"
|
#include "FindInFilesWidget.h"
|
||||||
|
@ -48,9 +48,9 @@
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
#include <LibGUI/INISyntaxHighlighter.h>
|
|
||||||
#include <LibGUI/CppSyntaxHighlighter.h>
|
#include <LibGUI/CppSyntaxHighlighter.h>
|
||||||
#include <LibGUI/FilePicker.h>
|
#include <LibGUI/FilePicker.h>
|
||||||
|
#include <LibGUI/INISyntaxHighlighter.h>
|
||||||
#include <LibGUI/InputBox.h>
|
#include <LibGUI/InputBox.h>
|
||||||
#include <LibGUI/JSSyntaxHighlighter.h>
|
#include <LibGUI/JSSyntaxHighlighter.h>
|
||||||
#include <LibGUI/Label.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 = get_editor_of_file(source_position.value().file_path);
|
||||||
current_editor_in_execution->editor().set_execution_position(source_position.value().line_number - 1);
|
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);
|
continue_action->set_enabled(true);
|
||||||
single_step_action->set_enabled(true);
|
single_step_action->set_enabled(true);
|
||||||
reveal_action_tab(debug_info_widget);
|
reveal_action_tab(debug_info_widget);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue