Fix display of memory breakpoint enable status and add context menu to breakpoint list

This commit is contained in:
Kingcom 2014-07-22 22:36:50 +02:00
parent 30a5e31b66
commit b37f6e9df1
5 changed files with 91 additions and 1 deletions

View File

@ -25,6 +25,7 @@ DEFINE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED )
DEFINE_LOCAL_EVENT_TYPE( debEVT_STEPOVER ) DEFINE_LOCAL_EVENT_TYPE( debEVT_STEPOVER )
DEFINE_LOCAL_EVENT_TYPE( debEVT_STEPINTO ) DEFINE_LOCAL_EVENT_TYPE( debEVT_STEPINTO )
DEFINE_LOCAL_EVENT_TYPE( debEVT_UPDATE ) DEFINE_LOCAL_EVENT_TYPE( debEVT_UPDATE )
DEFINE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW )
bool parseExpression(const char* exp, DebugInterface* cpu, u64& dest) bool parseExpression(const char* exp, DebugInterface* cpu, u64& dest)
{ {

View File

@ -26,5 +26,6 @@ DECLARE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPOVER, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPOVER, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPINTO, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPINTO, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW, wxNewEventType() )
bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest, const wxString& defaultValue = wxEmptyString); bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest, const wxString& defaultValue = wxEmptyString);

View File

