Add step out feature

This commit is contained in:
Kingcom 2014-08-23 10:45:53 +02:00
parent d3ffd13c25
commit 8dba78abce
5 changed files with 52 additions and 1 deletions

View File

@ -889,11 +889,17 @@ void CtrlDisassemblyView::keydownEvent(wxKeyEvent& evt)
} }
scanFunctions(); scanFunctions();
break; break;
case WXK_F8:
postEvent(debEVT_STEPOUT,0);
break;
case WXK_F10: case WXK_F10:
postEvent(debEVT_STEPOVER,0); postEvent(debEVT_STEPOVER,0);
return; return;
case WXK_F11: case WXK_F11:
postEvent(debEVT_STEPINTO,0); if (evt.ShiftDown())
postEvent(debEVT_STEPOUT,0);
else
postEvent(debEVT_STEPINTO,0);
return; return;
default: default:
evt.Skip(); evt.Skip();

View File

@ -24,6 +24,7 @@ DEFINE_LOCAL_EVENT_TYPE( debEVT_RUNTOPOS )
DEFINE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED ) 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_STEPOUT )
DEFINE_LOCAL_EVENT_TYPE( debEVT_UPDATE ) DEFINE_LOCAL_EVENT_TYPE( debEVT_UPDATE )
DEFINE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW ) DEFINE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW )

View File

@ -25,6 +25,7 @@ DECLARE_LOCAL_EVENT_TYPE( debEVT_RUNTOPOS, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED, wxNewEventType() ) 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_STEPOUT, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW, wxNewEventType() )

View File

