Index: ntoskrnl/kdbg/kdb.c =================================================================== --- ntoskrnl/kdbg/kdb.c (revision 45612) +++ ntoskrnl/kdbg/kdb.c (working copy) @@ -43,6 +43,7 @@ BOOLEAN KdbSingleStepOver = FALSE; /* Whether to step over calls/reps. */ ULONG KdbDebugState = 0; /* KDBG Settings (NOECHO, KDSERIAL) */ static BOOLEAN KdbEnteredOnSingleStep = FALSE; /* Set to true when KDB was entered because of single step */ +static BOOLEAN KdbEnteredOnNextStep = FALSE; /* Set to true when KDB was entered because of next step */ PEPROCESS KdbCurrentProcess = NULL; /* The current process context in which KDB runs */ PEPROCESS KdbOriginalProcess = NULL; /* The process in whichs context KDB was intered */ PETHREAD KdbCurrentThread = NULL; /* The current thread context in which KDB runs */ @@ -1377,6 +1378,7 @@ /* If we stopped on one of our breakpoints then let the user know. */ KdbLastBreakPointNr = -1; KdbEnteredOnSingleStep = FALSE; + KdbEnteredOnNextStep = FALSE; if (FirstChance && (ExceptionCode == STATUS_SINGLE_STEP || ExceptionCode == STATUS_BREAKPOINT) && (KdbLastBreakPointNr = KdbpIsBreakPointOurs(ExceptionCode, TrapFrame)) >= 0) @@ -1413,6 +1415,9 @@ /* Delete the temporary breakpoint which was used to step over or into the instruction. */ KdbpDeleteBreakPoint(-1, BreakPoint); + /* trap starts behind 0xCC (int 3) so rewind to the right start address */ + TrapFrame->Eip--; + if (--KdbNumSingleSteps > 0) { if ((KdbSingleStepOver && !KdbpStepOverInstruction(TrapFrame->Eip)) || @@ -1424,6 +1429,8 @@ goto continue_execution; /* return */ } + /* mark it as next instruction from the debugger */ + KdbEnteredOnNextStep = TRUE; KdbEnteredOnSingleStep = TRUE; } @@ -1681,8 +1688,13 @@ /* Clear dr6 status flags. */ TrapFrame->Dr6 &= ~0x0000e00f; - /* Skip the current instruction */ - Context->Eip++; + /* don't skip instruction when a run to next with int 3 */ + if (KdbEnteredOnNextStep==FALSE) + { + /* skip the current instruction */ + Context->Eip++; + } + } return ContinueType;