Index: ntoskrnl/kdbg/kdb.c =================================================================== --- ntoskrnl/kdbg/kdb.c (revision 40785) +++ 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; 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 */ @@ -368,7 +369,7 @@ BOOLEAN KdbpStepIntoInstruction(ULONG_PTR Eip) { - KDESCRIPTOR Idtr = {0}; + KDESCRIPTOR Idtr = {0}; UCHAR Mem[2]; INT IntVect; ULONG IntDesc[2]; @@ -1320,6 +1321,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) @@ -1360,6 +1362,9 @@ */ 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)) || @@ -1370,6 +1375,8 @@ goto continue_execution; /* return */ } + /* mark it as next instruction from the debugger */ + KdbEnteredOnNextStep = TRUE; KdbEnteredOnSingleStep = TRUE; } @@ -1626,8 +1633,12 @@ /* 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;