Skip to content

Commit

Permalink
Debugger: Add symbol tree widgets for functions and variables
Browse files Browse the repository at this point in the history
This adds three new tabs in the debugger: The Globals tab, the Locals
tab and the Parameters tab. In addition, it rewrites the Functions tab.

All four of these tabs use the new symbol tree widgets and the
associated model. This allows the user the inspect complex data
structures in memory with full type information.

Lastly, new dialogs have been added for creating symbols.
  • Loading branch information
chaoticgd committed Aug 26, 2024
1 parent e23df7a commit 7812cc1
Show file tree
Hide file tree
Showing 23 changed files with 5,223 additions and 391 deletions.
16 changes: 16 additions & 0 deletions pcsx2-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,22 @@ target_sources(pcsx2-qt PRIVATE
Debugger/Models/StackModel.h
Debugger/Models/SavedAddressesModel.cpp
Debugger/Models/SavedAddressesModel.h
Debugger/SymbolTree/NewSymbolDialogs.cpp
Debugger/SymbolTree/NewSymbolDialogs.h
Debugger/SymbolTree/NewSymbolDialog.ui
Debugger/SymbolTree/SymbolTreeLocation.cpp
Debugger/SymbolTree/SymbolTreeLocation.h
Debugger/SymbolTree/SymbolTreeModel.cpp
Debugger/SymbolTree/SymbolTreeModel.h
Debugger/SymbolTree/SymbolTreeNode.cpp
Debugger/SymbolTree/SymbolTreeNode.h
Debugger/SymbolTree/SymbolTreeDelegates.cpp
Debugger/SymbolTree/SymbolTreeDelegates.h
Debugger/SymbolTree/SymbolTreeWidgets.cpp
Debugger/SymbolTree/SymbolTreeWidgets.h
Debugger/SymbolTree/SymbolTreeWidget.ui
Debugger/SymbolTree/TypeString.cpp
Debugger/SymbolTree/TypeString.h
Tools/InputRecording/NewInputRecordingDlg.cpp
Tools/InputRecording/NewInputRecordingDlg.h
Tools/InputRecording/NewInputRecordingDlg.ui
Expand Down
50 changes: 50 additions & 0 deletions pcsx2-qt/Debugger/CpuWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ CpuWidget::CpuWidget(QWidget* parent, DebugInterface& cpu)
savedAddressesTableView->resizeColumnToContents(topLeft.column());
});

setupSymbolTrees();

DebuggerSettingsManager::loadGameSettings(&m_bpModel);
DebuggerSettingsManager::loadGameSettings(&m_savedAddressesModel);

Expand All @@ -135,6 +137,46 @@ CpuWidget::CpuWidget(QWidget* parent, DebugInterface& cpu)

CpuWidget::~CpuWidget() = default;

