From 520daeeb2427d3a9f89141fcc0ccee243e5ceea0 Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Sun, 24 Nov 2013 08:53:09 +0100 Subject: [PATCH] Remove empty lines in disasmview to remove visual noise. Port over part of the callstack code, still missing function name lookup and navigation on double click. This is just an intermediate commit, I don't want to have to rebase this again when I contine to work on it. --- Qt/ctrldisasmview.cpp | 30 ++++++++++------- Qt/ctrlmemview.cpp | 2 +- Qt/debugger_disasm.cpp | 76 ++++++++++++++++++++++++++++-------------- Qt/debugger_disasm.h | 8 ++++- Qt/debugger_disasm.ui | 36 ++++++++++++++++---- 5 files changed, 107 insertions(+), 45 deletions(-) diff --git a/Qt/ctrldisasmview.cpp b/Qt/ctrldisasmview.cpp index 55625b052e..d1a7fec5b1 100644 --- a/Qt/ctrldisasmview.cpp +++ b/Qt/ctrldisasmview.cpp @@ -237,7 +237,7 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *) int numBranches=0; int width = rect().width(); - int numRows=(rect().height()/rowHeight)/2+1; + int numRows=(rect().height()/rowHeight); QColor bgColor(0xFFFFFFFF); QPen nullPen(bgColor); @@ -253,6 +253,7 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *) QFont normalFont("Arial", 10); QFont boldFont("Arial", 10); QFont alignedFont("Monospace", 10); + alignedFont.setStyleHint(QFont::Monospace); boldFont.setBold(true); painter.setFont(normalFont); @@ -262,25 +263,29 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *) curAddress&=~(align-1); align=(debugger->getInstructionSize(0)); - for (i=-numRows; i<=numRows; i++) + for (i=0; i<=numRows; i++) { - unsigned int address=curAddress + i*align; + unsigned int address=curAddress + (i-(numRows/2))*align; - int rowY1 = rect().bottom()/2 + rowHeight*i - rowHeight/2; - int rowY2 = rect().bottom()/2 + rowHeight*i + rowHeight/2 - 1; + int rowY1 = rect().top() + rowHeight*i; + int rowY2 = rect().top() + rowHeight*i + rowHeight - 1; lbr.setColor((unsigned int)marker == address ? QColor(0xFFFFEEE0) : QColor(debugger->getColor(address))); QColor bg = lbr.color(); + painter.setBrush(currentBrush); painter.setPen(nullPen); painter.drawRect(0,rowY1,16-1,rowY2-rowY1); if (selecting && address == (unsigned int)selection) painter.setPen(selPen); else - painter.setPen(i==0 ? currentPen : nullPen); - - QBrush mojsBrush(lbr.color()); - painter.setBrush(mojsBrush); + { + if(i==numRows/2) + painter.setPen(currentPen); + else + painter.setPen(bg); + } + painter.setBrush(QBrush(bg)); if (address == debugger->getPC()) { @@ -410,7 +415,8 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *) int CtrlDisAsmView::yToAddress(int y) { - int ydiff=y-rect().bottom()/2-rowHeight/2; - ydiff=(int)(floor((float)ydiff / (float)rowHeight))+1; - return curAddress + ydiff * align; + //int ydiff=y - rect().bottom()/2;//-rowHeight/2; + int ydiff=(int)(floor((float)y / (float)rowHeight)); + ydiff -= (rect().height()/rowHeight)/2; + return curAddress + ydiff *align; } diff --git a/Qt/ctrlmemview.cpp b/Qt/ctrlmemview.cpp index bb244e9283..6e3c9a93b2 100644 --- a/Qt/ctrlmemview.cpp +++ b/Qt/ctrlmemview.cpp @@ -83,7 +83,7 @@ void CtrlMemView::paintEvent(QPaintEvent *) QFont normalFont("Arial", 10); QFont alignedFont("Monospace", 10); - alignedFont.setStyleHint(QFont::Monospace); + alignedFont.setStyleHint(QFont::Monospace); painter.setFont(normalFont); int i; diff --git a/Qt/debugger_disasm.cpp b/Qt/debugger_disasm.cpp index b32f6ab767..7ebef604fa 100644 --- a/Qt/debugger_disasm.cpp +++ b/Qt/debugger_disasm.cpp @@ -36,7 +36,8 @@ Debugger_Disasm::Debugger_Disasm(DebugInterface *_cpu, MainWindow* mainWindow_, QObject::connect(ui->RegListScroll,SIGNAL(actionTriggered(int)), ui->RegList, SLOT(scrollChanged(int))); QObject::connect(ui->RegList,SIGNAL(GotoDisasm(u32)),this,SLOT(Goto(u32))); - QObject::connect(this, SIGNAL(updateDisplayList_()), this, SLOT(UpdateDisplayListGUI())); + QObject::connect(this, SIGNAL(UpdateCallstack_()), this, SLOT(UpdateCallstackGUI())); + QObject::connect(this, SIGNAL(UpdateDisplayList_()), this, SLOT(UpdateDisplayListGUI())); QObject::connect(this, SIGNAL(UpdateBreakpoints_()), this, SLOT(UpdateBreakpointsGUI())); QObject::connect(this, SIGNAL(UpdateThread_()), this, SLOT(UpdateThreadGUI())); @@ -112,34 +113,12 @@ void Debugger_Disasm::UpdateDialog() UpdateBreakpoints(); UpdateThread(); UpdateDisplayList(); + UpdateCallstack(); char tempTicks[24]; sprintf(tempTicks, "%lld", CoreTiming::GetTicks()); ui->debugCount->setText(QString("Ctr : ") + tempTicks); - /*ui->callStack->clear(); - u32 pc = currentMIPS->pc; - u32 ra = currentMIPS->r[MIPS_REG_RA]; - u32 addr = Memory::ReadUnchecked_U32(pc); - int count=1; - char addr_[12]; - sprintf(addr_, "0x%08x",pc); - ui->callStack->addItem(new QListWidgetItem(addr_)); - - addr = Memory::ReadUnchecked_U32(ra); - sprintf(addr_, "0x%08x",ra); - ui->callStack->addItem(new QListWidgetItem(addr_)); - count++; - - while (addr != 0xFFFFFFFF && addr!=0 && Memory::IsValidAddress(addr+4) && count++<20) - { - u32 fun = Memory::ReadUnchecked_U32(addr+4); - sprintf(addr_, "0x%08x",fun); - ui->callStack->addItem(new QListWidgetItem(addr_)); - addr = Memory::ReadUnchecked_U32(addr); - }*/ - - if(mainWindow->GetDialogMemory()) mainWindow->GetDialogMemory()->Update(); @@ -320,6 +299,53 @@ void Debugger_Disasm::FillFunctions() } } +void Debugger_Disasm::UpdateCallstack() +{ + emit UpdateCallstack_(); +} + +void Debugger_Disasm::UpdateCallstackGUI() +{ + + auto threads = GetThreadsInfo(); + + u32 entry = 0, stackTop = 0; + for (size_t i = 0; i < threads.size(); i++) + { + if (threads[i].isCurrent) + { + entry = threads[i].entrypoint; + stackTop = threads[i].initialStack; + break; + } + } + if (entry != 0) { + stackTraceModel = MIPSStackWalk::Walk( + cpu->GetPC(), + cpu->GetRegValue(0,MIPS_REG_RA), + cpu->GetRegValue(0,MIPS_REG_SP), + entry, + stackTop); + } else { + stackTraceModel.clear(); + } + + ui->callStack->clear(); + + QTreeWidgetItem* item; + for(auto it=stackTraceModel.begin();it!=stackTraceModel.end();it++) + { + item = new QTreeWidgetItem(); + item->setText(0,QString("%1").arg(it->pc,8,16,QChar('0')).prepend("0x")); + item->setData(0,Qt::UserRole,it->pc); + item->setText(1,QString("%1").arg(it->entry,8,16,QChar('0')).prepend("0x")); + item->setData(1,Qt::UserRole,it->entry); + item->setText(2,QString("%1").arg(it->sp,8,16,QChar('0')).prepend("0x")); + item->setText(3,QString("%1").arg(it->stackSize,8,16,QChar('0')).prepend("0x")); + ui->callStack->addTopLevelItem(item); + } +} + void Debugger_Disasm::UpdateBreakpoints() { emit UpdateBreakpoints_(); @@ -492,7 +518,7 @@ void Debugger_Disasm::SetThreadStatusSuspend() void Debugger_Disasm::UpdateDisplayList() { - emit updateDisplayList_(); + emit UpdateDisplayList_(); } void Debugger_Disasm::UpdateDisplayListGUI() diff --git a/Qt/debugger_disasm.h b/Qt/debugger_disasm.h index 8eb5f735e8..aa06dc5bc8 100644 --- a/Qt/debugger_disasm.h +++ b/Qt/debugger_disasm.h @@ -1,12 +1,14 @@ #ifndef DEBUGGER_DISASM_H #define DEBUGGER_DISASM_H +#include "Core/MIPS/MIPSStackWalk.h" #include "Core/HLE/sceKernelThread.h" #include "Core/Debugger/DebugInterface.h" #include "debugger_vfpu.h" #include #include #include +#include class MainWindow; namespace Ui { @@ -36,12 +38,14 @@ public: void Update(); void ShowMemory(u32 addr); void FillFunctions(); + void UpdateCallstack(); void UpdateBreakpoints(); void UpdateThread(); void UpdateDisplayList(); signals: - void updateDisplayList_(); + void UpdateCallstack_(); + void UpdateDisplayList_(); void UpdateBreakpoints_(); void UpdateThread_(); @@ -51,6 +55,7 @@ public slots: void GotoThreadEntryPoint(); private slots: + void UpdateCallstackGUI(); void UpdateDisplayListGUI(); void UpdateBreakpointsGUI(); void UpdateThreadGUI(); @@ -91,6 +96,7 @@ private: u32 breakpointAddr; QTreeWidgetItem* threadRowSelected; QTreeWidgetItem* displayListRowSelected; + std::vector stackTraceModel; }; #endif // DEBUGGER_DISASM_H diff --git a/Qt/debugger_disasm.ui b/Qt/debugger_disasm.ui index 0cc8967bcf..fb3b7e6e17 100644 --- a/Qt/debugger_disasm.ui +++ b/Qt/debugger_disasm.ui @@ -175,7 +175,7 @@ - 229 + 120 20 @@ -315,7 +315,7 @@ 0 - + Breakpoints @@ -367,17 +367,41 @@ - + Callstack - + + + 4 + + + + Address + + + + + Entry Point + + + + + SP + + + + + length + + + - + Display Lists @@ -428,7 +452,7 @@ - + Threads