Fix stepping

This commit is contained in:
Kingcom 2013-11-25 19:51:16 +01:00
parent ea38eb4318
commit 8146e7bfb0
4 changed files with 36 additions and 26 deletions

View file

@ -312,9 +312,11 @@ int DisassemblyFunction::getLineNum(u32 address, bool findStart)
{
for (int i = 0; i < lineAddresses.size(); i++)
{
u32 next = (i == lineAddresses.size()-1) ? this->address+this->size : lineAddresses[i+1];
if (lineAddresses[i] == address)
return i;
if (findStart && lineAddresses[i] <= address && lineAddresses[i]+4 > address)
if (findStart && lineAddresses[i] <= address && next > address)
return i;
}

View file

@ -1255,3 +1255,21 @@ void CtrlDisAsmView::getOpcodeText(u32 address, char* dest)
manager.getLine(address,displaySymbols,line);
sprintf(dest,"%s %s",line.name.c_str(),line.params.c_str());
}
void CtrlDisAsmView::scrollStepping(u32 newPc)
{
u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows);
newPc = manager.getStartAddress(newPc);
if (newPc >= windowEnd || newPc >= manager.getNthPreviousAddress(windowEnd,1))
{
windowStart = manager.getNthPreviousAddress(newPc,visibleRows-2);
}
}
u32 CtrlDisAsmView::getInstructionSizeAt(u32 address)
{
u32 start = manager.getStartAddress(address);
u32 next = manager.getNthNextAddress(start,1);
return next-address;
}

View file

@ -118,7 +118,9 @@ public:
return debugger;
}
u32 getWindowEnd() { return windowStart+visibleRows*instructionSize; };
void scrollStepping(u32 newPc);
u32 getInstructionSizeAt(u32 address);
void gotoAddr(unsigned int addr)
{
addr = manager.getStartAddress(addr);

View file

@ -164,19 +164,15 @@ void CDisasm::stepInto()
CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW));
lastTicks = CoreTiming::GetTicks();
u32 currentPc = cpu->GetPC();
u32 windowEnd = ptr->getWindowEnd();
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
CBreakPoints::SetSkipFirst(currentMIPS->pc);
u32 newAddress = currentPc+cpu->getInstructionSize(0);
u32 newAddress = currentPc+ptr->getInstructionSizeAt(currentPc);
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,currentPc);
if (info.isBranch)
{
if (newAddress == windowEnd-4)
ptr->scrollWindow(1);
else if (newAddress == windowEnd)
ptr->scrollWindow(2);
ptr->scrollStepping(newAddress);
} else {
bool scroll = true;
if (currentMIPS->inDelaySlot)
@ -188,15 +184,16 @@ void CDisasm::stepInto()
if (scroll)
{
if (newAddress == windowEnd-4)
ptr->scrollWindow(1);
else if (newAddress == windowEnd)
ptr->scrollWindow(2);
ptr->scrollStepping(newAddress);
}
}
Core_DoSingleStep();
Sleep(1);
for (int i = 0; i < (newAddress-currentPc)/4; i++)
{
Core_DoSingleStep();
Sleep(1);
}
_dbg_update_();
ptr->gotoPC();
UpdateDialog();
@ -218,11 +215,10 @@ void CDisasm::stepOver()
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
CBreakPoints::SetSkipFirst(currentMIPS->pc);
u32 currentPc = cpu->GetPC();
u32 windowEnd = ptr->getWindowEnd();
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,cpu->GetPC());
ptr->setDontRedraw(true);
u32 breakpointAddress = currentPc+cpu->getInstructionSize(0);
u32 breakpointAddress = currentPc+ptr->getInstructionSizeAt(currentPc);
if (info.isBranch)
{
if (info.isConditional == false)
@ -241,19 +237,11 @@ void CDisasm::stepOver()
breakpointAddress = info.branchTarget;
} else {
breakpointAddress = currentPc+2*cpu->getInstructionSize(0);
if (breakpointAddress == windowEnd-4)
ptr->scrollWindow(1);
else if (breakpointAddress == windowEnd)
ptr->scrollWindow(2);
else if (breakpointAddress == windowEnd+4)
ptr->scrollWindow(3);
ptr->scrollStepping(breakpointAddress);
}
}
} else {
if (breakpointAddress == windowEnd-4)
ptr->scrollWindow(1);
else if (breakpointAddress == windowEnd)
ptr->scrollWindow(2);
ptr->scrollStepping(breakpointAddress);
}
SetDebugMode(false, true);