Play-/Source/ui_qt/DebugSupport/DebugView.cpp

115 lines
2.7 KiB
C++
Raw Normal View History

2019-08-31 12:33:24 -04:00
#include "DebugView.h"
#include "BiosDebugInfoProvider.h"
#include <QVBoxLayout>
//#include "DisAsmWnd.h"
CDebugView::CDebugView(QMdiArea* parent, CVirtualMachine& virtualMachine, CMIPS* ctx,
2019-12-19 11:58:52 +00:00
const StepFunction& stepFunction, CBiosDebugInfoProvider* biosDebugInfoProvider, const char* name, int size, CQtDisAsmTableModel::DISASM_TYPE disAsmType)
2019-12-19 21:37:47 +00:00
: m_virtualMachine(virtualMachine)
2019-08-31 12:33:24 -04:00
, m_ctx(ctx)
, m_name(name)
, m_stepFunction(stepFunction)
2019-12-11 14:52:12 +00:00
, m_disAsmWnd(nullptr)
2019-08-31 12:33:24 -04:00
, m_regViewWnd(nullptr)
2019-12-19 22:07:10 +00:00
, m_memoryViewWnd(nullptr)
2019-12-12 01:44:55 +00:00
, m_callStackWnd(nullptr)
2019-08-31 12:33:24 -04:00
, m_biosDebugInfoProvider(biosDebugInfoProvider)
{
2019-12-19 21:37:47 +00:00
2019-12-19 22:20:32 +00:00
m_disAsmWnd = new CDisAsmWnd(parent, virtualMachine, m_ctx, name, disAsmType);
2019-12-11 14:52:12 +00:00
this->m_disAsmWnd->show();
m_regViewWnd = new CRegViewWnd(parent, this->m_ctx);
this->m_regViewWnd->show();
2019-12-19 11:58:52 +00:00
m_memoryViewWnd = new CMemoryViewMIPSWnd(parent, virtualMachine, m_ctx, size);
this->m_regViewWnd->show();
m_callStackWnd = new CCallStackWnd(parent, m_ctx, m_biosDebugInfoProvider);
this->m_callStackWnd->show();
2019-12-12 01:44:55 +00:00
m_OnFunctionDblClickConnection = m_callStackWnd->OnFunctionDblClick.Connect(std::bind(&CDebugView::OnCallStackWndFunctionDblClick, this, std::placeholders::_1));
2019-08-31 12:33:24 -04:00
2019-12-10 00:59:39 +00:00
Hide();
2019-08-31 12:33:24 -04:00
}
CDebugView::~CDebugView()
{
2019-12-11 14:52:12 +00:00
delete m_disAsmWnd;
2019-08-31 12:33:24 -04:00
delete m_regViewWnd;
2019-12-19 11:58:52 +00:00
delete m_memoryViewWnd;
2019-12-10 00:59:39 +00:00
delete m_callStackWnd;
2019-08-31 12:33:24 -04:00
}
void CDebugView::HandleMachineStateChange()
{
2019-12-11 14:52:12 +00:00
m_disAsmWnd->HandleMachineStateChange();
2019-08-31 12:33:24 -04:00
m_regViewWnd->HandleMachineStateChange();
2019-12-19 11:58:52 +00:00
m_memoryViewWnd->HandleMachineStateChange();
m_callStackWnd->HandleMachineStateChange();
2019-08-31 12:33:24 -04:00
}
void CDebugView::HandleRunningStateChange(CVirtualMachine::STATUS newState)
{
2019-12-11 14:52:12 +00:00
m_disAsmWnd->HandleRunningStateChange(newState);
2019-08-31 12:33:24 -04:00
m_regViewWnd->HandleRunningStateChange(newState);
2019-12-19 11:58:52 +00:00
m_memoryViewWnd->HandleRunningStateChange(newState);
m_callStackWnd->HandleRunningStateChange(newState);
2019-08-31 12:33:24 -04:00
}
const char* CDebugView::GetName() const
{
return m_name.c_str();
}
void CDebugView::Hide()
{
2019-12-12 12:58:26 +00:00
m_disAsmWnd->hide();
2019-12-19 11:58:52 +00:00
m_memoryViewWnd->hide();
2019-08-31 12:33:24 -04:00
m_regViewWnd->hide();
2019-12-10 00:59:39 +00:00
m_callStackWnd->hide();
2019-08-31 12:33:24 -04:00
}
void CDebugView::Step()
{
m_stepFunction();
}
CBiosDebugInfoProvider* CDebugView::GetBiosDebugInfoProvider() const
{
return m_biosDebugInfoProvider;
}
CMIPS* CDebugView::GetContext()
{
return m_ctx;
}
2019-12-11 14:52:12 +00:00
CDisAsmWnd* CDebugView::GetDisassemblyWindow()
{
return m_disAsmWnd;
}
2019-08-31 12:33:24 -04:00
2019-12-19 11:58:52 +00:00
CMemoryViewMIPSWnd* CDebugView::GetMemoryViewWindow()
{
return m_memoryViewWnd;
}
2019-08-31 12:33:24 -04:00
CRegViewWnd* CDebugView::GetRegisterViewWindow()
{
return m_regViewWnd;
}
CCallStackWnd* CDebugView::GetCallStackWindow()
{
return m_callStackWnd;
}
2019-08-31 12:33:24 -04:00
void CDebugView::OnCallStackWndFunctionDblClick(uint32 nAddress)
{
2019-12-19 22:20:32 +00:00
auto disAsm = GetDisassemblyWindow();
2019-12-11 14:52:12 +00:00
disAsm->SetCenterAtAddress(nAddress);
disAsm->SetSelectedAddress(nAddress);
2019-08-31 12:33:24 -04:00
}