PPCSymbolDB: Use auto for iterators where applicable

This commit is contained in:
Lioncash 2018-04-08 21:59:55 -04:00
parent b44eb90ee4
commit 0461709c8d

View File

@ -48,7 +48,7 @@ Symbol* PPCSymbolDB::AddFunction(u32 start_addr)
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
Symbol::Type type) Symbol::Type type)
{ {
XFuncMap::iterator iter = functions.find(startAddr); auto iter = functions.find(startAddr);
if (iter != functions.end()) if (iter != functions.end())
{ {
// already got it, let's just update name, checksum & size to be sure. // already got it, let's just update name, checksum & size to be sure.
@ -80,7 +80,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr) Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
{ {
XFuncMap::iterator it = functions.lower_bound(addr); auto it = functions.lower_bound(addr);
if (it == functions.end()) if (it == functions.end())
return nullptr; return nullptr;
@ -118,14 +118,14 @@ void PPCSymbolDB::FillInCallers()
Symbol& f = entry.second; Symbol& f = entry.second;
for (const SCall& call : f.calls) for (const SCall& call : f.calls)
{ {
SCall NewCall(entry.first, call.callAddress); const SCall new_call(entry.first, call.callAddress);
u32 FunctionAddress = call.function; const u32 function_address = call.function;
XFuncMap::iterator FuncIterator = functions.find(FunctionAddress); auto func_iter = functions.find(function_address);
if (FuncIterator != functions.end()) if (func_iter != functions.end())
{ {
Symbol& rCalledFunction = FuncIterator->second; Symbol& called_function = func_iter->second;
rCalledFunction.callers.push_back(NewCall); called_function.callers.push_back(new_call);
} }
else else
{ {
@ -139,53 +139,51 @@ void PPCSymbolDB::FillInCallers()
void PPCSymbolDB::PrintCalls(u32 funcAddr) const void PPCSymbolDB::PrintCalls(u32 funcAddr) const
{ {
XFuncMap::const_iterator iter = functions.find(funcAddr); const auto iter = functions.find(funcAddr);
if (iter != functions.end()) if (iter == functions.end())
{
const Symbol& f = iter->second;
DEBUG_LOG(SYMBOLS, "The function %s at %08x calls:", f.name.c_str(), f.address);
for (const SCall& call : f.calls)
{
XFuncMap::const_iterator n = functions.find(call.function);
if (n != functions.end())
{
DEBUG_LOG(SYMBOLS, "* %08x : %s", call.callAddress, n->second.name.c_str());
}
}
}
else
{ {
WARN_LOG(SYMBOLS, "Symbol does not exist"); WARN_LOG(SYMBOLS, "Symbol does not exist");
return;
}
const Symbol& f = iter->second;
DEBUG_LOG(SYMBOLS, "The function %s at %08x calls:", f.name.c_str(), f.address);
for (const SCall& call : f.calls)
{
const auto n = functions.find(call.function);
if (n != functions.end())
{
DEBUG_LOG(SYMBOLS, "* %08x : %s", call.callAddress, n->second.name.c_str());
}
} }
} }
void PPCSymbolDB::PrintCallers(u32 funcAddr) const void PPCSymbolDB::PrintCallers(u32 funcAddr) const
{ {
XFuncMap::const_iterator iter = functions.find(funcAddr); const auto iter = functions.find(funcAddr);
if (iter != functions.end()) if (iter == functions.end())
return;
const Symbol& f = iter->second;
DEBUG_LOG(SYMBOLS, "The function %s at %08x is called by:", f.name.c_str(), f.address);
for (const SCall& caller : f.callers)
{ {
const Symbol& f = iter->second; const auto n = functions.find(caller.function);
DEBUG_LOG(SYMBOLS, "The function %s at %08x is called by:", f.name.c_str(), f.address); if (n != functions.end())
for (const SCall& caller : f.callers)
{ {
XFuncMap::const_iterator n = functions.find(caller.function); DEBUG_LOG(SYMBOLS, "* %08x : %s", caller.callAddress, n->second.name.c_str());
if (n != functions.end())
{
DEBUG_LOG(SYMBOLS, "* %08x : %s", caller.callAddress, n->second.name.c_str());
}
} }
} }
} }
void PPCSymbolDB::LogFunctionCall(u32 addr) void PPCSymbolDB::LogFunctionCall(u32 addr)
{ {
// u32 from = PC; auto iter = functions.find(addr);
XFuncMap::iterator iter = functions.find(addr); if (iter == functions.end())
if (iter != functions.end()) return;
{
Symbol& f = iter->second; Symbol& f = iter->second;
f.numCalls++; f.numCalls++;
}
} }
// The use case for handling bad map files is when you have a game with a map file on the disc, // The use case for handling bad map files is when you have a game with a map file on the disc,