2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <string>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
|
|
|
|
#include "Common/BreakPoints.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/StringUtil.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
#include "DolphinWX/Debugger/BreakpointWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
#define TEXT_BOX(text) new wxStaticText(this, wxID_ANY, _(text))
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2011-02-28 20:40:15 +00:00
|
|
|
MemoryCheckDlg::MemoryCheckDlg(CBreakPointWindow *parent)
|
2014-03-06 04:02:34 +00:00
|
|
|
: wxDialog(parent, wxID_ANY, _("Memory Check"))
|
2011-02-28 20:40:15 +00:00
|
|
|
, m_parent(parent)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2015-10-23 18:37:29 +00:00
|
|
|
Bind(wxEVT_BUTTON, &MemoryCheckDlg::OnOK, this, wxID_OK);
|
2014-11-06 03:19:52 +00:00
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
m_pEditStartAddress = new wxTextCtrl(this, wxID_ANY, "");
|
|
|
|
m_pEditEndAddress = new wxTextCtrl(this, wxID_ANY, "");
|
2011-02-27 23:03:08 +00:00
|
|
|
m_pWriteFlag = new wxCheckBox(this, wxID_ANY, _("Write"));
|
2011-02-25 11:03:49 +00:00
|
|
|
m_pWriteFlag->SetValue(true);
|
2011-02-27 23:03:08 +00:00
|
|
|
m_pReadFlag = new wxCheckBox(this, wxID_ANY, _("Read"));
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
m_log_flag = new wxCheckBox(this, wxID_ANY, _("Log"));
|
|
|
|
m_log_flag->SetValue(true);
|
|
|
|
m_break_flag = new wxCheckBox(this, wxID_ANY, _("Break"));
|
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxStaticBoxSizer *sAddressRangeBox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Address Range"));
|
2011-02-27 23:03:08 +00:00
|
|
|
sAddressRangeBox->Add(TEXT_BOX("Start"), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
|
|
|
sAddressRangeBox->Add(m_pEditStartAddress, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, 10);
|
|
|
|
sAddressRangeBox->Add(TEXT_BOX("End"), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
|
|
|
sAddressRangeBox->Add(m_pEditEndAddress, 1, wxALIGN_CENTER_VERTICAL);
|
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxStaticBoxSizer *sActionBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Action"));
|
2011-02-27 23:03:08 +00:00
|
|
|
sActionBox->Add(m_pWriteFlag);
|
|
|
|
sActionBox->Add(m_pReadFlag);
|
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxBoxSizer* sFlags = new wxStaticBoxSizer(wxVERTICAL, this, _("Flags"));
|
2011-02-27 23:03:08 +00:00
|
|
|
sFlags->Add(m_log_flag);
|
|
|
|
sFlags->Add(m_break_flag);
|
|
|
|
|
|
|
|
wxBoxSizer *sControls = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sControls->Add(sAddressRangeBox, 0, wxEXPAND);
|
|
|
|
sControls->Add(sActionBox, 0, wxEXPAND);
|
|
|
|
sControls->Add(sFlags, 0, wxEXPAND);
|
|
|
|
|
|
|
|
wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sMainSizer->Add(sControls, 0, wxEXPAND | wxALL, 5);
|
2011-03-17 04:26:01 +00:00
|
|
|
sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
SetSizerAndFit(sMainSizer);
|
|
|
|
SetFocus();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
void MemoryCheckDlg::OnOK(wxCommandEvent& event)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
wxString StartAddressString = m_pEditStartAddress->GetLineText(0);
|
|
|
|
wxString EndAddressString = m_pEditEndAddress->GetLineText(0);
|
|
|
|
bool OnRead = m_pReadFlag->GetValue();
|
|
|
|
bool OnWrite = m_pWriteFlag->GetValue();
|
2011-02-25 11:03:49 +00:00
|
|
|
bool Log = m_log_flag->GetValue();
|
2014-09-10 16:17:38 +00:00
|
|
|
bool Break = m_break_flag->GetValue();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
u32 StartAddress, EndAddress;
|
2011-02-25 11:03:49 +00:00
|
|
|
bool EndAddressOK = EndAddressString.Len() &&
|
2014-03-12 19:33:41 +00:00
|
|
|
AsciiToHex(WxStrToStr(EndAddressString), EndAddress);
|
2011-02-25 11:03:49 +00:00
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
if (AsciiToHex(WxStrToStr(StartAddressString), StartAddress) &&
|
2011-02-25 11:03:49 +00:00
|
|
|
(OnRead || OnWrite) && (Log || Break))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
TMemCheck MemCheck;
|
2011-02-25 11:03:49 +00:00
|
|
|
|
|
|
|
if (!EndAddressOK)
|
|
|
|
EndAddress = StartAddress;
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
MemCheck.StartAddress = StartAddress;
|
|
|
|
MemCheck.EndAddress = EndAddress;
|
2011-02-25 10:07:24 +00:00
|
|
|
MemCheck.bRange = StartAddress != EndAddress;
|
2008-12-08 05:30:24 +00:00
|
|
|
MemCheck.OnRead = OnRead;
|
|
|
|
MemCheck.OnWrite = OnWrite;
|
2011-02-25 11:03:49 +00:00
|
|
|
MemCheck.Log = Log;
|
|
|
|
MemCheck.Break = Break;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-06-28 11:47:39 +00:00
|
|
|
PowerPC::memchecks.Add(MemCheck);
|
2011-02-28 20:40:15 +00:00
|
|
|
m_parent->NotifyUpdate();
|
2008-12-08 05:30:24 +00:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|