dolphin/Source/Core/Common/SymbolDB.cpp
Léo Lam 303325768b 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.
2016-09-26 22:56:42 +02:00

55 lines
1.1 KiB
C++

// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cstring>
#include <map>
#include <string>
#include <utility>
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/SymbolDB.h"
void SymbolDB::List()
{
for (const auto& func : functions)
{
DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls", func.second.name.c_str(),
func.second.address, func.second.size, func.second.hash, func.second.numCalls);
}
INFO_LOG(OSHLE, "%zu functions known in this program above.", functions.size());
}
void SymbolDB::Clear(const char* prefix)
{
// TODO: honor prefix
functions.clear();
checksumToFunction.clear();
}
void SymbolDB::Index()
{
int i = 0;
for (auto& func : functions)
{
func.second.index = i++;
}
}
Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
{
for (auto& func : functions)
{
if (func.second.function_name == name)
return &func.second;
}
return nullptr;
}
void SymbolDB::AddCompleteSymbol(const Symbol& symbol)
{
functions.emplace(symbol.address, symbol);
}