From d6d17eea6022b79749976e41e321aab5207f8d40 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Apr 2018 21:54:50 -0400 Subject: [PATCH 1/3] PPCSymbolDB: Remove unused function pointer typedef --- Source/Core/Core/PowerPC/PPCSymbolDB.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h index eb92bf7f01..2a6afc4979 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.h +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h @@ -17,8 +17,6 @@ class PPCSymbolDB : public SymbolDB { public: - typedef void (*functionGetterCallback)(Symbol* f); - PPCSymbolDB(); ~PPCSymbolDB(); From b44eb90ee4014bbd8e41ae335287ee8bc2ba2157 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Apr 2018 21:56:24 -0400 Subject: [PATCH 2/3] PPCSymbolDB: Default destructor and pass to member variables in the constructor initializer-list --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 8 ++------ Source/Core/Core/PowerPC/PPCSymbolDB.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index a71f3722d2..cd1d6960f0 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -21,15 +21,11 @@ PPCSymbolDB g_symbolDB; -PPCSymbolDB::PPCSymbolDB() +PPCSymbolDB::PPCSymbolDB() : debugger{&PowerPC::debug_interface} { - // Get access to the disasm() fgnction - debugger = &PowerPC::debug_interface; } -PPCSymbolDB::~PPCSymbolDB() -{ -} +PPCSymbolDB::~PPCSymbolDB() = default; // Adds the function to the list, unless it's already there Symbol* PPCSymbolDB::AddFunction(u32 start_addr) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h index 2a6afc4979..de60c3d8dd 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.h +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h @@ -18,7 +18,7 @@ class PPCSymbolDB : public SymbolDB { public: PPCSymbolDB(); - ~PPCSymbolDB(); + ~PPCSymbolDB() override; Symbol* AddFunction(u32 start_addr) override; void AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, From 0461709c8d4a7f6347c832c2dad3823901c5b4dc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Apr 2018 21:59:55 -0400 Subject: [PATCH 3/3] PPCSymbolDB: Use auto for iterators where applicable --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 78 ++++++++++++------------ 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index cd1d6960f0..ff0f8b496a 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -48,7 +48,7 @@ Symbol* PPCSymbolDB::AddFunction(u32 start_addr) void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, Symbol::Type type) { - XFuncMap::iterator iter = functions.find(startAddr); + auto iter = functions.find(startAddr); if (iter != functions.end()) { // 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) { - XFuncMap::iterator it = functions.lower_bound(addr); + auto it = functions.lower_bound(addr); if (it == functions.end()) return nullptr; @@ -118,14 +118,14 @@ void PPCSymbolDB::FillInCallers() Symbol& f = entry.second; for (const SCall& call : f.calls) { - SCall NewCall(entry.first, call.callAddress); - u32 FunctionAddress = call.function; + const SCall new_call(entry.first, call.callAddress); + const u32 function_address = call.function; - XFuncMap::iterator FuncIterator = functions.find(FunctionAddress); - if (FuncIterator != functions.end()) + auto func_iter = functions.find(function_address); + if (func_iter != functions.end()) { - Symbol& rCalledFunction = FuncIterator->second; - rCalledFunction.callers.push_back(NewCall); + Symbol& called_function = func_iter->second; + called_function.callers.push_back(new_call); } else { @@ -139,53 +139,51 @@ void PPCSymbolDB::FillInCallers() void PPCSymbolDB::PrintCalls(u32 funcAddr) const { - XFuncMap::const_iterator iter = functions.find(funcAddr); - 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 + const auto iter = functions.find(funcAddr); + if (iter == functions.end()) { 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 { - XFuncMap::const_iterator iter = functions.find(funcAddr); - if (iter != functions.end()) + const auto iter = functions.find(funcAddr); + 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; - DEBUG_LOG(SYMBOLS, "The function %s at %08x is called by:", f.name.c_str(), f.address); - for (const SCall& caller : f.callers) + const auto n = functions.find(caller.function); + if (n != functions.end()) { - XFuncMap::const_iterator n = functions.find(caller.function); - if (n != functions.end()) - { - DEBUG_LOG(SYMBOLS, "* %08x : %s", caller.callAddress, n->second.name.c_str()); - } + DEBUG_LOG(SYMBOLS, "* %08x : %s", caller.callAddress, n->second.name.c_str()); } } } void PPCSymbolDB::LogFunctionCall(u32 addr) { - // u32 from = PC; - XFuncMap::iterator iter = functions.find(addr); - if (iter != functions.end()) - { - Symbol& f = iter->second; - f.numCalls++; - } + auto iter = functions.find(addr); + if (iter == functions.end()) + return; + + Symbol& f = iter->second; + f.numCalls++; } // The use case for handling bad map files is when you have a game with a map file on the disc,