SymbolDB: Only match against the function name

This changes GetSymbolFromName to not require the passed name to
completely match with the symbol name. Instead, we now match
against the stripped symbol name (i.e. only the function name).

This fixes a regression introduced by #4160, which prevented
HLE::PatchFunctions() from working properly.
This commit is contained in:
Léo Lam 2016-09-26 15:41:57 +02:00
parent e7aad130e9
commit 303325768b
3 changed files with 13 additions and 1 deletions

View File

@ -41,7 +41,7 @@ Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
{
for (auto& func : functions)
{
if (func.second.name == name)
if (func.second.function_name == name)
return &func.second;
}

View File

@ -30,6 +30,7 @@ struct Symbol
};
std::string name;
std::string function_name; // stripped function name
std::vector<SCall> callers; // addresses of functions that call this function
std::vector<SCall> calls; // addresses of functions that are called by this function
u32 hash = 0; // use for HLE function finding

View File

@ -16,6 +16,15 @@
#include "Core/PowerPC/PowerPC.h"
#include "Core/PowerPC/SignatureDB.h"
static std::string GetStrippedFunctionName(const std::string& symbol_name)
{
std::string name = symbol_name.substr(0, symbol_name.find('('));
size_t position = name.find(' ');
if (position != std::string::npos)
name.erase(position);
return name;
}
PPCSymbolDB g_symbolDB;
PPCSymbolDB::PPCSymbolDB()
@ -62,6 +71,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
// already got it, let's just update name, checksum & size to be sure.
Symbol* tempfunc = &iter->second;
tempfunc->name = name;
tempfunc->function_name = GetStrippedFunctionName(name);
tempfunc->hash = SignatureDB::ComputeCodeChecksum(startAddr, startAddr + size - 4);
tempfunc->type = type;
tempfunc->size = size;
@ -77,6 +87,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
{
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
checksumToFunction[tf.hash] = &(functions[startAddr]);
tf.function_name = GetStrippedFunctionName(name);
}
tf.size = size;
functions[startAddr] = tf;