diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 7f3c96e19..ca9a9d1d6 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -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; } diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 2695c79ca..c8e1ae05f 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -1254,4 +1254,22 @@ void CtrlDisAsmView::getOpcodeText(u32 address, char* dest) address = manager.getStartAddress(address); 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; } \ No newline at end of file diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h index 7bc5f7020..95e6b82c6 100644 --- a/Windows/Debugger/CtrlDisAsmView.h +++ b/Windows/Debugger/CtrlDisAsmView.h @@ -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); diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 4e33ca76e..cdea3fce0 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -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);