2019-12-19 11:58:52 +00:00
|
|
|
#include <QAction>
|
2020-01-05 21:37:00 +00:00
|
|
|
#include <QApplication>
|
2019-12-19 11:58:52 +00:00
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QFontDatabase>
|
|
|
|
#include <QFontMetrics>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include "string_format.h"
|
|
|
|
#include "MemoryViewMIPSWnd.h"
|
|
|
|
#include "DebugExpressionEvaluator.h"
|
|
|
|
|
|
|
|
CMemoryViewMIPSWnd::CMemoryViewMIPSWnd(QMdiArea* parent, CVirtualMachine& virtualMachine, CMIPS* ctx, int size)
|
|
|
|
: QMdiSubWindow(parent)
|
2020-01-05 22:46:47 +00:00
|
|
|
, m_tableView(new CMemoryViewTable(this, &virtualMachine, ctx, 0, true))
|
2019-12-19 11:58:52 +00:00
|
|
|
{
|
|
|
|
resize(320, 240);
|
|
|
|
parent->addSubWindow(this);
|
|
|
|
setWindowTitle("Memory");
|
|
|
|
|
|
|
|
auto centralwidget = new QWidget(this);
|
|
|
|
auto verticalLayout = new QVBoxLayout(centralwidget);
|
2019-12-19 21:37:47 +00:00
|
|
|
|
2019-12-19 11:58:52 +00:00
|
|
|
m_addressEdit = new QLineEdit(centralwidget);
|
|
|
|
m_addressEdit->setReadOnly(true);
|
|
|
|
|
|
|
|
verticalLayout->addWidget(m_addressEdit);
|
|
|
|
verticalLayout->addWidget(m_tableView);
|
|
|
|
|
|
|
|
setWidget(centralwidget);
|
2019-12-21 18:48:44 +00:00
|
|
|
auto getByte = [ctx](uint32 address) {
|
2019-12-21 18:05:47 +00:00
|
|
|
return ctx->m_pMemoryMap->GetByte(address);
|
|
|
|
};
|
|
|
|
|
2020-01-05 22:46:47 +00:00
|
|
|
m_tableView->SetData(getByte, size);
|
2019-12-19 11:58:52 +00:00
|
|
|
|
2020-01-05 22:46:47 +00:00
|
|
|
UpdateStatusBar(0);
|
|
|
|
m_OnSelectionChangeConnection = m_tableView->OnSelectionChange.Connect(std::bind(&CMemoryViewMIPSWnd::UpdateStatusBar, this, std::placeholders::_1));
|
2019-12-19 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CMemoryViewMIPSWnd::~CMemoryViewMIPSWnd()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryViewMIPSWnd::showEvent(QShowEvent* evt)
|
|
|
|
{
|
|
|
|
QMdiSubWindow::showEvent(evt);
|
2020-01-05 22:46:47 +00:00
|
|
|
m_tableView->ShowEvent();
|
2019-12-19 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryViewMIPSWnd::resizeEvent(QResizeEvent* evt)
|
|
|
|
{
|
|
|
|
QMdiSubWindow::resizeEvent(evt);
|
2020-01-05 22:46:47 +00:00
|
|
|
m_tableView->ResizeEvent();
|
2019-12-19 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryViewMIPSWnd::HandleMachineStateChange()
|
|
|
|
{
|
2020-01-05 22:46:47 +00:00
|
|
|
m_tableView->HandleMachineStateChange();
|
2019-12-19 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CMemoryViewMIPSWnd::GetBytesPerLine()
|
|
|
|
{
|
2020-01-05 22:46:47 +00:00
|
|
|
return m_tableView->GetBytesPerLine();
|
2019-12-19 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryViewMIPSWnd::SetBytesPerLine(int bytesForLine)
|
|
|
|
{
|
2020-01-05 22:46:47 +00:00
|
|
|
m_tableView->SetBytesPerLine(bytesForLine);
|
2019-12-19 11:58:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-05 22:46:47 +00:00
|
|
|
void CMemoryViewMIPSWnd::UpdateStatusBar(uint32 address)
|
2019-12-19 11:58:52 +00:00
|
|
|
{
|
2020-01-05 22:46:47 +00:00
|
|
|
auto caption = string_format("Address : 0x%08X", address);
|
2019-12-19 11:58:52 +00:00
|
|
|
m_addressEdit->setText(caption.c_str());
|
|
|
|
}
|