2013-01-13 23:29:42 +00:00
|
|
|
#include <QMenu>
|
2013-02-10 15:36:06 +00:00
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
#include <deque>
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
#include "debugger_disasm.h"
|
|
|
|
#include "ui_debugger_disasm.h"
|
|
|
|
#include "Core/CPU.h"
|
|
|
|
#include "Core/Debugger/DebugInterface.h"
|
2013-02-10 15:36:06 +00:00
|
|
|
#include "Core/Debugger/SymbolMap.h"
|
2013-01-13 23:29:42 +00:00
|
|
|
#include "ctrldisasmview.h"
|
|
|
|
#include "Core/Debugger/Breakpoints.h"
|
|
|
|
#include "Core/HLE/HLE.h"
|
2013-02-10 15:36:06 +00:00
|
|
|
#include "Core/CoreTiming.h"
|
2013-01-13 23:29:42 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ctrlregisterlist.h"
|
|
|
|
#include "native/base/stringutil.h"
|
|
|
|
#include "Core/Debugger/SymbolMap.h"
|
2013-02-10 15:36:06 +00:00
|
|
|
#include "GPU/GPUState.h"
|
|
|
|
#include "GPU/GPUInterface.h"
|
|
|
|
#include "GPU/GeDisasm.h"
|
2013-09-22 17:22:33 +00:00
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
2013-02-10 15:36:06 +00:00
|
|
|
#include "Core/Host.h"
|
2013-01-13 23:29:42 +00:00
|
|
|
|
|
|
|
Debugger_Disasm::Debugger_Disasm(DebugInterface *_cpu, MainWindow* mainWindow_, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::Debugger_Disasm),
|
|
|
|
cpu(_cpu),
|
|
|
|
mainWindow(mainWindow_)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
vfpudlg = new Debugger_VFPU(_cpu, mainWindow, this);
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
ui->DisasmView->setWindowTitle(_cpu->GetName());
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
QObject::connect(ui->RegListScroll,SIGNAL(actionTriggered(int)), ui->RegList, SLOT(scrollChanged(int)));
|
|
|
|
QObject::connect(ui->RegList,SIGNAL(GotoDisasm(u32)),this,SLOT(Goto(u32)));
|
2013-11-24 07:53:09 +00:00
|
|
|
QObject::connect(this, SIGNAL(UpdateCallstack_()), this, SLOT(UpdateCallstackGUI()));
|
|
|
|
QObject::connect(this, SIGNAL(UpdateDisplayList_()), this, SLOT(UpdateDisplayListGUI()));
|
2013-02-10 15:36:06 +00:00
|
|
|
QObject::connect(this, SIGNAL(UpdateBreakpoints_()), this, SLOT(UpdateBreakpointsGUI()));
|
|
|
|
QObject::connect(this, SIGNAL(UpdateThread_()), this, SLOT(UpdateThreadGUI()));
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
ptr->setDebugger(cpu);
|
2013-02-10 15:36:06 +00:00
|
|
|
ptr->setParentWindow(this);
|
2013-01-13 23:29:42 +00:00
|
|
|
ptr->gotoAddr(0x00000000);
|
|
|
|
|
|
|
|
CtrlRegisterList *rl = ui->RegList;
|
2013-02-10 15:36:06 +00:00
|
|
|
rl->setParentWindow(this);
|
2013-01-13 23:29:42 +00:00
|
|
|
rl->setCPU(cpu);
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
FillFunctions();
|
2013-01-13 23:29:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
Debugger_Disasm::~Debugger_Disasm()
|
|
|
|
{
|
|
|
|
delete ui;
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
void Debugger_Disasm::ShowVFPU()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
vfpudlg->show();
|
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
void Debugger_Disasm::Update()
|
|
|
|
{
|
|
|
|
ui->RegList->redraw();
|
2013-11-19 11:02:43 +00:00
|
|
|
mainWindow->updateMenus();
|
2013-02-10 15:36:06 +00:00
|
|
|
UpdateDialog();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Go()
|
|
|
|
{
|
|
|
|
SetDebugMode(false);
|
|
|
|
Core_EnableStepping(false);
|
2013-11-19 11:02:43 +00:00
|
|
|
mainWindow->updateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Step()
|
|
|
|
{
|
|
|
|
Core_DoSingleStep();
|
|
|
|
_dbg_update_();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::StepOver()
|
|
|
|
{
|
|
|
|
SetDebugMode(false);
|
|
|
|
CBreakPoints::AddBreakPoint(cpu->GetPC()+cpu->getInstructionSize(0),true);
|
|
|
|
_dbg_update_();
|
|
|
|
Core_EnableStepping(false);
|
2013-11-19 11:02:43 +00:00
|
|
|
mainWindow->updateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::StepHLE()
|
|
|
|
{
|
|
|
|
hleDebugBreak();
|
|
|
|
SetDebugMode(false);
|
|
|
|
_dbg_update_();
|
|
|
|
Core_EnableStepping(false);
|
2013-11-19 11:02:43 +00:00
|
|
|
mainWindow->updateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::UpdateDialog()
|
|
|
|
{
|
2013-02-19 23:10:38 +00:00
|
|
|
if(!isVisible())
|
|
|
|
return;
|
2013-02-10 15:36:06 +00:00
|
|
|
ui->DisasmView->setAlign(cpu->getInstructionSize(0));
|
|
|
|
ui->DisasmView->redraw();
|
|
|
|
ui->RegList->redraw();
|
|
|
|
vfpudlg->Update();
|
|
|
|
UpdateBreakpoints();
|
|
|
|
UpdateThread();
|
|
|
|
UpdateDisplayList();
|
2013-11-24 07:53:09 +00:00
|
|
|
UpdateCallstack();
|
2013-02-10 15:36:06 +00:00
|
|
|
|
|
|
|
char tempTicks[24];
|
|
|
|
sprintf(tempTicks, "%lld", CoreTiming::GetTicks());
|
|
|
|
ui->debugCount->setText(QString("Ctr : ") + tempTicks);
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
if(mainWindow->GetDialogMemory())
|
|
|
|
mainWindow->GetDialogMemory()->Update();
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Stop()
|
|
|
|
{
|
|
|
|
SetDebugMode(true);
|
|
|
|
Core_EnableStepping(true);
|
|
|
|
_dbg_update_();
|
2013-11-19 11:02:43 +00:00
|
|
|
mainWindow->updateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
UpdateDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Skip()
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
|
|
|
|
cpu->SetPC(cpu->GetPC() + cpu->getInstructionSize(0));
|
|
|
|
ptr->gotoPC();
|
|
|
|
UpdateDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::GotoPC()
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
|
|
|
|
ptr->gotoPC();
|
|
|
|
UpdateDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::GotoLR()
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
|
|
|
|
ptr->gotoAddr(cpu->GetLR());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::SetDebugMode(bool _bDebug)
|
|
|
|
{
|
|
|
|
if (_bDebug)
|
|
|
|
{
|
|
|
|
ui->Go->setEnabled(true);
|
|
|
|
ui->StepInto->setEnabled(true);
|
2013-02-10 15:36:06 +00:00
|
|
|
ui->StepOver->setEnabled(false); // Crash, so disable for now
|
2013-01-13 23:29:42 +00:00
|
|
|
ui->NextHLE->setEnabled(true);
|
|
|
|
ui->Stop->setEnabled(false);
|
|
|
|
ui->Skip->setEnabled(true);
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
ptr->gotoPC();
|
2013-02-10 15:36:06 +00:00
|
|
|
UpdateDialog();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->Go->setEnabled(false);
|
|
|
|
ui->StepInto->setEnabled(false);
|
|
|
|
ui->StepOver->setEnabled(false);
|
|
|
|
ui->NextHLE->setEnabled(false);
|
|
|
|
ui->Stop->setEnabled(true);
|
|
|
|
ui->Skip->setEnabled(false);
|
2013-02-10 15:36:06 +00:00
|
|
|
CtrlRegisterList *reglist = ui->RegList;
|
|
|
|
reglist->redraw();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Goto(u32 addr)
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
ptr->gotoAddr(addr);
|
|
|
|
ptr->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_GotoPc_clicked()
|
|
|
|
{
|
|
|
|
GotoPC();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_Go_clicked()
|
|
|
|
{
|
|
|
|
Go();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_Stop_clicked()
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_StepInto_clicked()
|
|
|
|
{
|
|
|
|
Step();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_StepOver_clicked()
|
|
|
|
{
|
|
|
|
StepOver();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_Skip_clicked()
|
|
|
|
{
|
|
|
|
Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_NextHLE_clicked()
|
|
|
|
{
|
|
|
|
StepHLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_GotoLr_clicked()
|
|
|
|
{
|
|
|
|
GotoLR();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_GotoInt_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
2013-10-19 21:16:07 +00:00
|
|
|
u32 addr = ui->GotoInt->itemData(index,Qt::UserRole).toInt();
|
2013-01-13 23:29:42 +00:00
|
|
|
if (addr != 0xFFFFFFFF)
|
|
|
|
ptr->gotoAddr(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_Address_textChanged(const QString &arg1)
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
ptr->gotoAddr(parseHex(ui->Address->text().toStdString().c_str()));
|
|
|
|
UpdateDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_DisasmView_customContextMenuRequested(const QPoint &pos)
|
|
|
|
{
|
|
|
|
ui->DisasmView->contextMenu(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::NotifyMapLoaded()
|
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
FillFunctions();
|
2013-01-13 23:29:42 +00:00
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
ptr->redraw();
|
|
|
|
}
|
2013-02-10 15:36:06 +00:00
|
|
|
|
|
|
|
void Debugger_Disasm::on_RegList_customContextMenuRequested(const QPoint &pos)
|
|
|
|
{
|
|
|
|
ui->RegList->contextMenu(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::ShowMemory(u32 addr)
|
|
|
|
{
|
|
|
|
mainWindow->ShowMemory(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_vfpu_clicked()
|
|
|
|
{
|
|
|
|
ShowVFPU();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_FuncList_itemClicked(QListWidgetItem *item)
|
|
|
|
{
|
|
|
|
u32 addr = item->data(Qt::UserRole).toInt();
|
|
|
|
|
|
|
|
ui->DisasmView->gotoAddr(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::FillFunctions()
|
|
|
|
{
|
|
|
|
QListWidgetItem* item = new QListWidgetItem();
|
|
|
|
item->setText("(0x02000000)");
|
|
|
|
item->setData(Qt::UserRole, 0x02000000);
|
|
|
|
ui->FuncList->addItem(item);
|
|
|
|
|
2013-11-27 14:06:41 +00:00
|
|
|
std::vector<SymbolEntry> symbols = symbolMap.GetAllSymbols(ST_FUNCTION);
|
|
|
|
for(int i = 0; i < (int)symbols.size(); i++)
|
|
|
|
{
|
|
|
|
QListWidgetItem* item = new QListWidgetItem();
|
|
|
|
item->setText(QString("%1 (%2)").arg(QString::fromStdString(symbols[i].name)).arg(symbols[i].size));
|
|
|
|
item->setData(Qt::UserRole, symbols[i].address);
|
|
|
|
ui->FuncList->addItem(item);
|
2013-02-10 15:36:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-24 07:53:09 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
void Debugger_Disasm::UpdateBreakpoints()
|
|
|
|
{
|
|
|
|
emit UpdateBreakpoints_();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::UpdateBreakpointsGUI()
|
|
|
|
{
|
|
|
|
u32 curBpAddr = 0;
|
|
|
|
QTreeWidgetItem* curItem = ui->breakpointsList->currentItem();
|
|
|
|
if(curItem)
|
|
|
|
curBpAddr = ui->breakpointsList->currentItem()->data(0,Qt::UserRole).toInt();
|
|
|
|
|
|
|
|
ui->breakpointsList->clear();
|
|
|
|
|
2013-07-02 18:43:26 +00:00
|
|
|
auto breakpoints = CBreakPoints::GetBreakpoints();
|
2013-07-02 15:03:07 +00:00
|
|
|
for(size_t i = 0; i < breakpoints.size(); i++)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
2013-07-02 15:03:07 +00:00
|
|
|
u32 addr_ = breakpoints[i].addr;
|
2013-02-10 15:36:06 +00:00
|
|
|
if(!CBreakPoints::IsTempBreakPoint(addr_))
|
|
|
|
{
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem();
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(0,QString("%1").arg(addr_,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(0,Qt::UserRole,addr_);
|
|
|
|
ui->breakpointsList->addTopLevelItem(item);
|
|
|
|
if(curBpAddr == addr_)
|
|
|
|
ui->breakpointsList->setCurrentItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_breakpointsList_itemClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
ui->DisasmView->gotoAddr(item->data(column,Qt::UserRole).toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_breakpointsList_customContextMenuRequested(const QPoint &pos)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem* item = ui->breakpointsList->itemAt(pos);
|
|
|
|
if(item)
|
|
|
|
{
|
|
|
|
breakpointAddr = item->data(0,Qt::UserRole).toInt();
|
|
|
|
|
|
|
|
QMenu menu(this);
|
|
|
|
|
|
|
|
QAction *removeBP = new QAction(tr("Remove breakpoint"), this);
|
|
|
|
connect(removeBP, SIGNAL(triggered()), this, SLOT(RemoveBreakpoint()));
|
|
|
|
menu.addAction(removeBP);
|
|
|
|
|
|
|
|
menu.exec( ui->breakpointsList->mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::RemoveBreakpoint()
|
|
|
|
{
|
|
|
|
CBreakPoints::RemoveBreakPoint(breakpointAddr);
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_clearAllBP_clicked()
|
|
|
|
{
|
|
|
|
CBreakPoints::ClearAllBreakPoints();
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::UpdateThread()
|
|
|
|
{
|
|
|
|
emit UpdateThread_();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::UpdateThreadGUI()
|
|
|
|
{
|
|
|
|
ui->threadList->clear();
|
|
|
|
|
|
|
|
std::vector<DebugThreadInfo> threads = GetThreadsInfo();
|
|
|
|
|
2013-02-24 15:34:32 +00:00
|
|
|
for(size_t i = 0; i < threads.size(); i++)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem();
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(0,QString::number(threads[i].id));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(0,Qt::UserRole,threads[i].id);
|
|
|
|
item->setText(1,threads[i].name);
|
|
|
|
QString status = "";
|
|
|
|
if(threads[i].status & THREADSTATUS_RUNNING) status += "Running ";
|
|
|
|
if(threads[i].status & THREADSTATUS_WAIT) status += "Wait ";
|
|
|
|
if(threads[i].status & THREADSTATUS_READY) status += "Ready ";
|
|
|
|
if(threads[i].status & THREADSTATUS_SUSPEND) status += "Suspend ";
|
|
|
|
if(threads[i].status & THREADSTATUS_DORMANT) status += "Dormant ";
|
|
|
|
if(threads[i].status & THREADSTATUS_DEAD) status += "Dead ";
|
|
|
|
item->setText(2,status);
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(3,QString("%1").arg(threads[i].curPC,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(3,Qt::UserRole,threads[i].curPC);
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(4,QString("%1").arg(threads[i].entrypoint,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(4,Qt::UserRole,threads[i].entrypoint);
|
|
|
|
|
|
|
|
if(threads[i].isCurrent)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < 5; j++)
|
|
|
|
item->setTextColor(j,Qt::green);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->threadList->addTopLevelItem(item);
|
|
|
|
}
|
2013-02-17 00:06:06 +00:00
|
|
|
for(int i = 0; i < ui->threadList->columnCount(); i++)
|
|
|
|
ui->threadList->resizeColumnToContents(i);
|
2013-02-10 15:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_threadList_itemClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
ui->DisasmView->gotoAddr(item->data(3,Qt::UserRole).toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_threadList_customContextMenuRequested(const QPoint &pos)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem* item = ui->threadList->itemAt(pos);
|
|
|
|
if(item)
|
|
|
|
{
|
|
|
|
threadRowSelected = item;
|
|
|
|
|
|
|
|
QMenu menu(this);
|
|
|
|
|
|
|
|
QAction *gotoEntryPoint = new QAction(tr("Go to entry point"), this);
|
|
|
|
connect(gotoEntryPoint, SIGNAL(triggered()), this, SLOT(GotoThreadEntryPoint()));
|
|
|
|
menu.addAction(gotoEntryPoint);
|
|
|
|
|
2013-02-24 15:34:32 +00:00
|
|
|
QMenu* changeStatus = menu.addMenu(tr("Change status"));
|
2013-02-10 15:36:06 +00:00
|
|
|
|
|
|
|
QAction *statusRunning = new QAction(tr("Running"), this);
|
|
|
|
connect(statusRunning, SIGNAL(triggered()), this, SLOT(SetThreadStatusRun()));
|
|
|
|
changeStatus->addAction(statusRunning);
|
|
|
|
|
|
|
|
QAction *statusWait = new QAction(tr("Wait"), this);
|
|
|
|
connect(statusWait, SIGNAL(triggered()), this, SLOT(SetThreadStatusWait()));
|
|
|
|
changeStatus->addAction(statusWait);
|
|
|
|
|
|
|
|
QAction *statusSuspend = new QAction(tr("Suspend"), this);
|
|
|
|
connect(statusSuspend, SIGNAL(triggered()), this, SLOT(SetThreadStatusSuspend()));
|
|
|
|
changeStatus->addAction(statusSuspend);
|
|
|
|
|
|
|
|
menu.exec( ui->threadList->mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::GotoThreadEntryPoint()
|
|
|
|
{
|
|
|
|
ui->DisasmView->gotoAddr(threadRowSelected->data(4,Qt::UserRole).toInt());
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::SetThreadStatus(ThreadStatus status)
|
|
|
|
{
|
|
|
|
__KernelChangeThreadState(threadRowSelected->data(0,Qt::UserRole).toInt(), status);
|
|
|
|
|
|
|
|
UpdateThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::SetThreadStatusRun()
|
|
|
|
{
|
|
|
|
SetThreadStatus(THREADSTATUS_RUNNING);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::SetThreadStatusWait()
|
|
|
|
{
|
|
|
|
SetThreadStatus(THREADSTATUS_WAIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::SetThreadStatusSuspend()
|
|
|
|
{
|
|
|
|
SetThreadStatus(THREADSTATUS_SUSPEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::UpdateDisplayList()
|
|
|
|
{
|
2013-11-24 07:53:09 +00:00
|
|
|
emit UpdateDisplayList_();
|
2013-02-10 15:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::UpdateDisplayListGUI()
|
|
|
|
{
|
|
|
|
u32 curDlId = 0;
|
|
|
|
QTreeWidgetItem* curItem = ui->displayList->currentItem();
|
|
|
|
if(curItem)
|
|
|
|
curDlId = ui->displayList->currentItem()->data(0,Qt::UserRole).toInt();
|
|
|
|
|
|
|
|
ui->displayList->clear();
|
|
|
|
|
2013-04-06 09:09:05 +00:00
|
|
|
const std::list<int>& dlQueue = gpu->GetDisplayLists();
|
2013-02-10 15:36:06 +00:00
|
|
|
|
2013-09-22 17:22:33 +00:00
|
|
|
DisplayList dlist;
|
|
|
|
DisplayList* dl = &dlist;
|
|
|
|
if(gpuDebug->GetCurrentDisplayList(dlist))
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem();
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(0,QString::number(dl->id));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(0, Qt::UserRole, dl->id);
|
2013-04-06 09:09:05 +00:00
|
|
|
switch(dl->state)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
2013-04-06 09:09:05 +00:00
|
|
|
case PSP_GE_DL_STATE_NONE: item->setText(1,"None"); break;
|
|
|
|
case PSP_GE_DL_STATE_QUEUED: item->setText(1,"Queued"); break;
|
|
|
|
case PSP_GE_DL_STATE_RUNNING: item->setText(1,"Running"); break;
|
|
|
|
case PSP_GE_DL_STATE_COMPLETED: item->setText(1,"Completed"); break;
|
|
|
|
case PSP_GE_DL_STATE_PAUSED: item->setText(1,"Paused"); break;
|
2013-02-10 15:36:06 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(2,QString("%1").arg(dl->startpc,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(2, Qt::UserRole, dl->startpc);
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(3,QString("%1").arg(dl->pc,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(3, Qt::UserRole, dl->pc);
|
|
|
|
ui->displayList->addTopLevelItem(item);
|
2013-02-24 15:34:32 +00:00
|
|
|
if(curDlId == (u32)dl->id)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
|
|
|
ui->displayList->setCurrentItem(item);
|
|
|
|
displayListRowSelected = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-06 09:09:05 +00:00
|
|
|
for(auto listIdIt = dlQueue.begin(); listIdIt != dlQueue.end(); ++listIdIt)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
2013-04-06 09:09:05 +00:00
|
|
|
DisplayList *it = gpu->getList(*listIdIt);
|
2013-02-10 15:36:06 +00:00
|
|
|
if(dl && it->id == dl->id)
|
|
|
|
continue;
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem();
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(0,QString::number(it->id));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(0, Qt::UserRole, it->id);
|
2013-04-06 09:09:05 +00:00
|
|
|
switch(it->state)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
2013-04-06 09:09:05 +00:00
|
|
|
case PSP_GE_DL_STATE_NONE: item->setText(1,"None"); break;
|
|
|
|
case PSP_GE_DL_STATE_QUEUED: item->setText(1,"Queued"); break;
|
|
|
|
case PSP_GE_DL_STATE_RUNNING: item->setText(1,"Running"); break;
|
|
|
|
case PSP_GE_DL_STATE_COMPLETED: item->setText(1,"Completed"); break;
|
|
|
|
case PSP_GE_DL_STATE_PAUSED: item->setText(1,"Paused"); break;
|
2013-02-10 15:36:06 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(2,QString("%1").arg(it->startpc,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(2, Qt::UserRole, it->startpc);
|
2013-02-17 00:06:06 +00:00
|
|
|
item->setText(3,QString("%1").arg(it->pc,8,16,QChar('0')));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(3, Qt::UserRole, it->pc);
|
|
|
|
ui->displayList->addTopLevelItem(item);
|
2013-02-24 15:34:32 +00:00
|
|
|
if(curDlId == (u32)it->id)
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
|
|
|
ui->displayList->setCurrentItem(item);
|
|
|
|
displayListRowSelected = item;
|
|
|
|
}
|
|
|
|
}
|
2013-02-17 00:06:06 +00:00
|
|
|
for(int i = 0; i < ui->displayList->columnCount(); i++)
|
|
|
|
ui->displayList->resizeColumnToContents(i);
|
2013-02-10 15:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::on_displayList_customContextMenuRequested(const QPoint &pos)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem* item = ui->displayList->itemAt(pos);
|
|
|
|
if(item)
|
|
|
|
{
|
|
|
|
displayListRowSelected = item;
|
|
|
|
|
2013-02-17 00:06:06 +00:00
|
|
|
/*QMenu menu(this);
|
2013-02-10 15:36:06 +00:00
|
|
|
|
|
|
|
QAction *showCode = new QAction(tr("Show code"), this);
|
|
|
|
connect(showCode, SIGNAL(triggered()), this, SLOT(ShowDLCode()));
|
2013-02-17 00:06:06 +00:00
|
|
|
menu.addAction(showCode);*/
|
2013-02-10 15:36:06 +00:00
|
|
|
|
2013-02-17 00:06:06 +00:00
|
|
|
//menu.exec( ui->displayList->mapToGlobal(pos));
|
2013-02-10 15:36:06 +00:00
|
|
|
}
|
|
|
|
}
|