From 7e974f10644101fbcacdd1131bd3af8395f2505d Mon Sep 17 00:00:00 2001 From: Sepalani Date: Wed, 5 Oct 2016 15:51:12 +0100 Subject: [PATCH] SymbolDB: GetSymbolsFromHash added --- Source/Core/Common/SymbolDB.cpp | 20 +++++++++++++++++++ Source/Core/Common/SymbolDB.h | 10 ++-------- .../Core/PowerPC/SignatureDB/SignatureDB.cpp | 6 ++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Source/Core/Common/SymbolDB.cpp b/Source/Core/Common/SymbolDB.cpp index 564ac55eb3..b4c64b4d91 100644 --- a/Source/Core/Common/SymbolDB.cpp +++ b/Source/Core/Common/SymbolDB.cpp @@ -61,6 +61,26 @@ std::vector SymbolDB::GetSymbolsFromName(const std::string& name) return symbols; } +Symbol* SymbolDB::GetSymbolFromHash(u32 hash) +{ + XFuncPtrMap::iterator iter = checksumToFunction.find(hash); + if (iter != checksumToFunction.end()) + return iter->second; + else + return nullptr; +} + +std::vector SymbolDB::GetSymbolsFromHash(u32 hash) +{ + std::vector symbols; + + for (const auto& iter : checksumToFunction) + if (iter.first == hash) + symbols.push_back(iter.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 453e37fe76..ef7f4664ee 100644 --- a/Source/Core/Common/SymbolDB.h +++ b/Source/Core/Common/SymbolDB.h @@ -72,14 +72,8 @@ public: Symbol* GetSymbolFromName(const std::string& name); std::vector GetSymbolsFromName(const std::string& name); - Symbol* GetSymbolFromHash(u32 hash) - { - XFuncPtrMap::iterator iter = checksumToFunction.find(hash); - if (iter != checksumToFunction.end()) - return iter->second; - else - return nullptr; - } + Symbol* GetSymbolFromHash(u32 hash); + std::vector GetSymbolsFromHash(u32 hash); const XFuncMap& Symbols() const { return functions; } XFuncMap& AccessSymbols() { return functions; } diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index 93485c43d0..5581f490fd 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -72,12 +72,10 @@ void SignatureDB::Apply(PPCSymbolDB* symbol_db) { for (const auto& entry : m_database) { - u32 hash = entry.first; - Symbol* function = symbol_db->GetSymbolFromHash(hash); - if (function) + for (const auto& function : symbol_db->GetSymbolsFromHash(entry.first)) { // Found the function. Let's rename it according to the symbol file. - if (entry.second.size == (unsigned int)function->size) + if (entry.second.size == static_cast(function->size)) { function->name = entry.second.name; INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(),