diff options
| author | JosJuice <josjuice@gmail.com> | 2025-06-30 21:31:06 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2025-07-27 17:03:57 +0200 |
| commit | 9f32562e3633b62526918cbf0cfb920b96a263da (patch) | |
| tree | 90e73de1f702541f45dc6e38e5dadcf5866078c2 /Source/Core/DolphinQt/Debugger | |
| parent | fef77a5f20d03f22315b2d77f7970c3fed895b13 (diff) | |
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.
Diffstat (limited to 'Source/Core/DolphinQt/Debugger')
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | 16 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/CodeWidget.cpp | 24 |
2 files changed, 20 insertions, 20 deletions
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; diff --git a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp index e5aaa1c2cd..3e4eedf49d 100644 --- a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp @@ -423,14 +423,13 @@ void CodeWidget::UpdateSymbols() m_symbols_list->selectedItems()[0]->text(); m_symbols_list->clear(); - for (const auto& symbol : m_ppc_symbol_db.Symbols()) - { - QString name = QString::fromStdString(symbol.second.name); + m_ppc_symbol_db.ForEachSymbol([&](const Common::Symbol& symbol) { + QString name = QString::fromStdString(symbol.name); // If the symbol has an object name, add it to the entry name. - if (!symbol.second.object_name.empty()) + if (!symbol.object_name.empty()) { - name += QString::fromStdString(fmt::format(" ({})", symbol.second.object_name)); + name += QString::fromStdString(fmt::format(" ({})", symbol.object_name)); } auto* item = new QListWidgetItem(name); @@ -438,14 +437,14 @@ void CodeWidget::UpdateSymbols() item->setSelected(true); // Disable non-function symbols as you can't do anything with them. - if (symbol.second.type != Common::Symbol::Type::Function) + if (symbol.type != Common::Symbol::Type::Function) item->setFlags(Qt::NoItemFlags); - item->setData(Qt::UserRole, symbol.second.address); + item->setData(Qt::UserRole, symbol.address); if (name.contains(m_symbol_filter, Qt::CaseInsensitive)) m_symbols_list->addItem(item); - } + }); m_symbols_list->sortItems(); } @@ -457,19 +456,18 @@ void CodeWidget::UpdateNotes() m_note_list->selectedItems()[0]->text(); m_note_list->clear(); - for (const auto& note : m_ppc_symbol_db.Notes()) - { - const QString name = QString::fromStdString(note.second.name); + m_ppc_symbol_db.ForEachNote([&](const Common::Note& note) { + const QString name = QString::fromStdString(note.name); auto* item = new QListWidgetItem(name); if (name == selection) item->setSelected(true); - item->setData(Qt::UserRole, note.second.address); + item->setData(Qt::UserRole, note.address); if (name.toUpper().indexOf(m_symbol_filter.toUpper()) != -1) m_note_list->addItem(item); - } + }); m_note_list->sortItems(); } |
