diff --git a/Source/Core/Common/SymbolDB.cpp b/Source/Core/Common/SymbolDB.cpp index 9e91b64457..564ac55eb3 100644 --- a/Source/Core/Common/SymbolDB.cpp +++ b/Source/Core/Common/SymbolDB.cpp @@ -48,6 +48,19 @@ Symbol* SymbolDB::GetSymbolFromName(const std::string& name) return nullptr; } +std::vector SymbolDB::GetSymbolsFromName(const std::string& name) +{ + std::vector symbols; + + for (auto& func : functions) + { + if (func.second.function_name == name) + symbols.push_back(&func.second); + } + + return symbols; +} + void SymbolDB::AddCompleteSymbol(const Symbol& symbol) { functions.emplace(symbol.address, symbol); diff --git a/Source/Core/Common/SymbolDB.h b/Source/Core/Common/SymbolDB.h index 8d2ae11614..453e37fe76 100644 --- a/Source/Core/Common/SymbolDB.h +++ b/Source/Core/Common/SymbolDB.h @@ -71,6 +71,7 @@ public: void AddCompleteSymbol(const Symbol& symbol); Symbol* GetSymbolFromName(const std::string& name); + std::vector GetSymbolsFromName(const std::string& name); Symbol* GetSymbolFromHash(u32 hash) { XFuncPtrMap::iterator iter = checksumToFunction.find(hash); diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index 024e984e1c..f95275a6f6 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -109,8 +109,7 @@ void PatchFunctions() if (OSPatches[i].flags == HLE_TYPE_FIXED) continue; - Symbol* symbol = g_symbolDB.GetSymbolFromName(OSPatches[i].m_szPatchName); - if (symbol) + for (const auto& symbol : g_symbolDB.GetSymbolsFromName(OSPatches[i].m_szPatchName)) { for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4) { @@ -125,8 +124,7 @@ void PatchFunctions() { for (size_t i = 1; i < ArraySize(OSBreakPoints); ++i) { - Symbol* symbol = g_symbolDB.GetSymbolFromName(OSBreakPoints[i].m_szPatchName); - if (symbol) + for (const auto& symbol : g_symbolDB.GetSymbolsFromName(OSBreakPoints[i].m_szPatchName)) { PowerPC::breakpoints.Add(symbol->address, false); INFO_LOG(OSHLE, "Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, symbol->address); @@ -211,7 +209,7 @@ u32 UnPatch(const std::string& patch_name) return addr; } - if (Symbol* symbol = g_symbolDB.GetSymbolFromName(patch_name)) + for (const auto& symbol : g_symbolDB.GetSymbolsFromName(patch_name)) { for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4) {