Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a RAM Watch window to the debugger
- Loading branch information
Showing
15 changed files
with
395 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
// Copyright 2013 Dolphin Emulator Project | ||
// Licensed under GPLv2 | ||
// Refer to the license.txt file included. | ||
|
||
#include <wx/chartype.h> | ||
#include <wx/colour.h> | ||
#include <wx/defs.h> | ||
#include <wx/grid.h> | ||
#include <wx/string.h> | ||
#include <wx/windowid.h> | ||
|
||
#include "Common/GekkoDisassembler.h" | ||
#include "Core/HW/Memmap.h" | ||
#include "Core/PowerPC/PowerPC.h" | ||
#include "DolphinWX/WxUtils.h" | ||
#include "DolphinWX/Debugger/DebuggerUIUtil.h" | ||
#include "DolphinWX/Debugger/WatchView.h" | ||
|
||
class wxWindow; | ||
|
||
const char *watch_name[1024]; | ||
u32 watch_addr[1024]; | ||
|
||
static const char* GetWatchName(int count) | ||
{ | ||
return watch_name[count - 1]; | ||
} | ||
|
||
static u32 GetWatchAddr(int count) | ||
{ | ||
return watch_addr[count - 1]; | ||
} | ||
|
||
static u32 GetWatchValue(int count) | ||
{ | ||
return Memory::ReadUnchecked_U32(watch_addr[count - 1]); | ||
} | ||
|
||
static void SetWatchName(int count, const char* value) | ||
{ | ||
watch_name[count - 1] = value; | ||
} | ||
|
||
static void SetWatchAddr(int count, u32 value) | ||
{ | ||
watch_addr[count - 1] = value; | ||
} | ||
|
||
static void SetWatchValue(int count, u32 value) | ||
{ | ||
Memory::WriteUnchecked_U32(value, GetWatchAddr(count)); | ||
} | ||
|
||
wxString CWatchTable::GetValue(int row, int col) | ||
{ | ||
if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) | ||
{ | ||
if (row == 0) | ||
{ | ||
// Column Labels | ||
switch (col) | ||
{ | ||
case 0: return wxString::Format("Label"); | ||
case 1: return wxString::Format("Addr"); | ||
case 2: return wxString::Format("Hex"); | ||
case 3: return wxString::Format("Dec"); | ||
case 4: return wxString::Format("Str"); | ||
default: return wxEmptyString; | ||
} | ||
} | ||
else if (row <= num_watches) | ||
{ | ||
switch (col) | ||
{ | ||
case 0: return wxString::Format("%s", GetWatchName(row)); | ||
case 1: return wxString::Format("%08x", GetWatchAddr(row)); | ||
case 2: return wxString::Format("%08x", GetWatchValue(row)); | ||
case 3: return wxString::Format("%lu", GetWatchValue(row)); | ||
case 4: | ||
{ | ||
u32 addr = GetWatchAddr(row); | ||
if (Memory::IsRAMAddress(addr)) | ||
return wxString::Format("%s", Memory::GetString(addr, 32)); | ||
else | ||
return wxEmptyString; | ||
} | ||
default: return wxEmptyString; | ||
} | ||
} | ||
} | ||
return wxEmptyString; | ||
} | ||
|
||
void CWatchTable::SetValue(int row, int col, const wxString& strNewVal) | ||
{ | ||
u32 newVal = 0; | ||
if (col == 0 || TryParse("0x" + WxStrToStr(strNewVal), &newVal)) | ||
{ | ||
if (row > 0) | ||
{ | ||
if (row > num_watches) | ||
{ | ||
num_watches++; | ||
row = num_watches; | ||
} | ||
switch (col) | ||
{ | ||
case 0: SetWatchName(row, strNewVal); break; | ||
case 1: SetWatchAddr(row, newVal); break; | ||
case 2: SetWatchValue(row, newVal); break; | ||
default: break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
void CWatchTable::UpdateWatch() | ||
{ | ||
for (int i = 0; i < num_watches; ++i) | ||
{ | ||
m_CachedWatchHasChanged[i] = (m_CachedWatch[i] != GetWatchValue(i)); | ||
m_CachedWatch[i] = GetWatchValue(i); | ||
} | ||
} | ||
|
||
wxGridCellAttr *CWatchTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind) | ||
{ | ||
wxGridCellAttr *attr = new wxGridCellAttr(); | ||
|
||
attr->SetBackgroundColour(*wxWHITE); | ||
attr->SetFont(DebuggerFont); | ||
|
||
switch (col) | ||
{ | ||
case 1: | ||
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER); | ||
break; | ||
case 3: | ||
case 4: | ||
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER); | ||
break; | ||
default: | ||
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER); | ||
break; | ||
} | ||
|
||
if (row == 0) | ||
{ | ||
attr->SetReadOnly(true); | ||
attr->SetBackgroundColour(*wxBLACK); | ||
attr->SetTextColour(*wxWHITE); | ||
} | ||
else | ||
{ | ||
bool red = false; | ||
switch (col) | ||
{ | ||
case 1: red = m_CachedWatchHasChanged[row]; break; | ||
} | ||
|
||
attr->SetTextColour(red ? *wxRED : *wxBLACK); | ||
|
||
if (row > (num_watches + 1)) | ||
{ | ||
attr->SetReadOnly(true); | ||
attr->SetBackgroundColour(*wxLIGHT_GREY); | ||
} | ||
} | ||
attr->IncRef(); | ||
return attr; | ||
} | ||
|
||
CWatchView::CWatchView(wxWindow *parent, wxWindowID id) | ||
: wxGrid(parent, id) | ||
{ | ||
SetTable(new CWatchTable(), true); | ||
SetRowLabelSize(0); | ||
SetColLabelSize(0); | ||
DisableDragRowSize(); | ||
|
||
if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) | ||
{ | ||
AutoSizeColumns(); | ||
} | ||
} | ||
|
||
void CWatchView::Update() | ||
{ | ||
if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) | ||
{ | ||
ForceRefresh(); | ||
((CWatchTable *)GetTable())->UpdateWatch(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2013 Dolphin Emulator Project | ||
// Licensed under GPLv2 | ||
// Refer to the license.txt file included. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <wx/defs.h> | ||
#include <wx/grid.h> | ||
#include <wx/string.h> | ||
#include <wx/windowid.h> | ||
|
||
#include "Common/CommonTypes.h" | ||
|
||
class wxWindow; | ||
|
||
class CWatchTable : public wxGridTableBase | ||
{ | ||
enum | ||
{ | ||
NUM_SPECIALS = 1, | ||
MAX_SPECIALS = 256, | ||
}; | ||
|
||
public: | ||
CWatchTable() | ||
{ | ||
memset(m_CachedWatch, 0, sizeof(m_CachedWatch)); | ||
memset(m_CachedWatchHasChanged, 0, sizeof(m_CachedWatchHasChanged)); | ||
} | ||
|
||
int GetNumberCols() override { return 5; } | ||
int GetNumberRows() override { return MAX_SPECIALS; } | ||
wxString GetValue(int row, int col) override; | ||
void SetValue(int row, int col, const wxString &) override; | ||
wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind) override; | ||
void UpdateWatch(); | ||
|
||
private: | ||
u32 m_CachedWatch[MAX_SPECIALS]; | ||
bool m_CachedWatchHasChanged[MAX_SPECIALS]; | ||
int num_watches = 0; | ||
|
||
DECLARE_NO_COPY_CLASS(CWatchTable); | ||
}; | ||
|
||
class CWatchView : public wxGrid | ||
{ | ||
public: | ||
CWatchView(wxWindow* parent, wxWindowID id); | ||
void Update() override; | ||
}; |
Oops, something went wrong.