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.
This commit is contained in:
JosJuice 2025-06-30 21:31:06 +02:00
commit 9f32562e36
15 changed files with 172 additions and 108 deletions

View file

@ -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;