Skip to content

Commit

Permalink
Debugger: Demangle symbols in the disassembly view as well
Browse files Browse the repository at this point in the history
  • Loading branch information
F0bes authored and stenzek committed Oct 12, 2023
1 parent 065f7d6 commit 8d13877
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pcsx2-qt/Debugger/CpuWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/Debugger/CpuWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
5 changes: 4 additions & 1 deletion pcsx2-qt/Debugger/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ( ■ )
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pcsx2-qt/Debugger/DisassemblyWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public slots:

void gotoAddress(u32 address);

void setDemangle(bool demangle) { m_demangleFunctions = demangle; };
signals:
void gotoInMemory(u32 address);
void breakpointsChanged();
Expand All @@ -88,6 +89,8 @@ public slots:
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);
Expand Down

0 comments on commit 8d13877

Please sign in to comment.