Skip to content

Commit

Permalink
Merge pull request #4211 from lioncash/symbol
Browse files Browse the repository at this point in the history
SymbolDB: Minor changes
  • Loading branch information
degasus committed Sep 14, 2016
2 parents 54a643a + 00ddbee commit ab37b02
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 29 deletions.
26 changes: 11 additions & 15 deletions Source/Core/Common/SymbolDB.h
Expand Up @@ -23,27 +23,23 @@ struct SCall

struct Symbol
{
enum
enum class Type
{
SYMBOL_FUNCTION = 0,
SYMBOL_DATA = 1,
Function,
Data,
};

Symbol() : hash(0), address(0), flags(0), size(0), numCalls(0), type(SYMBOL_FUNCTION), analyzed(0)
{
}

std::string name;
std::vector<SCall> callers; // addresses of functions that call this function
std::vector<SCall> calls; // addresses of functions that are called by this function
u32 hash; // use for HLE function finding
u32 address;
u32 flags;
int size;
int numCalls;
int type;
int index; // only used for coloring the disasm view
int analyzed;
u32 hash = 0; // use for HLE function finding
u32 address = 0;
u32 flags = 0;
int size = 0;
int numCalls = 0;
Type type = Type::Function;
int index = 0; // only used for coloring the disasm view
bool analyzed = false;
};

enum
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/Boot/ElfReader.cpp
Expand Up @@ -182,14 +182,14 @@ bool ElfReader::LoadSymbols()
if (bRelocate)
value += sectionAddrs[sectionIndex];

int symtype = Symbol::SYMBOL_DATA;
auto symtype = Symbol::Type::Data;
switch (type)
{
case STT_OBJECT:
symtype = Symbol::SYMBOL_DATA;
symtype = Symbol::Type::Data;
break;
case STT_FUNC:
symtype = Symbol::SYMBOL_FUNCTION;
symtype = Symbol::Type::Function;
break;
default:
continue;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Debugger/PPCDebugInterface.cpp
Expand Up @@ -186,7 +186,7 @@ int PPCDebugInterface::GetColor(unsigned int address)
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
if (!symbol)
return 0xFFFFFF;
if (symbol->type != Symbol::SYMBOL_FUNCTION)
if (symbol->type != Symbol::Type::Function)
return 0xEEEEFF;
return colors[symbol->index % 6];
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp
Expand Up @@ -170,7 +170,7 @@ int DSPDebugInterface::GetColor(unsigned int address)
Symbol* symbol = DSPSymbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
if (!symbol)
return 0xFFFFFF;
if (symbol->type != Symbol::SYMBOL_FUNCTION)
if (symbol->type != Symbol::Type::Function)
return 0xEEEEFF;
return colors[symbol->index % 6];
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/PowerPC/PPCAnalyst.cpp
Expand Up @@ -75,7 +75,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
{
if (!func.name.size())
func.name = StringFromFormat("zz_%07x_", startAddr & 0x0FFFFFF);
if (func.analyzed >= 1)
if (func.analyzed)
return true; // No error, just already did it.

func.calls.clear();
Expand All @@ -96,7 +96,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
if (max_size && func.size > max_size)
{
func.address = startAddr;
func.analyzed = 1;
func.analyzed = true;
func.hash = SignatureDB::ComputeCodeChecksum(startAddr, addr);
if (numInternalBranches == 0)
func.flags |= FFLAG_STRAIGHT;
Expand All @@ -117,7 +117,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
// We're done! Looks like we have a neat valid function. Perfect.
// Let's calc the checksum and get outta here
func.address = startAddr;
func.analyzed = 1;
func.analyzed = true;
func.hash = SignatureDB::ComputeCodeChecksum(startAddr, addr);
if (numInternalBranches == 0)
func.flags |= FFLAG_STRAIGHT;
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/Core/PowerPC/PPCSymbolDB.cpp
Expand Up @@ -47,13 +47,14 @@ Symbol* PPCSymbolDB::AddFunction(u32 startAddr)
return nullptr; // found a dud :(
// LOG(OSHLE, "Symbol found at %08x", startAddr);
functions[startAddr] = tempFunc;
tempFunc.type = Symbol::SYMBOL_FUNCTION;
tempFunc.type = Symbol::Type::Function;
checksumToFunction[tempFunc.hash] = &(functions[startAddr]);
return &functions[startAddr];
}
}

void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, int type)
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
Symbol::Type type)
{
XFuncMap::iterator iter = functions.find(startAddr);
if (iter != functions.end())
Expand All @@ -72,7 +73,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
tf.name = name;
tf.type = type;
tf.address = startAddr;
if (tf.type == Symbol::SYMBOL_FUNCTION)
if (tf.type == Symbol::Type::Function)
{
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
checksumToFunction[tf.hash] = &(functions[startAddr]);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/PPCSymbolDB.h
Expand Up @@ -27,7 +27,7 @@ class PPCSymbolDB : public SymbolDB

Symbol* AddFunction(u32 startAddr) override;
void AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
int type = Symbol::SYMBOL_FUNCTION);
Symbol::Type type = Symbol::Type::Function);

Symbol* GetSymbolFromAddr(u32 addr) override;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
Expand Up @@ -485,7 +485,7 @@ void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
Symbol* pSymbol = static_cast<Symbol*>(symbols->GetClientData(index));
if (pSymbol != nullptr)
{
if (pSymbol->type == Symbol::SYMBOL_DATA)
if (pSymbol->type == Symbol::Type::Data)
{
if (m_MemoryWindow) // && m_MemoryWindow->IsVisible())
m_MemoryWindow->JumpToAddress(pSymbol->address);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp
Expand Up @@ -224,7 +224,7 @@ void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
Symbol* pSymbol = static_cast<Symbol*>(m_SymbolList->GetClientData(index));
if (pSymbol != nullptr)
{
if (pSymbol->type == Symbol::SYMBOL_FUNCTION)
if (pSymbol->type == Symbol::Type::Function)
{
JumpToAddress(pSymbol->address);
}
Expand Down

0 comments on commit ab37b02

Please sign in to comment.