A hackish attempt at step into

This commit is contained in:
Kingcom 2014-02-24 14:56:09 +01:00
parent d8abd04a8e
commit e55229db40
7 changed files with 67 additions and 1 deletions

View File

@ -356,6 +356,10 @@ namespace MIPSAnalyst
switch (MIPS_GET_OP(op)) {
case 0: // special
switch (MIPS_GET_FUNC(op)) {
case 0x0C: // syscall
info.isSyscall = true;
info.branchTarget = 0x80000000+0x180;
break;
case 0x20: // add
case 0x21: // addu
info.hasRelevantAddress = true;

View File

@ -37,6 +37,7 @@ namespace MIPSAnalyst
// branches
u32 branchTarget;
bool isSyscall;
bool isBranch;
bool isLinkedBranch;
bool isLikelyBranch;

View File

@ -689,7 +689,10 @@ void CtrlDisassemblyView::keydownEvent(wxKeyEvent& evt)
break;
case WXK_F10:
postEvent(debEVT_STEPOVER,0);
break;
return;
case WXK_F11:
postEvent(debEVT_STEPINTO,0);
return;
default:
evt.Skip();
break;

View File

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

View File

@ -9,6 +9,7 @@ DECLARE_LOCAL_EVENT_TYPE( debEVT_GOTOINDISASM, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_RUNTOPOS, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPOVER, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPINTO, wxNewEventType() )
DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() )
bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest);

View File

@ -18,6 +18,7 @@ BEGIN_EVENT_TABLE(DisassemblyDialog, wxFrame)
EVT_COMMAND( wxID_ANY, debEVT_RUNTOPOS, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_GOTOINDISASM, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_STEPOVER, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_STEPINTO, DisassemblyDialog::onDebuggerEvent )
EVT_COMMAND( wxID_ANY, debEVT_UPDATE, DisassemblyDialog::onDebuggerEvent )
EVT_CLOSE( DisassemblyDialog::onClose )
END_EVENT_TABLE()
@ -97,6 +98,7 @@ DisassemblyDialog::DisassemblyDialog(wxWindow* parent):
stepIntoButton = new wxButton( panel, wxID_ANY, L"Step Into" );
stepIntoButton->Enable(false);
Connect( stepIntoButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DisassemblyDialog::onStepIntoClicked ) );
topRowSizer->Add(stepIntoButton,0,wxBOTTOM,2);
stepOverButton = new wxButton( panel, wxID_ANY, L"Step Over" );
@ -181,6 +183,11 @@ void DisassemblyDialog::onStepOverClicked(wxCommandEvent& evt)
stepOver();
}
void DisassemblyDialog::onStepIntoClicked(wxCommandEvent& evt)
{
stepInto();
}
void DisassemblyDialog::onPageChanging(wxCommandEvent& evt)
{
wxNotebook* notebook = (wxNotebook*)wxWindow::FindWindowById(evt.GetId());
@ -247,6 +254,48 @@ void DisassemblyDialog::stepOver()
r5900Debug.resumeCpu();
}
void DisassemblyDialog::stepInto()
{
if (!r5900Debug.isAlive() || !r5900Debug.isCpuPaused() || currentCpu == NULL)
return;
// todo: breakpoints for iop
if (currentCpu != eeTab)
return;
CtrlDisassemblyView* disassembly = currentCpu->getDisassembly();
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
CBreakPoints::SetSkipFirst(r5900Debug.getPC());
u32 currentPc = r5900Debug.getPC();
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(&r5900Debug,r5900Debug.getPC());
u32 breakpointAddress = currentPc+disassembly->getInstructionSizeAt(currentPc);
if (info.isBranch)
{
if (info.isConditional == false)
{
breakpointAddress = info.branchTarget;
} else {
if (info.conditionMet)
{
breakpointAddress = info.branchTarget;
} else {
breakpointAddress = currentPc+2*4;
disassembly->scrollStepping(breakpointAddress);
}
}
}
if (info.isSyscall)
breakpointAddress = info.branchTarget;
CBreakPoints::AddBreakPoint(breakpointAddress,true);
r5900Debug.resumeCpu();
}
void DisassemblyDialog::onBreakpointClick(wxCommandEvent& evt)
{
if (currentCpu == NULL)
@ -295,6 +344,10 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt)
{
if (currentCpu != NULL)
stepOver();
} else if (type == debEVT_STEPINTO)
{
if (currentCpu != NULL)
stepInto();
} else if (type == debEVT_UPDATE)
{
update();
@ -340,6 +393,7 @@ void DisassemblyDialog::setDebugMode(bool debugMode)
breakRunButton->SetLabel(L"Run");
stepOverButton->Enable(true);
stepIntoButton->Enable(true);
eeTab->getDisassembly()->gotoPc();
iopTab->getDisassembly()->gotoPc();

View File

@ -52,11 +52,13 @@ public:
protected:
void onBreakRunClicked(wxCommandEvent& evt);
void onStepOverClicked(wxCommandEvent& evt);
void onStepIntoClicked(wxCommandEvent& evt);
void onDebuggerEvent(wxCommandEvent& evt);
void onPageChanging(wxCommandEvent& evt);
void onBreakpointClick(wxCommandEvent& evt);
void onClose(wxCloseEvent& evt);
void stepOver();
void stepInto();
private:
CpuTabPage* eeTab;
CpuTabPage* iopTab;