SymbolDB: Use an enum class for representing symbol type
This commit is contained in:
parent
d8d127df25
commit
0ac77b0288
|
@ -23,10 +23,10 @@ struct SCall
|
||||||
|
|
||||||
struct Symbol
|
struct Symbol
|
||||||
{
|
{
|
||||||
enum
|
enum class Type
|
||||||
{
|
{
|
||||||
SYMBOL_FUNCTION = 0,
|
Function,
|
||||||
SYMBOL_DATA = 1,
|
Data,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -37,7 +37,7 @@ struct Symbol
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int numCalls = 0;
|
int numCalls = 0;
|
||||||
int type = SYMBOL_FUNCTION;
|
Type type = Type::Function;
|
||||||
int index = 0; // only used for coloring the disasm view
|
int index = 0; // only used for coloring the disasm view
|
||||||
int analyzed = 0;
|
int analyzed = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -182,14 +182,14 @@ bool ElfReader::LoadSymbols()
|
||||||
if (bRelocate)
|
if (bRelocate)
|
||||||
value += sectionAddrs[sectionIndex];
|
value += sectionAddrs[sectionIndex];
|
||||||
|
|
||||||
int symtype = Symbol::SYMBOL_DATA;
|
auto symtype = Symbol::Type::Data;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case STT_OBJECT:
|
case STT_OBJECT:
|
||||||
symtype = Symbol::SYMBOL_DATA;
|
symtype = Symbol::Type::Data;
|
||||||
break;
|
break;
|
||||||
case STT_FUNC:
|
case STT_FUNC:
|
||||||
symtype = Symbol::SYMBOL_FUNCTION;
|
symtype = Symbol::Type::Function;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -186,7 +186,7 @@ int PPCDebugInterface::GetColor(unsigned int address)
|
||||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
return 0xFFFFFF;
|
return 0xFFFFFF;
|
||||||
if (symbol->type != Symbol::SYMBOL_FUNCTION)
|
if (symbol->type != Symbol::Type::Function)
|
||||||
return 0xEEEEFF;
|
return 0xEEEEFF;
|
||||||
return colors[symbol->index % 6];
|
return colors[symbol->index % 6];
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ int DSPDebugInterface::GetColor(unsigned int address)
|
||||||
Symbol* symbol = DSPSymbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
|
Symbol* symbol = DSPSymbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
return 0xFFFFFF;
|
return 0xFFFFFF;
|
||||||
if (symbol->type != Symbol::SYMBOL_FUNCTION)
|
if (symbol->type != Symbol::Type::Function)
|
||||||
return 0xEEEEFF;
|
return 0xEEEEFF;
|
||||||
return colors[symbol->index % 6];
|
return colors[symbol->index % 6];
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,14 @@ Symbol* PPCSymbolDB::AddFunction(u32 startAddr)
|
||||||
return nullptr; // found a dud :(
|
return nullptr; // found a dud :(
|
||||||
// LOG(OSHLE, "Symbol found at %08x", startAddr);
|
// LOG(OSHLE, "Symbol found at %08x", startAddr);
|
||||||
functions[startAddr] = tempFunc;
|
functions[startAddr] = tempFunc;
|
||||||
tempFunc.type = Symbol::SYMBOL_FUNCTION;
|
tempFunc.type = Symbol::Type::Function;
|
||||||
checksumToFunction[tempFunc.hash] = &(functions[startAddr]);
|
checksumToFunction[tempFunc.hash] = &(functions[startAddr]);
|
||||||
return &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);
|
XFuncMap::iterator iter = functions.find(startAddr);
|
||||||
if (iter != functions.end())
|
if (iter != functions.end())
|
||||||
|
@ -72,7 +73,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
|
||||||
tf.name = name;
|
tf.name = name;
|
||||||
tf.type = type;
|
tf.type = type;
|
||||||
tf.address = startAddr;
|
tf.address = startAddr;
|
||||||
if (tf.type == Symbol::SYMBOL_FUNCTION)
|
if (tf.type == Symbol::Type::Function)
|
||||||
{
|
{
|
||||||
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
||||||
checksumToFunction[tf.hash] = &(functions[startAddr]);
|
checksumToFunction[tf.hash] = &(functions[startAddr]);
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
Symbol* AddFunction(u32 startAddr) override;
|
Symbol* AddFunction(u32 startAddr) override;
|
||||||
void AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
|
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;
|
Symbol* GetSymbolFromAddr(u32 addr) override;
|
||||||
|
|
||||||
|
|
|
@ -485,7 +485,7 @@ void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
|
||||||
Symbol* pSymbol = static_cast<Symbol*>(symbols->GetClientData(index));
|
Symbol* pSymbol = static_cast<Symbol*>(symbols->GetClientData(index));
|
||||||
if (pSymbol != nullptr)
|
if (pSymbol != nullptr)
|
||||||
{
|
{
|
||||||
if (pSymbol->type == Symbol::SYMBOL_DATA)
|
if (pSymbol->type == Symbol::Type::Data)
|
||||||
{
|
{
|
||||||
if (m_MemoryWindow) // && m_MemoryWindow->IsVisible())
|
if (m_MemoryWindow) // && m_MemoryWindow->IsVisible())
|
||||||
m_MemoryWindow->JumpToAddress(pSymbol->address);
|
m_MemoryWindow->JumpToAddress(pSymbol->address);
|
||||||
|
|
|
@ -224,7 +224,7 @@ void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
|
||||||
Symbol* pSymbol = static_cast<Symbol*>(m_SymbolList->GetClientData(index));
|
Symbol* pSymbol = static_cast<Symbol*>(m_SymbolList->GetClientData(index));
|
||||||
if (pSymbol != nullptr)
|
if (pSymbol != nullptr)
|
||||||
{
|
{
|
||||||
if (pSymbol->type == Symbol::SYMBOL_FUNCTION)
|
if (pSymbol->type == Symbol::Type::Function)
|
||||||
{
|
{
|
||||||
JumpToAddress(pSymbol->address);
|
JumpToAddress(pSymbol->address);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue