SymbolDB: Namespace code under the Common namespace
Moves more common code into the Common namespace where it belongs.
This commit is contained in:
parent
72e8058fb8
commit
f4ec419929
|
@ -11,6 +11,8 @@
|
|||
#include "Common/Logging/Log.h"
|
||||
#include "Common/SymbolDB.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
static std::string GetStrippedFunctionName(const std::string& symbol_name)
|
||||
{
|
||||
std::string name = symbol_name.substr(0, symbol_name.find('('));
|
||||
|
@ -103,3 +105,4 @@ void SymbolDB::AddCompleteSymbol(const Symbol& symbol)
|
|||
{
|
||||
m_functions.emplace(symbol.address, symbol);
|
||||
}
|
||||
} // namespace Common
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
struct SCall
|
||||
{
|
||||
SCall(u32 a, u32 b) : function(a), call_address(b) {}
|
||||
|
@ -84,3 +86,4 @@ protected:
|
|||
XFuncMap m_functions;
|
||||
XFuncPtrMap m_checksum_to_function;
|
||||
};
|
||||
} // namespace Common
|
||||
|
|
|
@ -204,14 +204,14 @@ bool ElfReader::LoadSymbols() const
|
|||
if (bRelocate)
|
||||
value += sectionAddrs[sectionIndex];
|
||||
|
||||
auto symtype = Symbol::Type::Data;
|
||||
auto symtype = Common::Symbol::Type::Data;
|
||||
switch (type)
|
||||
{
|
||||
case STT_OBJECT:
|
||||
symtype = Symbol::Type::Data;
|
||||
symtype = Common::Symbol::Type::Data;
|
||||
break;
|
||||
case STT_FUNC:
|
||||
symtype = Symbol::Type::Function;
|
||||
symtype = Common::Symbol::Type::Function;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
|
|
|
@ -29,7 +29,7 @@ void AddAutoBreakpoints()
|
|||
|
||||
for (const char* bp : bps)
|
||||
{
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromName(bp);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromName(bp);
|
||||
if (symbol)
|
||||
PowerPC::breakpoints.Add(symbol->address, false);
|
||||
}
|
||||
|
|
|
@ -310,10 +310,10 @@ int PPCDebugInterface::GetColor(unsigned int address)
|
|||
0xd0FFd0, // light green
|
||||
0xFFFFd0, // light yellow
|
||||
};
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (!symbol)
|
||||
return 0xFFFFFF;
|
||||
if (symbol->type != Symbol::Type::Function)
|
||||
if (symbol->type != Common::Symbol::Type::Function)
|
||||
return 0xEEEEFF;
|
||||
return colors[symbol->index % 6];
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ void RSOView::Apply(PPCSymbolDB* symbol_db) const
|
|||
u32 address = GetExportAddress(rso_export);
|
||||
if (address != 0)
|
||||
{
|
||||
Symbol* symbol = symbol_db->AddFunction(address);
|
||||
Common::Symbol* symbol = symbol_db->AddFunction(address);
|
||||
if (!symbol)
|
||||
symbol = symbol_db->GetSymbolFromAddr(address);
|
||||
|
||||
|
@ -389,7 +389,7 @@ void RSOView::Apply(PPCSymbolDB* symbol_db) const
|
|||
else
|
||||
{
|
||||
// Data symbol
|
||||
symbol_db->AddKnownSymbol(address, 0, export_name, Symbol::Type::Data);
|
||||
symbol_db->AddKnownSymbol(address, 0, export_name, Common::Symbol::Type::Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,10 +277,10 @@ int DSPDebugInterface::GetColor(unsigned int address)
|
|||
if (addr == -1)
|
||||
return 0xFFFFFF;
|
||||
|
||||
Symbol* symbol = Symbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* symbol = Symbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
|
||||
if (!symbol)
|
||||
return 0xFFFFFF;
|
||||
if (symbol->type != Symbol::Type::Function)
|
||||
if (symbol->type != Common::Symbol::Type::Function)
|
||||
return 0xEEEEFF;
|
||||
return colors[symbol->index % 6];
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ const char* GetLineText(int line)
|
|||
}
|
||||
}
|
||||
|
||||
Symbol* DSPSymbolDB::GetSymbolFromAddr(u32 addr)
|
||||
Common::Symbol* DSPSymbolDB::GetSymbolFromAddr(u32 addr)
|
||||
{
|
||||
auto it = m_functions.find(addr);
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace DSP
|
|||
{
|
||||
namespace Symbols
|
||||
{
|
||||
class DSPSymbolDB : public SymbolDB
|
||||
class DSPSymbolDB : public Common::SymbolDB
|
||||
{
|
||||
public:
|
||||
DSPSymbolDB() {}
|
||||
~DSPSymbolDB() {}
|
||||
Symbol* GetSymbolFromAddr(u32 addr) override;
|
||||
Common::Symbol* GetSymbolFromAddr(u32 addr) override;
|
||||
};
|
||||
|
||||
extern DSPSymbolDB g_dsp_symbol_db;
|
||||
|
|
|
@ -133,7 +133,7 @@ void JitBaseBlockCache::FinalizeBlock(JitBlock& block, bool block_link,
|
|||
LinkBlock(block);
|
||||
}
|
||||
|
||||
Symbol* symbol = nullptr;
|
||||
Common::Symbol* symbol = nullptr;
|
||||
if (JitRegister::IsEnabled() &&
|
||||
(symbol = g_symbolDB.GetSymbolFromAddr(block.effectiveAddress)) != nullptr)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ static u32 EvaluateBranchTarget(UGeckoInstruction instr, u32 pc)
|
|||
// Also collect which internal branch goes the farthest.
|
||||
// If any one goes farther than the blr or rfi, assume that there is more than
|
||||
// one blr or rfi, and keep scanning.
|
||||
bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
|
||||
bool AnalyzeFunction(u32 startAddr, Common::Symbol& func, u32 max_size)
|
||||
{
|
||||
if (func.name.empty())
|
||||
func.Rename(StringFromFormat("zz_%08x_", startAddr));
|
||||
|
@ -83,7 +83,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
|
|||
func.calls.clear();
|
||||
func.callers.clear();
|
||||
func.size = 0;
|
||||
func.flags = FFLAG_LEAF;
|
||||
func.flags = Common::FFLAG_LEAF;
|
||||
|
||||
u32 farthestInternalBranchTarget = startAddr;
|
||||
int numInternalBranches = 0;
|
||||
|
@ -100,7 +100,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
|
|||
func.size -= 4;
|
||||
func.hash = HashSignatureDB::ComputeCodeChecksum(startAddr, addr - 4);
|
||||
if (numInternalBranches == 0)
|
||||
func.flags |= FFLAG_STRAIGHT;
|
||||
func.flags |= Common::FFLAG_STRAIGHT;
|
||||
return true;
|
||||
}
|
||||
const PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(addr);
|
||||
|
@ -122,18 +122,18 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
|
|||
func.analyzed = true;
|
||||
func.hash = HashSignatureDB::ComputeCodeChecksum(startAddr, addr);
|
||||
if (numInternalBranches == 0)
|
||||
func.flags |= FFLAG_STRAIGHT;
|
||||
func.flags |= Common::FFLAG_STRAIGHT;
|
||||
return true;
|
||||
}
|
||||
else if (instr.hex == 0x4e800021 || instr.hex == 0x4e800420 || instr.hex == 0x4e800421)
|
||||
{
|
||||
func.flags &= ~FFLAG_LEAF;
|
||||
func.flags |= FFLAG_EVIL;
|
||||
func.flags &= ~Common::FFLAG_LEAF;
|
||||
func.flags |= Common::FFLAG_EVIL;
|
||||
}
|
||||
else if (instr.hex == 0x4c000064)
|
||||
{
|
||||
func.flags &= ~FFLAG_LEAF;
|
||||
func.flags |= FFLAG_RFI;
|
||||
func.flags &= ~Common::FFLAG_LEAF;
|
||||
func.flags |= Common::FFLAG_RFI;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
|
|||
{
|
||||
// Found a function call
|
||||
func.calls.emplace_back(target, addr);
|
||||
func.flags &= ~FFLAG_LEAF;
|
||||
func.flags &= ~Common::FFLAG_LEAF;
|
||||
}
|
||||
else if (instr.OPCD == 16)
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size)
|
|||
}
|
||||
}
|
||||
|
||||
bool ReanalyzeFunction(u32 start_addr, Symbol& func, u32 max_size)
|
||||
bool ReanalyzeFunction(u32 start_addr, Common::Symbol& func, u32 max_size)
|
||||
{
|
||||
ASSERT_MSG(SYMBOLS, func.analyzed, "The function wasn't previously analyzed!");
|
||||
|
||||
|
@ -176,17 +176,17 @@ bool ReanalyzeFunction(u32 start_addr, Symbol& func, u32 max_size)
|
|||
|
||||
// Second pass analysis, done after the first pass is done for all functions
|
||||
// so we have more information to work with
|
||||
static void AnalyzeFunction2(Symbol* func)
|
||||
static void AnalyzeFunction2(Common::Symbol* func)
|
||||
{
|
||||
u32 flags = func->flags;
|
||||
|
||||
bool nonleafcall = std::any_of(func->calls.begin(), func->calls.end(), [](const auto& call) {
|
||||
const Symbol* called_func = g_symbolDB.GetSymbolFromAddr(call.function);
|
||||
return called_func && (called_func->flags & FFLAG_LEAF) == 0;
|
||||
const Common::Symbol* called_func = g_symbolDB.GetSymbolFromAddr(call.function);
|
||||
return called_func && (called_func->flags & Common::FFLAG_LEAF) == 0;
|
||||
});
|
||||
|
||||
if (nonleafcall && !(flags & FFLAG_EVIL) && !(flags & FFLAG_RFI))
|
||||
flags |= FFLAG_ONLYCALLSNICELEAFS;
|
||||
if (nonleafcall && !(flags & Common::FFLAG_EVIL) && !(flags & Common::FFLAG_RFI))
|
||||
flags |= Common::FFLAG_ONLYCALLSNICELEAFS;
|
||||
|
||||
func->flags = flags;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ static bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b)
|
|||
// called by another function. Therefore, let's scan the
|
||||
// entire space for bl operations and find what functions
|
||||
// get called.
|
||||
static void FindFunctionsFromBranches(u32 startAddr, u32 endAddr, SymbolDB* func_db)
|
||||
static void FindFunctionsFromBranches(u32 startAddr, u32 endAddr, Common::SymbolDB* func_db)
|
||||
{
|
||||
for (u32 addr = startAddr; addr < endAddr; addr += 4)
|
||||
{
|
||||
|
@ -312,7 +312,7 @@ static void FindFunctionsFromHandlers(PPCSymbolDB* func_db)
|
|||
if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex))
|
||||
{
|
||||
// Check if this function is already mapped
|
||||
Symbol* f = func_db->AddFunction(entry.first);
|
||||
Common::Symbol* f = func_db->AddFunction(entry.first);
|
||||
if (!f)
|
||||
continue;
|
||||
f->Rename(entry.second);
|
||||
|
@ -344,7 +344,7 @@ static void FindFunctionsAfterReturnInstruction(PPCSymbolDB* func_db)
|
|||
if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex))
|
||||
{
|
||||
// check if this function is already mapped
|
||||
Symbol* f = func_db->AddFunction(location);
|
||||
Common::Symbol* f = func_db->AddFunction(location);
|
||||
if (!f)
|
||||
break;
|
||||
else
|
||||
|
@ -377,20 +377,20 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
|
|||
continue;
|
||||
}
|
||||
AnalyzeFunction2(&(func.second));
|
||||
Symbol& f = func.second;
|
||||
Common::Symbol& f = func.second;
|
||||
if (f.name.substr(0, 3) == "zzz")
|
||||
{
|
||||
if (f.flags & FFLAG_LEAF)
|
||||
if (f.flags & Common::FFLAG_LEAF)
|
||||
f.Rename(f.name + "_leaf");
|
||||
if (f.flags & FFLAG_STRAIGHT)
|
||||
if (f.flags & Common::FFLAG_STRAIGHT)
|
||||
f.Rename(f.name + "_straight");
|
||||
}
|
||||
if (f.flags & FFLAG_LEAF)
|
||||
if (f.flags & Common::FFLAG_LEAF)
|
||||
{
|
||||
numLeafs++;
|
||||
leafSize += f.size;
|
||||
}
|
||||
else if (f.flags & FFLAG_ONLYCALLSNICELEAFS)
|
||||
else if (f.flags & Common::FFLAG_ONLYCALLSNICELEAFS)
|
||||
{
|
||||
numNice++;
|
||||
niceSize += f.size;
|
||||
|
@ -401,11 +401,11 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
|
|||
unniceSize += f.size;
|
||||
}
|
||||
|
||||
if (f.flags & FFLAG_TIMERINSTRUCTIONS)
|
||||
if (f.flags & Common::FFLAG_TIMERINSTRUCTIONS)
|
||||
numTimer++;
|
||||
if (f.flags & FFLAG_RFI)
|
||||
if (f.flags & Common::FFLAG_RFI)
|
||||
numRFI++;
|
||||
if ((f.flags & FFLAG_STRAIGHT) && (f.flags & FFLAG_LEAF))
|
||||
if ((f.flags & Common::FFLAG_STRAIGHT) && (f.flags & Common::FFLAG_LEAF))
|
||||
numStraightLeaf++;
|
||||
}
|
||||
if (numLeafs == 0)
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
#include "Core/PowerPC/PPCTables.h"
|
||||
|
||||
class PPCSymbolDB;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
struct Symbol;
|
||||
}
|
||||
|
||||
namespace PPCAnalyst
|
||||
{
|
||||
|
@ -216,7 +220,7 @@ private:
|
|||
|
||||
void LogFunctionCall(u32 addr);
|
||||
void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db);
|
||||
bool AnalyzeFunction(u32 startAddr, Symbol& func, u32 max_size = 0);
|
||||
bool ReanalyzeFunction(u32 start_addr, Symbol& func, u32 max_size = 0);
|
||||
bool AnalyzeFunction(u32 startAddr, Common::Symbol& func, u32 max_size = 0);
|
||||
bool ReanalyzeFunction(u32 start_addr, Common::Symbol& func, u32 max_size = 0);
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -28,31 +28,31 @@ PPCSymbolDB::PPCSymbolDB() : debugger{&PowerPC::debug_interface}
|
|||
PPCSymbolDB::~PPCSymbolDB() = default;
|
||||
|
||||
// Adds the function to the list, unless it's already there
|
||||
Symbol* PPCSymbolDB::AddFunction(u32 start_addr)
|
||||
Common::Symbol* PPCSymbolDB::AddFunction(u32 start_addr)
|
||||
{
|
||||
// It's already in the list
|
||||
if (m_functions.find(start_addr) != m_functions.end())
|
||||
return nullptr;
|
||||
|
||||
Symbol symbol;
|
||||
Common::Symbol symbol;
|
||||
if (!PPCAnalyst::AnalyzeFunction(start_addr, symbol))
|
||||
return nullptr;
|
||||
|
||||
m_functions[start_addr] = std::move(symbol);
|
||||
Symbol* ptr = &m_functions[start_addr];
|
||||
ptr->type = Symbol::Type::Function;
|
||||
Common::Symbol* ptr = &m_functions[start_addr];
|
||||
ptr->type = Common::Symbol::Type::Function;
|
||||
m_checksum_to_function[ptr->hash].insert(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
|
||||
Symbol::Type type)
|
||||
Common::Symbol::Type type)
|
||||
{
|
||||
auto iter = m_functions.find(startAddr);
|
||||
if (iter != m_functions.end())
|
||||
{
|
||||
// already got it, let's just update name, checksum & size to be sure.
|
||||
Symbol* tempfunc = &iter->second;
|
||||
Common::Symbol* tempfunc = &iter->second;
|
||||
tempfunc->Rename(name);
|
||||
tempfunc->hash = HashSignatureDB::ComputeCodeChecksum(startAddr, startAddr + size - 4);
|
||||
tempfunc->type = type;
|
||||
|
@ -61,11 +61,11 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
|
|||
else
|
||||
{
|
||||
// new symbol. run analyze.
|
||||
Symbol tf;
|
||||
Common::Symbol tf;
|
||||
tf.Rename(name);
|
||||
tf.type = type;
|
||||
tf.address = startAddr;
|
||||
if (tf.type == Symbol::Type::Function)
|
||||
if (tf.type == Common::Symbol::Type::Function)
|
||||
{
|
||||
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
|
||||
// Do not truncate symbol when a size is expected
|
||||
|
@ -85,7 +85,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
|
|||
}
|
||||
}
|
||||
|
||||
Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
|
||||
Common::Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
|
||||
{
|
||||
auto it = m_functions.lower_bound(addr);
|
||||
if (it == m_functions.end())
|
||||
|
@ -106,7 +106,7 @@ Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
|
|||
|
||||
std::string PPCSymbolDB::GetDescription(u32 addr)
|
||||
{
|
||||
Symbol* symbol = GetSymbolFromAddr(addr);
|
||||
Common::Symbol* symbol = GetSymbolFromAddr(addr);
|
||||
if (symbol)
|
||||
return symbol->name;
|
||||
else
|
||||
|
@ -122,16 +122,16 @@ void PPCSymbolDB::FillInCallers()
|
|||
|
||||
for (auto& entry : m_functions)
|
||||
{
|
||||
Symbol& f = entry.second;
|
||||
for (const SCall& call : f.calls)
|
||||
Common::Symbol& f = entry.second;
|
||||
for (const Common::SCall& call : f.calls)
|
||||
{
|
||||
const SCall new_call(entry.first, call.call_address);
|
||||
const Common::SCall new_call(entry.first, call.call_address);
|
||||
const u32 function_address = call.function;
|
||||
|
||||
auto func_iter = m_functions.find(function_address);
|
||||
if (func_iter != m_functions.end())
|
||||
{
|
||||
Symbol& called_function = func_iter->second;
|
||||
Common::Symbol& called_function = func_iter->second;
|
||||
called_function.callers.push_back(new_call);
|
||||
}
|
||||
else
|
||||
|
@ -153,9 +153,9 @@ void PPCSymbolDB::PrintCalls(u32 funcAddr) const
|
|||
return;
|
||||
}
|
||||
|
||||
const Symbol& f = iter->second;
|
||||
const Common::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)
|
||||
for (const Common::SCall& call : f.calls)
|
||||
{
|
||||
const auto n = m_functions.find(call.function);
|
||||
if (n != m_functions.end())
|
||||
|
@ -171,9 +171,9 @@ void PPCSymbolDB::PrintCallers(u32 funcAddr) const
|
|||
if (iter == m_functions.end())
|
||||
return;
|
||||
|
||||
const Symbol& f = iter->second;
|
||||
const Common::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)
|
||||
for (const Common::SCall& caller : f.callers)
|
||||
{
|
||||
const auto n = m_functions.find(caller.function);
|
||||
if (n != m_functions.end())
|
||||
|
@ -189,7 +189,7 @@ void PPCSymbolDB::LogFunctionCall(u32 addr)
|
|||
if (iter == m_functions.end())
|
||||
return;
|
||||
|
||||
Symbol& f = iter->second;
|
||||
Common::Symbol& f = iter->second;
|
||||
f.num_calls++;
|
||||
}
|
||||
|
||||
|
@ -400,9 +400,9 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
|
|||
{
|
||||
++good_count;
|
||||
if (section_name == ".text" || section_name == ".init")
|
||||
AddKnownSymbol(vaddress, size, name, Symbol::Type::Function);
|
||||
AddKnownSymbol(vaddress, size, name, Common::Symbol::Type::Function);
|
||||
else
|
||||
AddKnownSymbol(vaddress, size, name, Symbol::Type::Data);
|
||||
AddKnownSymbol(vaddress, size, name, Common::Symbol::Type::Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -423,13 +423,13 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const
|
|||
if (!f)
|
||||
return false;
|
||||
|
||||
std::vector<const Symbol*> function_symbols;
|
||||
std::vector<const Symbol*> data_symbols;
|
||||
std::vector<const Common::Symbol*> function_symbols;
|
||||
std::vector<const Common::Symbol*> data_symbols;
|
||||
|
||||
for (const auto& function : m_functions)
|
||||
{
|
||||
const Symbol& symbol = function.second;
|
||||
if (symbol.type == Symbol::Type::Function)
|
||||
const Common::Symbol& symbol = function.second;
|
||||
if (symbol.type == Common::Symbol::Type::Function)
|
||||
function_symbols.push_back(&symbol);
|
||||
else
|
||||
data_symbols.push_back(&symbol);
|
||||
|
@ -474,7 +474,7 @@ bool PPCSymbolDB::SaveCodeMap(const std::string& filename) const
|
|||
u32 next_address = 0;
|
||||
for (const auto& function : m_functions)
|
||||
{
|
||||
const Symbol& symbol = function.second;
|
||||
const Common::Symbol& symbol = function.second;
|
||||
|
||||
// Skip functions which are inside bigger functions
|
||||
if (symbol.address + symbol.size <= next_address)
|
||||
|
|
|
@ -14,17 +14,17 @@
|
|||
#include "Core/Debugger/PPCDebugInterface.h"
|
||||
|
||||
// This has functionality overlapping Debugger_Symbolmap. Should merge that stuff in here later.
|
||||
class PPCSymbolDB : public SymbolDB
|
||||
class PPCSymbolDB : public Common::SymbolDB
|
||||
{
|
||||
public:
|
||||
PPCSymbolDB();
|
||||
~PPCSymbolDB() override;
|
||||
|
||||
Symbol* AddFunction(u32 start_addr) override;
|
||||
Common::Symbol* AddFunction(u32 start_addr) override;
|
||||
void AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
|
||||
Symbol::Type type = Symbol::Type::Function);
|
||||
Common::Symbol::Type type = Common::Symbol::Type::Function);
|
||||
|
||||
Symbol* GetSymbolFromAddr(u32 addr) override;
|
||||
Common::Symbol* GetSymbolFromAddr(u32 addr) override;
|
||||
|
||||
std::string GetDescription(u32 addr);
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ void CodeViewWidget::OnCopyFunction()
|
|||
{
|
||||
const u32 address = GetContextAddress();
|
||||
|
||||
const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (!symbol)
|
||||
return;
|
||||
|
||||
|
@ -361,7 +361,7 @@ void CodeViewWidget::OnRenameSymbol()
|
|||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
|
||||
if (!symbol)
|
||||
return;
|
||||
|
@ -396,7 +396,7 @@ void CodeViewWidget::OnSetSymbolSize()
|
|||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
|
||||
if (!symbol)
|
||||
return;
|
||||
|
@ -419,7 +419,7 @@ void CodeViewWidget::OnSetSymbolEndAddress()
|
|||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
|
||||
if (!symbol)
|
||||
return;
|
||||
|
|
|
@ -202,7 +202,7 @@ void CodeWidget::OnSelectSymbol()
|
|||
return;
|
||||
|
||||
const u32 address = items[0]->data(Qt::UserRole).toUInt();
|
||||
const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
|
||||
m_code_view->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate);
|
||||
UpdateCallstack();
|
||||
|
@ -252,7 +252,7 @@ void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update
|
|||
|
||||
void CodeWidget::Update()
|
||||
{
|
||||
const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
|
||||
UpdateCallstack();
|
||||
|
||||
|
@ -309,7 +309,7 @@ void CodeWidget::UpdateSymbols()
|
|||
item->setSelected(true);
|
||||
|
||||
// Disable non-function symbols as you can't do anything with them.
|
||||
if (symbol.second.type != Symbol::Type::Function)
|
||||
if (symbol.second.type != Common::Symbol::Type::Function)
|
||||
item->setFlags(Qt::NoItemFlags);
|
||||
|
||||
item->setData(Qt::UserRole, symbol.second.address);
|
||||
|
@ -321,14 +321,14 @@ void CodeWidget::UpdateSymbols()
|
|||
m_symbols_list->sortItems();
|
||||
}
|
||||
|
||||
void CodeWidget::UpdateFunctionCalls(const Symbol* symbol)
|
||||
void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
|
||||
{
|
||||
m_function_calls_list->clear();
|
||||
|
||||
for (const auto& call : symbol->calls)
|
||||
{
|
||||
const u32 addr = call.function;
|
||||
const Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
const Common::Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
|
||||
if (call_symbol)
|
||||
{
|
||||
|
@ -341,14 +341,14 @@ void CodeWidget::UpdateFunctionCalls(const Symbol* symbol)
|
|||
}
|
||||
}
|
||||
|
||||
void CodeWidget::UpdateFunctionCallers(const Symbol* symbol)
|
||||
void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
|
||||
{
|
||||
m_function_callers_list->clear();
|
||||
|
||||
for (const auto& caller : symbol->callers)
|
||||
{
|
||||
const u32 addr = caller.call_address;
|
||||
const Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
const Common::Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
|
||||
if (caller_symbol)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,11 @@ class QLineEdit;
|
|||
class QSplitter;
|
||||
class QListWidget;
|
||||
class QTableWidget;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
struct Symbol;
|
||||
}
|
||||
|
||||
class CodeWidget : public QDockWidget
|
||||
{
|
||||
|
@ -45,8 +49,8 @@ private:
|
|||
void CreateWidgets();
|
||||
void ConnectWidgets();
|
||||
void UpdateCallstack();
|
||||
void UpdateFunctionCalls(const Symbol* symbol);
|
||||
void UpdateFunctionCallers(const Symbol* symbol);
|
||||
void UpdateFunctionCalls(const Common::Symbol* symbol);
|
||||
void UpdateFunctionCallers(const Common::Symbol* symbol);
|
||||
|
||||
void OnSearchAddress();
|
||||
void OnSearchSymbols();
|
||||
|
|
|
@ -45,7 +45,7 @@ void CBreakPointView::Repopulate()
|
|||
int item = InsertItem(0, breakpoint_enabled_str);
|
||||
SetItem(item, 1, StrToWxStr("BP"));
|
||||
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rBP.address);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rBP.address);
|
||||
if (symbol)
|
||||
{
|
||||
wxString symbol_description = StrToWxStr(g_symbolDB.GetDescription(rBP.address));
|
||||
|
@ -67,7 +67,7 @@ void CBreakPointView::Repopulate()
|
|||
int item = InsertItem(0, memcheck_on_str);
|
||||
SetItem(item, 1, StrToWxStr("MBP"));
|
||||
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.start_address);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.start_address);
|
||||
if (symbol)
|
||||
{
|
||||
wxString memcheck_start_addr = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.start_address));
|
||||
|
|
|
@ -57,7 +57,7 @@ enum
|
|||
IDM_ADDFUNCTION,
|
||||
};
|
||||
|
||||
CCodeView::CCodeView(DebugInterface* debuginterface, SymbolDB* symboldb, wxWindow* parent,
|
||||
CCodeView::CCodeView(DebugInterface* debuginterface, Common::SymbolDB* symboldb, wxWindow* parent,
|
||||
wxWindowID Id)
|
||||
: wxControl(parent, Id), m_debugger(debuginterface), m_symbol_db(symboldb), m_plain(false),
|
||||
m_curAddress(debuginterface->GetPC()), m_align(debuginterface->GetInstructionSize(0)),
|
||||
|
@ -243,7 +243,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
|
|||
|
||||
case IDM_COPYFUNCTION:
|
||||
{
|
||||
Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
Common::Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
if (symbol)
|
||||
{
|
||||
std::string text;
|
||||
|
@ -335,7 +335,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
|
|||
|
||||
case IDM_RENAMESYMBOL:
|
||||
{
|
||||
Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
Common::Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
if (symbol)
|
||||
{
|
||||
wxTextEntryDialog input_symbol(this, _("Rename symbol:"), wxGetTextFromUserPromptStr,
|
||||
|
@ -352,7 +352,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
|
|||
|
||||
case IDM_SETSYMBOLSIZE:
|
||||
{
|
||||
Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
Common::Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
if (!symbol)
|
||||
break;
|
||||
|
||||
|
@ -375,7 +375,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
|
|||
|
||||
case IDM_SETSYMBOLEND:
|
||||
{
|
||||
Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
Common::Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
|
||||
if (!symbol)
|
||||
break;
|
||||
|
||||
|
|
|
@ -18,13 +18,17 @@
|
|||
wxDECLARE_EVENT(wxEVT_CODEVIEW_CHANGE, wxCommandEvent);
|
||||
|
||||
class DebugInterface;
|
||||
class SymbolDB;
|
||||
class wxPaintDC;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
class SymbolDB;
|
||||
}
|
||||
|
||||
class CCodeView : public wxControl
|
||||
{
|
||||
public:
|
||||
CCodeView(DebugInterface* debuginterface, SymbolDB* symbol_db, wxWindow* parent,
|
||||
CCodeView(DebugInterface* debuginterface, Common::SymbolDB* symbol_db, wxWindow* parent,
|
||||
wxWindowID Id = wxID_ANY);
|
||||
|
||||
void ToggleBreakpoint(u32 address);
|
||||
|
@ -58,7 +62,7 @@ private:
|
|||
static constexpr int LEFT_COL_WIDTH = 16;
|
||||
|
||||
DebugInterface* m_debugger;
|
||||
SymbolDB* m_symbol_db;
|
||||
Common::SymbolDB* m_symbol_db;
|
||||
|
||||
bool m_plain;
|
||||
|
||||
|
|
|
@ -434,14 +434,14 @@ void CCodeWindow::UpdateLists()
|
|||
{
|
||||
callers->Clear();
|
||||
u32 addr = codeview->GetSelection();
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
if (!symbol)
|
||||
return;
|
||||
|
||||
for (auto& call : symbol->callers)
|
||||
{
|
||||
u32 caller_addr = call.call_address;
|
||||
Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
|
||||
Common::Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
|
||||
if (caller_symbol)
|
||||
{
|
||||
int idx = callers->Append(StrToWxStr(
|
||||
|
@ -454,7 +454,7 @@ void CCodeWindow::UpdateLists()
|
|||
for (auto& call : symbol->calls)
|
||||
{
|
||||
u32 call_addr = call.function;
|
||||
Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
|
||||
Common::Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
|
||||
if (call_symbol)
|
||||
{
|
||||
int idx = calls->Append(StrToWxStr(
|
||||
|
|
|
@ -335,7 +335,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
|||
std::istringstream ss(line);
|
||||
ss >> std::hex >> address >> std::dec >> type >> name;
|
||||
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (symbol)
|
||||
symbol->Rename(line.substr(12));
|
||||
}
|
||||
|
@ -474,10 +474,10 @@ void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
|
|||
int index = symbols->GetSelection();
|
||||
if (index >= 0)
|
||||
{
|
||||
Symbol* pSymbol = static_cast<Symbol*>(symbols->GetClientData(index));
|
||||
auto* pSymbol = static_cast<Common::Symbol*>(symbols->GetClientData(index));
|
||||
if (pSymbol != nullptr)
|
||||
{
|
||||
if (pSymbol->type == Symbol::Type::Data)
|
||||
if (pSymbol->type == Common::Symbol::Type::Data)
|
||||
{
|
||||
CMemoryWindow* memory = GetPanel<CMemoryWindow>();
|
||||
if (memory)
|
||||
|
|
|
@ -223,10 +223,10 @@ void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
|
|||
int index = m_SymbolList->GetSelection();
|
||||
if (index >= 0)
|
||||
{
|
||||
Symbol* pSymbol = static_cast<Symbol*>(m_SymbolList->GetClientData(index));
|
||||
auto* pSymbol = static_cast<Common::Symbol*>(m_SymbolList->GetClientData(index));
|
||||
if (pSymbol != nullptr)
|
||||
{
|
||||
if (pSymbol->type == Symbol::Type::Function)
|
||||
if (pSymbol->type == Common::Symbol::Type::Function)
|
||||
{
|
||||
JumpToAddress(pSymbol->address);
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ wxString CMemoryView::ReadMemoryAsString(u32 address) const
|
|||
str += ' ';
|
||||
}
|
||||
|
||||
Symbol* sym = g_symbolDB.GetSymbolFromAddr(mem_data);
|
||||
Common::Symbol* sym = g_symbolDB.GetSymbolFromAddr(mem_data);
|
||||
if (sym)
|
||||
{
|
||||
str += StringFromFormat(" # -> %s", sym->name.c_str());
|
||||
|
|
Loading…
Reference in New Issue