Debugger: Demangle symbols in the disassembly view as well

This commit is contained in:
Ty Lamontagne 2023-10-09 21:52:12 -04:00 committed by Connor McLaughlin
parent 065f7d6cc7
commit 8d13877002
4 changed files with 9 additions and 1 deletions

View File

@ -550,6 +550,7 @@ void CpuWidget::onFuncListContextMenu(QPoint pos)
connect(demangleAction, &QAction::triggered, [this] {
m_demangleFunctions = !m_demangleFunctions;
m_ui.disassemblyWidget->setDemangle(m_demangleFunctions);
updateFunctionList();
});

View File

@ -73,6 +73,7 @@ public slots:
void updateFunctionList(bool whenEmpty = false);
void onFuncListContextMenu(QPoint pos);
void onFuncListDoubleClick(QListWidgetItem* item);
bool getDemangleFunctions() const { return m_demangleFunctions; }
void reloadCPUWidgets()
{

View File

@ -21,6 +21,7 @@
#include "DebugTools/DisassemblyManager.h"
#include "DebugTools/Breakpoints.h"
#include "DebugTools/MipsAssembler.h"
#include "demangler/demangler.h"
#include "QtUtils.h"
#include "QtHost.h"
@ -699,6 +700,8 @@ inline QString DisassemblyWidget::DisassemblyStringFromAddress(u32 address, QFon
const bool isBreakpoint = CBreakPoints::IsAddressBreakPoint(m_cpu->getCpuType(), address) && !CBreakPoints::IsTempBreakPoint(m_cpu->getCpuType(), address);
const std::string addressSymbol = m_cpu->GetSymbolMap().GetLabelString(address);
const auto demangler = demangler::CDemangler::createGcc();
QString lineString("%1 %2 %3 %4 %5 %6");
lineString = lineString.arg(isBreakpoint ? "\u25A0" : " "); // Bp block ( ■ )
@ -708,7 +711,7 @@ inline QString DisassemblyWidget::DisassemblyStringFromAddress(u32 address, QFon
{
// We want this text elided
QFontMetrics metric(font);
lineString = lineString.arg(metric.elidedText(QString::fromStdString(addressSymbol), Qt::ElideRight, (selected ? 32 : 8) * font.pointSize()));
lineString = lineString.arg(metric.elidedText(QString::fromStdString((m_demangleFunctions ? demangler->demangleToString(addressSymbol) : addressSymbol)), Qt::ElideRight, (selected ? 32 : 8) * font.pointSize()));
}
lineString = lineString.leftJustified(4, ' ') // Address / symbol

View File

@ -70,6 +70,7 @@ public slots:
void gotoAddress(u32 address);
void setDemangle(bool demangle) { m_demangleFunctions = demangle; };
signals:
void gotoInMemory(u32 address);
void breakpointsChanged();
@ -88,6 +89,8 @@ private:
std::map<u32, u32> m_nopedInstructions;
std::map<u32, std::tuple<u32, u32>> m_stubbedFunctions;
bool m_demangleFunctions = true;
DisassemblyManager m_disassemblyManager;
inline QString DisassemblyStringFromAddress(u32 address, QFont font, u32 pc, bool selected);