From 9f32562e3633b62526918cbf0cfb920b96a263da Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 30 Jun 2025 21:31:06 +0200 Subject: PPCSymbolDB: Don't return non-const pointers For thread safety, we shouldn't return any pointers or references that can be used to mutate the state of the PPCSymbolDB. This should be the final part of making PPCSymbolDB thread safe unless I've missed something. --- Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp') diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index a430be15a3..f94b640c41 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -335,7 +335,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)); - const std::string_view desc = debug_interface.GetDescription(addr); + const std::string desc = debug_interface.GetDescription(addr); const Common::Note* note = m_ppc_symbol_db.GetNoteFromAddr(addr); std::string note_string; @@ -950,7 +950,7 @@ void CodeViewWidget::OnFollowBranch() void CodeViewWidget::OnEditSymbol() { const u32 addr = GetContextAddress(); - Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr); + const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr); if (symbol == nullptr) { @@ -974,12 +974,14 @@ void CodeViewWidget::OnEditSymbol() } if (symbol->name != name) - symbol->Rename(name); + m_ppc_symbol_db.RenameSymbol(*symbol, name); if (symbol->size != size) { Core::CPUThreadGuard guard(m_system); - PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, size); + Common::Symbol new_symbol = *symbol; + PPCAnalyst::ReanalyzeFunction(guard, symbol->address, new_symbol, size); + m_ppc_symbol_db.AddCompleteSymbol(new_symbol); } emit Host::GetInstance()->PPCSymbolsChanged(); @@ -988,7 +990,7 @@ void CodeViewWidget::OnEditSymbol() void CodeViewWidget::OnDeleteSymbol() { const u32 addr = GetContextAddress(); - Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr); + const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr); if (symbol == nullptr) return; @@ -1039,7 +1041,7 @@ void CodeViewWidget::OnSelectionChanged() void CodeViewWidget::OnEditNote() { const u32 context_address = GetContextAddress(); - Common::Note* const note = m_ppc_symbol_db.GetNoteFromAddr(context_address); + const Common::Note* const note = m_ppc_symbol_db.GetNoteFromAddr(context_address); if (note == nullptr) return; @@ -1071,7 +1073,7 @@ void CodeViewWidget::OnEditNote() void CodeViewWidget::OnDeleteNote() { const u32 context_address = GetContextAddress(); - Common::Note* const note = m_ppc_symbol_db.GetNoteFromAddr(context_address); + const Common::Note* const note = m_ppc_symbol_db.GetNoteFromAddr(context_address); if (note == nullptr) return; -- cgit v1.2.3