Fix stepping
This commit is contained in:
parent
ea38eb4318
commit
8146e7bfb0
4 changed files with 36 additions and 26 deletions
|
@ -312,9 +312,11 @@ int DisassemblyFunction::getLineNum(u32 address, bool findStart)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < lineAddresses.size(); i++)
|
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)
|
if (lineAddresses[i] == address)
|
||||||
return i;
|
return i;
|
||||||
if (findStart && lineAddresses[i] <= address && lineAddresses[i]+4 > address)
|
if (findStart && lineAddresses[i] <= address && next > address)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1255,3 +1255,21 @@ void CtrlDisAsmView::getOpcodeText(u32 address, char* dest)
|
||||||
manager.getLine(address,displaySymbols,line);
|
manager.getLine(address,displaySymbols,line);
|
||||||
sprintf(dest,"%s %s",line.name.c_str(),line.params.c_str());
|
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;
|
||||||
|
}
|
|
@ -118,7 +118,9 @@ public:
|
||||||
return debugger;
|
return debugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getWindowEnd() { return windowStart+visibleRows*instructionSize; };
|
void scrollStepping(u32 newPc);
|
||||||
|
u32 getInstructionSizeAt(u32 address);
|
||||||
|
|
||||||
void gotoAddr(unsigned int addr)
|
void gotoAddr(unsigned int addr)
|
||||||
{
|
{
|
||||||
addr = manager.getStartAddress(addr);
|
addr = manager.getStartAddress(addr);
|
||||||
|
|
|
@ -164,19 +164,15 @@ void CDisasm::stepInto()
|
||||||
CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW));
|
CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW));
|
||||||
lastTicks = CoreTiming::GetTicks();
|
lastTicks = CoreTiming::GetTicks();
|
||||||
u32 currentPc = cpu->GetPC();
|
u32 currentPc = cpu->GetPC();
|
||||||
u32 windowEnd = ptr->getWindowEnd();
|
|
||||||
|
|
||||||
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
|
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
|
||||||
CBreakPoints::SetSkipFirst(currentMIPS->pc);
|
CBreakPoints::SetSkipFirst(currentMIPS->pc);
|
||||||
u32 newAddress = currentPc+cpu->getInstructionSize(0);
|
u32 newAddress = currentPc+ptr->getInstructionSizeAt(currentPc);
|
||||||
|
|
||||||
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,currentPc);
|
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,currentPc);
|
||||||
if (info.isBranch)
|
if (info.isBranch)
|
||||||
{
|
{
|
||||||
if (newAddress == windowEnd-4)
|
ptr->scrollStepping(newAddress);
|
||||||
ptr->scrollWindow(1);
|
|
||||||
else if (newAddress == windowEnd)
|
|
||||||
ptr->scrollWindow(2);
|
|
||||||
} else {
|
} else {
|
||||||
bool scroll = true;
|
bool scroll = true;
|
||||||
if (currentMIPS->inDelaySlot)
|
if (currentMIPS->inDelaySlot)
|
||||||
|
@ -188,15 +184,16 @@ void CDisasm::stepInto()
|
||||||
|
|
||||||
if (scroll)
|
if (scroll)
|
||||||
{
|
{
|
||||||
if (newAddress == windowEnd-4)
|
ptr->scrollStepping(newAddress);
|
||||||
ptr->scrollWindow(1);
|
|
||||||
else if (newAddress == windowEnd)
|
|
||||||
ptr->scrollWindow(2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < (newAddress-currentPc)/4; i++)
|
||||||
|
{
|
||||||
Core_DoSingleStep();
|
Core_DoSingleStep();
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
_dbg_update_();
|
_dbg_update_();
|
||||||
ptr->gotoPC();
|
ptr->gotoPC();
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
|
@ -218,11 +215,10 @@ void CDisasm::stepOver()
|
||||||
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
|
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
|
||||||
CBreakPoints::SetSkipFirst(currentMIPS->pc);
|
CBreakPoints::SetSkipFirst(currentMIPS->pc);
|
||||||
u32 currentPc = cpu->GetPC();
|
u32 currentPc = cpu->GetPC();
|
||||||
u32 windowEnd = ptr->getWindowEnd();
|
|
||||||
|
|
||||||
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,cpu->GetPC());
|
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,cpu->GetPC());
|
||||||
ptr->setDontRedraw(true);
|
ptr->setDontRedraw(true);
|
||||||
u32 breakpointAddress = currentPc+cpu->getInstructionSize(0);
|
u32 breakpointAddress = currentPc+ptr->getInstructionSizeAt(currentPc);
|
||||||
if (info.isBranch)
|
if (info.isBranch)
|
||||||
{
|
{
|
||||||
if (info.isConditional == false)
|
if (info.isConditional == false)
|
||||||
|
@ -241,19 +237,11 @@ void CDisasm::stepOver()
|
||||||
breakpointAddress = info.branchTarget;
|
breakpointAddress = info.branchTarget;
|
||||||
} else {
|
} else {
|
||||||
breakpointAddress = currentPc+2*cpu->getInstructionSize(0);
|
breakpointAddress = currentPc+2*cpu->getInstructionSize(0);
|
||||||
if (breakpointAddress == windowEnd-4)
|
ptr->scrollStepping(breakpointAddress);
|
||||||
ptr->scrollWindow(1);
|
|
||||||
else if (breakpointAddress == windowEnd)
|
|
||||||
ptr->scrollWindow(2);
|
|
||||||
else if (breakpointAddress == windowEnd+4)
|
|
||||||
ptr->scrollWindow(3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (breakpointAddress == windowEnd-4)
|
ptr->scrollStepping(breakpointAddress);
|
||||||
ptr->scrollWindow(1);
|
|
||||||
else if (breakpointAddress == windowEnd)
|
|
||||||
ptr->scrollWindow(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDebugMode(false, true);
|
SetDebugMode(false, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue