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 "EmuThread.h"
|
|
|
|
#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)));
|
|
|
|
QObject::connect(this, SIGNAL(updateDisplayList_()), this, SLOT(UpdateDisplayListGUI()));
|
|
|
|
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
|
|
|
void Debugger_Disasm::showEvent(QShowEvent *)
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
// Hack to remove the X11 crash with threaded opengl when opening the first dialog
|
|
|
|
EmuThread_LockDraw(true);
|
|
|
|
QTimer::singleShot(100, this, SLOT(releaseLock()));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(Core_IsStepping())
|
|
|
|
SetDebugMode(true);
|
|
|
|
else
|
|
|
|
SetDebugMode(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
void Debugger_Disasm::releaseLock()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
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();
|
|
|
|
mainWindow->UpdateMenus();
|
|
|
|
UpdateDialog();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Go()
|
|
|
|
{
|
|
|
|
SetDebugMode(false);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(true);
|
2013-01-13 23:29:42 +00:00
|
|
|
Core_EnableStepping(false);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
mainWindow->UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Step()
|
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(true);
|
2013-01-13 23:29:42 +00:00
|
|
|
Core_DoSingleStep();
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
_dbg_update_();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::StepOver()
|
|
|
|
{
|
|
|
|
SetDebugMode(false);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(true);
|
2013-01-13 23:29:42 +00:00
|
|
|
CBreakPoints::AddBreakPoint(cpu->GetPC()+cpu->getInstructionSize(0),true);
|
|
|
|
_dbg_update_();
|
|
|
|
Core_EnableStepping(false);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
mainWindow->UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::StepHLE()
|
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(true);
|
2013-01-13 23:29:42 +00:00
|
|
|
hleDebugBreak();
|
|
|
|
SetDebugMode(false);
|
|
|
|
_dbg_update_();
|
|
|
|
Core_EnableStepping(false);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
mainWindow->UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
char tempTicks[24];
|
|
|
|
sprintf(tempTicks, "%lld", CoreTiming::GetTicks());
|
|
|
|
ui->debugCount->setText(QString("Ctr : ") + tempTicks);
|
2013-01-13 23:29:42 +00:00
|
|
|
|
|
|
|
/*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_));
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
addr = Memory::ReadUnchecked_U32(ra);
|
2013-01-13 23:29:42 +00:00
|
|
|
sprintf(addr_, "0x%08x",ra);
|
|
|
|
ui->callStack->addItem(new QListWidgetItem(addr_));
|
|
|
|
count++;
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
while (addr != 0xFFFFFFFF && addr!=0 && Memory::IsValidAddress(addr+4) && count++<20)
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
|
|
|
u32 fun = Memory::ReadUnchecked_U32(addr+4);
|
|
|
|
sprintf(addr_, "0x%08x",fun);
|
|
|
|
ui->callStack->addItem(new QListWidgetItem(addr_));
|
|
|
|
addr = Memory::ReadUnchecked_U32(addr);
|
|
|
|
}*/
|
|
|
|
|
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);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(true);
|
2013-01-13 23:29:42 +00:00
|
|
|
Core_EnableStepping(true);
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
_dbg_update_();
|
|
|
|
mainWindow->UpdateMenus();
|
|
|
|
UpdateDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger_Disasm::Skip()
|
|
|
|
{
|
|
|
|
CtrlDisAsmView *ptr = ui->DisasmView;
|
|
|
|
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(true);
|
2013-01-13 23:29:42 +00:00
|
|
|
cpu->SetPC(cpu->GetPC() + cpu->getInstructionSize(0));
|
2013-02-10 15:36:06 +00:00
|
|
|
EmuThread_LockDraw(false);
|
2013-01-13 23:29:42 +00:00
|
|
|
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;
|
|
|
|
int addr = ui->GotoInt->itemData(index,Qt::UserRole).toInt();
|
|
|
|
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);
|
|
|
|
|
|
|
|
for(int i = 0; i < symbolMap.GetNumSymbols(); i++)
|
|
|
|
{
|
|
|
|
if(symbolMap.GetSymbolType(i) & ST_FUNCTION)
|
|
|
|
{
|
|
|
|
QListWidgetItem* item = new QListWidgetItem();
|
2013-02-24 15:34:32 +00:00
|
|
|
item->setText(QString("%1 (%2)").arg(symbolMap.GetSymbolName(i)).arg(symbolMap.GetSymbolSize(i)));
|
2013-02-10 15:36:06 +00:00
|
|
|
item->setData(Qt::UserRole, symbolMap.GetAddress(i));
|
|
|
|
ui->FuncList->addItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
EmuThread_LockDraw(true);
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EmuThread_LockDraw(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
EmuThread_LockDraw(true);
|
|
|
|
std::vector<DebugThreadInfo> threads = GetThreadsInfo();
|
|
|
|
EmuThread_LockDraw(false);
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
EmuThread_LockDraw(true);
|
|
|
|
__KernelChangeThreadState(threadRowSelected->data(0,Qt::UserRole).toInt(), status);
|
|
|
|
EmuThread_LockDraw(false);
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
emit updateDisplayList_();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
EmuThread_LockDraw(true);
|
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
|
|
|
EmuThread_LockDraw(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|