Skip to content

Commit

Permalink
DebugTools: Simplify the symbol map
Browse files Browse the repository at this point in the history
  • Loading branch information
F0bes committed Oct 26, 2023
1 parent e9ead0d commit a0ba441
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 482 deletions.
2 changes: 1 addition & 1 deletion pcsx2-qt/Debugger/CpuWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ void CpuWidget::onFuncListContextMenu(QPoint pos)
// Resolve the function name by fetching the symbolmap and filtering the address

const QListWidgetItem* selectedItem = m_ui.listFunctions->selectedItems().first();
const QString functionName = QString(m_cpu.GetSymbolMap().GetLabelString(selectedItem->data(256).toUInt()).c_str());
const QString functionName = QString(m_cpu.GetSymbolMap().GetLabelName(selectedItem->data(256).toUInt()).c_str());
QApplication::clipboard()->setText(functionName);
});
m_funclistContextMenu->addAction(copyName);
Expand Down
10 changes: 3 additions & 7 deletions pcsx2-qt/Debugger/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ void DisassemblyWidget::contextAddFunction()
newSize = prevSize - newSize;
m_cpu->GetSymbolMap().AddFunction(funcName.toLocal8Bit().constData(), curAddress, newSize);
m_cpu->GetSymbolMap().SortSymbols();
m_cpu->GetSymbolMap().UpdateActiveSymbols();
}
}
else
Expand All @@ -232,7 +231,6 @@ void DisassemblyWidget::contextAddFunction()

m_cpu->GetSymbolMap().AddFunction(funcName.toLocal8Bit().constData(), m_selectedAddressStart, m_selectedAddressEnd + 4 - m_selectedAddressStart);
m_cpu->GetSymbolMap().SortSymbols();
m_cpu->GetSymbolMap().UpdateActiveSymbols();
}
}

Expand All @@ -250,9 +248,8 @@ void DisassemblyWidget::contextRemoveFunction()
m_cpu->GetSymbolMap().SetFunctionSize(previousFuncAddr, expandedSize);
}

m_cpu->GetSymbolMap().RemoveFunction(curFuncAddr, true);
m_cpu->GetSymbolMap().RemoveFunction(curFuncAddr);
m_cpu->GetSymbolMap().SortSymbols();
m_cpu->GetSymbolMap().UpdateActiveSymbols();
}
}

