This commit is contained in:
Nayla Hanegan 2024-05-12 02:17:59 -04:00
commit 98c174edc4
520 changed files with 74815 additions and 58942 deletions

View file

@ -729,9 +729,7 @@ void AssemblerWidget::NewEditor(const QString& path)
if (!path.isEmpty() && !new_editor->LoadFromPath())
{
ModalMessageBox::warning(this, tr("Failed to open file"),
tr("Failed to read the contents of file\n\n"
"\"%1\"")
.arg(path));
tr("Failed to read the contents of file:\n%1").arg(path));
delete new_editor;
return;
}

View file

@ -42,6 +42,7 @@
#include "Core/System.h"
#include "DolphinQt/Debugger/BranchWatchTableModel.h"
#include "DolphinQt/Debugger/CodeWidget.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
@ -194,30 +195,33 @@ void BranchWatchProxyModel::SetInspected(const QModelIndex& index)
}
BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
CodeWidget* code_widget, QWidget* parent)
PPCSymbolDB& ppc_symbol_db, CodeWidget* code_widget,
QWidget* parent)
: QDialog(parent), m_system(system), m_branch_watch(branch_watch), m_code_widget(code_widget)
{
setWindowTitle(tr("Branch Watch Tool"));
setWindowFlags((windowFlags() | Qt::WindowMinMaxButtonsHint) & ~Qt::WindowContextHelpButtonHint);
SetQWidgetWindowDecorations(this);
setLayout([this]() {
auto* layout = new QVBoxLayout;
setLayout([this, &ppc_symbol_db]() {
auto* main_layout = new QVBoxLayout;
// Controls Toolbar (widgets are added later)
layout->addWidget(m_control_toolbar = new QToolBar);
main_layout->addWidget(m_control_toolbar = new QToolBar);
// Branch Watch Table
layout->addWidget(m_table_view = [this]() {
main_layout->addWidget(m_table_view = [this, &ppc_symbol_db]() {
const auto& ui_settings = Settings::Instance();
m_table_proxy = new BranchWatchProxyModel(m_branch_watch);
m_table_proxy->setSourceModel(m_table_model =
new BranchWatchTableModel(m_system, m_branch_watch));
m_table_proxy->setSourceModel(
m_table_model = new BranchWatchTableModel(m_system, m_branch_watch, ppc_symbol_db));
m_table_proxy->setSortRole(UserRole::SortRole);
m_table_model->setFont(ui_settings.GetDebugFont());
connect(&ui_settings, &Settings::DebugFontChanged, m_table_model,
&BranchWatchTableModel::setFont);
connect(Host::GetInstance(), &Host::PPCSymbolsChanged, m_table_model,
&BranchWatchTableModel::UpdateSymbols);
auto* const table_view = new QTableView;
table_view->setModel(m_table_proxy);
@ -271,7 +275,7 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
}();
// Menu Bar
layout->setMenuBar([this]() {
main_layout->setMenuBar([this]() {
QMenuBar* const menu_bar = new QMenuBar;
menu_bar->setNativeMenuBar(false);
@ -308,7 +312,7 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
}());
// Status Bar
layout->addWidget(m_status_bar = []() {
main_layout->addWidget(m_status_bar = []() {
auto* const status_bar = new QStatusBar;
status_bar->setSizeGripEnabled(false);
return status_bar;
@ -394,7 +398,8 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
m_control_toolbar->addWidget([this]() {
auto* const layout = new QGridLayout;
const auto routine = [this, layout](const QString& text, int row, int column, int width,
const auto routine = [this, layout](const QString& placeholder_text, int row, int column,
int width,
void (BranchWatchProxyModel::*slot)(const QString&)) {
QLineEdit* const line_edit = new QLineEdit;
layout->addWidget(line_edit, row, column, 1, width);
@ -402,7 +407,7 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
(m_table_proxy->*slot)(text);
UpdateStatus();
});
line_edit->setPlaceholderText(text);
line_edit->setPlaceholderText(placeholder_text);
return line_edit;
};
@ -487,7 +492,7 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
connect(m_table_proxy, &BranchWatchProxyModel::layoutChanged, this,
&BranchWatchDialog::UpdateStatus);
return layout;
return main_layout;
}());
// FIXME: On Linux, Qt6 has recently been resetting column widths to their defaults in many
@ -504,15 +509,9 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
restoreGeometry(settings.value(QStringLiteral("branchwatchdialog/geometry")).toByteArray());
}
void BranchWatchDialog::done(int r)
BranchWatchDialog::~BranchWatchDialog()
{
if (m_timer->isActive())
m_timer->stop();
auto& settings = Settings::GetQSettings();
settings.setValue(QStringLiteral("branchwatchdialog/geometry"), saveGeometry());
settings.setValue(QStringLiteral("branchwatchdialog/tableheader/state"),
m_table_view->horizontalHeader()->saveState());
QDialog::done(r);
SaveSettings();
}
static constexpr int BRANCH_WATCH_TOOL_TIMER_DELAY_MS = 100;
@ -523,18 +522,18 @@ static bool TimerCondition(const Core::BranchWatch& branch_watch, Core::State st
return branch_watch.GetRecordingActive() && state > Core::State::Paused;
}
int BranchWatchDialog::exec()
void BranchWatchDialog::hideEvent(QHideEvent* event)
{
if (TimerCondition(m_branch_watch, Core::GetState()))
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
return QDialog::exec();
if (m_timer->isActive())
m_timer->stop();
QDialog::hideEvent(event);
}
void BranchWatchDialog::open()
void BranchWatchDialog::showEvent(QShowEvent* event)
{
if (TimerCondition(m_branch_watch, Core::GetState()))
if (TimerCondition(m_branch_watch, Core::GetState(m_system)))
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
QDialog::open();
QDialog::showEvent(event);
}
void BranchWatchDialog::OnStartPause(bool checked)
@ -545,7 +544,7 @@ void BranchWatchDialog::OnStartPause(bool checked)
m_btn_start_pause->setText(tr("Pause Branch Watch"));
// Restart the timer if the situation calls for it, but always turn off single-shot.
m_timer->setSingleShot(false);
if (Core::GetState() > Core::State::Paused)
if (Core::GetState(m_system) > Core::State::Paused)
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
}
else
@ -553,7 +552,7 @@ void BranchWatchDialog::OnStartPause(bool checked)
m_branch_watch.Pause();
m_btn_start_pause->setText(tr("Start Branch Watch"));
// Schedule one last update in the future in case Branch Watch is in the middle of a hit.
if (Core::GetState() > Core::State::Paused)
if (Core::GetState(m_system) > Core::State::Paused)
m_timer->setInterval(BRANCH_WATCH_TOOL_TIMER_PAUSE_ONESHOT_MS);
m_timer->setSingleShot(true);
}
@ -646,7 +645,7 @@ void BranchWatchDialog::OnCodePathNotTaken()
void BranchWatchDialog::OnBranchWasOverwritten()
{
if (Core::GetState() == Core::State::Uninitialized)
if (Core::GetState(m_system) == Core::State::Uninitialized)
{
ModalMessageBox::warning(this, tr("Error"), tr("Core is uninitialized."));
return;
@ -661,7 +660,7 @@ void BranchWatchDialog::OnBranchWasOverwritten()
void BranchWatchDialog::OnBranchNotOverwritten()
{
if (Core::GetState() == Core::State::Uninitialized)
if (Core::GetState(m_system) == Core::State::Uninitialized)
{
ModalMessageBox::warning(this, tr("Error"), tr("Core is uninitialized."));
return;
@ -758,6 +757,8 @@ void BranchWatchDialog::OnToggleAutoSave(bool checked)
return;
const QString filepath = DolphinFileDialog::getSaveFileName(
// i18n: If the user selects a file, Branch Watch will save to that file.
// If the user presses Cancel, Branch Watch will save to a file in the user folder.
this, tr("Select Branch Watch snapshot auto-save file (for user folder location, cancel)"),
QString::fromStdString(File::GetUserPath(D_DUMPDEBUG_BRANCHWATCH_IDX)),
tr("Text file (*.txt);;All Files (*)"));
@ -805,13 +806,15 @@ void BranchWatchDialog::OnTableContextMenu(const QPoint& pos)
QModelIndexList index_list = m_table_view->selectionModel()->selectedRows(index.column());
QMenu* const menu = new QMenu;
menu->setAttribute(Qt::WA_DeleteOnClose, true);
menu->addAction(tr("&Delete"), [this, index_list]() { OnTableDelete(std::move(index_list)); });
switch (index.column())
{
case Column::Origin:
{
QAction* const action = menu->addAction(tr("Insert &NOP"));
if (Core::GetState() != Core::State::Uninitialized)
if (Core::GetState(m_system) != Core::State::Uninitialized)
connect(action, &QAction::triggered,
[this, index_list]() { OnTableSetNOP(std::move(index_list)); });
else
@ -825,9 +828,9 @@ void BranchWatchDialog::OnTableContextMenu(const QPoint& pos)
{
QAction* const action = menu->addAction(tr("Insert &BLR"));
const bool enable_action =
Core::GetState() != Core::State::Uninitialized &&
std::all_of(index_list.begin(), index_list.end(), [this](const QModelIndex& index) {
const QModelIndex sibling = index.siblingAtColumn(Column::Instruction);
Core::GetState(m_system) != Core::State::Uninitialized &&
std::all_of(index_list.begin(), index_list.end(), [this](const QModelIndex& idx) {
const QModelIndex sibling = idx.siblingAtColumn(Column::Instruction);
return BranchSavesLR(m_table_proxy->data(sibling, UserRole::ClickRole).value<u32>());
});
if (enable_action)
@ -845,9 +848,9 @@ void BranchWatchDialog::OnTableContextMenu(const QPoint& pos)
{
QAction* const action = menu->addAction(tr("Insert &BLR at start"));
const bool enable_action =
Core::GetState() != Core::State::Uninitialized &&
std::all_of(index_list.begin(), index_list.end(), [this](const QModelIndex& index) {
return m_table_proxy->data(index, UserRole::ClickRole).isValid();
Core::GetState(m_system) != Core::State::Uninitialized &&
std::all_of(index_list.begin(), index_list.end(), [this](const QModelIndex& idx) {
return m_table_proxy->data(idx, UserRole::ClickRole).isValid();
});
if (enable_action)
connect(action, &QAction::triggered, [this, index_list = std::move(index_list)]() {
@ -927,6 +930,14 @@ void BranchWatchDialog::OnTableCopyAddress(QModelIndexList index_list)
QApplication::clipboard()->setText(text);
}
void BranchWatchDialog::SaveSettings()
{
auto& settings = Settings::GetQSettings();
settings.setValue(QStringLiteral("branchwatchdialog/geometry"), saveGeometry());
settings.setValue(QStringLiteral("branchwatchdialog/tableheader/state"),
m_table_view->horizontalHeader()->saveState());
}
void BranchWatchDialog::Update()
{
if (m_branch_watch.GetRecordingPhase() == Core::BranchWatch::Phase::Blacklist)
@ -934,11 +945,6 @@ void BranchWatchDialog::Update()
m_table_model->UpdateHits();
}
void BranchWatchDialog::UpdateSymbols()
{
m_table_model->UpdateSymbols();
}
void BranchWatchDialog::UpdateStatus()
{
switch (m_branch_watch.GetRecordingPhase())

View file

@ -17,6 +17,8 @@ class BranchWatch;
class CPUThreadGuard;
class System;
} // namespace Core
class PPCSymbolDB;
class BranchWatchProxyModel;
class BranchWatchTableModel;
class CodeWidget;
@ -48,10 +50,13 @@ class BranchWatchDialog : public QDialog
public:
explicit BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
CodeWidget* code_widget, QWidget* parent = nullptr);
void done(int r) override;
int exec() override;
void open() override;
PPCSymbolDB& ppc_symbol_db, CodeWidget* code_widget,
QWidget* parent = nullptr);
~BranchWatchDialog() override;
protected:
void hideEvent(QHideEvent* event) override;
void showEvent(QShowEvent* event) override;
private:
void OnStartPause(bool checked);
@ -82,11 +87,11 @@ private:
void OnTableSetNOP(QModelIndexList index_list);
void OnTableCopyAddress(QModelIndexList index_list);
void SaveSettings();
public:
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
void Update();
// TODO: There seems to be a lack of a ubiquitous signal for when symbols change.
void UpdateSymbols();
private:
void UpdateStatus();

View file

@ -285,8 +285,8 @@ void BranchWatchTableModel::PrefetchSymbols()
for (const Core::BranchWatch::Selection::value_type& value : selection)
{
const Core::BranchWatch::Collection::value_type* const kv = value.collection_ptr;
m_symbol_list.emplace_back(g_symbolDB.GetSymbolFromAddr(kv->first.origin_addr),
g_symbolDB.GetSymbolFromAddr(kv->first.destin_addr));
m_symbol_list.emplace_back(m_ppc_symbol_db.GetSymbolFromAddr(kv->first.origin_addr),
m_ppc_symbol_db.GetSymbolFromAddr(kv->first.destin_addr));
}
}

View file

@ -18,6 +18,7 @@ class BranchWatch;
class CPUThreadGuard;
class System;
} // namespace Core
class PPCSymbolDB;
namespace BranchWatchTableModelColumn
{
@ -69,8 +70,9 @@ public:
using SymbolList = QList<SymbolListValueType>;
explicit BranchWatchTableModel(Core::System& system, Core::BranchWatch& branch_watch,
QObject* parent = nullptr)
: QAbstractTableModel(parent), m_system(system), m_branch_watch(branch_watch)
PPCSymbolDB& ppc_symbol_db, QObject* parent = nullptr)
: QAbstractTableModel(parent), m_system(system), m_branch_watch(branch_watch),
m_ppc_symbol_db(ppc_symbol_db)
{
}
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
@ -113,6 +115,7 @@ private:
Core::System& m_system;
Core::BranchWatch& m_branch_watch;
PPCSymbolDB& m_ppc_symbol_db;
SymbolList m_symbol_list;
mutable QFont m_font;

View file

@ -331,7 +331,12 @@ void BreakpointDialog::ShowConditionHelp()
"\n"
"Registers that can be referenced:\n"
"GPRs : r0..r31\n"
"FPRs : f0..f31\n LR, CTR, PC\n"
"FPRs : f0..f31\n"
"SPRs : xer, lr, ctr, dsisr, dar, dec, sdr1, srr0, srr1, tbl, tbu, pvr, sprg0..sprg3, ear, "
"ibat0u..ibat7u, ibat0l..ibat7l, dbat0u..dbat7u, dbat0l..dbat07, gqr0..gqr7, hid0, hid1, "
"hid2, hid4, iabr, dabr, wpar, dmau, dmal, ecid_u, ecid_m, ecid_l, upmc1..upmc4, usia, sia, "
"l2cr, ictc, mmcr0, mmcr1, pmc1..pmc4, thrm1..thrm3\n"
"Other : pc, msr\n"
"\n"
"Functions:\n"
"Set a register: r1 = 8\n"

View file

@ -150,7 +150,7 @@ void BreakpointWidget::UpdateButtonsEnabled()
if (!isVisible())
return;
const bool is_initialised = Core::GetState() != Core::State::Uninitialized;
const bool is_initialised = Core::GetState(m_system) != Core::State::Uninitialized;
m_new->setEnabled(is_initialised);
m_load->setEnabled(is_initialised);
m_save->setEnabled(is_initialised);
@ -178,6 +178,7 @@ void BreakpointWidget::Update()
auto& power_pc = m_system.GetPowerPC();
auto& breakpoints = power_pc.GetBreakPoints();
auto& memchecks = power_pc.GetMemChecks();
auto& ppc_symbol_db = power_pc.GetSymbolDB();
// Breakpoints
for (const auto& bp : breakpoints.GetBreakPoints())
@ -192,11 +193,8 @@ void BreakpointWidget::Update()
m_table->setItem(i, 0, active);
m_table->setItem(i, 1, create_item(QStringLiteral("BP")));
if (g_symbolDB.GetSymbolFromAddr(bp.address))
{
m_table->setItem(i, 2,
create_item(QString::fromStdString(g_symbolDB.GetDescription(bp.address))));
}
if (const Common::Symbol* const symbol = ppc_symbol_db.GetSymbolFromAddr(bp.address))
m_table->setItem(i, 2, create_item(QString::fromStdString(symbol->name)));
m_table->setItem(i, 3,
create_item(QStringLiteral("%1").arg(bp.address, 8, 16, QLatin1Char('0'))));
@ -233,11 +231,8 @@ void BreakpointWidget::Update()
m_table->setItem(i, 0, active);
m_table->setItem(i, 1, create_item(QStringLiteral("MBP")));
if (g_symbolDB.GetSymbolFromAddr(mbp.start_address))
{
m_table->setItem(
i, 2, create_item(QString::fromStdString(g_symbolDB.GetDescription(mbp.start_address))));
}
if (const Common::Symbol* const symbol = ppc_symbol_db.GetSymbolFromAddr(mbp.start_address))
m_table->setItem(i, 2, create_item(QString::fromStdString(symbol->name)));
if (mbp.is_ranged)
{
@ -314,6 +309,7 @@ void BreakpointWidget::OnClear()
void BreakpointWidget::OnNewBreakpoint()
{
BreakpointDialog* dialog = new BreakpointDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
SetQWidgetWindowDecorations(dialog);
dialog->exec();
}
@ -324,6 +320,7 @@ void BreakpointWidget::OnEditBreakpoint(u32 address, bool is_instruction_bp)
{
auto* dialog =
new BreakpointDialog(this, m_system.GetPowerPC().GetBreakPoints().GetBreakpoint(address));
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
SetQWidgetWindowDecorations(dialog);
dialog->exec();
}
@ -331,6 +328,7 @@ void BreakpointWidget::OnEditBreakpoint(u32 address, bool is_instruction_bp)
{
auto* dialog =
new BreakpointDialog(this, m_system.GetPowerPC().GetMemChecks().GetMemCheck(address));
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
SetQWidgetWindowDecorations(dialog);
dialog->exec();
}
@ -392,6 +390,7 @@ void BreakpointWidget::OnContextMenu()
const auto is_memory_breakpoint = selected_item->data(IS_MEMCHECK_ROLE).toBool();
auto* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose, true);
if (!is_memory_breakpoint)
{

View file

@ -38,6 +38,7 @@
#include "DolphinQt/Debugger/AssembleInstructionDialog.h"
#include "DolphinQt/Debugger/PatchInstructionDialog.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/QtUtils/FromStdString.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"
@ -138,7 +139,8 @@ constexpr int CODE_VIEW_COLUMN_DESCRIPTION = 4;
constexpr int CODE_VIEW_COLUMN_BRANCH_ARROWS = 5;
constexpr int CODE_VIEW_COLUMNCOUNT = 6;
CodeViewWidget::CodeViewWidget() : m_system(Core::System::GetInstance())
CodeViewWidget::CodeViewWidget()
: m_system(Core::System::GetInstance()), m_ppc_symbol_db(m_system.GetPPCSymbolDB())
{
setColumnCount(CODE_VIEW_COLUMNCOUNT);
setShowGrid(false);
@ -171,9 +173,8 @@ CodeViewWidget::CodeViewWidget() : m_system(Core::System::GetInstance())
connect(this, &CodeViewWidget::customContextMenuRequested, this, &CodeViewWidget::OnContextMenu);
connect(this, &CodeViewWidget::itemSelectionChanged, this, &CodeViewWidget::OnSelectionChanged);
connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &QWidget::setFont);
connect(&Settings::Instance(), &Settings::DebugFontChanged, this,
&CodeViewWidget::FontBasedSizing);
&CodeViewWidget::OnDebugFontChanged);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
m_address = m_system.GetPPCState().pc;
@ -183,6 +184,8 @@ CodeViewWidget::CodeViewWidget() : m_system(Core::System::GetInstance())
m_address = m_system.GetPPCState().pc;
Update();
});
connect(Host::GetInstance(), &Host::PPCSymbolsChanged, this,
qOverload<>(&CodeViewWidget::Update));
connect(&Settings::Instance(), &Settings::ThemeChanged, this,
qOverload<>(&CodeViewWidget::Update));
@ -207,7 +210,7 @@ void CodeViewWidget::FontBasedSizing()
// just text width is too small with some fonts, so increase by a bit
constexpr int extra_text_width = 8;
const QFontMetrics fm(Settings::Instance().GetDebugFont());
const QFontMetrics fm(font());
const int rowh = fm.height() + 1;
verticalHeader()->setMaximumSectionSize(rowh);
@ -265,7 +268,7 @@ void CodeViewWidget::Update()
if (m_updating)
return;
if (Core::GetState() == Core::State::Paused)
if (Core::GetState(m_system) == Core::State::Paused)
{
Core::CPUThreadGuard guard(m_system);
Update(&guard);
@ -324,7 +327,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
std::string ins = (split == std::string::npos ? disas : disas.substr(0, split));
std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
std::string desc = debug_interface.GetDescription(addr);
const std::string_view desc = debug_interface.GetDescription(addr);
// Adds whitespace and a minimum size to ins and param. Helps to prevent frequent resizing while
// scrolling.
@ -332,7 +335,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
QStringLiteral("%1").arg(QString::fromStdString(ins), -7, QLatin1Char(' '));
const QString param_formatted =
QStringLiteral("%1").arg(QString::fromStdString(param), -19, QLatin1Char(' '));
const QString desc_formatted = QStringLiteral("%1 ").arg(QString::fromStdString(desc));
const QString desc_formatted = QStringLiteral("%1 ").arg(QtUtils::FromStdString(desc));
auto* ins_item = new QTableWidgetItem(ins_formatted);
auto* param_item = new QTableWidgetItem(param_formatted);
@ -372,7 +375,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
branch.is_link = IsBranchInstructionWithLink(ins);
description_item->setText(
tr("--> %1").arg(QString::fromStdString(debug_interface.GetDescription(branch_addr))));
tr("--> %1").arg(QtUtils::FromStdString(debug_interface.GetDescription(branch_addr))));
param_item->setForeground(dark_theme ? QColor(255, 135, 255) : Qt::magenta);
}
@ -382,7 +385,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
if (debug_interface.IsBreakpoint(addr))
{
auto icon = Resources::GetThemeIcon("debugger_breakpoint").pixmap(QSize(rowh - 2, rowh - 2));
if (!m_system.GetPowerPC().GetBreakPoints().IsBreakPointEnable(addr))
if (!power_pc.GetBreakPoints().IsBreakPointEnable(addr))
{
QPixmap disabled_icon(icon.size());
disabled_icon.fill(Qt::transparent);
@ -410,7 +413,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
CalculateBranchIndentation();
g_symbolDB.FillInCallers();
m_ppc_symbol_db.FillInCallers();
repaint();
m_updating = false;
@ -555,13 +558,14 @@ void CodeViewWidget::ReplaceAddress(u32 address, ReplaceWith replace)
void CodeViewWidget::OnContextMenu()
{
QMenu* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose, true);
const bool running = Core::GetState() != Core::State::Uninitialized;
const bool paused = Core::GetState() == Core::State::Paused;
const bool running = Core::GetState(m_system) != Core::State::Uninitialized;
const bool paused = Core::GetState(m_system) == Core::State::Paused;
const u32 addr = GetContextAddress();
bool has_symbol = g_symbolDB.GetSymbolFromAddr(addr);
const bool has_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
auto* follow_branch_action =
menu->addAction(tr("Follow &branch"), this, &CodeViewWidget::OnFollowBranch);
@ -744,6 +748,12 @@ void CodeViewWidget::AutoStep(CodeTrace::AutoStop option)
} while (msgbox.clickedButton() == (QAbstractButton*)run_button);
}
void CodeViewWidget::OnDebugFontChanged(const QFont& font)
{
setFont(font);
FontBasedSizing();
}
void CodeViewWidget::OnCopyAddress()
{
const u32 addr = GetContextAddress();
@ -753,7 +763,7 @@ void CodeViewWidget::OnCopyAddress()
void CodeViewWidget::OnCopyTargetAddress()
{
if (Core::GetState() != Core::State::Paused)
if (Core::GetState(m_system) != Core::State::Paused)
return;
const u32 addr = GetContextAddress();
@ -783,7 +793,7 @@ void CodeViewWidget::OnShowInMemory()
void CodeViewWidget::OnShowTargetInMemory()
{
if (Core::GetState() != Core::State::Paused)
if (Core::GetState(m_system) != Core::State::Paused)
return;
const u32 addr = GetContextAddress();
@ -819,7 +829,7 @@ void CodeViewWidget::OnCopyFunction()
{
const u32 address = GetContextAddress();
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(address);
if (!symbol)
return;
@ -877,9 +887,8 @@ void CodeViewWidget::OnAddFunction()
Core::CPUThreadGuard guard(m_system);
g_symbolDB.AddFunction(guard, addr);
emit SymbolsChanged();
Update(&guard);
m_ppc_symbol_db.AddFunction(guard, addr);
emit Host::GetInstance()->PPCSymbolsChanged();
}
void CodeViewWidget::OnInsertBLR()
@ -915,7 +924,7 @@ void CodeViewWidget::OnRenameSymbol()
{
const u32 addr = GetContextAddress();
Common::Symbol* const symbol = g_symbolDB.GetSymbolFromAddr(addr);
Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (!symbol)
return;
@ -928,8 +937,7 @@ void CodeViewWidget::OnRenameSymbol()
if (good && !name.isEmpty())
{
symbol->Rename(name.toStdString());
emit SymbolsChanged();
Update();
emit Host::GetInstance()->PPCSymbolsChanged();
}
}
@ -950,7 +958,7 @@ void CodeViewWidget::OnSetSymbolSize()
{
const u32 addr = GetContextAddress();
Common::Symbol* const symbol = g_symbolDB.GetSymbolFromAddr(addr);
Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (!symbol)
return;
@ -967,15 +975,14 @@ void CodeViewWidget::OnSetSymbolSize()
Core::CPUThreadGuard guard(m_system);
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, size);
emit SymbolsChanged();
Update(&guard);
emit Host::GetInstance()->PPCSymbolsChanged();
}
void CodeViewWidget::OnSetSymbolEndAddress()
{
const u32 addr = GetContextAddress();
Common::Symbol* const symbol = g_symbolDB.GetSymbolFromAddr(addr);
Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (!symbol)
return;
@ -995,8 +1002,7 @@ void CodeViewWidget::OnSetSymbolEndAddress()
Core::CPUThreadGuard guard(m_system);
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, address - symbol->address);
emit SymbolsChanged();
Update(&guard);
emit Host::GetInstance()->PPCSymbolsChanged();
}
void CodeViewWidget::OnReplaceInstruction()

View file

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
#include "Core/Debugger/CodeTrace.h"
class QFont;
class QKeyEvent;
class QMouseEvent;
class QResizeEvent;
@ -23,6 +24,7 @@ class System;
struct CodeViewBranch;
class BranchDisplayDelegate;
class PPCSymbolDB;
class CodeViewWidget : public QTableWidget
{
@ -55,7 +57,6 @@ public:
signals:
void RequestPPCComparison(u32 addr);
void ShowMemory(u32 address);
void SymbolsChanged();
void BreakpointsChanged();
void UpdateCodeWidget();
@ -77,6 +78,7 @@ private:
void OnContextMenu();
void AutoStep(CodeTrace::AutoStop option = CodeTrace::AutoStop::Always);
void OnDebugFontChanged(const QFont& font);
void OnFollowBranch();
void OnCopyAddress();
void OnCopyTargetAddress();
@ -102,6 +104,7 @@ private:
void CalculateBranchIndentation();
Core::System& m_system;
PPCSymbolDB& m_ppc_symbol_db;
bool m_updating = false;

View file

@ -38,8 +38,7 @@ static const QString BOX_SPLITTER_STYLESHEET = QStringLiteral(
CodeWidget::CodeWidget(QWidget* parent)
: QDockWidget(parent), m_system(Core::System::GetInstance()),
m_branch_watch_dialog(
new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(), this))
m_ppc_symbol_db(m_system.GetPPCSymbolDB())
{
setWindowTitle(tr("Code"));
setObjectName(QStringLiteral("code"));
@ -61,13 +60,11 @@ CodeWidget::CodeWidget(QWidget* parent)
[this](bool visible) { setHidden(!visible); });
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, [this] {
if (Core::GetState() == Core::State::Paused)
if (Core::GetState(m_system) == Core::State::Paused)
SetAddress(m_system.GetPPCState().pc, CodeViewWidget::SetAddressUpdate::WithoutUpdate);
Update();
});
connect(Host::GetInstance(), &Host::NotifyMapLoaded, this, &CodeWidget::UpdateSymbols);
connect(&Settings::Instance(), &Settings::DebugModeToggled, this,
[this](bool enabled) { setHidden(!enabled || !Settings::Instance().IsCodeVisible()); });
@ -174,13 +171,11 @@ void CodeWidget::ConnectWidgets()
connect(m_search_address, &QLineEdit::returnPressed, this, &CodeWidget::OnSearchAddress);
connect(m_search_symbols, &QLineEdit::textChanged, this, &CodeWidget::OnSearchSymbols);
connect(m_search_calls, &QLineEdit::textChanged, this, [this]() {
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
if (symbol)
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
UpdateFunctionCalls(symbol);
});
connect(m_search_callers, &QLineEdit::textChanged, this, [this]() {
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
if (symbol)
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
UpdateFunctionCallers(symbol);
});
connect(m_search_callstack, &QLineEdit::textChanged, this, &CodeWidget::UpdateCallstack);
@ -194,16 +189,7 @@ void CodeWidget::ConnectWidgets()
connect(m_function_callers_list, &QListWidget::itemPressed, this,
&CodeWidget::OnSelectFunctionCallers);
connect(m_code_view, &CodeViewWidget::SymbolsChanged, this, [this]() {
UpdateCallstack();
UpdateSymbols();
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
if (symbol)
{
UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol);
}
});
connect(Host::GetInstance(), &Host::PPCSymbolsChanged, this, &CodeWidget::OnPPCSymbolsChanged);
connect(m_code_view, &CodeViewWidget::BreakpointsChanged, this,
[this] { emit BreakpointsChanged(); });
connect(m_code_view, &CodeViewWidget::UpdateCodeWidget, this, &CodeWidget::Update);
@ -215,11 +201,27 @@ void CodeWidget::ConnectWidgets()
void CodeWidget::OnBranchWatchDialog()
{
m_branch_watch_dialog->open();
if (m_branch_watch_dialog == nullptr)
{
m_branch_watch_dialog = new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(),
m_ppc_symbol_db, this, this);
}
m_branch_watch_dialog->show();
m_branch_watch_dialog->raise();
m_branch_watch_dialog->activateWindow();
}
void CodeWidget::OnPPCSymbolsChanged()
{
UpdateSymbols();
UpdateCallstack();
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
{
UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol);
}
}
void CodeWidget::OnSearchAddress()
{
bool good = true;
@ -258,7 +260,7 @@ void CodeWidget::OnSelectSymbol()
return;
const u32 address = items[0]->data(Qt::UserRole).toUInt();
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(address);
m_code_view->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate);
UpdateCallstack();
@ -319,7 +321,7 @@ void CodeWidget::Update()
if (!isVisible())
return;
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress());
UpdateCallstack();
@ -337,17 +339,11 @@ void CodeWidget::UpdateCallstack()
{
m_callstack_list->clear();
if (Core::GetState() != Core::State::Paused)
if (Core::GetState(m_system) != Core::State::Paused)
return;
std::vector<Dolphin_Debugger::CallstackEntry> stack;
const bool success = [this, &stack] {
Core::CPUThreadGuard guard(m_system);
return Dolphin_Debugger::GetCallstack(guard, stack);
}();
if (!success)
if (!Dolphin_Debugger::GetCallstack(Core::CPUThreadGuard{m_system}, stack))
{
m_callstack_list->addItem(tr("Invalid callstack"));
return;
@ -375,7 +371,7 @@ void CodeWidget::UpdateSymbols()
m_symbols_list->selectedItems()[0]->text();
m_symbols_list->clear();
for (const auto& symbol : g_symbolDB.Symbols())
for (const auto& symbol : m_ppc_symbol_db.Symbols())
{
QString name = QString::fromStdString(symbol.second.name);
@ -394,10 +390,6 @@ void CodeWidget::UpdateSymbols()
}
m_symbols_list->sortItems();
// TODO: There seems to be a lack of a ubiquitous signal for when symbols change.
// This is the best location to catch the signals from MenuBar and CodeViewWidget.
m_branch_watch_dialog->UpdateSymbols();
}
void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
@ -408,7 +400,7 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
for (const auto& call : symbol->calls)
{
const u32 addr = call.function;
const Common::Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);
const Common::Symbol* const call_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (call_symbol)
{
@ -433,7 +425,7 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
for (const auto& caller : symbol->callers)
{
const u32 addr = caller.call_address;
const Common::Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);
const Common::Symbol* const caller_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (caller_symbol)
{
@ -470,7 +462,8 @@ void CodeWidget::Step()
// Will get a UpdateDisasmDialog(), don't update the GUI here.
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
m_branch_watch_dialog->Update();
if (m_branch_watch_dialog != nullptr)
m_branch_watch_dialog->Update();
}
void CodeWidget::StepOver()

View file

@ -26,6 +26,7 @@ namespace Core
{
class System;
}
class PPCSymbolDB;
class CodeWidget : public QDockWidget
{
@ -60,6 +61,7 @@ private:
void UpdateFunctionCalls(const Common::Symbol* symbol);
void UpdateFunctionCallers(const Common::Symbol* symbol);
void OnPPCSymbolsChanged();
void OnSearchAddress();
void OnSearchSymbols();
void OnSelectSymbol();
@ -71,8 +73,9 @@ private:
void showEvent(QShowEvent* event) override;
Core::System& m_system;
PPCSymbolDB& m_ppc_symbol_db;
BranchWatchDialog* m_branch_watch_dialog;
BranchWatchDialog* m_branch_watch_dialog = nullptr;
QLineEdit* m_search_address;
QPushButton* m_branch_watch;

View file

@ -14,6 +14,7 @@
#include "Common/GekkoDisassembler.h"
#include "Core/Core.h"
#include "Core/PowerPC/PPCAnalyst.h"
#include "Core/System.h"
#include "UICommon/Disassembler.h"
#include "DolphinQt/Host.h"
@ -136,7 +137,7 @@ void JITWidget::Update()
if (!isVisible())
return;
if (!m_address || (Core::GetState() != Core::State::Paused))
if (!m_address || (Core::GetState(Core::System::GetInstance()) != Core::State::Paused))
{
m_ppc_asm_widget->setHtml(QStringLiteral("<i>%1</i>").arg(tr("(ppc)")));
m_host_asm_widget->setHtml(QStringLiteral("<i>%1</i>").arg(tr("(host)")));

View file

@ -3,6 +3,9 @@
#include "DolphinQt/Debugger/MemoryViewWidget.h"
#include <bit>
#include <cmath>
#include <QApplication>
#include <QClipboard>
#include <QHBoxLayout>
@ -14,10 +17,10 @@
#include <QTableWidget>
#include <QtGlobal>
#include <cmath>
#include <fmt/printf.h>
#include "Common/Align.h"
#include "Common/BitUtils.h"
#include "Common/FloatUtils.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
@ -154,7 +157,7 @@ public:
u32 end_address = address + static_cast<u32>(bytes.size()) - 1;
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_view->GetAddressSpace());
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_view->m_system);
if (!bytes.empty() && accessors->IsValidAddress(guard, address) &&
accessors->IsValidAddress(guard, end_address))
@ -170,8 +173,8 @@ private:
MemoryViewWidget* m_view;
};
MemoryViewWidget::MemoryViewWidget(QWidget* parent)
: QWidget(parent), m_system(Core::System::GetInstance())
MemoryViewWidget::MemoryViewWidget(Core::System& system, QWidget* parent)
: QWidget(parent), m_system(system)
{
auto* layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
@ -202,18 +205,18 @@ MemoryViewWidget::MemoryViewWidget(QWidget* parent)
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &MemoryViewWidget::Update);
// Also calls create table.
UpdateFont();
UpdateFont(Settings::Instance().GetDebugFont());
}
void MemoryViewWidget::UpdateFont()
void MemoryViewWidget::UpdateFont(const QFont& font)
{
const QFontMetrics fm(Settings::Instance().GetDebugFont());
const QFontMetrics fm(font);
m_font_vspace = fm.lineSpacing() + 4;
// BoundingRect is too unpredictable, a custom one would be needed for each view type. Different
// fonts have wildly different spacing between two characters and horizontalAdvance includes
// spacing.
m_font_width = fm.horizontalAdvance(QLatin1Char('0'));
m_table->setFont(Settings::Instance().GetDebugFont());
m_table->setFont(font);
CreateTable();
}
@ -441,9 +444,9 @@ void MemoryViewWidget::UpdateColumns()
if (m_table->item(1, 1) == nullptr)
return;
if (Core::GetState() == Core::State::Paused)
if (Core::GetState(m_system) == Core::State::Paused)
{
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_system);
UpdateColumns(&guard);
}
else
@ -520,11 +523,11 @@ QString MemoryViewWidget::ValueToString(const Core::CPUThreadGuard& guard, u32 a
case Type::Unsigned32:
return QString::number(accessors->ReadU32(guard, address));
case Type::Signed8:
return QString::number(Common::BitCast<s8>(accessors->ReadU8(guard, address)));
return QString::number(std::bit_cast<s8>(accessors->ReadU8(guard, address)));
case Type::Signed16:
return QString::number(Common::BitCast<s16>(accessors->ReadU16(guard, address)));
return QString::number(std::bit_cast<s16>(accessors->ReadU16(guard, address)));
case Type::Signed32:
return QString::number(Common::BitCast<s32>(accessors->ReadU32(guard, address)));
return QString::number(std::bit_cast<s32>(accessors->ReadU32(guard, address)));
case Type::Float32:
{
QString string = QString::number(accessors->ReadF32(guard, address), 'g', 4);
@ -537,7 +540,7 @@ QString MemoryViewWidget::ValueToString(const Core::CPUThreadGuard& guard, u32 a
case Type::Double:
{
QString string =
QString::number(Common::BitCast<double>(accessors->ReadU64(guard, address)), 'g', 4);
QString::number(std::bit_cast<double>(accessors->ReadU64(guard, address)), 'g', 4);
// Align to first digit.
if (!string.startsWith(QLatin1Char('-')))
string.prepend(QLatin1Char(' '));
@ -635,7 +638,7 @@ std::vector<u8> MemoryViewWidget::ConvertTextToBytes(Type type, QStringView inpu
if (good)
{
const u32 value = Common::BitCast<u32>(float_value);
const u32 value = std::bit_cast<u32>(float_value);
auto std_array = Common::BitCastToArray<u8>(Common::swap32(value));
return std::vector<u8>(std_array.begin(), std_array.end());
}
@ -647,7 +650,7 @@ std::vector<u8> MemoryViewWidget::ConvertTextToBytes(Type type, QStringView inpu
if (good)
{
const u64 value = Common::BitCast<u64>(double_value);
const u64 value = std::bit_cast<u64>(double_value);
auto std_array = Common::BitCastToArray<u8>(Common::swap64(value));
return std::vector<u8>(std_array.begin(), std_array.end());
}
@ -850,12 +853,8 @@ void MemoryViewWidget::OnCopyHex(u32 addr)
{
const auto length = GetTypeSize(m_type);
const AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_address_space);
const u64 value = [addr, accessors] {
Core::CPUThreadGuard guard(Core::System::GetInstance());
return accessors->ReadU64(guard, addr);
}();
const u64 value =
AddressSpace::GetAccessors(m_address_space)->ReadU64(Core::CPUThreadGuard{m_system}, addr);
QApplication::clipboard()->setText(
QStringLiteral("%1").arg(value, sizeof(u64) * 2, 16, QLatin1Char('0')).left(length * 2));
@ -873,14 +872,11 @@ void MemoryViewWidget::OnContextMenu(const QPoint& pos)
const u32 addr = item_selected->data(USER_ROLE_CELL_ADDRESS).toUInt();
const bool item_has_value =
item_selected->data(USER_ROLE_VALUE_TYPE).toInt() != static_cast<int>(Type::Null) &&
[this, addr] {
const AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_address_space);
Core::CPUThreadGuard guard(Core::System::GetInstance());
return accessors->IsValidAddress(guard, addr);
}();
AddressSpace::GetAccessors(m_address_space)
->IsValidAddress(Core::CPUThreadGuard{m_system}, addr);
auto* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose, true);
menu->addAction(tr("Copy Address"), this, [this, addr] { OnCopyAddress(addr); });

View file

@ -7,6 +7,7 @@
#include "Common/CommonTypes.h"
class QFont;
class QPoint;
class QScrollBar;
@ -53,11 +54,11 @@ public:
WriteOnly
};
explicit MemoryViewWidget(QWidget* parent = nullptr);
explicit MemoryViewWidget(Core::System& system, QWidget* parent = nullptr);
void CreateTable();
void Update();
void UpdateFont();
void UpdateFont(const QFont& font);
void ToggleBreakpoint(u32 addr, bool row);
std::vector<u8> ConvertTextToBytes(Type type, QStringView input_text) const;

View file

@ -40,7 +40,8 @@
using Type = MemoryViewWidget::Type;
MemoryWidget::MemoryWidget(QWidget* parent) : QDockWidget(parent)
MemoryWidget::MemoryWidget(Core::System& system, QWidget* parent)
: QDockWidget(parent), m_system(system)
{
setWindowTitle(tr("Memory"));
setObjectName(QStringLiteral("memory"));
@ -199,6 +200,7 @@ void MemoryWidget::CreateWidgets()
m_display_combo->addItem(tr("Double"), int(Type::Double));
m_align_combo = new QComboBox;
// i18n: "Fixed" here means that the alignment is always the same
m_align_combo->addItem(tr("Fixed Alignment"));
m_align_combo->addItem(tr("Type-based Alignment"), 0);
m_align_combo->addItem(tr("No Alignment"), 1);
@ -287,7 +289,7 @@ void MemoryWidget::CreateWidgets()
sidebar_scroll->setWidget(sidebar);
sidebar_scroll->setWidgetResizable(true);
m_memory_view = new MemoryViewWidget(this);
m_memory_view = new MemoryViewWidget(m_system, this);
m_splitter->addWidget(m_memory_view);
m_splitter->addWidget(sidebar_scroll);
@ -496,7 +498,7 @@ void MemoryWidget::SetAddress(u32 address)
AddressSpace::Accessors* accessors =
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_system);
good = accessors->IsValidAddress(guard, current_addr);
}
@ -627,7 +629,7 @@ QByteArray MemoryWidget::GetInputData() const
void MemoryWidget::OnSetValue()
{
if (!Core::IsRunning())
if (!Core::IsRunning(m_system))
return;
auto target_addr = GetTargetAddress();
@ -653,7 +655,7 @@ void MemoryWidget::OnSetValue()
return;
}
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_system);
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
u32 end_address = target_addr.address + static_cast<u32>(bytes.size()) - 1;
@ -673,7 +675,7 @@ void MemoryWidget::OnSetValue()
void MemoryWidget::OnSetValueFromFile()
{
if (!Core::IsRunning())
if (!Core::IsRunning(m_system))
return;
auto target_addr = GetTargetAddress();
@ -715,7 +717,7 @@ void MemoryWidget::OnSetValueFromFile()
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_system);
for (u8 b : file_contents)
accessors->WriteU8(guard, target_addr.address++, b);
@ -833,7 +835,7 @@ void MemoryWidget::FindValue(bool next)
AddressSpace::Accessors* accessors =
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_system);
return accessors->Search(guard, target_addr.address,
reinterpret_cast<const u8*>(search_for.data()),
static_cast<u32>(search_for.size()), next);

View file

@ -22,14 +22,15 @@ class QSplitter;
namespace Core
{
class System;
class CPUThreadGuard;
}
} // namespace Core
class MemoryWidget : public QDockWidget
{
Q_OBJECT
public:
explicit MemoryWidget(QWidget* parent = nullptr);
explicit MemoryWidget(Core::System& system, QWidget* parent = nullptr);
~MemoryWidget();
void SetAddress(u32 address);
@ -78,6 +79,8 @@ private:
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
Core::System& m_system;
MemoryViewWidget* m_memory_view;
QSplitter* m_splitter;
QComboBox* m_search_address;

View file

@ -239,7 +239,8 @@ void NetworkWidget::Update()
if (!isVisible())
return;
if (Core::GetState() != Core::State::Paused)
auto& system = Core::System::GetInstance();
if (Core::GetState(system) != Core::State::Paused)
{
m_socket_table->setDisabled(true);
m_ssl_table->setDisabled(true);
@ -250,9 +251,9 @@ void NetworkWidget::Update()
m_ssl_table->setDisabled(false);
// needed because there's a race condition on the IOS instance otherwise
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(system);
auto* ios = guard.GetSystem().GetIOS();
auto* ios = system.GetIOS();
if (!ios)
return;

View file

@ -106,7 +106,7 @@ void RegisterWidget::ConnectWidgets()
connect(m_table, &QTableWidget::customContextMenuRequested, this,
&RegisterWidget::ShowContextMenu);
connect(m_table, &QTableWidget::itemChanged, this, &RegisterWidget::OnItemChanged);
connect(&Settings::Instance(), &Settings::DebugFontChanged, m_table, &QWidget::setFont);
connect(&Settings::Instance(), &Settings::DebugFontChanged, m_table, &RegisterWidget::setFont);
}
void RegisterWidget::OnItemChanged(QTableWidgetItem* item)
@ -118,6 +118,7 @@ void RegisterWidget::OnItemChanged(QTableWidgetItem* item)
void RegisterWidget::ShowContextMenu()
{
QMenu* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose, true);
auto* raw_item = m_table->currentItem();
@ -533,7 +534,7 @@ void RegisterWidget::AddRegister(int row, int column, RegisterType type, std::st
void RegisterWidget::Update()
{
if (isVisible() && Core::GetState() == Core::State::Paused)
if (isVisible() && Core::GetState(m_system) == Core::State::Paused)
{
m_updating = true;
emit UpdateTable();

View file

@ -3,6 +3,8 @@
#include "DolphinQt/Debugger/ThreadWidget.h"
#include <bit>
#include <QGroupBox>
#include <QHeaderView>
#include <QLabel>
@ -11,12 +13,12 @@
#include <QTableWidget>
#include <QVBoxLayout>
#include "Common/BitUtils.h"
#include "Core/Core.h"
#include "Core/PowerPC/MMU.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/QtUtils/FromStdString.h"
#include "DolphinQt/Settings.h"
ThreadWidget::ThreadWidget(QWidget* parent) : QDockWidget(parent)
@ -118,6 +120,8 @@ void ThreadWidget::ShowContextMenu(QTableWidget* table)
return;
QMenu* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose, true);
const QString watch_name = QStringLiteral("thread_context_%1").arg(addr, 8, 16, QLatin1Char('0'));
menu->addAction(tr("Add &breakpoint"), this, [this, addr] { emit RequestBreakpoint(addr); });
menu->addAction(tr("Add memory breakpoint"), this,
@ -252,13 +256,14 @@ void ThreadWidget::Update()
if (!isVisible())
return;
const auto emu_state = Core::GetState();
auto& system = Core::System::GetInstance();
const auto emu_state = Core::GetState(system);
if (emu_state == Core::State::Stopping)
{
m_thread_table->setRowCount(0);
UpdateThreadContext({});
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(system);
UpdateThreadCallstack(guard, {});
}
if (emu_state != Core::State::Paused)
@ -303,7 +308,7 @@ void ThreadWidget::Update()
};
{
Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(system);
// YAGCD - Section 4.2.1.4 Dolphin OS Globals
m_current_context->setText(format_hex_from(guard, 0x800000D4));
@ -359,8 +364,7 @@ void ThreadWidget::UpdateThreadContext(const Common::Debug::PartialContext& cont
const auto format_f64_as_u64_idx = [](const auto& table, std::size_t index) {
if (!table || index >= table->size())
return QString{};
return QStringLiteral("%1").arg(Common::BitCast<u64>(table->at(index)), 16, 16,
QLatin1Char('0'));
return QStringLiteral("%1").arg(std::bit_cast<u64>(table->at(index)), 16, 16, QLatin1Char('0'));
};
m_context_table->setRowCount(0);
@ -460,7 +464,7 @@ void ThreadWidget::UpdateThreadCallstack(const Core::CPUThreadGuard& guard,
m_callstack_table->setItem(i, 2, new QTableWidgetItem(format_hex(lr_save)));
m_callstack_table->setItem(
i, 3,
new QTableWidgetItem(QString::fromStdString(
new QTableWidgetItem(QtUtils::FromStdString(
guard.GetSystem().GetPowerPC().GetDebugInterface().GetDescription(lr_save))));
}
else

View file

@ -143,7 +143,7 @@ void WatchWidget::UpdateButtonsEnabled()
if (!isVisible())
return;
const bool is_enabled = Core::IsRunning();
const bool is_enabled = Core::IsRunning(m_system);
m_new->setEnabled(is_enabled);
m_delete->setEnabled(is_enabled);
m_clear->setEnabled(is_enabled);
@ -158,7 +158,7 @@ void WatchWidget::Update()
m_updating = true;
if (Core::GetState() != Core::State::Paused)
if (Core::GetState(m_system) != Core::State::Paused)
{
m_table->setDisabled(true);
m_updating = false;
@ -195,10 +195,10 @@ void WatchWidget::Update()
QBrush brush = QPalette().brush(QPalette::Text);
if (!Core::IsRunning() || !PowerPC::MMU::HostIsRAMAddress(guard, entry.address))
if (!Core::IsRunning(m_system) || !PowerPC::MMU::HostIsRAMAddress(guard, entry.address))
brush.setColor(Qt::red);
if (Core::IsRunning())
if (Core::IsRunning(m_system))
{
if (PowerPC::MMU::HostIsRAMAddress(guard, entry.address))
{
@ -327,6 +327,7 @@ void WatchWidget::OnSave()
void WatchWidget::ShowContextMenu()
{
QMenu* menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose, true);
if (!m_table->selectedItems().empty())
{