void CpuWidget::setupSymbolTrees()
{
m_ui.tabFunctions->setLayout(new QVBoxLayout());
m_ui.tabGlobalVariables->setLayout(new QVBoxLayout());
m_ui.tabLocalVariables->setLayout(new QVBoxLayout());
m_ui.tabParameterVariables->setLayout(new QVBoxLayout());

m_ui.tabFunctions->layout()->setContentsMargins(0, 0, 0, 0);
m_ui.tabGlobalVariables->layout()->setContentsMargins(0, 0, 0, 0);
m_ui.tabLocalVariables->layout()->setContentsMargins(0, 0, 0, 0);
m_ui.tabParameterVariables->layout()->setContentsMargins(0, 0, 0, 0);

m_function_tree = new FunctionTreeWidget(m_cpu);
m_global_variable_tree = new GlobalVariableTreeWidget(m_cpu);
m_local_variable_tree = new LocalVariableTreeWidget(m_cpu);
m_parameter_variable_tree = new ParameterVariableTreeWidget(m_cpu);

m_ui.tabFunctions->layout()->addWidget(m_function_tree);
m_ui.tabGlobalVariables->layout()->addWidget(m_global_variable_tree);
m_ui.tabLocalVariables->layout()->addWidget(m_local_variable_tree);
m_ui.tabParameterVariables->layout()->addWidget(m_parameter_variable_tree);

connect(m_ui.tabWidgetRegFunc, &QTabWidget::currentChanged, m_function_tree, &SymbolTreeWidget::updateModel);
connect(m_ui.tabWidget, &QTabWidget::currentChanged, m_global_variable_tree, &SymbolTreeWidget::updateModel);
connect(m_ui.tabWidget, &QTabWidget::currentChanged, m_local_variable_tree, &SymbolTreeWidget::updateModel);

connect(m_function_tree, &SymbolTreeWidget::goToInDisassembly, m_ui.disassemblyWidget, &DisassemblyWidget::gotoAddressAndSetFocus);
connect(m_global_variable_tree, &SymbolTreeWidget::goToInDisassembly, m_ui.disassemblyWidget, &DisassemblyWidget::gotoAddressAndSetFocus);
connect(m_local_variable_tree, &SymbolTreeWidget::goToInDisassembly, m_ui.disassemblyWidget, &DisassemblyWidget::gotoAddressAndSetFocus);
connect(m_parameter_variable_tree, &SymbolTreeWidget::goToInDisassembly, m_ui.disassemblyWidget, &DisassemblyWidget::gotoAddressAndSetFocus);

connect(m_function_tree, &SymbolTreeWidget::goToInMemoryView, this, &CpuWidget::onGotoInMemory);
connect(m_global_variable_tree, &SymbolTreeWidget::goToInMemoryView, this, &CpuWidget::onGotoInMemory);
connect(m_local_variable_tree, &SymbolTreeWidget::goToInMemoryView, this, &CpuWidget::onGotoInMemory);
connect(m_parameter_variable_tree, &SymbolTreeWidget::goToInMemoryView, this, &CpuWidget::onGotoInMemory);

connect(m_function_tree, &SymbolTreeWidget::nameColumnClicked, m_ui.disassemblyWidget, &DisassemblyWidget::gotoAddressAndSetFocus);
connect(m_function_tree, &SymbolTreeWidget::locationColumnClicked, m_ui.disassemblyWidget, &DisassemblyWidget::gotoAddressAndSetFocus);
}

void CpuWidget::refreshDebugger()
{
if (!m_cpu.isAlive())
Expand All @@ -144,6 +186,11 @@ void CpuWidget::refreshDebugger()
m_ui.disassemblyWidget->update();
m_ui.memoryviewWidget->update();
m_ui.memorySearchWidget->update();

m_function_tree->updateModel();
m_global_variable_tree->updateModel();
m_local_variable_tree->updateModel();
m_parameter_variable_tree->updateModel();
}

void CpuWidget::reloadCPUWidgets()
Expand All @@ -154,6 +201,9 @@ void CpuWidget::reloadCPUWidgets()
m_ui.registerWidget->update();
m_ui.disassemblyWidget->update();
m_ui.memoryviewWidget->update();

m_local_variable_tree->reset();
m_parameter_variable_tree->reset();
}

void CpuWidget::paintEvent(QPaintEvent* event)
Expand Down
8 changes: 8 additions & 0 deletions pcsx2-qt/Debugger/CpuWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Models/ThreadModel.h"
#include "Models/StackModel.h"
#include "Models/SavedAddressesModel.h"
#include "Debugger/SymbolTree/SymbolTreeWidgets.h"

#include "QtHost.h"
#include <QtWidgets/QWidget>
Expand Down Expand Up @@ -70,6 +71,8 @@ public slots:
void saveSavedAddressesToDebuggerSettings();

private:
void setupSymbolTrees();

std::vector<QTableWidget*> m_registerTableViews;

QMenu* m_stacklistContextMenu = 0;
Expand All @@ -86,4 +89,9 @@ public slots:
QSortFilterProxyModel m_threadProxyModel;
StackModel m_stackModel;
SavedAddressesModel m_savedAddressesModel;

FunctionTreeWidget* m_function_tree = nullptr;
GlobalVariableTreeWidget* m_global_variable_tree = nullptr;
LocalVariableTreeWidget* m_local_variable_tree = nullptr;
ParameterVariableTreeWidget* m_parameter_variable_tree = nullptr;
};
Loading

0 comments on commit 7812cc1

Please sign in to comment.