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
|
|
|
|
2017-01-15 17:16:36 +00:00
|
|
|
#include "DolphinWX/Debugger/MemoryView.h"
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cctype>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cmath>
|
2017-01-15 17:16:36 +00:00
|
|
|
#include <cstring>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <string>
|
|
|
|
#include <wx/brush.h>
|
2008-12-08 05:30:24 +00:00
|
|
|
#include <wx/clipbrd.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/colour.h>
|
|
|
|
#include <wx/control.h>
|
|
|
|
#include <wx/dataobj.h>
|
|
|
|
#include <wx/dcclient.h>
|
|
|
|
#include <wx/font.h>
|
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <wx/pen.h>
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/DebugInterface.h"
|
2014-09-08 00:36:02 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2016-10-03 07:29:50 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
2016-09-06 14:19:40 +00:00
|
|
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
2015-01-17 21:17:36 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Debugger/WatchWindow.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
2016-10-03 07:29:50 +00:00
|
|
|
#include "DolphinWX/Main.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
enum
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IDM_GOTOINMEMVIEW = 12000,
|
|
|
|
IDM_COPYADDRESS,
|
|
|
|
IDM_COPYHEX,
|
|
|
|
IDM_COPYCODE,
|
|
|
|
IDM_RUNTOHERE,
|
|
|
|
IDM_DYNARECRESULTS,
|
|
|
|
IDM_WATCHADDRESS,
|
|
|
|
IDM_TOGGLEMEMORY,
|
|
|
|
IDM_VIEWASFP,
|
|
|
|
IDM_VIEWASASCII,
|
|
|
|
IDM_VIEWASHEX,
|
2008-12-08 05:30:24 +00:00
|
|
|
};
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
wxDEFINE_EVENT(DOLPHIN_EVT_MEMORY_VIEW_DATA_TYPE_CHANGED, wxCommandEvent);
|
|
|
|
|
2011-02-24 05:05:25 +00:00
|
|
|
CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent)
|
2016-10-03 07:29:50 +00:00
|
|
|
: wxControl(parent, wxID_ANY), debugger(debuginterface), align(0), rowHeight(FromDIP(13)),
|
|
|
|
m_left_col_width(FromDIP(LEFT_COL_WIDTH)), selection(0), oldSelection(0), selecting(false),
|
|
|
|
memory(0), curAddress(debuginterface->GetPC()), m_data_type(MemoryDataType::U8)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_PAINT, &CMemoryView::OnPaint, this);
|
|
|
|
Bind(wxEVT_LEFT_DOWN, &CMemoryView::OnMouseDownL, this);
|
|
|
|
Bind(wxEVT_LEFT_UP, &CMemoryView::OnMouseUpL, this);
|
|
|
|
Bind(wxEVT_MOTION, &CMemoryView::OnMouseMove, this);
|
|
|
|
Bind(wxEVT_RIGHT_DOWN, &CMemoryView::OnMouseDownR, this);
|
|
|
|
Bind(wxEVT_MOUSEWHEEL, &CMemoryView::OnScrollWheel, this);
|
|
|
|
Bind(wxEVT_MENU, &CMemoryView::OnPopupMenu, this);
|
|
|
|
Bind(wxEVT_SIZE, &CMemoryView::OnResize, this);
|
2016-10-03 07:29:50 +00:00
|
|
|
|
|
|
|
SetDataType(MemoryDataType::FloatingPoint);
|
|
|
|
|
|
|
|
// Every pixel will be drawn over in the paint event so erasing will just cause flickering.
|
|
|
|
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
|
|
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
|
|
|
SetDoubleBuffered(true);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryView::SetDataType(MemoryDataType data_type)
|
|
|
|
{
|
|
|
|
if (m_data_type == data_type)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_data_type = data_type;
|
|
|
|
switch (data_type)
|
|
|
|
{
|
|
|
|
case MemoryDataType::FloatingPoint:
|
|
|
|
case MemoryDataType::ASCII:
|
|
|
|
align = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
align = 16;
|
|
|
|
m_last_hex_type = data_type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Refresh();
|
|
|
|
|
|
|
|
wxCommandEvent ev(DOLPHIN_EVT_MEMORY_VIEW_DATA_TYPE_CHANGED, GetId());
|
|
|
|
ev.SetInt(static_cast<int>(data_type));
|
|
|
|
GetEventHandler()->ProcessEvent(ev);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CMemoryView::YToAddress(int y)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxRect rc = GetClientRect();
|
|
|
|
int ydiff = y - rc.height / 2 - rowHeight / 2;
|
|
|
|
ydiff = (int)(floorf((float)ydiff / (float)rowHeight)) + 1;
|
|
|
|
return curAddress + ydiff * align;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2017-01-15 17:12:10 +00:00
|
|
|
wxString CMemoryView::ReadMemoryAsString(u32 address) const
|
|
|
|
{
|
|
|
|
std::string str;
|
|
|
|
|
|
|
|
// FIXME: This doesn't work with the DSP Debugger
|
|
|
|
u32 mem_data = debugger->ReadExtraMemory(memory, address);
|
|
|
|
|
|
|
|
if (m_data_type == MemoryDataType::FloatingPoint)
|
|
|
|
{
|
2017-01-15 17:16:36 +00:00
|
|
|
float real;
|
|
|
|
std::memcpy(&real, &mem_data, sizeof(u32));
|
|
|
|
str = StringFromFormat("f: %f", real);
|
2017-01-15 17:12:10 +00:00
|
|
|
}
|
|
|
|
else if (m_data_type == MemoryDataType::ASCII)
|
|
|
|
{
|
|
|
|
str.reserve(4);
|
|
|
|
for (unsigned int i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
u8 byte = static_cast<u8>(mem_data >> (24 - i * 8));
|
|
|
|
if (std::isprint(byte))
|
|
|
|
str += static_cast<char>(byte);
|
|
|
|
else
|
|
|
|
str += ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* sym = g_symbolDB.GetSymbolFromAddr(mem_data);
|
|
|
|
if (sym)
|
|
|
|
{
|
|
|
|
str += StringFromFormat(" # -> %s", sym->name.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str.reserve(48);
|
|
|
|
for (unsigned int i = 0; i < align; i += sizeof(u32))
|
|
|
|
{
|
|
|
|
if (!PowerPC::HostIsRAMAddress(address + i))
|
|
|
|
break;
|
|
|
|
u32 word = debugger->ReadExtraMemory(memory, address + i);
|
|
|
|
switch (m_data_type)
|
|
|
|
{
|
|
|
|
case MemoryDataType::U8:
|
|
|
|
default:
|
|
|
|
str += StringFromFormat(" %02X %02X %02X %02X", (word >> 24) & 0xFF, (word >> 16) & 0xFF,
|
|
|
|
(word >> 8) & 0xFF, word & 0xFF);
|
|
|
|
break;
|
|
|
|
case MemoryDataType::U16:
|
|
|
|
str += StringFromFormat(" %04X %04X", (word >> 16) & 0xFFFF, word & 0xFFFF);
|
|
|
|
break;
|
|
|
|
case MemoryDataType::U32:
|
|
|
|
str += StringFromFormat(" %08X", word);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return StrToWxStr(str);
|
|
|
|
}
|
|
|
|
|
2009-10-12 16:20:31 +00:00
|
|
|
void CMemoryView::OnMouseDownL(wxMouseEvent& event)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
int x = event.GetX();
|
|
|
|
int y = event.GetY();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
if (x > m_left_col_width)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
oldSelection = selection;
|
|
|
|
selection = YToAddress(y);
|
|
|
|
bool oldselecting = selecting;
|
|
|
|
selecting = true;
|
|
|
|
|
|
|
|
if (!oldselecting || (selection != oldSelection))
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-18 20:08:26 +00:00
|
|
|
debugger->ToggleMemCheck(YToAddress(y), memCheckRead, memCheckWrite, memCheckLog);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
|
|
// Propagate back to the parent window to update the breakpoint list.
|
|
|
|
wxCommandEvent evt(wxEVT_HOST_COMMAND, IDM_UPDATE_BREAKPOINTS);
|
|
|
|
GetEventHandler()->AddPendingEvent(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryView::OnMouseMove(wxMouseEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxRect rc = GetClientRect();
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
if (event.m_leftDown && event.m_x > m_left_col_width)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
if (event.m_y < 0)
|
|
|
|
{
|
|
|
|
curAddress -= align;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
else if (event.m_y > rc.height)
|
|
|
|
{
|
|
|
|
curAddress += align;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OnMouseDownL(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryView::OnMouseUpL(wxMouseEvent& event)
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
if (event.m_x > m_left_col_width)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
curAddress = YToAddress(event.m_y);
|
|
|
|
selecting = false;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-07-19 02:42:03 +00:00
|
|
|
void CMemoryView::OnScrollWheel(wxMouseEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
const bool scroll_down = (event.GetWheelRotation() < 0);
|
|
|
|
const int num_lines = event.GetLinesPerAction();
|
|
|
|
|
|
|
|
if (scroll_down)
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
curAddress += num_lines * align;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
curAddress -= num_lines * align;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Refresh();
|
|
|
|
event.Skip();
|
2014-07-19 02:42:03 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CMemoryView::OnPopupMenu(wxCommandEvent& event)
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
// FIXME: This is terrible. Generate events instead.
|
|
|
|
CFrame* cframe = wxGetApp().GetCFrame();
|
|
|
|
CCodeWindow* code_window = cframe->g_pCodeWindow;
|
|
|
|
CWatchWindow* watch_window = code_window->GetPanel<CWatchWindow>();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-12-08 05:30:24 +00:00
|
|
|
#if wxUSE_CLIPBOARD
|
2016-06-24 08:43:46 +00:00
|
|
|
case IDM_COPYADDRESS:
|
2016-10-03 07:29:50 +00:00
|
|
|
{
|
|
|
|
wxClipboardLocker clipboard_lock;
|
2016-06-24 08:43:46 +00:00
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format("%08x", selection)));
|
2016-10-03 07:29:50 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
case IDM_COPYHEX:
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
wxClipboardLocker clipboard_lock;
|
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(
|
|
|
|
wxString::Format("%08x", debugger->ReadExtraMemory(memory, selection))));
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-12 16:20:31 +00:00
|
|
|
#endif
|
2009-10-12 16:24:24 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
case IDM_WATCHADDRESS:
|
|
|
|
debugger->AddWatch(selection);
|
|
|
|
if (watch_window)
|
|
|
|
watch_window->NotifyUpdate();
|
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_TOGGLEMEMORY:
|
|
|
|
memory ^= 1;
|
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEWASFP:
|
2016-10-03 07:29:50 +00:00
|
|
|
SetDataType(MemoryDataType::FloatingPoint);
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEWASASCII:
|
2016-10-03 07:29:50 +00:00
|
|
|
SetDataType(MemoryDataType::ASCII);
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
2016-10-03 07:29:50 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
case IDM_VIEWASHEX:
|
2016-10-03 07:29:50 +00:00
|
|
|
SetDataType(m_last_hex_type);
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
default:
|
|
|
|
event.Skip();
|
|
|
|
break;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 16:20:31 +00:00
|
|
|
void CMemoryView::OnMouseDownR(wxMouseEvent& event)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// popup menu
|
|
|
|
wxMenu menu;
|
|
|
|
// menu.Append(IDM_GOTOINMEMVIEW, _("&Goto in mem view"));
|
2008-12-08 05:30:24 +00:00
|
|
|
#if wxUSE_CLIPBOARD
|
2016-06-24 08:43:46 +00:00
|
|
|
menu.Append(IDM_COPYADDRESS, _("Copy &address"));
|
|
|
|
menu.Append(IDM_COPYHEX, _("Copy &hex"));
|
2008-12-08 05:30:24 +00:00
|
|
|
#endif
|
2016-10-31 14:06:27 +00:00
|
|
|
// i18n: This kind of "watch" is used for watching emulated memory.
|
|
|
|
// It's not related to timekeeping devices.
|
2016-06-24 08:43:46 +00:00
|
|
|
menu.Append(IDM_WATCHADDRESS, _("Add to &watch"));
|
2016-10-03 07:29:50 +00:00
|
|
|
menu.AppendCheckItem(IDM_TOGGLEMEMORY, _("Toggle &memory"))->Check(memory != 0);
|
2009-10-12 16:20:31 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
wxMenu* viewAsSubMenu = new wxMenu;
|
2016-10-03 07:29:50 +00:00
|
|
|
viewAsSubMenu->AppendRadioItem(IDM_VIEWASFP, _("FP value"))
|
|
|
|
->Check(m_data_type == MemoryDataType::FloatingPoint);
|
|
|
|
viewAsSubMenu->AppendRadioItem(IDM_VIEWASASCII, "ASCII")
|
|
|
|
->Check(m_data_type == MemoryDataType::ASCII);
|
|
|
|
viewAsSubMenu->AppendRadioItem(IDM_VIEWASHEX, _("Hex"))->Check(IsHexMode());
|
2016-06-24 08:43:46 +00:00
|
|
|
menu.AppendSubMenu(viewAsSubMenu, _("View As:"));
|
2009-10-12 16:20:31 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
PopupMenu(&menu);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryView::OnPaint(wxPaintEvent& event)
|
2009-11-25 10:07:56 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxPaintDC dc(this);
|
|
|
|
wxRect rc = GetClientRect();
|
2016-10-03 07:29:50 +00:00
|
|
|
|
2016-10-04 08:17:46 +00:00
|
|
|
dc.SetFont(DebuggerFont);
|
2016-10-03 07:29:50 +00:00
|
|
|
|
|
|
|
int font_width;
|
|
|
|
{
|
|
|
|
wxFontMetrics metrics = dc.GetFontMetrics();
|
|
|
|
font_width = metrics.averageWidth;
|
2016-10-04 08:17:46 +00:00
|
|
|
rowHeight = std::max(rowHeight, metrics.height);
|
|
|
|
if (!DebuggerFont.IsFixedWidth())
|
|
|
|
font_width = dc.GetTextExtent("mxx").GetWidth() / 3; // (1em + 2ex) / 3
|
2016-10-03 07:29:50 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
const int row_start_x = m_left_col_width + 1;
|
|
|
|
const int mchk_x = FromDIP(LEFT_COL_WIDTH / 8);
|
|
|
|
const wxSize mchk_size = FromDIP(wxSize(LEFT_COL_WIDTH * 3 / 4, LEFT_COL_WIDTH * 3 / 4));
|
|
|
|
const int mchk_offset_y = (rowHeight - mchk_size.GetHeight()) / 2;
|
|
|
|
|
|
|
|
int col_width = rc.width - m_left_col_width;
|
|
|
|
int num_rows = (rc.height / rowHeight) / 2 + 2;
|
|
|
|
const wxColour navy_color = wxTheColourDatabase->Find("NAVY");
|
|
|
|
|
|
|
|
const int pen_width = FromDIP(1);
|
|
|
|
wxPen focus_pen(*wxBLACK, pen_width);
|
|
|
|
wxPen selection_pen(*wxLIGHT_GREY, pen_width);
|
|
|
|
wxBrush pc_brush(*wxGREEN_BRUSH);
|
|
|
|
wxBrush mc_brush(*wxBLUE_BRUSH);
|
|
|
|
wxBrush bg_brush(*wxWHITE_BRUSH);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
// TODO - clean up this freaking mess!!!!!
|
2016-10-03 07:29:50 +00:00
|
|
|
for (int row = -num_rows; row <= num_rows; ++row)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
u32 address = curAddress + row * align;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
int row_y = rc.height / 2 + rowHeight * row - rowHeight / 2;
|
|
|
|
int row_x = row_start_x;
|
|
|
|
|
|
|
|
auto draw_text = [&](const wxString& s, int offset_chars = 0, int min_length = 0) -> void {
|
|
|
|
dc.DrawText(s, row_x + font_width * offset_chars, row_y);
|
|
|
|
row_x += font_width * (std::max(static_cast<int>(s.size()), min_length) + offset_chars);
|
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
wxString temp = wxString::Format("%08x", address);
|
|
|
|
u32 col = debugger->GetColor(address);
|
|
|
|
wxBrush rowBrush(wxColour(col >> 16, col >> 8, col));
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetBrush(bg_brush);
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.DrawRectangle(0, row_y, m_left_col_width, rowHeight);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (selecting && (address == selection))
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetPen(selection_pen);
|
2016-06-24 08:43:46 +00:00
|
|
|
else
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetPen(row == 0 ? focus_pen : *wxTRANSPARENT_PEN);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (address == debugger->GetPC())
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetBrush(pc_brush);
|
2016-06-24 08:43:46 +00:00
|
|
|
else
|
|
|
|
dc.SetBrush(rowBrush);
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.DrawRectangle(m_left_col_width, row_y, col_width, rowHeight);
|
|
|
|
dc.SetTextForeground(wxColour(0x60, 0x00, 0x00)); // Dark red
|
|
|
|
draw_text(temp);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
if (!IsHexMode())
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-07 13:56:02 +00:00
|
|
|
const std::string mem = debugger->GetRawMemoryString(memory, address);
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetTextForeground(navy_color);
|
|
|
|
draw_text(StrToWxStr(mem), 2);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetTextForeground(*wxBLACK);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
// NOTE: We can trigger a segfault inside HostIsRAMAddress (nullptr) during shutdown
|
|
|
|
// because we still get paint events even though the core is being deleted so we
|
|
|
|
// need to make sure the Memory still exists.
|
|
|
|
// FIXME: This isn't relevant to the DSP Memory View
|
|
|
|
if (!debugger->IsAlive() || !Memory::IsInitialized() || !PowerPC::HostIsRAMAddress(address))
|
|
|
|
continue;
|
2016-10-03 21:45:02 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
// Pad to a minimum of 48 characters for full fixed point float width
|
2017-01-15 17:12:10 +00:00
|
|
|
draw_text(ReadMemoryAsString(address), 2, 48);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
dc.SetTextForeground(*wxBLUE);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
std::string desc = debugger->GetDescription(address);
|
|
|
|
if (!desc.empty())
|
|
|
|
draw_text(StrToWxStr(desc), 2);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
// Show blue memory check dot
|
|
|
|
if (debugger->IsMemCheck(address))
|
|
|
|
{
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.SetBrush(mc_brush);
|
|
|
|
dc.DrawEllipse(mchk_x, row_y + mchk_offset_y, mchk_size.GetWidth(), mchk_size.GetHeight());
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2011-02-24 05:05:25 +00:00
|
|
|
|
|
|
|
void CMemoryView::OnResize(wxSizeEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
Refresh();
|
|
|
|
event.Skip();
|
2011-02-24 05:05:25 +00:00
|
|
|
}
|