debugger: memory view improvements

Highlight memory location referenced by current register
Allow memory window not be aligned by row size
Use radio and checks in menu
This commit is contained in:
Vladimir Jigulin 2016-11-16 15:49:28 +03:00 committed by Gregory Hainaut
parent dc85989553
commit 268b4d9f9f
6 changed files with 63 additions and 19 deletions

View File

@ -58,6 +58,7 @@ enum MemoryViewMenuIdentifiers
ID_MEMVIEW_COPYVALUE_64,
ID_MEMVIEW_COPYVALUE_128,
ID_MEMVIEW_DUMP,
ID_MEMVIEW_ALIGNWINDOW,
};
CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu)
@ -73,8 +74,9 @@ CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu)
selectedNibble = 0;
addressStart = charWidth;
hexStart = addressStart + 9*charWidth;
alignWindowStart = true;
setRowSize(16);
setRowSize(32);
font = pxGetFixedFont(8);
underlineFont = pxGetFixedFont(8, wxFONTWEIGHT_NORMAL, true);
@ -85,11 +87,12 @@ CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu)
menu.Append(ID_MEMVIEW_COPYADDRESS, L"Copy address");
menu.Append(ID_MEMVIEW_FOLLOWADDRESS, L"Follow address");
menu.AppendSeparator();
menu.Append(ID_MEMVIEW_DISPLAYVALUE_8, L"Display as 1 byte");
menu.Append(ID_MEMVIEW_DISPLAYVALUE_16, L"Display as 2 byte");
menu.Append(ID_MEMVIEW_DISPLAYVALUE_32, L"Display as 4 byte");
menu.Append(ID_MEMVIEW_DISPLAYVALUE_64, L"Display as 8 byte");
menu.Append(ID_MEMVIEW_DISPLAYVALUE_128, L"Display as 16 byte");
menu.AppendRadioItem(ID_MEMVIEW_DISPLAYVALUE_8, L"Display as 1 byte");
menu.AppendRadioItem(ID_MEMVIEW_DISPLAYVALUE_16, L"Display as 2 byte");
menu.AppendRadioItem(ID_MEMVIEW_DISPLAYVALUE_32, L"Display as 4 byte");
menu.AppendRadioItem(ID_MEMVIEW_DISPLAYVALUE_64, L"Display as 8 byte");
menu.AppendRadioItem(ID_MEMVIEW_DISPLAYVALUE_128, L"Display as 16 byte");
menu.Check(ID_MEMVIEW_DISPLAYVALUE_8, true);
menu.AppendSeparator();
menu.Append(ID_MEMVIEW_COPYVALUE_8, L"Copy Value (8 bit)");
menu.Append(ID_MEMVIEW_COPYVALUE_16, L"Copy Value (16 bit)");
@ -98,6 +101,9 @@ CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu)
menu.Append(ID_MEMVIEW_COPYVALUE_128, L"Copy Value (128 bit)");
menu.Append(ID_MEMVIEW_DUMP, L"Dump...");
menu.Enable(ID_MEMVIEW_DUMP,false);
menu.AppendSeparator();
menu.AppendCheckItem(ID_MEMVIEW_ALIGNWINDOW, L"Align window to row size");
menu.Check(ID_MEMVIEW_ALIGNWINDOW, alignWindowStart);
menu.Bind(wxEVT_MENU, &CtrlMemView::onPopupClick, this);
SetScrollbar(wxVERTICAL,100,1,201,true);
@ -164,6 +170,7 @@ void CtrlMemView::render(wxDC& dc)
const wxColor COLOR_BLACK = wxColor(0xFF000000);
const wxColor COLOR_SELECTED_BG = wxColor(0xFFFF9933);
const wxColor COLOR_SELECTED_INACTIVE_BG = wxColor(0xFFC0C0C0);
const wxColor COLOR_REFRENCE_BG = wxColor(0xFFFFCFC8);
const wxColor COLOR_ADDRESS = wxColor(0xFF600000);
const wxColor COLOR_DELIMETER = wxColor(0xFFC0C0C0);
@ -221,6 +228,7 @@ void CtrlMemView::render(wxDC& dc)
u32 groupAddress = byteAddress - groupIndex;
bool backgroundIsDark = false;
if (curAddress >= groupAddress && curAddress < groupAddress + byteGroupSize)
{
// if group selected, draw rectangle behind
@ -237,12 +245,17 @@ void CtrlMemView::render(wxDC& dc)
dc.DrawRectangle(groupPosX, rowY, groupWidth, rowHeight);
}
dc.SetTextForeground((hasFocus && !asciiSelected) ? COLOR_WHITE : COLOR_BLACK);
backgroundIsDark = hasFocus && !asciiSelected;
}
else {
dc.SetTextForeground(COLOR_BLACK);
if (groupAddress + groupIndex == referencedAddress) {
dc.SetPen(COLOR_REFRENCE_BG);
dc.SetBrush(COLOR_REFRENCE_BG);
dc.DrawRectangle(symbolPosX, rowY, charWidth*2, rowHeight);
backgroundIsDark = false;
}
dc.SetTextForeground(backgroundIsDark ? COLOR_WHITE : COLOR_BLACK);
swprintf(temp, TEMP_SIZE, byteValid ? L"%02X" : L"??", byteCurrent);
// if selected byte, need hint current nibble
if (byteAddress == curAddress) {
@ -383,6 +396,12 @@ void CtrlMemView::onPopupClick(wxCommandEvent& evt)
wxTheClipboard->Close();
}
break;
case ID_MEMVIEW_ALIGNWINDOW:
if (alignWindowStart = evt.IsChecked()) {
windowStart -= windowStart % rowSize;
redraw();
}
break;
}
}
@ -401,17 +420,19 @@ void CtrlMemView::mouseEvent(wxMouseEvent& evt)
menu.Enable(ID_MEMVIEW_FOLLOWADDRESS, (curAddress & 3) == 0);
menu.Enable(ID_MEMVIEW_DISPLAYVALUE_8, byteGroupSize != 1);
menu.Enable(ID_MEMVIEW_DISPLAYVALUE_16, byteGroupSize != 2);
menu.Enable(ID_MEMVIEW_DISPLAYVALUE_32, byteGroupSize != 4);
menu.Enable(ID_MEMVIEW_DISPLAYVALUE_64, byteGroupSize != 8);
menu.Enable(ID_MEMVIEW_DISPLAYVALUE_128, byteGroupSize != 16);
menu.Check(ID_MEMVIEW_DISPLAYVALUE_8, byteGroupSize == 1);
menu.Check(ID_MEMVIEW_DISPLAYVALUE_16, byteGroupSize == 2);
menu.Check(ID_MEMVIEW_DISPLAYVALUE_32, byteGroupSize == 4);
menu.Check(ID_MEMVIEW_DISPLAYVALUE_64, byteGroupSize == 8);
menu.Check(ID_MEMVIEW_DISPLAYVALUE_128, byteGroupSize == 16);
menu.Enable(ID_MEMVIEW_COPYVALUE_128,(curAddress & 15) == 0);
menu.Enable(ID_MEMVIEW_COPYVALUE_64,(curAddress & 7) == 0);
menu.Enable(ID_MEMVIEW_COPYVALUE_32,(curAddress & 3) == 0);
menu.Enable(ID_MEMVIEW_COPYVALUE_16,(curAddress & 1) == 0);
menu.Check(ID_MEMVIEW_ALIGNWINDOW, alignWindowStart);
PopupMenu(&menu);
return;
} else if (evt.GetEventType() == wxEVT_MOUSEWHEEL)
@ -638,11 +659,15 @@ void CtrlMemView::gotoAddress(u32 addr, bool pushInHistory)
curAddress = addr;
selectedNibble = 0;
int visibleRows = GetClientSize().y/rowHeight;
u32 windowEnd = windowStart+visibleRows*rowSize;
if (alignWindowStart) {
int visibleRows = GetClientSize().y / rowHeight;
u32 windowEnd = windowStart + visibleRows*rowSize;
if (curAddress < windowStart || curAddress >= windowEnd)
windowStart = (curAddress / rowSize) * rowSize;
if (curAddress < windowStart || curAddress >= windowEnd)
windowStart = (curAddress / rowSize) * rowSize;
} else {
windowStart = curAddress;
}
updateStatusBarText();
redraw();
@ -699,3 +724,8 @@ void CtrlMemView::gotoPoint(int x, int y)
redraw();
}
}
void CtrlMemView::updateReference(u32 address) {
referencedAddress = address;
redraw();
}

