mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #4299 from sepalani/hle_symbols
SymbolDB: Multiple symbols detection allowed
This commit is contained in:
commit
5790f15be8
@ -48,6 +48,40 @@ Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Symbol*> SymbolDB::GetSymbolsFromName(const std::string& name)
|
||||||
|
{
|
||||||
|
std::vector<Symbol*> symbols;
|
||||||
|
|
||||||
|
for (auto& func : functions)
|
||||||
|
{
|
||||||
|
if (func.second.function_name == name)
|
||||||
|
symbols.push_back(&func.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
return symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
Symbol* SymbolDB::GetSymbolFromHash(u32 hash)
|
||||||
|
{
|
||||||
|
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
|
||||||
|
if (iter != checksumToFunction.end())
|
||||||
|
return *iter->second.begin();
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Symbol*> SymbolDB::GetSymbolsFromHash(u32 hash)
|
||||||
|
{
|
||||||
|
std::vector<Symbol*> symbols;
|
||||||
|
|
||||||
|
for (const auto& iter : checksumToFunction)
|
||||||
|
if (iter.first == hash)
|
||||||
|
for (const auto& symbol : iter.second)
|
||||||
|
symbols.push_back(symbol);
|
||||||
|
|
||||||
|
return symbols;
|
||||||
|
}
|
||||||
|
|
||||||
void SymbolDB::AddCompleteSymbol(const Symbol& symbol)
|
void SymbolDB::AddCompleteSymbol(const Symbol& symbol)
|
||||||
{
|
{
|
||||||
functions.emplace(symbol.address, symbol);
|
functions.emplace(symbol.address, symbol);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -57,7 +58,7 @@ class SymbolDB
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<u32, Symbol> XFuncMap;
|
typedef std::map<u32, Symbol> XFuncMap;
|
||||||
typedef std::map<u32, Symbol*> XFuncPtrMap;
|
typedef std::map<u32, std::set<Symbol*>> XFuncPtrMap;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XFuncMap functions;
|
XFuncMap functions;
|
||||||
@ -71,14 +72,9 @@ public:
|
|||||||
void AddCompleteSymbol(const Symbol& symbol);
|
void AddCompleteSymbol(const Symbol& symbol);
|
||||||
|
|
||||||
Symbol* GetSymbolFromName(const std::string& name);
|
Symbol* GetSymbolFromName(const std::string& name);
|
||||||
Symbol* GetSymbolFromHash(u32 hash)
|
std::vector<Symbol*> GetSymbolsFromName(const std::string& name);
|
||||||
{
|
Symbol* GetSymbolFromHash(u32 hash);
|
||||||
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
|
std::vector<Symbol*> GetSymbolsFromHash(u32 hash);
|
||||||
if (iter != checksumToFunction.end())
|
|
||||||
return iter->second;
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const XFuncMap& Symbols() const { return functions; }
|
const XFuncMap& Symbols() const { return functions; }
|
||||||
XFuncMap& AccessSymbols() { return functions; }
|
XFuncMap& AccessSymbols() { return functions; }
|
||||||
|
@ -110,8 +110,7 @@ void PatchFunctions()
|
|||||||
if (OSPatches[i].flags == HLE_TYPE_FIXED)
|
if (OSPatches[i].flags == HLE_TYPE_FIXED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Symbol* symbol = g_symbolDB.GetSymbolFromName(OSPatches[i].m_szPatchName);
|
for (const auto& symbol : g_symbolDB.GetSymbolsFromName(OSPatches[i].m_szPatchName))
|
||||||
if (symbol)
|
|
||||||
{
|
{
|
||||||
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
||||||
{
|
{
|
||||||
@ -126,8 +125,7 @@ void PatchFunctions()
|
|||||||
{
|
{
|
||||||
for (size_t i = 1; i < ArraySize(OSBreakPoints); ++i)
|
for (size_t i = 1; i < ArraySize(OSBreakPoints); ++i)
|
||||||
{
|
{
|
||||||
Symbol* symbol = g_symbolDB.GetSymbolFromName(OSBreakPoints[i].m_szPatchName);
|
for (const auto& symbol : g_symbolDB.GetSymbolsFromName(OSBreakPoints[i].m_szPatchName))
|
||||||
if (symbol)
|
|
||||||
{
|
{
|
||||||
PowerPC::breakpoints.Add(symbol->address, false);
|
PowerPC::breakpoints.Add(symbol->address, false);
|
||||||
INFO_LOG(OSHLE, "Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, symbol->address);
|
INFO_LOG(OSHLE, "Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, symbol->address);
|
||||||
@ -212,7 +210,7 @@ u32 UnPatch(const std::string& patch_name)
|
|||||||
return addr;
|
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)
|
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ Symbol* PPCSymbolDB::AddFunction(u32 startAddr)
|
|||||||
// LOG(OSHLE, "Symbol found at %08x", startAddr);
|
// LOG(OSHLE, "Symbol found at %08x", startAddr);
|
||||||
functions[startAddr] = tempFunc;
|
functions[startAddr] = tempFunc;
|
||||||
tempFunc.type = Symbol::Type::Function;
|
tempFunc.type = Symbol::Type::Function;
|
||||||
checksumToFunction[tempFunc.hash] = &(functions[startAddr]);
|
checksumToFunction[tempFunc.hash].insert(&functions[startAddr]);
|
||||||
return &functions[startAddr];
|
return &functions[startAddr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
|
|||||||
if (tf.type == Symbol::Type::Function)
|
if (tf.type == Symbol::Type::Function)
|
||||||
{
|
{
|
||||||
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
||||||
checksumToFunction[tf.hash] = &(functions[startAddr]);
|
checksumToFunction[tf.hash].insert(&functions[startAddr]);
|
||||||
tf.function_name = GetStrippedFunctionName(name);
|
tf.function_name = GetStrippedFunctionName(name);
|
||||||
}
|
}
|
||||||
tf.size = size;
|
tf.size = size;
|
||||||
|
@ -72,12 +72,10 @@ void SignatureDB::Apply(PPCSymbolDB* symbol_db)
|
|||||||
{
|
{
|
||||||
for (const auto& entry : m_database)
|
for (const auto& entry : m_database)
|
||||||
{
|
{
|
||||||
u32 hash = entry.first;
|
for (const auto& function : symbol_db->GetSymbolsFromHash(entry.first))
|
||||||
Symbol* function = symbol_db->GetSymbolFromHash(hash);
|
|
||||||
if (function)
|
|
||||||
{
|
{
|
||||||
// Found the function. Let's rename it according to the symbol file.
|
// 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<unsigned int>(function->size))
|
||||||
{
|
{
|
||||||
function->name = entry.second.name;
|
function->name = entry.second.name;
|
||||||
INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(),
|
INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(),
|
||||||
|
Loading…
Reference in New Issue
Block a user