Memory(View)Widget: Avoid Global System Accessor
This commit is contained in:
parent
5a81916ee9
commit
26141eece8
|
@ -154,7 +154,7 @@ public:
|
||||||
u32 end_address = address + static_cast<u32>(bytes.size()) - 1;
|
u32 end_address = address + static_cast<u32>(bytes.size()) - 1;
|
||||||
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_view->GetAddressSpace());
|
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_view->GetAddressSpace());
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
const Core::CPUThreadGuard guard(m_view->m_system);
|
||||||
|
|
||||||
if (!bytes.empty() && accessors->IsValidAddress(guard, address) &&
|
if (!bytes.empty() && accessors->IsValidAddress(guard, address) &&
|
||||||
accessors->IsValidAddress(guard, end_address))
|
accessors->IsValidAddress(guard, end_address))
|
||||||
|
@ -170,8 +170,8 @@ private:
|
||||||
MemoryViewWidget* m_view;
|
MemoryViewWidget* m_view;
|
||||||
};
|
};
|
||||||
|
|
||||||
MemoryViewWidget::MemoryViewWidget(QWidget* parent)
|
MemoryViewWidget::MemoryViewWidget(Core::System& system, QWidget* parent)
|
||||||
: QWidget(parent), m_system(Core::System::GetInstance())
|
: QWidget(parent), m_system(system)
|
||||||
{
|
{
|
||||||
auto* layout = new QHBoxLayout();
|
auto* layout = new QHBoxLayout();
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -443,7 +443,7 @@ void MemoryViewWidget::UpdateColumns()
|
||||||
|
|
||||||
if (Core::GetState() == Core::State::Paused)
|
if (Core::GetState() == Core::State::Paused)
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
UpdateColumns(&guard);
|
UpdateColumns(&guard);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -850,12 +850,8 @@ void MemoryViewWidget::OnCopyHex(u32 addr)
|
||||||
{
|
{
|
||||||
const auto length = GetTypeSize(m_type);
|
const auto length = GetTypeSize(m_type);
|
||||||
|
|
||||||
const AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_address_space);
|
const u64 value =
|
||||||
|
AddressSpace::GetAccessors(m_address_space)->ReadU64(Core::CPUThreadGuard{m_system}, addr);
|
||||||
const u64 value = [addr, accessors] {
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
return accessors->ReadU64(guard, addr);
|
|
||||||
}();
|
|
||||||
|
|
||||||
QApplication::clipboard()->setText(
|
QApplication::clipboard()->setText(
|
||||||
QStringLiteral("%1").arg(value, sizeof(u64) * 2, 16, QLatin1Char('0')).left(length * 2));
|
QStringLiteral("%1").arg(value, sizeof(u64) * 2, 16, QLatin1Char('0')).left(length * 2));
|
||||||
|
@ -873,12 +869,8 @@ void MemoryViewWidget::OnContextMenu(const QPoint& pos)
|
||||||
const u32 addr = item_selected->data(USER_ROLE_CELL_ADDRESS).toUInt();
|
const u32 addr = item_selected->data(USER_ROLE_CELL_ADDRESS).toUInt();
|
||||||
const bool item_has_value =
|
const bool item_has_value =
|
||||||
item_selected->data(USER_ROLE_VALUE_TYPE).toInt() != static_cast<int>(Type::Null) &&
|
item_selected->data(USER_ROLE_VALUE_TYPE).toInt() != static_cast<int>(Type::Null) &&
|
||||||
[this, addr] {
|
AddressSpace::GetAccessors(m_address_space)
|
||||||
const AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_address_space);
|
->IsValidAddress(Core::CPUThreadGuard{m_system}, addr);
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
return accessors->IsValidAddress(guard, addr);
|
|
||||||
}();
|
|
||||||
|
|
||||||
auto* menu = new QMenu(this);
|
auto* menu = new QMenu(this);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
WriteOnly
|
WriteOnly
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit MemoryViewWidget(QWidget* parent = nullptr);
|
explicit MemoryViewWidget(Core::System& system, QWidget* parent = nullptr);
|
||||||
|
|
||||||
void CreateTable();
|
void CreateTable();
|
||||||
void Update();
|
void Update();
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
|
|
||||||
using Type = MemoryViewWidget::Type;
|
using Type = MemoryViewWidget::Type;
|
||||||
|
|
||||||
MemoryWidget::MemoryWidget(QWidget* parent) : QDockWidget(parent)
|
MemoryWidget::MemoryWidget(Core::System& system, QWidget* parent)
|
||||||
|
: QDockWidget(parent), m_system(system)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Memory"));
|
setWindowTitle(tr("Memory"));
|
||||||
setObjectName(QStringLiteral("memory"));
|
setObjectName(QStringLiteral("memory"));
|
||||||
|
@ -287,7 +288,7 @@ void MemoryWidget::CreateWidgets()
|
||||||
sidebar_scroll->setWidget(sidebar);
|
sidebar_scroll->setWidget(sidebar);
|
||||||
sidebar_scroll->setWidgetResizable(true);
|
sidebar_scroll->setWidgetResizable(true);
|
||||||
|
|
||||||
m_memory_view = new MemoryViewWidget(this);
|
m_memory_view = new MemoryViewWidget(m_system, this);
|
||||||
|
|
||||||
m_splitter->addWidget(m_memory_view);
|
m_splitter->addWidget(m_memory_view);
|
||||||
m_splitter->addWidget(sidebar_scroll);
|
m_splitter->addWidget(sidebar_scroll);
|
||||||
|
@ -496,7 +497,7 @@ void MemoryWidget::SetAddress(u32 address)
|
||||||
AddressSpace::Accessors* accessors =
|
AddressSpace::Accessors* accessors =
|
||||||
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
good = accessors->IsValidAddress(guard, current_addr);
|
good = accessors->IsValidAddress(guard, current_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +654,7 @@ void MemoryWidget::OnSetValue()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
||||||
u32 end_address = target_addr.address + static_cast<u32>(bytes.size()) - 1;
|
u32 end_address = target_addr.address + static_cast<u32>(bytes.size()) - 1;
|
||||||
|
@ -715,7 +716,7 @@ void MemoryWidget::OnSetValueFromFile()
|
||||||
|
|
||||||
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
for (u8 b : file_contents)
|
for (u8 b : file_contents)
|
||||||
accessors->WriteU8(guard, target_addr.address++, b);
|
accessors->WriteU8(guard, target_addr.address++, b);
|
||||||
|
@ -833,7 +834,7 @@ void MemoryWidget::FindValue(bool next)
|
||||||
AddressSpace::Accessors* accessors =
|
AddressSpace::Accessors* accessors =
|
||||||
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
return accessors->Search(guard, target_addr.address,
|
return accessors->Search(guard, target_addr.address,
|
||||||
reinterpret_cast<const u8*>(search_for.data()),
|
reinterpret_cast<const u8*>(search_for.data()),
|
||||||
static_cast<u32>(search_for.size()), next);
|
static_cast<u32>(search_for.size()), next);
|
||||||
|
|
|
@ -22,14 +22,15 @@ class QSplitter;
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
class System;
|
||||||
class CPUThreadGuard;
|
class CPUThreadGuard;
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
class MemoryWidget : public QDockWidget
|
class MemoryWidget : public QDockWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MemoryWidget(QWidget* parent = nullptr);
|
explicit MemoryWidget(Core::System& system, QWidget* parent = nullptr);
|
||||||
~MemoryWidget();
|
~MemoryWidget();
|
||||||
|
|
||||||
void SetAddress(u32 address);
|
void SetAddress(u32 address);
|
||||||
|
@ -78,6 +79,8 @@ private:
|
||||||
void closeEvent(QCloseEvent*) override;
|
void closeEvent(QCloseEvent*) override;
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
|
|
||||||
MemoryViewWidget* m_memory_view;
|
MemoryViewWidget* m_memory_view;
|
||||||
QSplitter* m_splitter;
|
QSplitter* m_splitter;
|
||||||
QComboBox* m_search_address;
|
QComboBox* m_search_address;
|
||||||
|
|
|
@ -449,7 +449,7 @@ void MainWindow::CreateComponents()
|
||||||
m_jit_widget = new JITWidget(this);
|
m_jit_widget = new JITWidget(this);
|
||||||
m_log_widget = new LogWidget(this);
|
m_log_widget = new LogWidget(this);
|
||||||
m_log_config_widget = new LogConfigWidget(this);
|
m_log_config_widget = new LogConfigWidget(this);
|
||||||
m_memory_widget = new MemoryWidget(this);
|
m_memory_widget = new MemoryWidget(Core::System::GetInstance(), this);
|
||||||
m_network_widget = new NetworkWidget(this);
|
m_network_widget = new NetworkWidget(this);
|
||||||
m_register_widget = new RegisterWidget(this);
|
m_register_widget = new RegisterWidget(this);
|
||||||
m_thread_widget = new ThreadWidget(this);
|
m_thread_widget = new ThreadWidget(this);
|
||||||
|
|
Loading…
Reference in New Issue