Expand All @@ -262,7 +259,7 @@ void DisassemblyWidget::contextRenameFunction()
if (curFuncAddress != SymbolMap::INVALID_ADDRESS)
{
bool ok;
QString funcName = QInputDialog::getText(this, tr("Rename Function"), tr("Function name"), QLineEdit::Normal, m_cpu->GetSymbolMap().GetLabelString(curFuncAddress).c_str(), &ok);
QString funcName = QInputDialog::getText(this, tr("Rename Function"), tr("Function name"), QLineEdit::Normal, m_cpu->GetSymbolMap().GetLabelName(curFuncAddress).c_str(), &ok);
if (!ok)
return;

Expand All @@ -274,7 +271,6 @@ void DisassemblyWidget::contextRenameFunction()
{
m_cpu->GetSymbolMap().SetLabelName(funcName.toLocal8Bit().constData(), curFuncAddress);
m_cpu->GetSymbolMap().SortSymbols();
m_cpu->GetSymbolMap().UpdateActiveSymbols();
this->repaint();
}
}
Expand Down Expand Up @@ -713,7 +709,7 @@ inline QString DisassemblyWidget::DisassemblyStringFromAddress(u32 address, QFon
const bool isConditionalMet = line.info.conditionMet;
const bool isCurrentPC = m_cpu->getPC() == address;

const std::string addressSymbol = m_cpu->GetSymbolMap().GetLabelString(address);
const std::string addressSymbol = m_cpu->GetSymbolMap().GetLabelName(address);

const auto demangler = demangler::CDemangler::createGcc();

Expand Down
6 changes: 3 additions & 3 deletions pcsx2-qt/Debugger/Models/BreakpointModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ QVariant BreakpointModel::data(const QModelIndex& index, int role) const
case BreakpointColumns::OFFSET:
return QtUtils::FilledQStringFromValue(bp->addr, 16);
case BreakpointColumns::SIZE_LABEL:
return m_cpu.GetSymbolMap().GetLabelString(bp->addr).c_str();
return m_cpu.GetSymbolMap().GetLabelName(bp->addr).c_str();
case BreakpointColumns::OPCODE:
// Note: Fix up the disassemblymanager so we can use it here, instead of calling a function through the disassemblyview (yuck)
return m_cpu.disasm(bp->addr, true).c_str();
Expand Down Expand Up @@ -111,7 +111,7 @@ QVariant BreakpointModel::data(const QModelIndex& index, int role) const
case BreakpointColumns::OFFSET:
return bp->addr;
case BreakpointColumns::SIZE_LABEL:
return m_cpu.GetSymbolMap().GetLabelString(bp->addr).c_str();
return m_cpu.GetSymbolMap().GetLabelName(bp->addr).c_str();
case BreakpointColumns::OPCODE:
// Note: Fix up the disassemblymanager so we can use it here, instead of calling a function through the disassemblyview (yuck)
return m_cpu.disasm(bp->addr, true).c_str();
Expand Down Expand Up @@ -157,7 +157,7 @@ QVariant BreakpointModel::data(const QModelIndex& index, int role) const
case BreakpointColumns::OFFSET:
return QtUtils::FilledQStringFromValue(bp->addr, 16);
case BreakpointColumns::SIZE_LABEL:
return m_cpu.GetSymbolMap().GetLabelString(bp->addr).c_str();
return m_cpu.GetSymbolMap().GetLabelName(bp->addr).c_str();
case BreakpointColumns::OPCODE:
// Note: Fix up the disassemblymanager so we can use it here, instead of calling a function through the disassemblyview (yuck)
return m_cpu.disasm(bp->addr, true).c_str();
Expand Down
4 changes: 2 additions & 2 deletions pcsx2-qt/Debugger/Models/StackModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ QVariant StackModel::data(const QModelIndex& index, int role) const
case StackModel::ENTRY:
return QtUtils::FilledQStringFromValue(stackFrame.entry, 16);
case StackModel::ENTRY_LABEL:
return m_cpu.GetSymbolMap().GetLabelString(stackFrame.entry).c_str();
return m_cpu.GetSymbolMap().GetLabelName(stackFrame.entry).c_str();
case StackModel::PC:
return QtUtils::FilledQStringFromValue(stackFrame.pc, 16);
case StackModel::PC_OPCODE:
Expand All @@ -66,7 +66,7 @@ QVariant StackModel::data(const QModelIndex& index, int role) const
case StackModel::ENTRY:
return stackFrame.entry;
case StackModel::ENTRY_LABEL:
return m_cpu.GetSymbolMap().GetLabelString(stackFrame.entry).c_str();
return m_cpu.GetSymbolMap().GetLabelName(stackFrame.entry).c_str();
case StackModel::PC:
return stackFrame.pc;
case StackModel::PC_OPCODE:
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/CDVD/CDVDcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void CDVDsys_SetFile(CDVD_SourceType srctype, std::string newfile)
symName = m_SourceFilename[enum_cast(srctype)].substr(0, n) + ".sym";

R5900SymbolMap.LoadNocashSym(symName.c_str());
R5900SymbolMap.UpdateActiveSymbols();
R5900SymbolMap.SortSymbols();
}
}

Expand Down
8 changes: 4 additions & 4 deletions pcsx2/DebugTools/DisassemblyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static void parseDisasm(SymbolMap& map, const char* disasm, char* opcode, char*
u32 branchTarget;
sscanf(disasm+3,"0x%08x",&branchTarget);

const std::string addressSymbol = map.GetLabelString(branchTarget);
const std::string addressSymbol = map.GetLabelName(branchTarget);
if (!addressSymbol.empty() && insertSymbols)
{
arguments += std::snprintf(arguments, arguments_size, "%s",addressSymbol.c_str());
Expand Down Expand Up @@ -777,7 +777,7 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool
case MACRO_LI:
dest.name = name;

addressSymbol = cpu->GetSymbolMap().GetLabelString(immediate);
addressSymbol = cpu->GetSymbolMap().GetLabelName(immediate);
if (!addressSymbol.empty() && insertSymbols)
{
std::snprintf(buffer,std::size(buffer),"%s,%s",cpu->getRegisterName(0,rt),addressSymbol.c_str());
Expand All @@ -793,7 +793,7 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool
case MACRO_MEMORYIMM:
dest.name = name;

addressSymbol = cpu->GetSymbolMap().GetLabelString(immediate);
addressSymbol = cpu->GetSymbolMap().GetLabelName(immediate);
if (!addressSymbol.empty() && insertSymbols)
{
std::snprintf(buffer,std::size(buffer),"%s,%s",cpu->getRegisterName(0,rt),addressSymbol.c_str());
Expand Down Expand Up @@ -988,7 +988,7 @@ void DisassemblyData::createLines()
case DATATYPE_WORD:
{
value = memRead32(pos);
const std::string label = cpu->GetSymbolMap().GetLabelString(value);
const std::string label = cpu->GetSymbolMap().GetLabelName(value);
if (!label.empty())
std::snprintf(buffer,std::size(buffer),"%s",label.c_str());
else
Expand Down
Loading

0 comments on commit a0ba441

Please sign in to comment.