Subject: kern/835: Kernel and ddb printf don't agree on %r format handling
To: None <gnats-admin@NetBSD.ORG>
From: None <osymh@lightning.oscs.montana.edu>
List: netbsd-bugs
Date: 03/01/1995 21:35:14
>Number:         835
>Category:       kern
>Synopsis:       Kernel and ddb printf treat %r format differently
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar  1 21:35:12 1995
>Originator:     Michael L. Hitch
>Organization:
"	Montana State University"
>Release:        NetBSD-current 02/26/95<NetBSD-current source date>
>Environment:
System: NetBSD amiga2.oscs.montana.edu 1.0A NetBSD 1.0A (ZEUS) #950213-0: Tue Feb 14 00:23:01 MST 1995 root@amiga2.oscs.montana.edu:/altroot/tmp/src/sys/arch/amiga/compile/ZEUS amiga


>Description:
	The kernel printf uses %r to specify a format control string and
	list of arguments.  The vm_map_print() and vm_object_print() use
	iprintf() in vm_glue.c that uses the %r format to pass the control
	string and argument list to the passed print routine.  If the
	print routine is the kernel printf, it will work.  Most calls
	of vm_map_print() and vm_object_print() are from the ddb debugger.
	The ddb debugger printf routine uses %r to specify a dynamic
	radix for numeric output.  Trying to display map or object data
	from the debugger fails.
>How-To-Repeat:
	Enter the ddb debugger, do "ps/m", and try to display the map entries
	for a process.  The output won't make any sense.
>Fix:
	A different format character needs to be used for one or the other
	uses of %r.

	A rather crude work-around I am currently using uses the "sharpflag"
	to detect which usage the %r refers to.  The ddb usage as a radix
	appears to always (as far as I can tell) use %#r, so sharpflag
	will be set if the %r is from ddb, otherwise the %r is from
	vm_glue.c.

diff -cr /usr/src/sys/ddb/db_output.c sys/ddb/db_output.c
*** /usr/src/sys/ddb/db_output.c	Thu Jun 30 04:36:42 1994
--- sys/ddb/db_output.c	Sun Feb 26 11:39:52 1995
***************
*** 338,343 ****
--- 338,350 ----
  					db_putchar (padc);
  			break;
  		case 'r':
+ #if 1
+ 			if (!sharpflag) {
+ 				p = va_arg(ap, char *);
+ 				db_printf_guts(p, va_arg(ap, va_list));
+ 				break;
+ 			}
+ #endif
  			ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
  			if ((long)ul < 0) {
  				neg = 1;

>Audit-Trail:
>Unformatted: