mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
SymbolDB: Normalize variable names
Normalizes variable naming so that it adheres to our coding style While we're at it do minor cleanup relating to modified lines
This commit is contained in:
@ -28,25 +28,25 @@ void Symbol::Rename(const std::string& symbol_name)
|
||||
|
||||
void SymbolDB::List()
|
||||
{
|
||||
for (const auto& func : functions)
|
||||
for (const auto& func : m_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);
|
||||
func.second.address, func.second.size, func.second.hash, func.second.num_calls);
|
||||
}
|
||||
INFO_LOG(OSHLE, "%zu functions known in this program above.", functions.size());
|
||||
INFO_LOG(OSHLE, "%zu functions known in this program above.", m_functions.size());
|
||||
}
|
||||
|
||||
void SymbolDB::Clear(const char* prefix)
|
||||
{
|
||||
// TODO: honor prefix
|
||||
functions.clear();
|
||||
checksumToFunction.clear();
|
||||
m_functions.clear();
|
||||
m_checksum_to_function.clear();
|
||||
}
|
||||
|
||||
void SymbolDB::Index()
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& func : functions)
|
||||
for (auto& func : m_functions)
|
||||
{
|
||||
func.second.index = i++;
|
||||
}
|
||||
@ -54,7 +54,7 @@ void SymbolDB::Index()
|
||||
|
||||
Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
|
||||
{
|
||||
for (auto& func : functions)
|
||||
for (auto& func : m_functions)
|
||||
{
|
||||
if (func.second.function_name == name)
|
||||
return &func.second;
|
||||
@ -67,7 +67,7 @@ std::vector<Symbol*> SymbolDB::GetSymbolsFromName(const std::string& name)
|
||||
{
|
||||
std::vector<Symbol*> symbols;
|
||||
|
||||
for (auto& func : functions)
|
||||
for (auto& func : m_functions)
|
||||
{
|
||||
if (func.second.function_name == name)
|
||||
symbols.push_back(&func.second);
|
||||
@ -78,18 +78,18 @@ std::vector<Symbol*> SymbolDB::GetSymbolsFromName(const std::string& name)
|
||||
|
||||
Symbol* SymbolDB::GetSymbolFromHash(u32 hash)
|
||||
{
|
||||
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
|
||||
if (iter != checksumToFunction.end())
|
||||
return *iter->second.begin();
|
||||
else
|
||||
auto iter = m_checksum_to_function.find(hash);
|
||||
if (iter == m_checksum_to_function.end())
|
||||
return nullptr;
|
||||
|
||||
return *iter->second.begin();
|
||||
}
|
||||
|
||||
std::vector<Symbol*> SymbolDB::GetSymbolsFromHash(u32 hash)
|
||||
{
|
||||
const auto iter = checksumToFunction.find(hash);
|
||||
const auto iter = m_checksum_to_function.find(hash);
|
||||
|
||||
if (iter == checksumToFunction.cend())
|
||||
if (iter == m_checksum_to_function.cend())
|
||||
return {};
|
||||
|
||||
return {iter->second.cbegin(), iter->second.cend()};
|
||||
@ -97,5 +97,5 @@ std::vector<Symbol*> SymbolDB::GetSymbolsFromHash(u32 hash)
|
||||
|
||||
void SymbolDB::AddCompleteSymbol(const Symbol& symbol)
|
||||
{
|
||||
functions.emplace(symbol.address, symbol);
|
||||
m_functions.emplace(symbol.address, symbol);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
struct SCall
|
||||
{
|
||||
SCall(u32 a, u32 b) : function(a), callAddress(b) {}
|
||||
SCall(u32 a, u32 b) : function(a), call_address(b) {}
|
||||
u32 function;
|
||||
u32 callAddress;
|
||||
u32 call_address;
|
||||
};
|
||||
|
||||
struct Symbol
|
||||
@ -40,7 +40,7 @@ struct Symbol
|
||||
u32 address = 0;
|
||||
u32 flags = 0;
|
||||
u32 size = 0;
|
||||
int numCalls = 0;
|
||||
int num_calls = 0;
|
||||
Type type = Type::Function;
|
||||
int index = 0; // only used for coloring the disasm view
|
||||
bool analyzed = false;
|
||||
@ -62,15 +62,10 @@ public:
|
||||
typedef std::map<u32, Symbol> XFuncMap;
|
||||
typedef std::map<u32, std::set<Symbol*>> XFuncPtrMap;
|
||||
|
||||
protected:
|
||||
XFuncMap functions;
|
||||
XFuncPtrMap checksumToFunction;
|
||||
|
||||
public:
|
||||
SymbolDB() {}
|
||||
virtual ~SymbolDB() {}
|
||||
virtual Symbol* GetSymbolFromAddr(u32 addr) { return nullptr; }
|
||||
virtual Symbol* AddFunction(u32 startAddr) { return nullptr; }
|
||||
virtual Symbol* AddFunction(u32 start_addr) { return nullptr; }
|
||||
void AddCompleteSymbol(const Symbol& symbol);
|
||||
|
||||
Symbol* GetSymbolFromName(const std::string& name);
|
||||
@ -78,9 +73,13 @@ public:
|
||||
Symbol* GetSymbolFromHash(u32 hash);
|
||||
std::vector<Symbol*> GetSymbolsFromHash(u32 hash);
|
||||
|
||||
const XFuncMap& Symbols() const { return functions; }
|
||||
XFuncMap& AccessSymbols() { return functions; }
|
||||
const XFuncMap& Symbols() const { return m_functions; }
|
||||
XFuncMap& AccessSymbols() { return m_functions; }
|
||||
void Clear(const char* prefix = "");
|
||||
void List();
|
||||
void Index();
|
||||
|
||||
protected:
|
||||
XFuncMap m_functions;
|
||||
XFuncPtrMap m_checksum_to_function;
|
||||
};
|
||||
|
Reference in New Issue
Block a user