From 703286356986ae2317bedfa20ee7dc36fa3aac81 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 May 2018 18:01:08 -0400 Subject: [PATCH 1/4] CodeViewWidget: Remove unnecessary QColor constructions QBrush also accepts regular GlobalColor values as well. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index e531fc66c8..ad8b4a54c7 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -127,13 +127,13 @@ void CodeViewWidget::Update() if (color != 0xFFFFFF) { - item->setForeground(QColor(Qt::black)); + item->setForeground(Qt::black); item->setBackground(QColor(color)); } if (addr == pc && item != bp_item) { - item->setBackground(QColor(Qt::green)); - item->setForeground(QColor(Qt::black)); + item->setBackground(Qt::green); + item->setForeground(Qt::black); } } From 644bbb29f3d351cfa6bdbc03577c376f3e917970 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 May 2018 18:06:37 -0400 Subject: [PATCH 2/4] CodeViewWidget: Remove unnecessary includes --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index ad8b4a54c7..abeb49d80c 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -22,11 +22,9 @@ #include "Common/StringUtil.h" #include "Core/Core.h" #include "Core/Debugger/PPCDebugInterface.h" -#include "Core/Host.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" -#include "DolphinQt2/Debugger/CodeWidget.h" #include "DolphinQt2/QtUtils/ActionHelper.h" #include "DolphinQt2/Resources.h" #include "DolphinQt2/Settings.h" From bbc0aee5eaf3c9fbc810fdeb8ccb8308fde9021f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 May 2018 18:11:06 -0400 Subject: [PATCH 3/4] CodeViewWidget: Replaces usages of QString::fromStdString with QStringLiteral where applicable There's no need to construct a std::string here, when there's no dynamic elements to the text. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index abeb49d80c..198202b424 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -395,12 +395,12 @@ void CodeViewWidget::OnSelectionChanged() { if (m_address == PowerPC::ppcState.pc) { - setStyleSheet(QString::fromStdString( - "QTableView::item:selected {background-color: #00FF00; color: #000000;}")); + setStyleSheet( + QStringLiteral("QTableView::item:selected {background-color: #00FF00; color: #000000;}")); } else if (!styleSheet().isEmpty()) { - setStyleSheet(QString::fromStdString("")); + setStyleSheet(QStringLiteral("")); } } From d7a3ce26def900a8e7c4945f202bea472668c757 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 May 2018 18:24:30 -0400 Subject: [PATCH 4/4] CodeViewWidget: Get rid of magic values in OnInsertBLR() and OnInsertNOP() A call like ReplaceAddress(address, 0) is pretty ambiguous; so is ReplaceAddress(address, false), so use an enum class that tells people straight-up what the replacer is. This also gets rid of the really weird naming, where if 'blr' is true, we'd be replacing the address with a NOP, rather than an actual BLR instruction, so we invert that so it actually makes sense. There's no actual bug fixed here though, considering the OnInsert functions specified the correct values; it's literally just weird naming. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 10 +++++----- Source/Core/DolphinQt2/Debugger/CodeViewWidget.h | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index 198202b424..7ecffdd9d7 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -195,14 +195,14 @@ void CodeViewWidget::SetAddress(u32 address, SetAddressUpdate update) Update(); } -void CodeViewWidget::ReplaceAddress(u32 address, bool blr) +void CodeViewWidget::ReplaceAddress(u32 address, ReplaceWith replace) { auto found = std::find_if(m_repl_list.begin(), m_repl_list.end(), [address](ReplStruct r) { return r.address == address; }); if (found != m_repl_list.end()) { - PowerPC::debug_interface.WriteExtraMemory(0, (*found).old_value, address); + PowerPC::debug_interface.WriteExtraMemory(0, found->old_value, address); m_repl_list.erase(found); } else @@ -214,7 +214,7 @@ void CodeViewWidget::ReplaceAddress(u32 address, bool blr) m_repl_list.push_back(repl); - PowerPC::debug_interface.Patch(address, blr ? 0x60000000 : 0x4e800020); + PowerPC::debug_interface.Patch(address, replace == ReplaceWith::BLR ? 0x4e800020 : 0x60000000); } Update(); @@ -347,14 +347,14 @@ void CodeViewWidget::OnInsertBLR() { const u32 addr = GetContextAddress(); - ReplaceAddress(addr, 0); + ReplaceAddress(addr, ReplaceWith::BLR); } void CodeViewWidget::OnInsertNOP() { const u32 addr = GetContextAddress(); - ReplaceAddress(addr, 1); + ReplaceAddress(addr, ReplaceWith::NOP); } void CodeViewWidget::OnFollowBranch() diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h index a6e038b447..c879b70d4b 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h @@ -40,7 +40,13 @@ signals: void BreakpointsChanged(); private: - void ReplaceAddress(u32 address, bool blr); + enum class ReplaceWith + { + BLR, + NOP + }; + + void ReplaceAddress(u32 address, ReplaceWith replace); void resizeEvent(QResizeEvent*) override; void keyPressEvent(QKeyEvent* event) override;