2022-12-24 06:51:44 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2022 PCSX2 Dev Team
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
|
|
|
|
|
|
|
#include "DebuggerWindow.h"
|
|
|
|
|
|
|
|
#include "DebugTools/DebugInterface.h"
|
|
|
|
#include "DebugTools/Breakpoints.h"
|
|
|
|
#include "VMManager.h"
|
|
|
|
#include "QtHost.h"
|
|
|
|
#include "MainWindow.h"
|
|
|
|
|
|
|
|
DebuggerWindow::DebuggerWindow(QWidget* parent)
|
|
|
|
: QMainWindow(parent)
|
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
// Easiest way to handle cross platform monospace fonts
|
|
|
|
// There are issues related to TabWidget -> Children font inheritance otherwise
|
2023-09-23 11:13:47 +00:00
|
|
|
#if defined(WIN32)
|
|
|
|
m_ui.cpuTabs->setStyleSheet(QStringLiteral("font: 8pt 'Lucida Console'"));
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
m_ui.cpuTabs->setStyleSheet(QStringLiteral("font: 10pt 'Monaco'"));
|
2022-12-24 06:51:44 +00:00
|
|
|
#else
|
2023-09-23 11:13:47 +00:00
|
|
|
m_ui.cpuTabs->setStyleSheet(QStringLiteral("font: 8pt 'Monospace'"));
|
2022-12-24 06:51:44 +00:00
|
|
|
#endif
|
|
|
|
|
2023-09-23 11:14:17 +00:00
|
|
|
connect(m_ui.actionRun, &QAction::triggered, this, &DebuggerWindow::onRunPause);
|
|
|
|
connect(m_ui.actionStepInto, &QAction::triggered, this, &DebuggerWindow::onStepInto);
|
|
|
|
connect(m_ui.actionStepOver, &QAction::triggered, this, &DebuggerWindow::onStepOver);
|
|
|
|
connect(m_ui.actionStepOut, &QAction::triggered, this, &DebuggerWindow::onStepOut);
|
2022-12-24 06:51:44 +00:00
|
|
|
|
|
|
|
connect(g_emu_thread, &EmuThread::onVMPaused, this, &DebuggerWindow::onVMStateChanged);
|
|
|
|
connect(g_emu_thread, &EmuThread::onVMResumed, this, &DebuggerWindow::onVMStateChanged);
|
|
|
|
|
|
|
|
onVMStateChanged(); // If we missed a state change while we weren't loaded
|
|
|
|
|
|
|
|
m_cpuWidget_r5900 = new CpuWidget(this, r5900Debug);
|
|
|
|
m_cpuWidget_r3000 = new CpuWidget(this, r3000Debug);
|
|
|
|
|
|
|
|
m_ui.cpuTabs->addTab(m_cpuWidget_r5900, "R5900");
|
|
|
|
m_ui.cpuTabs->addTab(m_cpuWidget_r3000, "R3000");
|
2023-01-03 05:27:05 +00:00
|
|
|
|
|
|
|
CBreakPoints::SetUpdateHandler(std::bind(&DebuggerWindow::onBreakpointsChanged, this));
|
|
|
|
|
2022-12-24 06:51:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebuggerWindow::~DebuggerWindow() = default;
|
|
|
|
|
|
|
|
void DebuggerWindow::onVMStateChanged()
|
|
|
|
{
|
|
|
|
if (!QtHost::IsVMPaused())
|
|
|
|
{
|
2023-09-23 11:14:17 +00:00
|
|
|
m_ui.actionRun->setText(tr("Pause"));
|
|
|
|
m_ui.actionRun->setIcon(QIcon::fromTheme(QStringLiteral("pause-line")));
|
|
|
|
m_ui.actionStepInto->setEnabled(false);
|
|
|
|
m_ui.actionStepOver->setEnabled(false);
|
|
|
|
m_ui.actionStepOut->setEnabled(false);
|
2022-12-24 06:51:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-09-23 11:14:17 +00:00
|
|
|
m_ui.actionRun->setText(tr("Run"));
|
|
|
|
m_ui.actionRun->setIcon(QIcon::fromTheme(QStringLiteral("play-line")));
|
|
|
|
m_ui.actionStepInto->setEnabled(true);
|
|
|
|
m_ui.actionStepOver->setEnabled(true);
|
|
|
|
m_ui.actionStepOut->setEnabled(true);
|
2023-01-15 03:29:42 +00:00
|
|
|
Host::RunOnCPUThread([] {
|
|
|
|
if (CBreakPoints::GetBreakpointTriggered())
|
|
|
|
{
|
|
|
|
CBreakPoints::ClearTemporaryBreakPoints();
|
|
|
|
CBreakPoints::SetBreakpointTriggered(false);
|
|
|
|
// Our current PC is on a breakpoint.
|
|
|
|
// When we run the core again, we want to skip this breakpoint and run
|
|
|
|
CBreakPoints::SetSkipFirst(BREAKPOINT_EE, r5900Debug.getPC());
|
|
|
|
CBreakPoints::SetSkipFirst(BREAKPOINT_IOP, r3000Debug.getPC());
|
|
|
|
}
|
|
|
|
});
|
2022-12-24 06:51:44 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerWindow::onRunPause()
|
|
|
|
{
|
2023-09-23 11:26:19 +00:00
|
|
|
g_emu_thread->setVMPaused(!QtHost::IsVMPaused());
|
2022-12-24 06:51:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerWindow::onStepInto()
|
|
|
|
{
|
|
|
|
CpuWidget* currentCpu = static_cast<CpuWidget*>(m_ui.cpuTabs->currentWidget());
|
|
|
|
currentCpu->onStepInto();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerWindow::onStepOver()
|
|
|
|
{
|
|
|
|
CpuWidget* currentCpu = static_cast<CpuWidget*>(m_ui.cpuTabs->currentWidget());
|
|
|
|
currentCpu->onStepOver();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerWindow::onStepOut()
|
|
|
|
{
|
|
|
|
CpuWidget* currentCpu = static_cast<CpuWidget*>(m_ui.cpuTabs->currentWidget());
|
|
|
|
currentCpu->onStepOut();
|
|
|
|
}
|
2023-01-03 05:27:05 +00:00
|
|
|
|
|
|
|
void DebuggerWindow::onBreakpointsChanged()
|
|
|
|
{
|
|
|
|
m_cpuWidget_r5900->reloadCPUWidgets();
|
|
|
|
m_cpuWidget_r3000->reloadCPUWidgets();
|
|
|
|
}
|