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 <cmath>
|
|
|
|
#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"
|
2015-01-17 21:17:36 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
2014-08-05 03:46:37 +00:00
|
|
|
#include "DolphinWX/Globals.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/WxUtils.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"
|
|
|
|
#include "DolphinWX/Debugger/MemoryView.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Debugger/WatchWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IDM_GOTOINMEMVIEW = 12000,
|
|
|
|
IDM_COPYADDRESS,
|
|
|
|
IDM_COPYHEX,
|
|
|
|
IDM_COPYCODE,
|
|
|
|
IDM_RUNTOHERE,
|
|
|
|
IDM_DYNARECRESULTS,
|
2014-10-19 10:45:40 +00:00
|
|
|
IDM_WATCHADDRESS,
|
2009-06-17 19:50:59 +00:00
|
|
|
IDM_TOGGLEMEMORY,
|
2009-10-12 16:20:31 +00:00
|
|
|
IDM_VIEWASFP,
|
|
|
|
IDM_VIEWASASCII,
|
2009-11-25 10:07:56 +00:00
|
|
|
IDM_VIEWASHEX,
|
2008-12-08 05:30:24 +00:00
|
|
|
};
|
|
|
|
|
2011-02-24 05:05:25 +00:00
|
|
|
CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent)
|
2014-03-06 04:02:34 +00:00
|
|
|
: wxControl(parent, wxID_ANY)
|
2011-02-24 05:05:25 +00:00
|
|
|
, debugger(debuginterface)
|
2014-03-03 05:39:08 +00:00
|
|
|
, align(debuginterface->GetInstructionSize(0))
|
2011-02-24 05:05:25 +00:00
|
|
|
, rowHeight(13)
|
|
|
|
, selection(0)
|
|
|
|
, oldSelection(0)
|
|
|
|
, selecting(false)
|
|
|
|
, memory(0)
|
2015-07-09 11:47:51 +00:00
|
|
|
, curAddress(debuginterface->GetPC())
|
|
|
|
, dataType(MemoryDataType::U8)
|
2011-02-24 05:05:25 +00:00
|
|
|
, viewAsType(VIEWAS_FP)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2014-11-06 03:19:52 +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);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CMemoryView::YToAddress(int y)
|
|
|
|
{
|
|
|
|
wxRect rc = GetClientRect();
|
|
|
|
int ydiff = y - rc.height / 2 - rowHeight / 2;
|
|
|
|
ydiff = (int)(floorf((float)ydiff / (float)rowHeight)) + 1;
|
2011-02-24 05:05:25 +00:00
|
|
|
return curAddress + ydiff * align;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 16:20:31 +00:00
|
|
|
void CMemoryView::OnMouseDownL(wxMouseEvent& event)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
int x = event.m_x;
|
|
|
|
int y = event.m_y;
|
|
|
|
|
|
|
|
if (x > 16)
|
|
|
|
{
|
|
|
|
oldSelection = selection;
|
|
|
|
selection = YToAddress(y);
|
|
|
|
bool oldselecting = selecting;
|
|
|
|
selecting = true;
|
|
|
|
|
|
|
|
if (!oldselecting || (selection != oldSelection))
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-03 05:39:08 +00:00
|
|
|
debugger->ToggleMemCheck(YToAddress(y));
|
2009-09-27 21:28:09 +00:00
|
|
|
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2014-08-05 03:46:37 +00:00
|
|
|
|
|
|
|
// Propagate back to the parent window to update the breakpoint list.
|
2014-12-21 01:36:26 +00:00
|
|
|
wxCommandEvent evt(wxEVT_HOST_COMMAND, IDM_UPDATE_BREAKPOINTS);
|
2014-08-05 03:46:37 +00:00
|
|
|
GetEventHandler()->AddPendingEvent(evt);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 00:39:26 +00:00
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryView::OnMouseMove(wxMouseEvent& event)
|
|
|
|
{
|
|
|
|
wxRect rc = GetClientRect();
|
|
|
|
|
2011-02-24 05:05:25 +00:00
|
|
|
if (event.m_leftDown && event.m_x > 16)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-24 05:05:25 +00:00
|
|
|
if (event.m_y < 0)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-24 05:05:25 +00:00
|
|
|
curAddress -= align;
|
|
|
|
Refresh();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2011-02-24 05:05:25 +00:00
|
|
|
else if (event.m_y > rc.height)
|
|
|
|
{
|
|
|
|
curAddress += align;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OnMouseDownL(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 00:39:26 +00:00
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryView::OnMouseUpL(wxMouseEvent& event)
|
|
|
|
{
|
|
|
|
if (event.m_x > 16)
|
|
|
|
{
|
|
|
|
curAddress = YToAddress(event.m_y);
|
|
|
|
selecting = false;
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 00:39:26 +00:00
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-07-19 02:42:03 +00:00
|
|
|
void CMemoryView::OnScrollWheel(wxMouseEvent& event)
|
|
|
|
{
|
|
|
|
const bool scroll_down = (event.GetWheelRotation() < 0);
|
|
|
|
const int num_lines = event.GetLinesPerAction();
|
|
|
|
|
|
|
|
if (scroll_down)
|
|
|
|
{
|
2014-09-18 10:54:57 +00:00
|
|
|
curAddress += num_lines * 4;
|
2014-07-19 02:42:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-18 10:54:57 +00:00
|
|
|
curAddress -= num_lines * 4;
|
2014-07-19 02:42:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Refresh();
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CMemoryView::OnPopupMenu(wxCommandEvent& event)
|
|
|
|
{
|
2015-11-28 21:38:53 +00:00
|
|
|
CFrame* main_frame = static_cast<CFrame*>(GetGrandParent()->GetParent());
|
2014-10-23 13:47:00 +00:00
|
|
|
CCodeWindow* code_window = main_frame->g_pCodeWindow;
|
|
|
|
CWatchWindow* watch_window = code_window->m_WatchWindow;
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
#if wxUSE_CLIPBOARD
|
|
|
|
wxTheClipboard->Open();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
#if wxUSE_CLIPBOARD
|
2013-04-08 05:16:50 +00:00
|
|
|
case IDM_COPYADDRESS:
|
2014-05-17 17:17:28 +00:00
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format("%08x", selection)));
|
2013-04-08 05:16:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_COPYHEX:
|
|
|
|
{
|
2014-09-08 00:36:02 +00:00
|
|
|
std::string temp = StringFromFormat("%08x", debugger->ReadExtraMemory(memory, selection));
|
2013-04-08 05:16:50 +00:00
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp)));
|
|
|
|
}
|
|
|
|
break;
|
2009-10-12 16:20:31 +00:00
|
|
|
#endif
|
2009-10-12 16:24:24 +00:00
|
|
|
|
2014-10-19 10:45:40 +00:00
|
|
|
case IDM_WATCHADDRESS:
|
|
|
|
debugger->AddWatch(selection);
|
2014-10-23 13:47:00 +00:00
|
|
|
if (watch_window)
|
|
|
|
watch_window->NotifyUpdate();
|
2014-10-19 10:45:40 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
|
2009-10-12 16:24:24 +00:00
|
|
|
case IDM_TOGGLEMEMORY:
|
|
|
|
memory ^= 1;
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2009-10-12 16:24:24 +00:00
|
|
|
break;
|
|
|
|
|
2009-10-12 16:20:31 +00:00
|
|
|
case IDM_VIEWASFP:
|
|
|
|
viewAsType = VIEWAS_FP;
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2009-10-12 16:20:31 +00:00
|
|
|
break;
|
2009-06-17 19:50:59 +00:00
|
|
|
|
2009-10-12 16:20:31 +00:00
|
|
|
case IDM_VIEWASASCII:
|
|
|
|
viewAsType = VIEWAS_ASCII;
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2009-06-17 19:50:59 +00:00
|
|
|
break;
|
2009-11-25 10:07:56 +00:00
|
|
|
case IDM_VIEWASHEX:
|
|
|
|
viewAsType = VIEWAS_HEX;
|
2011-02-24 05:05:25 +00:00
|
|
|
Refresh();
|
2009-11-25 10:07:56 +00:00
|
|
|
break;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if wxUSE_CLIPBOARD
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
#endif
|
2014-07-11 00:39:26 +00:00
|
|
|
event.Skip();
|
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
|
|
|
{
|
|
|
|
// popup menu
|
2014-11-11 14:50:11 +00:00
|
|
|
wxMenu menu;
|
2014-05-17 17:17:28 +00:00
|
|
|
//menu.Append(IDM_GOTOINMEMVIEW, _("&Goto in mem view"));
|
2008-12-08 05:30:24 +00:00
|
|
|
#if wxUSE_CLIPBOARD
|
2014-11-11 14:50:11 +00:00
|
|
|
menu.Append(IDM_COPYADDRESS, _("Copy &address"));
|
|
|
|
menu.Append(IDM_COPYHEX, _("Copy &hex"));
|
2008-12-08 05:30:24 +00:00
|
|
|
#endif
|
2014-11-11 14:50:11 +00:00
|
|
|
menu.Append(IDM_WATCHADDRESS, _("Add to &watch"));
|
|
|
|
menu.Append(IDM_TOGGLEMEMORY, _("Toggle &memory"));
|
2009-10-12 16:20:31 +00:00
|
|
|
|
2014-11-14 01:10:36 +00:00
|
|
|
wxMenu* viewAsSubMenu = new wxMenu;
|
|
|
|
viewAsSubMenu->Append(IDM_VIEWASFP, _("FP value"));
|
|
|
|
viewAsSubMenu->Append(IDM_VIEWASASCII, "ASCII");
|
|
|
|
viewAsSubMenu->Append(IDM_VIEWASHEX, _("Hex"));
|
|
|
|
menu.AppendSubMenu(viewAsSubMenu, _("View As:"));
|
2009-10-12 16:20:31 +00:00
|
|
|
|
2014-11-11 14:50:11 +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
|
|
|
{
|
|
|
|
wxPaintDC dc(this);
|
|
|
|
wxRect rc = GetClientRect();
|
2014-05-17 17:17:28 +00:00
|
|
|
wxFont hFont("Courier");
|
2011-07-01 14:20:33 +00:00
|
|
|
hFont.SetFamily(wxFONTFAMILY_TELETYPE);
|
|
|
|
|
|
|
|
wxCoord w,h;
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &hFont);
|
2011-07-01 14:20:33 +00:00
|
|
|
if (h > rowHeight)
|
2013-04-08 05:16:50 +00:00
|
|
|
rowHeight = h;
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &DebuggerFont);
|
2011-07-01 14:20:33 +00:00
|
|
|
if (h > rowHeight)
|
2013-04-08 05:16:50 +00:00
|
|
|
rowHeight = h;
|
2011-07-01 14:20:33 +00:00
|
|
|
|
2010-02-18 12:06:13 +00:00
|
|
|
if (viewAsType==VIEWAS_HEX)
|
2009-11-25 10:07:56 +00:00
|
|
|
dc.SetFont(hFont);
|
2010-02-18 12:06:13 +00:00
|
|
|
else
|
|
|
|
dc.SetFont(DebuggerFont);
|
2011-02-24 05:05:25 +00:00
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.GetTextExtent("W", &w, &h);
|
2011-07-01 14:20:33 +00:00
|
|
|
int fontSize = w;
|
2011-07-01 18:32:18 +00:00
|
|
|
int textPlacement = 17 + 9 * fontSize;
|
2009-11-25 10:07:56 +00:00
|
|
|
|
|
|
|
// TODO: Add any drawing code here...
|
|
|
|
int width = rc.width;
|
|
|
|
int numRows = (rc.height / rowHeight) / 2 + 2;
|
|
|
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
2014-05-17 17:17:28 +00:00
|
|
|
const wxColour bgColor = *wxWHITE;
|
2009-11-25 10:07:56 +00:00
|
|
|
wxPen nullPen(bgColor);
|
2014-05-17 17:17:28 +00:00
|
|
|
wxPen currentPen(*wxBLACK_PEN);
|
|
|
|
wxPen selPen(*wxGREY_PEN);
|
2009-11-25 10:07:56 +00:00
|
|
|
nullPen.SetStyle(wxTRANSPARENT);
|
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxBrush currentBrush(*wxLIGHT_GREY_BRUSH);
|
|
|
|
wxBrush pcBrush(*wxGREEN_BRUSH);
|
|
|
|
wxBrush mcBrush(*wxBLUE_BRUSH);
|
2009-11-25 10:07:56 +00:00
|
|
|
wxBrush bgBrush(bgColor);
|
|
|
|
wxBrush nullBrush(bgColor);
|
|
|
|
nullBrush.SetStyle(wxTRANSPARENT);
|
|
|
|
|
|
|
|
dc.SetPen(nullPen);
|
|
|
|
dc.SetBrush(bgBrush);
|
|
|
|
dc.DrawRectangle(0, 0, 16, rc.height);
|
|
|
|
dc.DrawRectangle(0, 0, rc.width, 5+8);
|
|
|
|
|
2010-02-18 12:06:13 +00:00
|
|
|
// TODO - clean up this freaking mess!!!!!
|
2010-02-21 18:55:00 +00:00
|
|
|
for (int row = -numRows; row <= numRows; row++)
|
2009-11-25 10:07:56 +00:00
|
|
|
{
|
2010-02-21 18:55:00 +00:00
|
|
|
unsigned int address = curAddress + row * align;
|
2009-11-25 10:07:56 +00:00
|
|
|
|
2010-02-21 18:55:00 +00:00
|
|
|
int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2;
|
|
|
|
int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2;
|
2009-11-25 10:07:56 +00:00
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxString temp = wxString::Format("%08x", address);
|
2014-03-03 05:39:08 +00:00
|
|
|
u32 col = debugger->GetColor(address);
|
2014-05-17 17:17:28 +00:00
|
|
|
wxBrush rowBrush(wxColour(col >> 16, col >> 8, col));
|
2009-11-25 10:07:56 +00:00
|
|
|
dc.SetBrush(nullBrush);
|
|
|
|
dc.SetPen(nullPen);
|
|
|
|
dc.DrawRectangle(0, rowY1, 16, rowY2);
|
|
|
|
|
|
|
|
if (selecting && (address == selection))
|
|
|
|
dc.SetPen(selPen);
|
|
|
|
else
|
2010-02-21 18:55:00 +00:00
|
|
|
dc.SetPen(row == 0 ? currentPen : nullPen);
|
2009-11-25 10:07:56 +00:00
|
|
|
|
2014-03-03 05:39:08 +00:00
|
|
|
if (address == debugger->GetPC())
|
2009-11-25 10:07:56 +00:00
|
|
|
dc.SetBrush(pcBrush);
|
|
|
|
else
|
|
|
|
dc.SetBrush(rowBrush);
|
|
|
|
|
|
|
|
dc.DrawRectangle(16, rowY1, width, rowY2 - 1);
|
|
|
|
dc.SetBrush(currentBrush);
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.SetTextForeground("#600000"); // Dark red
|
2009-11-25 10:07:56 +00:00
|
|
|
dc.DrawText(temp, 17, rowY1);
|
2010-02-18 12:06:13 +00:00
|
|
|
|
|
|
|
if (viewAsType != VIEWAS_HEX)
|
|
|
|
{
|
|
|
|
char mem[256];
|
2014-03-03 05:39:08 +00:00
|
|
|
debugger->GetRawMemoryString(memory, address, mem, 256);
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.SetTextForeground(wxTheColourDatabase->Find("NAVY"));
|
2013-02-28 04:37:38 +00:00
|
|
|
dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1);
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.SetTextForeground(*wxBLACK);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
2010-02-18 12:06:13 +00:00
|
|
|
|
2015-01-17 21:17:36 +00:00
|
|
|
if (!PowerPC::HostIsRAMAddress(address))
|
2014-09-21 15:47:03 +00:00
|
|
|
continue;
|
|
|
|
|
2014-03-03 05:39:08 +00:00
|
|
|
if (debugger->IsAlive())
|
2009-11-25 10:07:56 +00:00
|
|
|
{
|
2014-09-08 00:36:02 +00:00
|
|
|
std::string dis;
|
2014-03-03 05:39:08 +00:00
|
|
|
u32 mem_data = debugger->ReadExtraMemory(memory, address);
|
2009-11-25 10:07:56 +00:00
|
|
|
|
|
|
|
if (viewAsType == VIEWAS_FP)
|
|
|
|
{
|
|
|
|
float flt = *(float *)(&mem_data);
|
2014-09-08 00:36:02 +00:00
|
|
|
dis = StringFromFormat("f: %f", flt);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
|
|
|
else if (viewAsType == VIEWAS_ASCII)
|
|
|
|
{
|
2014-09-08 00:36:02 +00:00
|
|
|
u32 a[4] = {
|
|
|
|
(mem_data & 0xff000000) >> 24,
|
|
|
|
(mem_data & 0xff0000) >> 16,
|
|
|
|
(mem_data & 0xff00) >> 8,
|
|
|
|
(mem_data & 0xff)
|
|
|
|
};
|
|
|
|
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& word : a)
|
2014-09-08 00:36:02 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
if (word == '\0')
|
|
|
|
word = ' ';
|
2014-09-08 00:36:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dis = StringFromFormat("%c%c%c%c", a[0], a[1], a[2], a[3]);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
2010-02-18 12:06:13 +00:00
|
|
|
else if (viewAsType == VIEWAS_HEX)
|
|
|
|
{
|
|
|
|
u32 mema[8] = {
|
2014-03-03 05:39:08 +00:00
|
|
|
debugger->ReadExtraMemory(memory, address),
|
|
|
|
debugger->ReadExtraMemory(memory, address+4),
|
|
|
|
debugger->ReadExtraMemory(memory, address+8),
|
|
|
|
debugger->ReadExtraMemory(memory, address+12),
|
|
|
|
debugger->ReadExtraMemory(memory, address+16),
|
|
|
|
debugger->ReadExtraMemory(memory, address+20),
|
|
|
|
debugger->ReadExtraMemory(memory, address+24),
|
|
|
|
debugger->ReadExtraMemory(memory, address+28)
|
2010-02-18 12:06:13 +00:00
|
|
|
};
|
|
|
|
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& word : mema)
|
2010-02-18 12:06:13 +00:00
|
|
|
{
|
|
|
|
switch (dataType)
|
|
|
|
{
|
2015-07-09 11:47:51 +00:00
|
|
|
case MemoryDataType::U8:
|
2014-09-08 00:36:02 +00:00
|
|
|
dis += StringFromFormat(" %02X %02X %02X %02X",
|
|
|
|
((word & 0xff000000) >> 24) & 0xFF,
|
|
|
|
((word & 0xff0000) >> 16) & 0xFF,
|
|
|
|
((word & 0xff00) >> 8) & 0xFF,
|
|
|
|
word & 0xff);
|
2010-02-18 12:06:13 +00:00
|
|
|
break;
|
2015-07-09 11:47:51 +00:00
|
|
|
case MemoryDataType::U16:
|
2014-09-08 00:36:02 +00:00
|
|
|
dis += StringFromFormat(" %02X%02X %02X%02X",
|
|
|
|
((word & 0xff000000) >> 24) & 0xFF,
|
|
|
|
((word & 0xff0000) >> 16) & 0xFF,
|
|
|
|
((word & 0xff00) >> 8) & 0xFF,
|
|
|
|
word & 0xff);
|
2010-02-18 12:06:13 +00:00
|
|
|
break;
|
2015-07-09 11:47:51 +00:00
|
|
|
case MemoryDataType::U32:
|
2014-09-08 00:36:02 +00:00
|
|
|
dis += StringFromFormat(" %02X%02X%02X%02X",
|
|
|
|
((word & 0xff000000) >> 24) & 0xFF,
|
|
|
|
((word & 0xff0000) >> 16) & 0xFF,
|
|
|
|
((word & 0xff00) >> 8) & 0xFF,
|
|
|
|
word & 0xff);
|
2010-02-18 12:06:13 +00:00
|
|
|
break;
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2014-09-08 00:36:02 +00:00
|
|
|
dis = "INVALID VIEWAS TYPE";
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-02-18 12:06:13 +00:00
|
|
|
if (viewAsType != VIEWAS_HEX)
|
2013-02-28 04:37:38 +00:00
|
|
|
dc.DrawText(StrToWxStr(dis), textPlacement + fontSize*(8 + 8), rowY1);
|
2011-02-24 05:05:25 +00:00
|
|
|
else
|
2013-02-28 04:37:38 +00:00
|
|
|
dc.DrawText(StrToWxStr(dis), textPlacement, rowY1);
|
2011-02-24 05:05:25 +00:00
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
dc.SetTextForeground(*wxBLUE);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-09-08 00:36:02 +00:00
|
|
|
std::string desc = debugger->GetDescription(address);
|
|
|
|
if (!desc.empty())
|
2013-02-28 04:37:38 +00:00
|
|
|
dc.DrawText(StrToWxStr(desc), 17+fontSize*((8+8+8+30)*2), rowY1);
|
2009-09-27 21:28:09 +00:00
|
|
|
|
|
|
|
// Show blue memory check dot
|
2014-03-03 05:39:08 +00:00
|
|
|
if (debugger->IsMemCheck(address))
|
2009-09-27 21:28:09 +00:00
|
|
|
{
|
|
|
|
dc.SetBrush(mcBrush);
|
2010-02-18 12:06:13 +00:00
|
|
|
dc.DrawRectangle(8, rowY1 + 1, 11, 11);
|
2009-09-27 21:28:09 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dc.SetPen(currentPen);
|
|
|
|
}
|
2011-02-24 05:05:25 +00:00
|
|
|
|
|
|
|
void CMemoryView::OnResize(wxSizeEvent& event)
|
|
|
|
{
|
|
|
|
Refresh();
|
|
|
|
event.Skip();
|
|
|
|
}
|