Merge pull request #6488 from aldelaro5/symbols-log
LOG: Add a log type for Symbols
This commit is contained in:
commit
5e76f3a6d4
|
@ -52,6 +52,7 @@ enum LOG_TYPE
|
|||
POWERPC,
|
||||
SERIALINTERFACE,
|
||||
SP1,
|
||||
SYMBOLS,
|
||||
VIDEO,
|
||||
VIDEOINTERFACE,
|
||||
WII_IPC,
|
||||
|
|
|
@ -120,6 +120,7 @@ LogManager::LogManager()
|
|||
m_log[LogTypes::POWERPC] = {"PowerPC", "IBM CPU"};
|
||||
m_log[LogTypes::SERIALINTERFACE] = {"SI", "Serial Interface (SI)"};
|
||||
m_log[LogTypes::SP1] = {"SP1", "Serial Port 1"};
|
||||
m_log[LogTypes::SYMBOLS] = {"SYMBOLS", "Symbols"};
|
||||
m_log[LogTypes::VIDEO] = {"Video", "Video Backend"};
|
||||
m_log[LogTypes::VIDEOINTERFACE] = {"VI", "Video Interface (VI)"};
|
||||
m_log[LogTypes::WIIMOTE] = {"Wiimote", "Wiimote"};
|
||||
|
|
|
@ -331,7 +331,7 @@ void RSOView::LoadImports()
|
|||
{
|
||||
std::size_t size = m_header.GetImportsSize();
|
||||
if (size % sizeof(RSOImport) != 0)
|
||||
WARN_LOG(OSHLE, "RSO Imports Table has an incoherent size (%08zx)", size);
|
||||
WARN_LOG(SYMBOLS, "RSO Imports Table has an incoherent size (%08zx)", size);
|
||||
m_imports.Load(m_header.GetImportsOffset(), size / sizeof(RSOImport));
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ void RSOView::LoadExports()
|
|||
{
|
||||
std::size_t size = m_header.GetExportsSize();
|
||||
if (size % sizeof(RSOExport) != 0)
|
||||
WARN_LOG(OSHLE, "RSO Exports Table has an incoherent size (%08zx)", size);
|
||||
WARN_LOG(SYMBOLS, "RSO Exports Table has an incoherent size (%08zx)", size);
|
||||
m_exports.Load(m_header.GetExportsOffset(), size / sizeof(RSOExport));
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ void RSOView::LoadInternals()
|
|||
{
|
||||
std::size_t size = m_header.GetInternalsSize();
|
||||
if (size % sizeof(RSOInternalsEntry) != 0)
|
||||
WARN_LOG(OSHLE, "RSO Internals Relocation Table has an incoherent size (%08zx)", size);
|
||||
WARN_LOG(SYMBOLS, "RSO Internals Relocation Table has an incoherent size (%08zx)", size);
|
||||
m_imports.Load(m_header.GetInternalsOffset(), size / sizeof(RSOInternalsEntry));
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ void RSOView::LoadExternals()
|
|||
{
|
||||
std::size_t size = m_header.GetExternalsSize();
|
||||
if (size % sizeof(RSOExternalsEntry) != 0)
|
||||
WARN_LOG(OSHLE, "RSO Externals Relocation Table has an incoherent size (%08zx)", size);
|
||||
WARN_LOG(SYMBOLS, "RSO Externals Relocation Table has an incoherent size (%08zx)", size);
|
||||
m_imports.Load(m_header.GetExternalsOffset(), size / sizeof(RSOExternalsEntry));
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ void RSOView::Apply(PPCSymbolDB* symbol_db) const
|
|||
}
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(OSHLE, "RSO(%s): %zu symbols applied", GetName().c_str(), GetExportsCount());
|
||||
DEBUG_LOG(SYMBOLS, "RSO(%s): %zu symbols applied", GetName().c_str(), GetExportsCount());
|
||||
}
|
||||
|
||||
u32 RSOView::GetNextEntry() const
|
||||
|
@ -530,9 +530,9 @@ u32 RSOView::GetProlog() const
|
|||
{
|
||||
u32 section_index = m_header.GetPrologSectionIndex();
|
||||
if (section_index == 0)
|
||||
WARN_LOG(OSHLE, "RSO doesn't have a prolog function");
|
||||
WARN_LOG(SYMBOLS, "RSO doesn't have a prolog function");
|
||||
else if (section_index >= m_sections.Count())
|
||||
WARN_LOG(OSHLE, "RSO prolog section index out of bound");
|
||||
WARN_LOG(SYMBOLS, "RSO prolog section index out of bound");
|
||||
else
|
||||
return GetSection(section_index).offset + m_header.GetPrologSectionOffset();
|
||||
return 0;
|
||||
|
@ -542,9 +542,9 @@ u32 RSOView::GetEpilog() const
|
|||
{
|
||||
u32 section_index = m_header.GetEpilogSectionIndex();
|
||||
if (section_index == 0)
|
||||
WARN_LOG(OSHLE, "RSO doesn't have an epilog function");
|
||||
WARN_LOG(SYMBOLS, "RSO doesn't have an epilog function");
|
||||
else if (section_index >= m_sections.Count())
|
||||
WARN_LOG(OSHLE, "RSO epilog section index out of bound");
|
||||
WARN_LOG(SYMBOLS, "RSO epilog section index out of bound");
|
||||
else
|
||||
return GetSection(section_index).offset + m_header.GetEpilogSectionOffset();
|
||||
return 0;
|
||||
|
@ -554,9 +554,9 @@ u32 RSOView::GetUnresolved() const
|
|||
{
|
||||
u32 section_index = m_header.GetUnresolvedSectionIndex();
|
||||
if (section_index == 0)
|
||||
WARN_LOG(OSHLE, "RSO doesn't have a unresolved function");
|
||||
WARN_LOG(SYMBOLS, "RSO doesn't have a unresolved function");
|
||||
else if (section_index >= m_sections.Count())
|
||||
WARN_LOG(OSHLE, "RSO unresolved section index out of bound");
|
||||
WARN_LOG(SYMBOLS, "RSO unresolved section index out of bound");
|
||||
else
|
||||
return GetSection(section_index).offset + m_header.GetUnresolvedSectionOffset();
|
||||
return 0;
|
||||
|
@ -567,7 +567,7 @@ bool RSOChainView::Load(u32 address)
|
|||
// Load node
|
||||
RSOView node;
|
||||
node.LoadHeader(address);
|
||||
DEBUG_LOG(OSHLE, "RSOChain node name: %s", node.GetName().c_str());
|
||||
DEBUG_LOG(SYMBOLS, "RSOChain node name: %s", node.GetName().c_str());
|
||||
m_chain.emplace_front(std::move(node));
|
||||
|
||||
if (LoadNextChain(m_chain.front()) && LoadPrevChain(m_chain.front()))
|
||||
|
@ -613,8 +613,8 @@ bool RSOChainView::LoadNextChain(const RSOView& view)
|
|||
|
||||
if (prev_address != next_node.GetPrevEntry())
|
||||
{
|
||||
ERROR_LOG(OSHLE, "RSOChain has an incoherent previous link %08x != %08x in %s", prev_address,
|
||||
next_node.GetPrevEntry(), next_node.GetName().c_str());
|
||||
ERROR_LOG(SYMBOLS, "RSOChain has an incoherent previous link %08x != %08x in %s",
|
||||
prev_address, next_node.GetPrevEntry(), next_node.GetName().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ bool RSOChainView::LoadPrevChain(const RSOView& view)
|
|||
|
||||
if (next_address != prev_node.GetNextEntry())
|
||||
{
|
||||
ERROR_LOG(OSHLE, "RSOChain has an incoherent next link %08x != %08x in %s", next_address,
|
||||
ERROR_LOG(SYMBOLS, "RSOChain has an incoherent next link %08x != %08x in %s", next_address,
|
||||
prev_node.GetNextEntry(), prev_node.GetName().c_str());
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
|
|||
|
||||
bool ReanalyzeFunction(u32 start_addr, Symbol& func, int max_size)
|
||||
{
|
||||
ASSERT_MSG(OSHLE, func.analyzed, "The function wasn't previously analyzed!");
|
||||
ASSERT_MSG(SYMBOLS, func.analyzed, "The function wasn't previously analyzed!");
|
||||
|
||||
func.analyzed = false;
|
||||
return AnalyzeFunction(start_addr, func, max_size);
|
||||
|
@ -399,7 +399,7 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
|
|||
{
|
||||
if (func.second.address == 4)
|
||||
{
|
||||
WARN_LOG(OSHLE, "Weird function");
|
||||
WARN_LOG(SYMBOLS, "Weird function");
|
||||
continue;
|
||||
}
|
||||
AnalyzeFunction2(&(func.second));
|
||||
|
@ -449,10 +449,11 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
|
|||
else
|
||||
unniceSize /= numUnNice;
|
||||
|
||||
INFO_LOG(OSHLE, "Functions analyzed. %i leafs, %i nice, %i unnice."
|
||||
"%i timer, %i rfi. %i are branchless leafs.",
|
||||
INFO_LOG(SYMBOLS, "Functions analyzed. %i leafs, %i nice, %i unnice."
|
||||
"%i timer, %i rfi. %i are branchless leafs.",
|
||||
numLeafs, numNice, numUnNice, numTimer, numRFI, numStraightLeaf);
|
||||
INFO_LOG(OSHLE, "Average size: %i (leaf), %i (nice), %i(unnice)", leafSize, niceSize, unniceSize);
|
||||
INFO_LOG(SYMBOLS, "Average size: %i (leaf), %i (nice), %i(unnice)", leafSize, niceSize,
|
||||
unniceSize);
|
||||
}
|
||||
|
||||
static bool isCmp(const CodeOp& a)
|
||||
|
|
|
@ -133,7 +133,7 @@ void PPCSymbolDB::FillInCallers()
|
|||
}
|
||||
else
|
||||
{
|
||||
// LOG(OSHLE, "FillInCallers tries to fill data in an unknown function 0x%08x.",
|
||||
// LOG(SYMBOLS, "FillInCallers tries to fill data in an unknown function 0x%08x.",
|
||||
// FunctionAddress);
|
||||
// TODO - analyze the function instead.
|
||||
}
|
||||
|
@ -147,19 +147,19 @@ void PPCSymbolDB::PrintCalls(u32 funcAddr) const
|
|||
if (iter != functions.end())
|
||||
{
|
||||
const Symbol& f = iter->second;
|
||||
DEBUG_LOG(OSHLE, "The function %s at %08x calls:", f.name.c_str(), f.address);
|
||||
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(CONSOLE, "* %08x : %s", call.callAddress, n->second.name.c_str());
|
||||
DEBUG_LOG(SYMBOLS, "* %08x : %s", call.callAddress, n->second.name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(CONSOLE, "Symbol does not exist");
|
||||
WARN_LOG(SYMBOLS, "Symbol does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,13 +169,13 @@ void PPCSymbolDB::PrintCallers(u32 funcAddr) const
|
|||
if (iter != functions.end())
|
||||
{
|
||||
const Symbol& f = iter->second;
|
||||
DEBUG_LOG(CONSOLE, "The function %s at %08x is called by:", f.name.c_str(), f.address);
|
||||
DEBUG_LOG(SYMBOLS, "The function %s at %08x is called by:", f.name.c_str(), f.address);
|
||||
for (const SCall& caller : f.callers)
|
||||
{
|
||||
XFuncMap::const_iterator n = functions.find(caller.function);
|
||||
if (n != functions.end())
|
||||
{
|
||||
DEBUG_LOG(CONSOLE, "* %08x : %s", caller.callAddress, n->second.name.c_str());
|
||||
DEBUG_LOG(SYMBOLS, "* %08x : %s", caller.callAddress, n->second.name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ bool CSVSignatureDB::Load(const std::string& file_path)
|
|||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(OSHLE, "CSV database failed to parse line %zu", i);
|
||||
WARN_LOG(SYMBOLS, "CSV database failed to parse line %zu", i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ bool CSVSignatureDB::Save(const std::string& file_path) const
|
|||
|
||||
if (!f)
|
||||
{
|
||||
ERROR_LOG(OSHLE, "CSV database save failed");
|
||||
ERROR_LOG(SYMBOLS, "CSV database save failed");
|
||||
return false;
|
||||
}
|
||||
for (const auto& func : m_database)
|
||||
|
@ -75,6 +75,6 @@ bool CSVSignatureDB::Save(const std::string& file_path) const
|
|||
func.second.object_name.c_str());
|
||||
}
|
||||
|
||||
INFO_LOG(OSHLE, "CSV database save successful");
|
||||
INFO_LOG(SYMBOLS, "CSV database save successful");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ bool DSYSignatureDB::Save(const std::string& file_path) const
|
|||
|
||||
if (!f)
|
||||
{
|
||||
ERROR_LOG(OSHLE, "Database save failed");
|
||||
ERROR_LOG(SYMBOLS, "Database save failed");
|
||||
return false;
|
||||
}
|
||||
u32 fcount = static_cast<u32>(m_database.size());
|
||||
|
@ -69,6 +69,6 @@ bool DSYSignatureDB::Save(const std::string& file_path) const
|
|||
f.WriteArray(&temp, 1);
|
||||
}
|
||||
|
||||
INFO_LOG(OSHLE, "Database save successful");
|
||||
INFO_LOG(SYMBOLS, "Database save successful");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ bool GetCode(MEGASignature* sig, std::istringstream* iss)
|
|||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(OSHLE, "MEGA database failed to parse code");
|
||||
WARN_LOG(SYMBOLS, "MEGA database failed to parse code");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -84,13 +84,13 @@ bool GetRefs(MEGASignature* sig, std::istringstream* iss)
|
|||
|
||||
if (ptr == endptr || offset > std::numeric_limits<u32>::max())
|
||||
{
|
||||
WARN_LOG(OSHLE, "MEGA database failed to parse reference %u offset", ref_count);
|
||||
WARN_LOG(SYMBOLS, "MEGA database failed to parse reference %u offset", ref_count);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetFunctionName(iss, &ref))
|
||||
{
|
||||
WARN_LOG(OSHLE, "MEGA database failed to parse reference %u name", ref_count);
|
||||
WARN_LOG(SYMBOLS, "MEGA database failed to parse reference %u name", ref_count);
|
||||
return false;
|
||||
}
|
||||
sig->refs.emplace_back(static_cast<u32>(offset), std::move(ref));
|
||||
|
@ -145,7 +145,7 @@ bool MEGASignatureDB::Load(const std::string& file_path)
|
|||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(OSHLE, "MEGA database failed to parse line %zu", i);
|
||||
WARN_LOG(SYMBOLS, "MEGA database failed to parse line %zu", i);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -153,7 +153,7 @@ bool MEGASignatureDB::Load(const std::string& file_path)
|
|||
|
||||
bool MEGASignatureDB::Save(const std::string& file_path) const
|
||||
{
|
||||
ERROR_LOG(OSHLE, "MEGA database save unsupported yet.");
|
||||
ERROR_LOG(SYMBOLS, "MEGA database save unsupported yet.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ void MEGASignatureDB::Apply(PPCSymbolDB* symbol_db) const
|
|||
if (Compare(symbol.address, symbol.size, sig))
|
||||
{
|
||||
symbol.name = sig.name;
|
||||
INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", sig.name.c_str(), symbol.address,
|
||||
INFO_LOG(SYMBOLS, "Found %s at %08x (size: %08x)!", sig.name.c_str(), symbol.address,
|
||||
symbol.size);
|
||||
break;
|
||||
}
|
||||
|
@ -178,12 +178,12 @@ void MEGASignatureDB::Apply(PPCSymbolDB* symbol_db) const
|
|||
|
||||
void MEGASignatureDB::Populate(const PPCSymbolDB* func_db, const std::string& filter)
|
||||
{
|
||||
ERROR_LOG(OSHLE, "MEGA database can't be populated yet.");
|
||||
ERROR_LOG(SYMBOLS, "MEGA database can't be populated yet.");
|
||||
}
|
||||
|
||||
bool MEGASignatureDB::Add(u32 startAddr, u32 size, const std::string& name)
|
||||
{
|
||||
ERROR_LOG(OSHLE, "Can't add symbol to MEGA database yet.");
|
||||
ERROR_LOG(SYMBOLS, "Can't add symbol to MEGA database yet.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ void MEGASignatureDB::List() const
|
|||
{
|
||||
for (const auto& entry : m_signatures)
|
||||
{
|
||||
DEBUG_LOG(OSHLE, "%s : %zu bytes", entry.name.c_str(), entry.code.size() * sizeof(u32));
|
||||
DEBUG_LOG(SYMBOLS, "%s : %zu bytes", entry.name.c_str(), entry.code.size() * sizeof(u32));
|
||||
}
|
||||
INFO_LOG(OSHLE, "%zu functions known in current MEGA database.", m_signatures.size());
|
||||
INFO_LOG(SYMBOLS, "%zu functions known in current MEGA database.", m_signatures.size());
|
||||
}
|
||||
|
|
|
@ -109,10 +109,10 @@ void HashSignatureDB::List() const
|
|||
{
|
||||
for (const auto& entry : m_database)
|
||||
{
|
||||
DEBUG_LOG(OSHLE, "%s : %i bytes, hash = %08x", entry.second.name.c_str(), entry.second.size,
|
||||
DEBUG_LOG(SYMBOLS, "%s : %i bytes, hash = %08x", entry.second.name.c_str(), entry.second.size,
|
||||
entry.first);
|
||||
}
|
||||
INFO_LOG(OSHLE, "%zu functions known in current database.", m_database.size());
|
||||
INFO_LOG(SYMBOLS, "%zu functions known in current database.", m_database.size());
|
||||
}
|
||||
|
||||
void HashSignatureDB::Clear()
|
||||
|
@ -130,12 +130,12 @@ void HashSignatureDB::Apply(PPCSymbolDB* symbol_db) const
|
|||
function->Rename(entry.second.name);
|
||||
if (entry.second.size == static_cast<unsigned int>(function->size))
|
||||
{
|
||||
INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(),
|
||||
INFO_LOG(SYMBOLS, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(),
|
||||
function->address, function->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!",
|
||||
ERROR_LOG(SYMBOLS, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!",
|
||||
entry.second.name.c_str(), function->address, function->size, entry.second.size);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue