Large diffs are not rendered by default.

@@ -0,0 +1,62 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <QTableWidget>

#include "Common/CommonTypes.h"

class MemoryViewWidget : public QTableWidget
{
Q_OBJECT
public:
enum class Type
{
U8,
U16,
U32,
ASCII,
Float32
};

enum class BPType
{
ReadWrite,
ReadOnly,
WriteOnly
};

explicit MemoryViewWidget(QWidget* parent = nullptr);

void Update();
void ToggleBreakpoint();

void SetType(Type type);
void SetBPType(BPType type);
void SetAddress(u32 address);

void SetBPLoggingEnabled(bool enabled);

u32 GetContextAddress() const;

void resizeEvent(QResizeEvent*) override;
void keyPressEvent(QKeyEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;

signals:
void BreakpointsChanged();

private:
void OnContextMenu();
void OnCopyAddress();
void OnCopyHex();

Type m_type = Type::U8;
BPType m_bp_type = BPType::ReadWrite;
bool m_do_log = true;
u32 m_context_address;
u32 m_address = 0;
};

Large diffs are not rendered by default.

@@ -0,0 +1,88 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <vector>

#include <QDockWidget>

#include "Common/CommonTypes.h"

class MemoryViewWidget;
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QSplitter;

class MemoryWidget : public QDockWidget
{
Q_OBJECT
public:
explicit MemoryWidget(QWidget* parent = nullptr);
~MemoryWidget();

void Update();
signals:
void BreakpointsChanged();

private:
void CreateWidgets();
void ConnectWidgets();

void LoadSettings();
void SaveSettings();

void OnTypeChanged();
void OnBPLogChanged();
void OnBPTypeChanged();

void OnSearchAddress();
void OnFindNextValue();
void OnFindPreviousValue();
void ValidateSearchValue();

void OnSetValue();

void OnDumpMRAM();
void OnDumpExRAM();
void OnDumpFakeVMEM();

std::vector<u8> GetValueData() const;

void FindValue(bool next);

void closeEvent(QCloseEvent*) override;

MemoryViewWidget* m_memory_view;
QSplitter* m_splitter;
QLineEdit* m_search_address;
QLineEdit* m_data_edit;
QPushButton* m_set_value;
QPushButton* m_dump_mram;
QPushButton* m_dump_exram;
QPushButton* m_dump_fake_vmem;

// Search
QPushButton* m_find_next;
QPushButton* m_find_previous;
QRadioButton* m_find_ascii;
QRadioButton* m_find_hex;
QLabel* m_result_label;

// Datatypes
QRadioButton* m_type_u8;
QRadioButton* m_type_u16;
QRadioButton* m_type_u32;
QRadioButton* m_type_ascii;
QRadioButton* m_type_float;

// Breakpoint options
QRadioButton* m_bp_read_write;
QRadioButton* m_bp_read_only;
QRadioButton* m_bp_write_only;
QCheckBox* m_bp_log_check;
};
@@ -97,6 +97,8 @@
<QtMoc Include="Debugger\BreakpointWidget.h" />
<QtMoc Include="Debugger\CodeWidget.h" />
<QtMoc Include="Debugger\CodeViewWidget.h" />
<QtMoc Include="Debugger\MemoryWidget.h" />
<QtMoc Include="Debugger\MemoryViewWidget.h" />
<QtMoc Include="Debugger\NewBreakpointDialog.h" />
<QtMoc Include="Debugger\RegisterWidget.h" />
<QtMoc Include="Debugger\WatchWidget.h" />
@@ -181,6 +183,8 @@
<ClCompile Include="$(QtMocOutPrefix)MappingWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MappingWindow.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MD5Dialog.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MemoryWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MemoryViewWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MenuBar.cpp" />
<ClCompile Include="$(QtMocOutPrefix)NetPlayDialog.cpp" />
<ClCompile Include="$(QtMocOutPrefix)NetPlaySetupDialog.cpp" />
@@ -250,6 +254,8 @@
<ClCompile Include="Config\SettingsWindow.cpp" />
<ClCompile Include="Debugger\CodeViewWidget.cpp" />
<ClCompile Include="Debugger\CodeWidget.cpp" />
<ClCompile Include="Debugger\MemoryWidget.cpp" />
<ClCompile Include="Debugger\MemoryViewWidget.cpp" />
<ClCompile Include="FIFOPlayerWindow.cpp" />
<ClCompile Include="QtUtils\WinIconHelper.cpp" />
<ClCompile Include="TAS\GCTASInputWindow.cpp" />
@@ -54,6 +54,7 @@
#include "DolphinQt2/Config/SettingsWindow.h"
#include "DolphinQt2/Debugger/BreakpointWidget.h"
#include "DolphinQt2/Debugger/CodeWidget.h"
#include "DolphinQt2/Debugger/MemoryWidget.h"
#include "DolphinQt2/Debugger/RegisterWidget.h"
#include "DolphinQt2/Debugger/WatchWidget.h"
#include "DolphinQt2/FIFOPlayerWindow.h"
@@ -195,6 +196,7 @@ void MainWindow::CreateComponents()
m_log_widget = new LogWidget(this);
m_log_config_widget = new LogConfigWidget(this);
m_fifo_window = new FIFOPlayerWindow(this);
m_memory_widget = new MemoryWidget(this);

connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
[this](const QString& path) { StartGame(path); });
@@ -207,8 +209,16 @@ void MainWindow::CreateComponents()
[this](u32 addr) { m_breakpoint_widget->AddAddressMBP(addr); });
connect(m_register_widget, &RegisterWidget::RequestMemoryBreakpoint,
[this](u32 addr) { m_breakpoint_widget->AddAddressMBP(addr); });

