SymbolDB: Blank stripped symbol name fixed

This commit is contained in:
Sepalani 2017-08-16 02:40:24 +01:00
parent 9b79e0ac72
commit 93b5a5369b
9 changed files with 29 additions and 24 deletions

View File

@ -11,6 +11,21 @@
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/SymbolDB.h" #include "Common/SymbolDB.h"
static std::string GetStrippedFunctionName(const std::string& symbol_name)
{
std::string name = symbol_name.substr(0, symbol_name.find('('));
size_t position = name.find(' ');
if (position != std::string::npos)
name.erase(position);
return name;
}
void Symbol::Rename(const std::string& symbol_name)
{
this->name = symbol_name;
this->function_name = GetStrippedFunctionName(symbol_name);
}
void SymbolDB::List() void SymbolDB::List()
{ {
for (const auto& func : functions) for (const auto& func : functions)

View File

@ -30,6 +30,8 @@ struct Symbol
Data, Data,
}; };
void Rename(const std::string& symbol_name);
std::string name; std::string name;
std::string function_name; // stripped function name std::string function_name; // stripped function name
std::vector<SCall> callers; // addresses of functions that call this function std::vector<SCall> callers; // addresses of functions that call this function

View File

@ -384,7 +384,7 @@ void RSOView::Apply(PPCSymbolDB* symbol_db) const
if (symbol) if (symbol)
{ {
// Function symbol // Function symbol
symbol->name = export_name; symbol->Rename(export_name);
} }
else else
{ {

View File

@ -149,7 +149,7 @@ bool ReadAnnotatedAssembly(const std::string& filename)
temp[i - 5] = 0; temp[i - 5] = 0;
// Mark symbol so the next hex sets the address // Mark symbol so the next hex sets the address
current_symbol.name = temp; current_symbol.Rename(temp);
current_symbol.address = 0xFFFF; current_symbol.address = 0xFFFF;
current_symbol.index = symbol_count++; current_symbol.index = symbol_count++;
symbol_in_progress = true; symbol_in_progress = true;

View File

@ -85,8 +85,8 @@ static u32 EvaluateBranchTarget(UGeckoInstruction instr, u32 pc)
// one blr or rfi, and keep scanning. // one blr or rfi, and keep scanning.
bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size) bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
{ {
if (!func.name.size()) if (func.name.empty())
func.name = StringFromFormat("zz_%07x_", startAddr & 0x0FFFFFFF); func.Rename(StringFromFormat("zz_%07x_", startAddr & 0x0FFFFFFF));
if (func.analyzed) if (func.analyzed)
return true; // No error, just already did it. return true; // No error, just already did it.
@ -341,7 +341,7 @@ static void FindFunctionsFromHandlers(PPCSymbolDB* func_db)
Symbol* f = func_db->AddFunction(entry.first); Symbol* f = func_db->AddFunction(entry.first);
if (!f) if (!f)
continue; continue;
f->name = entry.second; f->Rename(entry.second);
} }
} }
} }
@ -407,9 +407,9 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
if (f.name.substr(0, 3) == "zzz") if (f.name.substr(0, 3) == "zzz")
{ {
if (f.flags & FFLAG_LEAF) if (f.flags & FFLAG_LEAF)
f.name += "_leaf"; f.Rename(f.name + "_leaf");
if (f.flags & FFLAG_STRAIGHT) if (f.flags & FFLAG_STRAIGHT)
f.name += "_straight"; f.Rename(f.name + "_straight");
} }
if (f.flags & FFLAG_LEAF) if (f.flags & FFLAG_LEAF)
{ {

View File

@ -17,15 +17,6 @@
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include "Core/PowerPC/SignatureDB/SignatureDB.h" #include "Core/PowerPC/SignatureDB/SignatureDB.h"
static std::string GetStrippedFunctionName(const std::string& symbol_name)
{
std::string name = symbol_name.substr(0, symbol_name.find('('));
size_t position = name.find(' ');
if (position != std::string::npos)
name.erase(position);
return name;
}
PPCSymbolDB g_symbolDB; PPCSymbolDB g_symbolDB;
PPCSymbolDB::PPCSymbolDB() PPCSymbolDB::PPCSymbolDB()
@ -64,8 +55,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
{ {
// 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.
Symbol* tempfunc = &iter->second; Symbol* tempfunc = &iter->second;
tempfunc->name = name; tempfunc->Rename(name);
tempfunc->function_name = GetStrippedFunctionName(name);
tempfunc->hash = HashSignatureDB::ComputeCodeChecksum(startAddr, startAddr + size - 4); tempfunc->hash = HashSignatureDB::ComputeCodeChecksum(startAddr, startAddr + size - 4);
tempfunc->type = type; tempfunc->type = type;
tempfunc->size = size; tempfunc->size = size;
@ -74,14 +64,13 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
{ {
// new symbol. run analyze. // new symbol. run analyze.
Symbol tf; Symbol tf;
tf.name = name; tf.Rename(name);
tf.type = type; tf.type = type;
tf.address = startAddr; tf.address = startAddr;
if (tf.type == Symbol::Type::Function) if (tf.type == Symbol::Type::Function)
{ {
PPCAnalyst::AnalyzeFunction(startAddr, tf, size); PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
checksumToFunction[tf.hash].insert(&functions[startAddr]); checksumToFunction[tf.hash].insert(&functions[startAddr]);
tf.function_name = GetStrippedFunctionName(name);
} }
tf.size = size; tf.size = size;
functions[startAddr] = tf; functions[startAddr] = tf;

View File

@ -127,15 +127,14 @@ void HashSignatureDB::Apply(PPCSymbolDB* symbol_db) const
for (const auto& function : symbol_db->GetSymbolsFromHash(entry.first)) for (const auto& function : symbol_db->GetSymbolsFromHash(entry.first))
{ {
// Found the function. Let's rename it according to the symbol file. // Found the function. Let's rename it according to the symbol file.
function->Rename(entry.second.name);
if (entry.second.size == static_cast<unsigned int>(function->size)) if (entry.second.size == static_cast<unsigned int>(function->size))
{ {
function->name = entry.second.name;
INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(), INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(),
function->address, function->size); function->address, function->size);
} }
else else
{ {
function->name = entry.second.name;
ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!", ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!",
entry.second.name.c_str(), function->address, function->size, entry.second.size); entry.second.name.c_str(), function->address, function->size, entry.second.size);
} }

View File

@ -361,7 +361,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
StrToWxStr(symbol->name)); StrToWxStr(symbol->name));
if (input_symbol.ShowModal() == wxID_OK) if (input_symbol.ShowModal() == wxID_OK)
{ {
symbol->name = WxStrToStr(input_symbol.GetValue()); symbol->Rename(WxStrToStr(input_symbol.GetValue()));
Refresh(); // Redraw to show the renamed symbol Refresh(); // Redraw to show the renamed symbol
} }
Host_NotifyMapLoaded(); Host_NotifyMapLoaded();

View File

@ -337,7 +337,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address); Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
if (symbol) if (symbol)
symbol->name = line.substr(12); symbol->Rename(line.substr(12));
} }
Host_NotifyMapLoaded(); Host_NotifyMapLoaded();