View File

@ -31,6 +31,7 @@ public:
void charEvent(wxKeyEvent& evt);
void redraw();
void gotoAddress(u32 address, bool pushInHistory = false);
void updateReference(u32 address);
DECLARE_EVENT_TABLE()
private:
@ -50,7 +51,9 @@ private:
int rowHeight;
int charWidth;
u32 windowStart;
u32 curAddress;
bool alignWindowStart;
u32 curAddress; // current selected address
u32 referencedAddress; // refrenced by register
u32 byteGroupSize;
int rowSize;
wxFont font,underlineFont;

View File

@ -480,6 +480,8 @@ void CtrlRegisterList::setCurrentRow(int row)
{
case DebugInterface::NORMAL:
value = cpu->getRegister(category,row);
postEvent(debEVT_REFERENCEMEMORYVIEW, value._u32[0]);
switch (cpu->getRegisterSize(category))
{
case 128:

View File

@ -19,6 +19,7 @@
wxDEFINE_EVENT(debEVT_SETSTATUSBARTEXT, wxCommandEvent);
wxDEFINE_EVENT(debEVT_UPDATELAYOUT, wxCommandEvent);
wxDEFINE_EVENT(debEVT_GOTOINMEMORYVIEW, wxCommandEvent);
wxDEFINE_EVENT(debEVT_REFERENCEMEMORYVIEW, wxCommandEvent);
wxDEFINE_EVENT(debEVT_GOTOINDISASM, wxCommandEvent);
wxDEFINE_EVENT(debEVT_RUNTOPOS, wxCommandEvent);
wxDEFINE_EVENT(debEVT_MAPLOADED, wxCommandEvent);

View File

@ -20,6 +20,7 @@
wxDECLARE_EVENT(debEVT_SETSTATUSBARTEXT, wxCommandEvent);
wxDECLARE_EVENT(debEVT_UPDATELAYOUT, wxCommandEvent);
wxDECLARE_EVENT(debEVT_GOTOINMEMORYVIEW, wxCommandEvent);
wxDECLARE_EVENT(debEVT_REFERENCEMEMORYVIEW, wxCommandEvent);
wxDECLARE_EVENT(debEVT_GOTOINDISASM, wxCommandEvent);
wxDECLARE_EVENT(debEVT_RUNTOPOS, wxCommandEvent);
wxDECLARE_EVENT(debEVT_MAPLOADED, wxCommandEvent);

View File

@ -31,6 +31,7 @@ BEGIN_EVENT_TABLE(DisassemblyDialog, wxFrame)
EVT_COMMAND( wxID_ANY, debEVT_SETSTATUSBARTEXT, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_UPDATELAYOUT, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_GOTOINMEMORYVIEW, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_REFERENCEMEMORYVIEW, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_RUNTOPOS, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_GOTOINDISASM, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_STEPOVER, DisassemblyDialog::onDebuggerEvent )
@ -505,6 +506,12 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt)
currentCpu->getMemoryView()->gotoAddress(evt.GetInt(), true);
currentCpu->getDisassembly()->SetFocus();
}
} else if (type == debEVT_REFERENCEMEMORYVIEW)
{
if (currentCpu != NULL)
{
currentCpu->getMemoryView()->updateReference(evt.GetInt());
}
} else if (type == debEVT_RUNTOPOS)
{
// todo: breakpoints for iop