summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Debugger/DebugInterface.h3
-rw-r--r--Source/Core/Core/Debugger/Debugger_SymbolMap.cpp10
-rw-r--r--Source/Core/Core/Debugger/PPCDebugInterface.cpp2
-rw-r--r--Source/Core/Core/Debugger/PPCDebugInterface.h2
-rw-r--r--Source/Core/Core/PowerPC/PPCSymbolDB.cpp8
-rw-r--r--Source/Core/Core/PowerPC/PPCSymbolDB.h3
-rw-r--r--Source/Core/DolphinQt/CMakeLists.txt1
-rw-r--r--Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp15
-rw-r--r--Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp7
-rw-r--r--Source/Core/DolphinQt/Debugger/ThreadWidget.cpp3
-rw-r--r--Source/Core/DolphinQt/DolphinQt.vcxproj1
-rw-r--r--Source/Core/DolphinQt/QtUtils/FromStdString.h23
12 files changed, 49 insertions, 29 deletions
diff --git a/Source/Core/Core/Debugger/DebugInterface.h b/Source/Core/Core/Debugger/DebugInterface.h
index 1e2814e822..9802c31f3a 100644
--- a/Source/Core/Core/Debugger/DebugInterface.h
+++ b/Source/Core/Core/Debugger/DebugInterface.h
@@ -6,6 +6,7 @@
#include <cstddef>
#include <optional>
#include <string>
+#include <string_view>
#include <vector>
#include "Common/CommonTypes.h"
@@ -103,7 +104,7 @@ public:
{
return 0xFFFFFFFF;
}
- virtual std::string GetDescription(u32 /*address*/) const = 0;
+ virtual std::string_view GetDescription(u32 /*address*/) const = 0;
virtual void Clear(const CPUThreadGuard& guard) = 0;
};
} // namespace Core
diff --git a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp
index c50e790d56..8a7aea1071 100644
--- a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp
+++ b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp
@@ -79,7 +79,7 @@ bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>
});
WalkTheStack(guard, [&output, &ppc_symbol_db](u32 func_addr) {
- std::string func_desc = ppc_symbol_db.GetDescription(func_addr);
+ std::string_view func_desc = ppc_symbol_db.GetDescription(func_addr);
if (func_desc.empty() || func_desc == "Invalid")
func_desc = "(unknown)";
@@ -106,14 +106,14 @@ void PrintCallstack(const Core::CPUThreadGuard& guard, Common::Log::LogType type
GENERIC_LOG_FMT(type, level, " LR = 0 - this is bad");
}
- if (ppc_symbol_db.GetDescription(ppc_state.pc) != ppc_symbol_db.GetDescription(LR(ppc_state)))
+ if (const std::string_view lr_desc = ppc_symbol_db.GetDescription(LR(ppc_state));
+ lr_desc != ppc_symbol_db.GetDescription(ppc_state.pc))
{
- GENERIC_LOG_FMT(type, level, " * {} [ LR = {:08x} ]",
- ppc_symbol_db.GetDescription(LR(ppc_state)), LR(ppc_state));
+ GENERIC_LOG_FMT(type, level, " * {} [ LR = {:08x} ]", lr_desc, LR(ppc_state));
}
WalkTheStack(guard, [type, level, &ppc_symbol_db](u32 func_addr) {
- std::string func_desc = ppc_symbol_db.GetDescription(func_addr);
+ std::string_view func_desc = ppc_symbol_db.GetDescription(func_addr);
if (func_desc.empty() || func_desc == "Invalid")
func_desc = "(unknown)";
GENERIC_LOG_FMT(type, level, " * {} [ addr = {:08x} ]", func_desc, func_addr);
diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp
index c9d0346858..89e266b5bb 100644
--- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp
+++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp
@@ -442,7 +442,7 @@ u32 PPCDebugInterface::GetColor(const Core::CPUThreadGuard* guard, u32 address)
}
// =============
-std::string PPCDebugInterface::GetDescription(u32 address) const
+std::string_view PPCDebugInterface::GetDescription(u32 address) const
{
return m_ppc_symbol_db.GetDescription(address);
}
diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h
index 579a779209..86207bc1da 100644
--- a/Source/Core/Core/Debugger/PPCDebugInterface.h
+++ b/Source/Core/Core/Debugger/PPCDebugInterface.h
@@ -102,7 +102,7 @@ public:
void Step() override {}
void RunToBreakpoint() override;
u32 GetColor(const Core::CPUThreadGuard* guard, u32 address) const override;
- std::string GetDescription(u32 address) const override;
+ std::string_view GetDescription(u32 address) const override;
std::shared_ptr<Core::NetworkCaptureLogger> NetworkLogger();
diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp
index d1f2a5a719..4bbf5ca7db 100644
--- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp
+++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp
@@ -108,13 +108,11 @@ Common::Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
return nullptr;
}
-std::string PPCSymbolDB::GetDescription(u32 addr)
+std::string_view PPCSymbolDB::GetDescription(u32 addr)
{
- Common::Symbol* symbol = GetSymbolFromAddr(addr);
- if (symbol)
+ if (const Common::Symbol* const symbol = GetSymbolFromAddr(addr))
return symbol->name;
- else
- return " --- ";
+ return " --- ";
}
void PPCSymbolDB::FillInCallers()
diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h
index 7c5861ff43..13abc4489e 100644
--- a/Source/Core/Core/PowerPC/PPCSymbolDB.h
+++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h
@@ -4,6 +4,7 @@
#pragma once
#include <string>
+#include <string_view>
#include "Common/CommonTypes.h"
#include "Common/SymbolDB.h"
@@ -27,7 +28,7 @@ public:
Common::Symbol* GetSymbolFromAddr(u32 addr) override;
- std::string GetDescription(u32 addr);
+ std::string_view GetDescription(u32 addr);
void FillInCallers();
diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt
index 437323fc74..87bd9883d5 100644
--- a/Source/Core/DolphinQt/CMakeLists.txt
+++ b/Source/Core/DolphinQt/CMakeLists.txt
@@ -303,6 +303,7 @@ add_executable(dolphin-emu
QtUtils/ElidedButton.h
QtUtils/FileOpenEventFilter.cpp
QtUtils/FileOpenEventFilter.h
+ QtUtils/FromStdString.h
QtUtils/ImageConverter.cpp
QtUtils/ImageConverter.h
QtUtils/ModalMessageBox.cpp
diff --git a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp
index df49683ca6..e4897a24a8 100644
--- a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp
@@ -193,11 +193,8 @@ void BreakpointWidget::Update()
m_table->setItem(i, 0, active);
m_table->setItem(i, 1, create_item(QStringLiteral("BP")));
- if (ppc_symbol_db.GetSymbolFromAddr(bp.address))
- {
- m_table->setItem(
- i, 2, create_item(QString::fromStdString(ppc_symbol_db.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'))));
@@ -234,12 +231,8 @@ void BreakpointWidget::Update()
m_table->setItem(i, 0, active);
m_table->setItem(i, 1, create_item(QStringLiteral("MBP")));
- if (ppc_symbol_db.GetSymbolFromAddr(mbp.start_address))
- {
- m_table->setItem(
- i, 2,
- create_item(QString::fromStdString(ppc_symbol_db.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)
{
diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
index 26d6d0e053..e33fbde2fa 100644
--- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
@@ -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"
@@ -326,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.
@@ -334,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);
@@ -374,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);
}
diff --git a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp
index 09f7771ba6..0140ff58d9 100644
--- a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp
@@ -17,6 +17,7 @@
#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)
@@ -461,7 +462,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
diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj
index 4cdb14fb33..cbcd07bfad 100644
--- a/Source/Core/DolphinQt/DolphinQt.vcxproj
+++ b/Source/Core/DolphinQt/DolphinQt.vcxproj
@@ -396,6 +396,7 @@
<QtMoc Include="QtUtils\DoubleClickEventFilter.h" />
<QtMoc Include="QtUtils\ElidedButton.h" />
<QtMoc Include="QtUtils\FileOpenEventFilter.h" />
+ <ClInclude Include="QtUtils\FromStdString.h" />
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
<QtMoc Include="QtUtils\PartiallyClosableTabWidget.h" />
<ClInclude Include="QtUtils\SetWindowDecorations.h" />
diff --git a/Source/Core/DolphinQt/QtUtils/FromStdString.h b/Source/Core/DolphinQt/QtUtils/FromStdString.h
new file mode 100644
index 0000000000..945d422f3f
--- /dev/null
+++ b/Source/Core/DolphinQt/QtUtils/FromStdString.h
@@ -0,0 +1,23 @@
+// Copyright 2024 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <QString>
+#include <string_view>
+
+namespace QtUtils
+{
+inline QString FromStdString(std::string_view s)
+{
+ return QString::fromUtf8(s.data(), s.size());
+}
+inline QString FromStdString(std::u8string_view s)
+{
+ return QString::fromUtf8(s.data(), s.size());
+}
+inline QString FromStdString(std::u16string_view s)
+{
+ return QString::fromUtf16(s.data(), s.size());
+}
+} // namespace QtUtils