2020-05-04 06:23:30 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-04 06:23:30 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-05-28 15:40:53 -03:00
|
|
|
|
2020-05-04 06:23:30 -03:00
|
|
|
#include "Debugger.h"
|
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
|
|
|
|
#include <LibGUI/Model.h>
|
2020-05-08 07:32:55 -03:00
|
|
|
#include <LibGUI/TreeView.h>
|
2022-10-03 23:39:57 -03:00
|
|
|
#include <sys/arch/regs.h>
|
2020-05-04 06:23:30 -03:00
|
|
|
|
2020-08-17 10:22:30 -03:00
|
|
|
namespace HackStudio {
|
|
|
|
|
|
2020-05-08 07:32:55 -03:00
|
|
|
class VariablesModel final : public GUI::Model {
|
2020-05-04 06:23:30 -03:00
|
|
|
public:
|
2021-11-19 11:13:07 -03:00
|
|
|
static RefPtr<VariablesModel> create(Debug::ProcessInspector&, PtraceRegisters const& regs);
|
2020-05-04 06:23:30 -03:00
|
|
|
|
2021-11-10 20:55:02 -03:00
|
|
|
void set_variable_value(const GUI::ModelIndex&, StringView, GUI::Window*);
|
2020-05-30 15:19:49 -03:00
|
|
|
|
2020-05-04 06:23:30 -03:00
|
|
|
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
|
|
|
|
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
|
2020-08-16 11:00:07 -03:00
|
|
|
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
|
2020-05-04 06:23:30 -03:00
|
|
|
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
|
|
|
|
|
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
2021-11-19 11:13:07 -03:00
|
|
|
Debug::ProcessInspector& inspector() { return m_inspector; }
|
2020-05-04 06:23:30 -03:00
|
|
|
|
|
|
|
|
private:
|
2023-03-06 13:16:25 -03:00
|
|
|
explicit VariablesModel(Debug::ProcessInspector& inspector, Vector<NonnullOwnPtr<Debug::DebugInfo::VariableInfo>>&& variables, PtraceRegisters const& regs)
|
2020-05-08 07:32:55 -03:00
|
|
|
: m_variables(move(variables))
|
|
|
|
|
, m_regs(regs)
|
2021-11-19 11:13:07 -03:00
|
|
|
, m_inspector(inspector)
|
2020-05-08 07:32:55 -03:00
|
|
|
{
|
2023-01-20 16:06:05 -03:00
|
|
|
m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
|
2020-05-08 07:32:55 -03:00
|
|
|
}
|
2023-03-06 13:16:25 -03:00
|
|
|
Vector<NonnullOwnPtr<Debug::DebugInfo::VariableInfo>> m_variables;
|
2020-05-04 06:23:30 -03:00
|
|
|
PtraceRegisters m_regs;
|
|
|
|
|
|
|
|
|
|
GUI::Icon m_variable_icon;
|
2021-11-19 11:13:07 -03:00
|
|
|
Debug::ProcessInspector& m_inspector;
|
2020-05-04 06:23:30 -03:00
|
|
|
};
|
2020-08-17 10:22:30 -03:00
|
|
|
|
|
|
|
|
}
|