Subject: kern/9569: ddb doesn't keep "count"
To: None <gnats-bugs@gnats.netbsd.org>
From: John Hawkinson <jhawk@mit.edu>
List: netbsd-bugs
Date: 03/07/2000 23:54:40
>Number:         9569
>Category:       kern
>Synopsis:       ddb doesn't keep "count"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Mar  7 23:54:00 2000
>Last-Modified:
>Originator:     John Hawkinson
>Organization:
MIT
>Release:        NetBSD 1.4.1
>Environment:
System: NetBSD zorkmid.mit.edu 1.4.1 NetBSD 1.4.1 (ZORKMID) #59: Wed Mar 8 02:08:10 EST 2000 jhawk@zorkmid.mit.edu:/usr/src/sys/arch/i386/compile/ZORKMID i386


>Description:
	ddb doesn't preserve "count" when you use the "hit enter to
repeat the last command". This is inconvenient if you're paging
through dissassembly, i.e.

		x/i fxp_init,8
		<nl>
		<nl>
		<nl>

prints the first 8 instructions, then each time you hit <nl>, you only
see one instruction rather than the next 8. Makes for slow going.
Additionally, you'd like to be able to re-execute the previous command
with a different count only by specifying the count, rather than
the command and argument.

This patch adds support for both.

>How-To-Repeat:
	I don't have a handy serial console so the above will have to do.
>Fix:
	
===================================================================
RCS file: sys/ddb/RCS/db_command.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** sys/ddb/db_command.c	2000/03/08 02:37:30	1.1
--- sys/ddb/db_command.c	2000/03/08 07:26:37	1.2
***************
*** 163,175 ****
  	boolean_t	have_addr = FALSE;
  	int		result;
  
  	t = db_read_token();
! 	if (t == tEOL) {
! 	    /* empty line repeats last command, at 'next' */
  	    cmd = *last_cmdp;
  	    addr = (db_expr_t)db_next;
  	    have_addr = FALSE;
- 	    count = 1;
  	    modif[0] = '\0';
  	}
  	else if (t == tEXCL) {
--- 163,187 ----
  	boolean_t	have_addr = FALSE;
  	int		result;
  
+ 	static db_expr_t               last_count = 0;
+ 
  	t = db_read_token();
! 	if ((t == tEOL) || (t == tCOMMA)) {
! 	    /*
! 	     * An empty line repeats last command, at 'next'.
! 	     * Only a count repeats the last command with the new count.
! 	     */
  	    cmd = *last_cmdp;
  	    addr = (db_expr_t)db_next;
+ 	    if (t == tCOMMA) {
+ 	      if (!db_expression(&count)) {
+ 		db_printf("Count missing\n");
+ 		db_flush_lex();
+ 		return;
+ 	      }
+ 	    } else
+ 	      count = last_count;
  	    have_addr = FALSE;
  	    modif[0] = '\0';
  	}
  	else if (t == tEXCL) {
***************
*** 262,267 ****
--- 274,280 ----
  	    }
  	}
  	*last_cmdp = cmd;
+ 	last_count = count;
  	if (cmd != 0) {
  	    /*
  	     * Execute the command.
===================================================================
RCS file: share/man/man4/RCS/ddb.4,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** share/man/man4/ddb.4	2000/03/08 07:27:45	1.1
--- share/man/man4/ddb.4	2000/03/08 07:34:04	1.2
***************
*** 177,185 ****
  .Pp
  A blank line repeats the previous command from the address
  .Ar next
! with a
  .Cm count
! of 1 and no modifiers.
  Specifying
  .Cm address
  sets
--- 177,185 ----
  .Pp
  A blank line repeats the previous command from the address
  .Ar next
! with the previous
  .Cm count
! and no modifiers.
  Specifying
  .Cm address
  sets
***************
*** 193,198 ****
--- 193,207 ----
  A missing
  .Cm count
  is taken to be 1 for printing commands, and infinity for stack traces.
+ .Pp
+ The syntax:
+ .Bd -ragged -offset indent
+ .Ic Cm , Ns Ar count
+ .Ed
+ .Pp
+ repeats the previous command, just as a blank line does, but with
+ the specified
+ .Cm count .
  .Pp
  .Nm
  has a
>Audit-Trail:
>Unformatted: