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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
#include <string>
#include <wx/radiobut.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "Core/PowerPC/BreakPoints.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinWX/Debugger/BreakpointWindow.h"
#include "DolphinWX/WxUtils.h"
MemoryCheckDlg::MemoryCheckDlg(wxWindow* parent)
: wxDialog(parent, wxID_ANY, _("Add a Memory Breakpoint"))
{
Bind(wxEVT_BUTTON, &MemoryCheckDlg::OnOK, this, wxID_OK);
Bind(wxEVT_RADIOBUTTON, &MemoryCheckDlg::OnRadioButtonClick, this);
const int space5 = FromDIP(5);
m_textAddress = new wxStaticText(this, wxID_ANY, _("Address"));
m_textStartAddress = new wxStaticText(this, wxID_ANY, _("Start"));
m_textStartAddress->Disable();
m_textEndAddress = new wxStaticText(this, wxID_ANY, _("End"));
m_textEndAddress->Disable();
m_pEditAddress = new wxTextCtrl(this, wxID_ANY);
m_pEditStartAddress = new wxTextCtrl(this, wxID_ANY);
m_pEditStartAddress->Disable();
m_pEditEndAddress = new wxTextCtrl(this, wxID_ANY);
m_pEditEndAddress->Disable();
m_radioAddress = new wxRadioButton(this, wxID_ANY, _("With an address"), wxDefaultPosition,
wxDefaultSize, wxRB_GROUP);
m_radioRange = new wxRadioButton(this, wxID_ANY, _("Within a range"));
m_radioRead =
new wxRadioButton(this, wxID_ANY, _("Read"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
m_radioWrite = new wxRadioButton(this, wxID_ANY, _("Write"));
m_radioReadWrite = new wxRadioButton(this, wxID_ANY, _("Read and write"));
m_radioLog =
new wxRadioButton(this, wxID_ANY, _("Log"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
m_radioBreak = new wxRadioButton(this, wxID_ANY, _("Break"));
m_radioBreakLog = new wxRadioButton(this, wxID_ANY, _("Break and log"));
m_radioBreakLog->SetValue(true);
auto* sAddressBox = new wxBoxSizer(wxHORIZONTAL);
sAddressBox->AddSpacer(space5);
sAddressBox->Add(m_textAddress, 0, wxALIGN_CENTER_VERTICAL);
sAddressBox->AddSpacer(space5);
sAddressBox->Add(m_pEditAddress, 1, wxALIGN_CENTER_VERTICAL);
sAddressBox->AddSpacer(space5);
auto* sAddressRangeBox = new wxBoxSizer(wxHORIZONTAL);
sAddressRangeBox->AddSpacer(space5);
sAddressRangeBox->Add(m_textStartAddress, 0, wxALIGN_CENTER_VERTICAL);
sAddressRangeBox->AddSpacer(space5);
sAddressRangeBox->Add(m_pEditStartAddress, 1, wxALIGN_CENTER_VERTICAL);
sAddressRangeBox->AddSpacer(space5);
sAddressRangeBox->Add(m_textEndAddress, 0, wxALIGN_CENTER_VERTICAL);
sAddressRangeBox->AddSpacer(space5);
sAddressRangeBox->Add(m_pEditEndAddress, 1, wxALIGN_CENTER_VERTICAL);
sAddressRangeBox->AddSpacer(space5);
auto* sActions = new wxStaticBoxSizer(wxVERTICAL, this, _("Action"));
sActions->Add(m_radioRead, 0, wxEXPAND);
sActions->Add(m_radioWrite, 0, wxEXPAND);
sActions->Add(m_radioReadWrite, 0, wxEXPAND);
m_radioWrite->SetValue(true);
auto* sFlags = new wxStaticBoxSizer(wxVERTICAL, this, _("Flags"));
sFlags->Add(m_radioLog);
sFlags->Add(m_radioBreak);
sFlags->Add(m_radioBreakLog);
auto* sOptionsBox = new wxBoxSizer(wxHORIZONTAL);
sOptionsBox->Add(sActions, 1, wxEXPAND, space5);
sOptionsBox->Add(sFlags, 1, wxEXPAND | wxLEFT, space5);
auto* sControls = new wxBoxSizer(wxVERTICAL);
sControls->Add(m_radioAddress, 0, wxEXPAND);
sControls->AddSpacer(5);
sControls->Add(sAddressBox, 0, wxEXPAND);
sControls->AddSpacer(5);
sControls->Add(m_radioRange, 0, wxEXPAND);
sControls->AddSpacer(5);
sControls->Add(sAddressRangeBox, 0, wxEXPAND);
sControls->AddSpacer(5);
sControls->Add(sOptionsBox, 0, wxEXPAND);
auto* sMainSizer = new wxBoxSizer(wxVERTICAL);
sMainSizer->AddSpacer(space5);
sMainSizer->Add(sControls, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sMainSizer->AddSpacer(space5);
sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sMainSizer->AddSpacer(space5);
SetSizerAndFit(sMainSizer);
SetFocus();
m_pEditAddress->SetFocus();
}
void MemoryCheckDlg::OnRadioButtonClick(wxCommandEvent& event)
{
if (m_radioAddress->GetValue())
{
m_pEditAddress->Enable();
m_textAddress->Enable();
m_pEditStartAddress->Disable();
m_pEditEndAddress->Disable();
m_textStartAddress->Disable();
m_textEndAddress->Disable();
}
else
{
m_pEditStartAddress->Enable();
m_textStartAddress->Enable();
m_textEndAddress->Enable();
m_pEditEndAddress->Enable();
m_pEditAddress->Disable();
m_textAddress->Disable();
}
}
void MemoryCheckDlg::OnOK(wxCommandEvent& event)
{
wxString StartAddressString;
wxString EndAddressString;
if (m_radioAddress->GetValue())
{
StartAddressString = m_pEditAddress->GetLineText(0);
EndAddressString = m_pEditAddress->GetLineText(0);
}
else
{
StartAddressString = m_pEditStartAddress->GetLineText(0);
EndAddressString = m_pEditEndAddress->GetLineText(0);
}
bool OnRead = m_radioRead->GetValue() || m_radioReadWrite->GetValue();
bool OnWrite = m_radioWrite->GetValue() || m_radioReadWrite->GetValue();
bool Log = m_radioLog->GetValue() || m_radioBreakLog->GetValue();
bool Break = m_radioBreak->GetValue() || m_radioBreakLog->GetValue();
u32 StartAddress, EndAddress;
bool EndAddressOK =
EndAddressString.Len() && AsciiToHex(WxStrToStr(EndAddressString), EndAddress);
if (AsciiToHex(WxStrToStr(StartAddressString), StartAddress) && (OnRead || OnWrite) &&
(Log || Break))
{
TMemCheck MemCheck;
if (!EndAddressOK)
EndAddress = StartAddress;
MemCheck.start_address = StartAddress;
MemCheck.end_address = EndAddress;
MemCheck.is_ranged = StartAddress != EndAddress;
MemCheck.is_break_on_read = OnRead;
MemCheck.is_break_on_write = OnWrite;
MemCheck.log_on_hit = Log;
MemCheck.break_on_hit = Break;
PowerPC::memchecks.Add(MemCheck);
EndModal(wxID_OK);
}
event.Skip();
}
|