summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorfires.gc <fires.gc@gmail.com>2008-07-24 08:47:38 +0000
committerfires.gc <fires.gc@gmail.com>2008-07-24 08:47:38 +0000
commitdc717f7283bde539c534295eac0cedf8bb7c049d (patch)
treea473559072e6ae7e6c834cc8023779209858e168 /Source/Core
parent185a214329df831bc21dfaddb98c7b3b9aff7427 (diff)
finished dialogs for memory checks and breakpoints
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@76 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp7
-rw-r--r--Source/Core/Common/Src/StringUtil.h2
-rw-r--r--Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp12
-rw-r--r--Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h14
-rw-r--r--Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp3
-rw-r--r--Source/Core/Core/Src/HW/Memmap.cpp11
-rw-r--r--Source/Core/Core/Src/HW/Memmap.h1
-rw-r--r--Source/Core/DebuggerWX/src/BreakPointDlg.cpp24
-rw-r--r--Source/Core/DebuggerWX/src/BreakPointDlg.h7
-rw-r--r--Source/Core/DebuggerWX/src/BreakpointView.cpp36
-rw-r--r--Source/Core/DebuggerWX/src/MemoryCheckDlg.cpp45
-rw-r--r--Source/Core/DebuggerWX/src/MemoryCheckDlg.h2
12 files changed, 137 insertions, 27 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 7df5164698..882a811077 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -22,7 +22,7 @@
#include "TestFramework.h"
// faster than sscanf
-u32 AsciiToHex(const char* _szValue)
+bool AsciiToHex(const char* _szValue, u32& result)
{
u32 value = 0;
size_t finish = strlen(_szValue);
@@ -126,12 +126,13 @@ u32 AsciiToHex(const char* _szValue)
break;
default:
- value >>= 4;
+ return false;
break;
}
}
- return(value);
+ result = value;
+ return (true);
}
diff --git a/Source/Core/Common/Src/StringUtil.h b/Source/Core/Common/Src/StringUtil.h
index c700d9bdc2..bc6496d198 100644
--- a/Source/Core/Common/Src/StringUtil.h
+++ b/Source/Core/Common/Src/StringUtil.h
@@ -60,7 +60,7 @@ bool TryParseUInt(const std::string& str, u32* output);
// TODO: kill this
-u32 AsciiToHex(const char* ascii);
+bool AsciiToHex(const char* _szValue, u32& result);
void SplitString(const std::string& str, const std::string& delim, std::vector<std::string>& output);
int ChooseStringFrom(const char* str, const char* * items);
diff --git a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp
index 39ec765c19..e333d3f03c 100644
--- a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp
+++ b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp
@@ -45,14 +45,14 @@ TMemCheck::TMemCheck()
void TMemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc)
{
- if ((write && bOnWrite) || (!write && bOnRead))
+ if ((write && OnWrite) || (!write && OnRead))
{
- if (bLog)
+ if (Log)
{
const char *copy = Debugger::GetDescription(addr);
LOG(MEMMAP,"CHK %08x %s%i at %08x (%s)", iValue, write ? "Write" : "Read", size*8, addr, copy);
}
- if (bBreak)
+ if (Break)
CCPU::Break();
}
}
@@ -86,12 +86,12 @@ TMemCheck *CBreakPoints::GetMemCheck(u32 address)
{
if ((*iter).bRange)
{
- if (address >= (*iter).iStartAddress && address <= (*iter).iEndAddress)
+ if (address >= (*iter).StartAddress && address <= (*iter).EndAddress)
return &(*iter);
}
else
{
- if ((*iter).iStartAddress==address)
+ if ((*iter).StartAddress==address)
return &(*iter);
}
}
@@ -186,7 +186,7 @@ void CBreakPoints::DeleteElementByAddress(u32 _Address)
std::vector<TMemCheck>::iterator iter;
for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter)
{
- if ((*iter).iStartAddress == _Address)
+ if ((*iter).StartAddress == _Address)
{
m_MemChecks.erase(iter);
Host_UpdateBreakPointView();
diff --git a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h
index 1203ceff26..b7ddaed804 100644
--- a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h
+++ b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h
@@ -33,18 +33,18 @@ struct TBreakPoint
struct TMemCheck
{
TMemCheck();
- u32 iStartAddress;
- u32 iEndAddress;
+ u32 StartAddress;
+ u32 EndAddress;
bool bRange;
- bool bOnRead;
- bool bOnWrite;
+ bool OnRead;
+ bool OnWrite;
- bool bLog;
- bool bBreak;
+ bool Log;
+ bool Break;
- u32 numHits;
+ u32 numHits;
void Action(u32 _iValue, u32 addr, bool write, int size, u32 pc);
};
diff --git a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp
index c34c3b8999..5b93f0516b 100644
--- a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp
+++ b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp
@@ -357,6 +357,9 @@ void AnalyzeBackwards()
bool GetCallstack(std::vector<SCallstackEntry> &output)
{
+ if (!Memory::IsInitialized())
+ return false;
+
if (!Memory::IsRAMAddress(PowerPC::ppcState.gpr[1]))
return false;
diff --git a/Source/Core/Core/Src/HW/Memmap.cpp b/Source/Core/Core/Src/HW/Memmap.cpp
index 8452a35ca9..39ab532879 100644
--- a/Source/Core/Core/Src/HW/Memmap.cpp
+++ b/Source/Core/Core/Src/HW/Memmap.cpp
@@ -65,6 +65,7 @@ u8* m_pFakeVMEM = NULL;
u8* m_pEXRAM = NULL; //wii
u8* m_pEFB = NULL;
u8* m_pL1Cache = NULL;
+bool m_IsInitialized = false;
MemArena g_arena;
@@ -407,6 +408,12 @@ writeFn32 GetHWWriteFun32(const u32 _Address)
}
+bool IsInitialized()
+{
+ return m_IsInitialized;
+}
+
+
bool Init()
{
bool wii = Core::GetStartupParameter().bWii;
@@ -509,12 +516,16 @@ bool Init()
InitHWMemFuncsWii();
else
InitHWMemFuncs();
+
+ m_IsInitialized = true;
return true;
}
bool Shutdown()
{
+ m_IsInitialized = false;
+
bool wii = Core::GetStartupParameter().bWii;
g_arena.ReleaseView(m_pRAM, RAM_SIZE);
diff --git a/Source/Core/Core/Src/HW/Memmap.h b/Source/Core/Core/Src/HW/Memmap.h
index 7f01c7a7f6..62c1b5b6a2 100644
--- a/Source/Core/Core/Src/HW/Memmap.h
+++ b/Source/Core/Core/Src/HW/Memmap.h
@@ -60,6 +60,7 @@ namespace Memory
#endif
};
+ bool IsInitialized();
bool Init();
bool Shutdown();
void Clear();
diff --git a/Source/Core/DebuggerWX/src/BreakPointDlg.cpp b/Source/Core/DebuggerWX/src/BreakPointDlg.cpp
index 5c89669b77..c42271fdd1 100644
--- a/Source/Core/DebuggerWX/src/BreakPointDlg.cpp
+++ b/Source/Core/DebuggerWX/src/BreakPointDlg.cpp
@@ -16,10 +16,16 @@
// http://code.google.com/p/dolphin-emu/
#include "BreakPointDlg.h"
+#include "Common.h"
+#include "Debugger.h"
+#include "StringUtil.h"
+#include "Debugger/Debugger_BreakPoints.h"
BEGIN_EVENT_TABLE(BreakPointDlg,wxDialog)
EVT_CLOSE(BreakPointDlg::OnClose)
+ EVT_BUTTON(ID_OK, BreakPointDlg::OnOK)
+ EVT_BUTTON(ID_CANCEL, BreakPointDlg::OnCancel)
END_EVENT_TABLE()
@@ -51,7 +57,7 @@ void BreakPointDlg::CreateGUIControls()
m_pButtonCancel = new wxButton(this, ID_CANCEL, wxT("Cancel"), wxPoint(112,64), wxSize(73,25), 0, wxDefaultValidator, wxT("Cancel"));
m_pButtonCancel->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
- m_pEditAddress = new wxTextCtrl(this, ID_ADDRESS, wxT("WxEdit1"), wxPoint(56,24), wxSize(197,20), 0, wxDefaultValidator, wxT("WxEdit1"));
+ m_pEditAddress = new wxTextCtrl(this, ID_ADDRESS, wxT("80000000"), wxPoint(56,24), wxSize(197,20), 0, wxDefaultValidator, wxT("WxEdit1"));
m_pEditAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox1 = new wxStaticBox(this, ID_WXSTATICBOX1, wxT("Address"), wxPoint(0,0), wxSize(265,57));
@@ -63,3 +69,19 @@ void BreakPointDlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}
+
+void BreakPointDlg::OnOK(wxCommandEvent& /*event*/)
+{
+ wxString AddressString = m_pEditAddress->GetLineText(0);
+ u32 Address = 0;
+ if (AsciiToHex(AddressString.GetData(), Address))
+ {
+ CBreakPoints::AddBreakPoint(Address);
+ Close();
+ }
+}
+
+void BreakPointDlg::OnCancel(wxCommandEvent& /*event*/)
+{
+ Close();
+} \ No newline at end of file
diff --git a/Source/Core/DebuggerWX/src/BreakPointDlg.h b/Source/Core/DebuggerWX/src/BreakPointDlg.h
index 2490e6f430..5f0b974981 100644
--- a/Source/Core/DebuggerWX/src/BreakPointDlg.h
+++ b/Source/Core/DebuggerWX/src/BreakPointDlg.h
@@ -27,7 +27,7 @@
#include <wx/statbox.h>
#undef BreakPointDlg_STYLE
-#define BreakPointDlg_STYLE wxCAPTION | wxSYSTEM_MENU | wxSTAY_ON_TOP | wxDIALOG_NO_PARENT | wxCLOSE_BOX
+#define BreakPointDlg_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX
class BreakPointDlg : public wxDialog
@@ -57,8 +57,11 @@ class BreakPointDlg : public wxDialog
};
private:
- void OnClose(wxCloseEvent& event);
+
void CreateGUIControls();
+ void OnClose(wxCloseEvent& event);
+ void OnCancel(wxCommandEvent& event);
+ void OnOK(wxCommandEvent& event);
};
#endif
diff --git a/Source/Core/DebuggerWX/src/BreakpointView.cpp b/Source/Core/DebuggerWX/src/BreakpointView.cpp
index ebe9169263..f1c7e2806f 100644
--- a/Source/Core/DebuggerWX/src/BreakpointView.cpp
+++ b/Source/Core/DebuggerWX/src/BreakpointView.cpp
@@ -44,10 +44,10 @@ CBreakPointView::Update()
InsertColumn(0, wxT("Active"), wxLIST_FORMAT_LEFT, 50);
InsertColumn(1, wxT("Type"), wxLIST_FORMAT_LEFT, 50);
InsertColumn(2, wxT("Function"), wxLIST_FORMAT_CENTER, 200);
- InsertColumn(3, wxT("Address"), wxLIST_FORMAT_CENTER, 100);
+ InsertColumn(3, wxT("Address"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(4, wxT("Flags"), wxLIST_FORMAT_CENTER, 100);
- char szBuffer[32];
+ char szBuffer[64];
const CBreakPoints::TBreakPoints& rBreakPoints = CBreakPoints::GetBreakPoints();
for (size_t i=0; i<rBreakPoints.size(); i++)
{
@@ -75,6 +75,38 @@ CBreakPointView::Update()
}
}
+ const CBreakPoints::TMemChecks& rMemChecks = CBreakPoints::GetMemChecks();
+ for (size_t i=0; i<rMemChecks.size(); i++)
+ {
+ const TMemCheck& rMemCheck = rMemChecks[i];
+
+ wxString temp;
+ temp = wxString::FromAscii(rMemCheck.Break ? "on" : " ");
+ int Item = InsertItem(0, temp);
+ temp = wxString::FromAscii("MC");
+ SetItem(Item, 1, temp);
+
+ Debugger::XSymbolIndex index = Debugger::FindSymbol(rMemCheck.StartAddress);
+ if (index > 0)
+ {
+ temp = wxString::FromAscii(Debugger::GetDescription(rMemCheck.StartAddress));
+ SetItem(Item, 2, temp);
+ }
+
+ sprintf(szBuffer, "0x%08x to 0%08x", rMemCheck.StartAddress, rMemCheck.EndAddress);
+ temp = wxString::FromAscii(szBuffer);
+ SetItem(Item, 3, temp);
+
+ size_t c = 0;
+ if (rMemCheck.OnRead) szBuffer[c++] = 'r';
+ if (rMemCheck.OnWrite) szBuffer[c++] = 'w';
+ szBuffer[c] = 0x00;
+ temp = wxString::FromAscii(szBuffer);
+ SetItem(Item, 4, temp);
+
+ SetItemData(Item, rMemCheck.StartAddress);
+ }
+
Refresh();
}
diff --git a/Source/Core/DebuggerWX/src/MemoryCheckDlg.cpp b/Source/Core/DebuggerWX/src/MemoryCheckDlg.cpp
index 57c14c5b5b..b2dbb27fda 100644
--- a/Source/Core/DebuggerWX/src/MemoryCheckDlg.cpp
+++ b/Source/Core/DebuggerWX/src/MemoryCheckDlg.cpp
@@ -16,10 +16,15 @@
// http://code.google.com/p/dolphin-emu/
#include "MemoryCheckDlg.h"
-
+#include "Common.h"
+#include "Debugger.h"
+#include "StringUtil.h"
+#include "Debugger/Debugger_BreakPoints.h"
BEGIN_EVENT_TABLE(MemoryCheckDlg,wxDialog)
EVT_CLOSE(MemoryCheckDlg::OnClose)
+ EVT_BUTTON(ID_OK, MemoryCheckDlg::OnOK)
+ EVT_BUTTON(ID_CANCEL, MemoryCheckDlg::OnCancel)
END_EVENT_TABLE()
@@ -54,18 +59,18 @@ void MemoryCheckDlg::CreateGUIControls()
wxStaticBox* WxStaticBox2 = new wxStaticBox(this, ID_WXSTATICBOX2, wxT("Break On"), wxPoint(328,0), wxSize(73,57));
WxStaticBox2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
- m_pEditEndAddress = new wxTextCtrl(this, ID_EDIT_END_ADDRESS, wxT("EndAddr"), wxPoint(200,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit2"));
- m_pEditEndAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
-
wxStaticText* WxStaticText2 = new wxStaticText(this, ID_WXSTATICTEXT2, wxT("End"), wxPoint(168,24), wxDefaultSize, 0, wxT("WxStaticText2"));
WxStaticText2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticText* WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Start"), wxPoint(8,24), wxDefaultSize, 0, wxT("WxStaticText1"));
WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
- m_pEditStartAddress = new wxTextCtrl(this, ID_EDIT_START_ADDR, wxT("StartAddr"), wxPoint(40,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit1"));
+ m_pEditStartAddress = new wxTextCtrl(this, ID_EDIT_START_ADDR, wxT("80000000"), wxPoint(40,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit1"));
m_pEditStartAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
+ m_pEditEndAddress = new wxTextCtrl(this, ID_EDIT_END_ADDRESS, wxT("80000000"), wxPoint(200,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit2"));
+ m_pEditEndAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
+
wxStaticBox* WxStaticBox1 = new wxStaticBox(this, ID_WXSTATICBOX1, wxT("Address Range"), wxPoint(0,0), wxSize(321,57));
WxStaticBox1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
}
@@ -74,3 +79,33 @@ void MemoryCheckDlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}
+
+void MemoryCheckDlg::OnOK(wxCommandEvent& /*event*/)
+{
+ wxString StartAddressString = m_pEditStartAddress->GetLineText(0);
+ wxString EndAddressString = m_pEditEndAddress->GetLineText(0);
+ bool OnRead = m_pReadFlag->GetValue();
+ bool OnWrite = m_pWriteFlag->GetValue();
+
+ u32 StartAddress, EndAddress;
+ if (AsciiToHex(StartAddressString.GetData(), StartAddress) &&
+ AsciiToHex(EndAddressString.GetData(), EndAddress))
+ {
+ TMemCheck MemCheck;
+ MemCheck.StartAddress = StartAddress;
+ MemCheck.EndAddress = EndAddress;
+ MemCheck.OnRead = OnRead;
+ MemCheck.OnWrite = OnWrite;
+
+ MemCheck.Log = true;
+ MemCheck.Break = true;
+
+ CBreakPoints::AddMemoryCheck(MemCheck);
+ Close();
+ }
+}
+
+void MemoryCheckDlg::OnCancel(wxCommandEvent& /*event*/)
+{
+ Close();
+} \ No newline at end of file
diff --git a/Source/Core/DebuggerWX/src/MemoryCheckDlg.h b/Source/Core/DebuggerWX/src/MemoryCheckDlg.h
index 173e774769..b0b3a86222 100644
--- a/Source/Core/DebuggerWX/src/MemoryCheckDlg.h
+++ b/Source/Core/DebuggerWX/src/MemoryCheckDlg.h
@@ -65,6 +65,8 @@ class MemoryCheckDlg : public wxDialog
private:
void OnClose(wxCloseEvent& event);
+ void OnOK(wxCommandEvent& event);
+ void OnCancel(wxCommandEvent& event);
void CreateGUIControls();
};