@@ -2910,7 +2910,7 @@ KdbpPagerInternal(
29102910 KdpInitTerminal ();
29112911 }
29122912
2913- /* Refresh terminal size each time when number of rows printed is 0 */
2913+ /* Refresh terminal size each time when number of printed rows is 0 */
29142914 if (KdbNumberOfRowsPrinted == 0 )
29152915 {
29162916 KdpUpdateTerminalSize (& KdTermSize );
@@ -3030,7 +3030,7 @@ KdbpPagerInternal(
30303030 p [i + 1 ] = c ;
30313031
30323032 /* Set p to the start of the next line and
3033- * remember the number of rows/cols printed */
3033+ * remember the number of printed rows/cols */
30343034 p += i ;
30353035 if (p [0 ] == '\n' )
30363036 {
@@ -3205,6 +3205,7 @@ static BOOLEAN
32053205KdbpDoCommand (
32063206 IN PCHAR Command )
32073207{
3208+ BOOLEAN Continue = TRUE;
32083209 SIZE_T i ;
32093210 PCHAR p ;
32103211 ULONG Argc ;
@@ -3238,25 +3239,31 @@ KdbpDoCommand(
32383239 if (Argc < 1 )
32393240 return TRUE;
32403241
3242+ /* Reset the pager state: number of printed rows/cols and aborted output flag */
3243+ KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0 ;
3244+ KdbOutputAborted = FALSE;
3245+
32413246 for (i = 0 ; i < RTL_NUMBER_OF (KdbDebuggerCommands ); i ++ )
32423247 {
32433248 if (!KdbDebuggerCommands [i ].Name )
32443249 continue ;
32453250
32463251 if (strcmp (KdbDebuggerCommands [i ].Name , Argv [0 ]) == 0 )
32473252 {
3248- return KdbDebuggerCommands [i ].Fn (Argc , Argv );
3253+ Continue = KdbDebuggerCommands [i ].Fn (Argc , Argv );
3254+ goto Done ;
32493255 }
32503256 }
32513257
32523258 /* Now invoke the registered callbacks */
32533259 if (KdbpInvokeCliCallbacks (Command , Argc , Argv ))
3254- {
3255- return TRUE;
3256- }
3260+ goto Done ;
32573261
3258- KdbpPrint ("Command '%s' is unknown.\n" , OrigCommand );
3259- return TRUE;
3262+ KdbPrintf ("Command '%s' is unknown.\n" , OrigCommand );
3263+
3264+ Done :
3265+ KdbOutputAborted = FALSE;
3266+ return Continue ;
32603267}
32613268
32623269/*!\brief KDB Main Loop.
@@ -3267,39 +3274,37 @@ VOID
32673274KdbpCliMainLoop (
32683275 IN BOOLEAN EnteredOnSingleStep )
32693276{
3270- BOOLEAN Continue ;
3271- SIZE_T CmdLen ;
3277+ BOOLEAN Continue = TRUE;
32723278 static CHAR Command [1024 ];
32733279 static CHAR LastCommand [1024 ] = "" ;
32743280
32753281 if (EnteredOnSingleStep )
32763282 {
32773283 if (!KdbSymPrintAddress ((PVOID )KeGetContextPc (KdbCurrentTrapFrame ), KdbCurrentTrapFrame ))
3278- {
3279- KdbpPrint ("<%p>" , KeGetContextPc (KdbCurrentTrapFrame ));
3280- }
3284+ KdbPrintf ("<%p>" , KeGetContextPc (KdbCurrentTrapFrame ));
32813285
3282- KdbpPrint (": " );
3286+ KdbPuts (": " );
32833287 if (KdbpDisassemble (KeGetContextPc (KdbCurrentTrapFrame ), KdbUseIntelSyntax ) < 0 )
3284- {
3285- KdbpPrint ("<INVALID>" );
3286- }
3287- KdbpPrint ("\n" );
3288+ KdbPuts ("<INVALID>" );
3289+ KdbPuts ("\n" );
3290+ }
3291+ else
3292+ {
3293+ /* Preceding this message is one of the "Entered debugger..." banners */
3294+ // KdbPuts("\nEntered debugger\n");
3295+ KdbPuts ("\nType \"help\" for a list of commands.\n" );
32883296 }
32893297
32903298 /* Main loop */
3291- do
3299+ while ( Continue )
32923300 {
3293- /* Reset the number of rows/cols printed */
3294- KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0 ;
3295-
32963301 /*
32973302 * Print the prompt and read a command.
32983303 * Repeat the last one if the user pressed Enter.
32993304 * This reduces the risk of RSI when single-stepping!
33003305 */
33013306 // TEMP HACK! Issue an empty string instead of duplicating "kdb:>"
3302- CmdLen = KdbPrompt (/*KdbPromptStr.Buffer*/ "" , Command , sizeof (Command ));
3307+ SIZE_T CmdLen = KdbPrompt (/*KdbPromptStr.Buffer*/ "" , Command , sizeof (Command ));
33033308 if (CmdLen == 0 )
33043309 {
33053310 /* Nothing received but the user didn't press Enter, retry */
@@ -3320,15 +3325,9 @@ KdbpCliMainLoop(
33203325 RtlStringCbCopyA (Command , sizeof (Command ), LastCommand );
33213326 }
33223327
3323- /* Reset the number of rows/cols printed and output aborted state */
3324- KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0 ;
3325- KdbOutputAborted = FALSE;
3326-
3327- /* Call the command */
3328+ /* Invoke the command */
33283329 Continue = KdbpDoCommand (Command );
3329- KdbOutputAborted = FALSE;
33303330 }
3331- while (Continue );
33323331}
33333332
33343333/*!\brief This function is called by KdbEnterDebuggerException...
0 commit comments