@ -35,6 +35,7 @@ BEGIN_EVENT_TABLE(DisassemblyDialog, wxFrame)
EVT_COMMAND( wxID_ANY, debEVT_GOTOINDISASM, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_GOTOINDISASM, DisassemblyDialog::onDebuggerEvent )
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_STEPOUT, 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_COMMAND( wxID_ANY, debEVT_BREAKPOINTWINDOW, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_MAPLOADED, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_MAPLOADED, DisassemblyDialog::onDebuggerEvent )
@ -196,6 +197,22 @@ void CpuTabPage::loadCycles()
lastCycles = cycles; lastCycles = cycles;
} }
u32 CpuTabPage::getStepOutAddress()
{
if (threadList == NULL)
return (u32)-1;
EEThread currentThread = threadList->getRunningThread();
std::vector<MipsStackWalk::StackFrame> frames =
MipsStackWalk::Walk(cpu,cpu->getPC(),cpu->getRegister(0,31),cpu->getRegister(0,29),
currentThread.data.entry_init,currentThread.data.stack);
if (frames.size() < 2)
return (u32)-1;
return frames[1].pc;
}
DisassemblyDialog::DisassemblyDialog(wxWindow* parent): DisassemblyDialog::DisassemblyDialog(wxWindow* parent):
wxFrame( parent, wxID_ANY, L"Debugger", wxDefaultPosition,wxDefaultSize,wxRESIZE_BORDER|wxCLOSE_BOX|wxCAPTION|wxSYSTEM_MENU ), wxFrame( parent, wxID_ANY, L"Debugger", wxDefaultPosition,wxDefaultSize,wxRESIZE_BORDER|wxCLOSE_BOX|wxCAPTION|wxSYSTEM_MENU ),
currentCpu(NULL) currentCpu(NULL)
@ -225,6 +242,7 @@ DisassemblyDialog::DisassemblyDialog(wxWindow* parent):
stepOutButton = new wxButton( panel, wxID_ANY, L"Step Out" ); stepOutButton = new wxButton( panel, wxID_ANY, L"Step Out" );
stepOutButton->Enable(false); stepOutButton->Enable(false);
Connect( stepOutButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DisassemblyDialog::onStepOutClicked ) );
topRowSizer->Add(stepOutButton,0,wxRIGHT,8); topRowSizer->Add(stepOutButton,0,wxRIGHT,8);
breakpointButton = new wxButton( panel, wxID_ANY, L"Breakpoint" ); breakpointButton = new wxButton( panel, wxID_ANY, L"Breakpoint" );
@ -307,6 +325,11 @@ void DisassemblyDialog::onStepIntoClicked(wxCommandEvent& evt)
stepInto(); stepInto();
} }
void DisassemblyDialog::onStepOutClicked(wxCommandEvent& evt)
{
stepOut();
}
void DisassemblyDialog::onPageChanging(wxCommandEvent& evt) void DisassemblyDialog::onPageChanging(wxCommandEvent& evt)
{ {
wxNotebook* notebook = (wxNotebook*)wxWindow::FindWindowById(evt.GetId()); wxNotebook* notebook = (wxNotebook*)wxWindow::FindWindowById(evt.GetId());
@ -414,6 +437,18 @@ void DisassemblyDialog::stepInto()
r5900Debug.resumeCpu(); r5900Debug.resumeCpu();
} }
void DisassemblyDialog::stepOut()
{
if (!r5900Debug.isAlive() || !r5900Debug.isCpuPaused() || currentCpu == NULL)
return;
u32 addr = currentCpu->getStepOutAddress();
if (addr == (u32)-1)
return;
CBreakPoints::AddBreakPoint(addr,true);
r5900Debug.resumeCpu();
}
void DisassemblyDialog::onBreakpointClick(wxCommandEvent& evt) void DisassemblyDialog::onBreakpointClick(wxCommandEvent& evt)
{ {
@ -485,6 +520,10 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt)
{ {
eeTab->reloadSymbolMap(); eeTab->reloadSymbolMap();
iopTab->reloadSymbolMap(); iopTab->reloadSymbolMap();
} else if (type == debEVT_STEPOUT)
{
if (currentCpu != NULL)
stepOut();
} }
} }
@ -536,6 +575,7 @@ void DisassemblyDialog::setDebugMode(bool debugMode, bool switchPC)
stepOverButton->Enable(true); stepOverButton->Enable(true);
stepIntoButton->Enable(true); stepIntoButton->Enable(true);
stepOutButton->Enable(currentCpu == eeTab);
if (switchPC || CBreakPoints::GetBreakpointTriggered()) if (switchPC || CBreakPoints::GetBreakpointTriggered())
gotoPc(); gotoPc();

View File

@ -43,6 +43,7 @@ public:
void showMemoryView() { setBottomTabPage(memory); }; void showMemoryView() { setBottomTabPage(memory); };
void loadCycles(); void loadCycles();
void reloadSymbolMap(); void reloadSymbolMap();
u32 getStepOutAddress();
void listBoxHandler(wxCommandEvent& event); void listBoxHandler(wxCommandEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@ -86,12 +87,14 @@ protected:
void onBreakRunClicked(wxCommandEvent& evt); void onBreakRunClicked(wxCommandEvent& evt);
void onStepOverClicked(wxCommandEvent& evt); void onStepOverClicked(wxCommandEvent& evt);
void onStepIntoClicked(wxCommandEvent& evt); void onStepIntoClicked(wxCommandEvent& evt);
void onStepOutClicked(wxCommandEvent& evt);
void onDebuggerEvent(wxCommandEvent& evt); void onDebuggerEvent(wxCommandEvent& evt);
void onPageChanging(wxCommandEvent& evt); void onPageChanging(wxCommandEvent& evt);
void onBreakpointClick(wxCommandEvent& evt); void onBreakpointClick(wxCommandEvent& evt);
void onClose(wxCloseEvent& evt); void onClose(wxCloseEvent& evt);
void stepOver(); void stepOver();
void stepInto(); void stepInto();
void stepOut();
void gotoPc(); void gotoPc();
private: private:
CpuTabPage* eeTab; CpuTabPage* eeTab;