summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Debugger/MemoryWidget.h
blob: b3a8d751860b6afb254603687c7025f9b49fb63f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <vector>

#include <QByteArray>
#include <QDockWidget>

#include "Common/CommonTypes.h"

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

enum class InputID : int
{
  // Order does not matter here.
  S8 = 1,
  S16,
  S32,
  U8,
  U16,
  U32,
  HEXSTR,
  FLOAT,
  DOUBLE,
  ASCII
};

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

  void SetAddress(u32 address);
  void Update();
signals:
  void BreakpointsChanged();
  void ShowCode(u32 address);
  void RequestWatch(QString name, u32 address);

private:
  struct TargetAddress
  {
    u32 address = 0;
    bool is_good_address = false;
    bool is_good_offset = false;
  };

  void CreateWidgets();
  void ConnectWidgets();

  void LoadSettings();
  void SaveSettings();

  void OnAddressSpaceChanged();
  void OnDisplayChanged();
  void OnBPLogChanged();
  void OnBPTypeChanged();

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

  void OnSetValue();
  void OnSetValueFromFile();

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

  void ValidateAndPreviewInputValue();
  QByteArray GetInputData() const;
  TargetAddress GetTargetAddress() const;
  void FindValue(bool next);

  void closeEvent(QCloseEvent*) override;
  void showEvent(QShowEvent* event) override;

  MemoryViewWidget* m_memory_view;
  QSplitter* m_splitter;
  QLineEdit* m_search_address;
  QLineEdit* m_search_offset;
  QLineEdit* m_data_edit;
  QCheckBox* m_base_check;
  QLabel* m_data_preview;
  QComboBox* m_display_combo;
  QComboBox* m_align_combo;
  QComboBox* m_row_length_combo;
  QPushButton* m_set_value;
  QPushButton* m_from_file;
  QPushButton* m_dump_mram;
  QPushButton* m_dump_exram;
  QPushButton* m_dump_aram;
  QPushButton* m_dump_fake_vmem;

  // Search
  QPushButton* m_find_next;
  QPushButton* m_find_previous;
  QComboBox* m_input_combo;
  QLabel* m_result_label;

  // Address Spaces
  QRadioButton* m_address_space_physical;
  QRadioButton* m_address_space_effective;
  QRadioButton* m_address_space_auxiliary;

  // Breakpoint options
  QRadioButton* m_bp_read_write;
  QRadioButton* m_bp_read_only;
  QRadioButton* m_bp_write_only;
  QCheckBox* m_bp_log_check;
};