connect(m_code_widget, &CodeWidget::BreakpointsChanged, m_breakpoint_widget,
&BreakpointWidget::Update);
connect(m_memory_widget, &MemoryWidget::BreakpointsChanged, m_breakpoint_widget,
&BreakpointWidget::Update);

connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_code_widget,
&CodeWidget::Update);
connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_memory_widget,
&MemoryWidget::Update);

#if defined(HAVE_XRANDR) && HAVE_XRANDR
m_graphics_window = new GraphicsWindow(
@@ -410,12 +420,14 @@ void MainWindow::ConnectStack()
addDockWidget(Qt::RightDockWidgetArea, m_register_widget);
addDockWidget(Qt::RightDockWidgetArea, m_watch_widget);
addDockWidget(Qt::RightDockWidgetArea, m_breakpoint_widget);
addDockWidget(Qt::RightDockWidgetArea, m_memory_widget);

tabifyDockWidget(m_log_widget, m_log_config_widget);
tabifyDockWidget(m_log_widget, m_code_widget);
tabifyDockWidget(m_log_widget, m_register_widget);
tabifyDockWidget(m_log_widget, m_watch_widget);
tabifyDockWidget(m_log_widget, m_breakpoint_widget);
tabifyDockWidget(m_log_widget, m_memory_widget);
}

QString MainWindow::PromptFileName()
@@ -32,6 +32,7 @@ class HotkeyScheduler;
class LogConfigWidget;
class LogWidget;
class MappingWindow;
class MemoryWidget;
class NetPlayClient;
class NetPlayDialog;
class NetPlayServer;
@@ -174,6 +175,7 @@ class MainWindow final : public QMainWindow
CodeWidget* m_code_widget;
LogWidget* m_log_widget;
LogConfigWidget* m_log_config_widget;
MemoryWidget* m_memory_widget;
FIFOPlayerWindow* m_fifo_window;
RegisterWidget* m_register_widget;
WatchWidget* m_watch_widget;
@@ -120,6 +120,7 @@ void MenuBar::OnDebugModeToggled(bool enabled)
m_show_registers->setVisible(enabled);
m_show_watch->setVisible(enabled);
m_show_breakpoints->setVisible(enabled);
m_show_memory->setVisible(enabled);

if (enabled)
addMenu(m_symbols);
@@ -377,6 +378,14 @@ void MenuBar::AddViewMenu()
connect(&Settings::Instance(), &Settings::BreakpointsVisibilityChanged, m_show_breakpoints,
&QAction::setChecked);

m_show_memory = view_menu->addAction(tr("&Memory"));
m_show_memory->setCheckable(true);
m_show_memory->setChecked(Settings::Instance().IsMemoryVisible());

connect(m_show_memory, &QAction::toggled, &Settings::Instance(), &Settings::SetMemoryVisible);
connect(&Settings::Instance(), &Settings::MemoryVisibilityChanged, m_show_memory,
&QAction::setChecked);

view_menu->addSeparator();

AddGameListTypeSection(view_menu);
@@ -201,6 +201,7 @@ class MenuBar final : public QMenuBar
QAction* m_show_registers;
QAction* m_show_watch;
QAction* m_show_breakpoints;
QAction* m_show_memory;

// Symbols
QMenu* m_symbols;
@@ -305,6 +305,20 @@ bool Settings::IsCodeVisible() const
return GetQSettings().value(QStringLiteral("debugger/showcode")).toBool();
}

void Settings::SetMemoryVisible(bool enabled)
{
if (IsMemoryVisible() == enabled)
return;
QSettings().setValue(QStringLiteral("debugger/showmemory"), enabled);

emit MemoryVisibilityChanged(enabled);
}

bool Settings::IsMemoryVisible() const
{
return QSettings().value(QStringLiteral("debugger/showmemory")).toBool();
}

void Settings::SetDebugFont(QFont font)
{
if (GetDebugFont() != font)
@@ -97,6 +97,8 @@ class Settings final : public QObject
bool IsBreakpointsVisible() const;
void SetCodeVisible(bool enabled);
bool IsCodeVisible() const;
void SetMemoryVisible(bool enabled);
bool IsMemoryVisible() const;
QFont GetDebugFont() const;
void SetDebugFont(QFont font);

@@ -127,6 +129,7 @@ class Settings final : public QObject
void WatchVisibilityChanged(bool visible);
void BreakpointsVisibilityChanged(bool visible);
void CodeVisibilityChanged(bool visible);
void MemoryVisibilityChanged(bool visible);
void DebugModeToggled(bool enabled);
void DebugFontChanged(QFont font);
void AutoUpdateTrackChanged(const QString& mode);