@ -47,10 +47,21 @@ void resizeListViewColumns(wxListCtrl* list, GenericListViewColumn* columns, int
BEGIN_EVENT_TABLE(BreakpointList, wxWindow) BEGIN_EVENT_TABLE(BreakpointList, wxWindow)
EVT_SIZE(BreakpointList::sizeEvent) EVT_SIZE(BreakpointList::sizeEvent)
EVT_KEY_DOWN(BreakpointList::keydownEvent) EVT_KEY_DOWN(BreakpointList::keydownEvent)
EVT_RIGHT_DOWN(BreakpointList::mouseEvent)
EVT_RIGHT_UP(BreakpointList::mouseEvent)
EVT_LIST_ITEM_RIGHT_CLICK(wxID_ANY,BreakpointList::listEvent)
END_EVENT_TABLE() END_EVENT_TABLE()
enum { BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, BPL_ENABLED, BPL_COLUMNCOUNT }; enum { BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, BPL_ENABLED, BPL_COLUMNCOUNT };
enum BreakpointListMenuIdentifiers
{
ID_BREAKPOINTLIST_ENABLE = 1,
ID_BREAKPOINTLIST_EDIT,
ID_BREAKPOINTLIST_ADDNEW,
};
GenericListViewColumn breakpointColumns[BPL_COLUMNCOUNT] = { GenericListViewColumn breakpointColumns[BPL_COLUMNCOUNT] = {
{ L"Type", 0.12f }, { L"Type", 0.12f },
{ L"Offset", 0.12f }, { L"Offset", 0.12f },
@ -189,7 +200,7 @@ wxString BreakpointList::OnGetItemText(long item, long col) const
case BPL_ENABLED: case BPL_ENABLED:
{ {
if (isMemory) { if (isMemory) {
dest.Write(L"%s",displayedMemChecks_[index].cond & MEMCHECK_BREAK ? "true" : "false"); dest.Write(L"%s",displayedMemChecks_[index].result & MEMCHECK_BREAK ? "true" : "false");
} else { } else {
dest.Write(L"%s",displayedBreakPoints_[index].enabled ? "true" : "false"); dest.Write(L"%s",displayedBreakPoints_[index].enabled ? "true" : "false");
} }
@ -352,3 +363,70 @@ void BreakpointList::postEvent(wxEventType type, int value)
event.SetInt(value); event.SetInt(value);
wxPostEvent(this,event); wxPostEvent(this,event);
} }
void BreakpointList::onPopupClick(wxCommandEvent& evt)
{
int index = GetFirstSelected();
switch (evt.GetId())
{
case ID_BREAKPOINTLIST_ENABLE:
toggleEnabled(index);
break;
case ID_BREAKPOINTLIST_EDIT:
editBreakpoint(index);
break;
case ID_BREAKPOINTLIST_ADDNEW:
postEvent(debEVT_BREAKPOINTWINDOW,0);
break;
default:
wxMessageBox( L"Unimplemented.", L"Unimplemented.", wxICON_INFORMATION);
break;
}
}
void BreakpointList::showMenu(wxPoint& pos)
{
bool isMemory;
int index = getBreakpointIndex(GetFirstSelected(),isMemory);
wxMenu menu;
if (index != -1)
{
menu.AppendCheckItem(ID_BREAKPOINTLIST_ENABLE, L"Enable");
menu.Append(ID_BREAKPOINTLIST_EDIT, L"Edit");
menu.AppendSeparator();
// check if the breakpoint is enabled
bool enabled;
if (isMemory)
enabled = (displayedMemChecks_[index].result & MEMCHECK_BREAK) != 0;
else
enabled = displayedBreakPoints_[index].enabled;
menu.Check(ID_BREAKPOINTLIST_ENABLE,enabled);
}
menu.Append(ID_BREAKPOINTLIST_ADDNEW, L"Add new");
menu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&BreakpointList::onPopupClick, NULL, this);
PopupMenu(&menu,pos);
}
void BreakpointList::mouseEvent(wxMouseEvent& evt)
{
wxEventType type = evt.GetEventType();
if (type == wxEVT_RIGHT_DOWN)
{
clickPos = evt.GetPosition();
evt.Skip();
} else if (type == wxEVT_RIGHT_UP)
{
showMenu(evt.GetPosition());
}
}
void BreakpointList::listEvent(wxListEvent& evt)
{
showMenu(clickPos);
}

View File

@ -35,9 +35,12 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
protected: protected:
wxString OnGetItemText(long item, long col) const; wxString OnGetItemText(long item, long col) const;
void onPopupClick(wxCommandEvent& evt);
void sizeEvent(wxSizeEvent& evt); void sizeEvent(wxSizeEvent& evt);
void keydownEvent(wxKeyEvent& evt); void keydownEvent(wxKeyEvent& evt);
void mouseEvent(wxMouseEvent& evt);
void listEvent(wxListEvent& evt);
private: private:
int getBreakpointIndex(int itemIndex, bool& isMemory) const; int getBreakpointIndex(int itemIndex, bool& isMemory) const;
int getTotalBreakpointCount(); int getTotalBreakpointCount();
@ -46,9 +49,11 @@ private:
void gotoBreakpointAddress(int itemIndex); void gotoBreakpointAddress(int itemIndex);
void removeBreakpoint(int itemIndex); void removeBreakpoint(int itemIndex);
void postEvent(wxEventType type, int value); void postEvent(wxEventType type, int value);
void showMenu(wxPoint& pos);
std::vector<BreakPoint> displayedBreakPoints_; std::vector<BreakPoint> displayedBreakPoints_;
std::vector<MemCheck> displayedMemChecks_; std::vector<MemCheck> displayedMemChecks_;
DebugInterface* cpu; DebugInterface* cpu;
CtrlDisassemblyView* disasm; CtrlDisassemblyView* disasm;
wxPoint clickPos;
}; };

View File

@ -35,6 +35,7 @@ BEGIN_EVENT_TABLE(DisassemblyDialog, wxFrame)
EVT_COMMAND( wxID_ANY, debEVT_STEPOVER, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_STEPOVER, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_STEPINTO, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_STEPINTO, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_UPDATE, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_UPDATE, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_BREAKPOINTWINDOW, DisassemblyDialog::onDebuggerEvent )
EVT_CLOSE( DisassemblyDialog::onClose ) EVT_CLOSE( DisassemblyDialog::onClose )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -414,6 +415,10 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt)
} else if (type == debEVT_UPDATE) } else if (type == debEVT_UPDATE)
{ {
update(); update();
} else if (type == debEVT_BREAKPOINTWINDOW)
{
wxCommandEvent evt;
onBreakpointClick(evt);
} }
} }