Module Name:    src
Committed By:   ryo
Date:           Thu Sep 12 09:20:23 UTC 2019

Modified Files:
        src/sys/ddb: db_access.c db_access.h db_examine.c

Log Message:
changes of r1.39 was incomplete. only "examin/m" could handle 'q'.
added support 'r','x','z','d','u', and 'o' with 'q' modifier on 32bit arch.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ddb/db_access.c
cvs rdiff -u -r1.13 -r1.14 src/sys/ddb/db_access.h
cvs rdiff -u -r1.39 -r1.40 src/sys/ddb/db_examine.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ddb/db_access.c
diff -u src/sys/ddb/db_access.c:1.24 src/sys/ddb/db_access.c:1.25
--- src/sys/ddb/db_access.c:1.24	Fri Aug 23 14:48:50 2019
+++ src/sys/ddb/db_access.c	Thu Sep 12 09:20:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_access.c,v 1.24 2019/08/23 14:48:50 kamil Exp $	*/
+/*	$NetBSD: db_access.c,v 1.25 2019/09/12 09:20:23 ryo Exp $	*/
 
 /*
  * Mach Operating System
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.24 2019/08/23 14:48:50 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.25 2019/09/12 09:20:23 ryo Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_kgdb.h"
@@ -82,6 +82,26 @@ db_get_value(db_addr_t addr, size_t size
 	return (value);
 }
 
+quad_t
+db_get_qvalue(db_addr_t addr, size_t size, bool is_signed)
+{
+	uint64_t data;
+
+	if (sizeof(db_expr_t) >= sizeof(quad_t) || size <= sizeof(db_expr_t)) {
+		if (is_signed)
+			return db_get_value(addr, size, true);
+		return (uint32_t)db_get_value(addr, size, false);
+	}
+
+	if (size != sizeof(data)) {
+		db_error("unnsupported size\n");
+		/*NOTREACHED*/
+	}
+
+	db_read_bytes(addr, sizeof(data), (char *)&data);
+	return data;
+}
+
 void
 db_put_value(db_addr_t addr, size_t size, db_expr_t value)
 {

Index: src/sys/ddb/db_access.h
diff -u src/sys/ddb/db_access.h:1.13 src/sys/ddb/db_access.h:1.14
--- src/sys/ddb/db_access.h:1.13	Sat Mar  7 22:02:17 2009
+++ src/sys/ddb/db_access.h	Thu Sep 12 09:20:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_access.h,v 1.13 2009/03/07 22:02:17 ad Exp $	*/
+/*	$NetBSD: db_access.h,v 1.14 2019/09/12 09:20:23 ryo Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,6 +33,7 @@
  * Data access functions for debugger.
  */
 db_expr_t	db_get_value(db_addr_t, size_t, bool);
+quad_t		db_get_qvalue(db_addr_t, size_t, bool);
 void		db_put_value(db_addr_t, size_t, db_expr_t);
 
 void		db_read_bytes(db_addr_t, size_t, char *);

Index: src/sys/ddb/db_examine.c
diff -u src/sys/ddb/db_examine.c:1.39 src/sys/ddb/db_examine.c:1.40
--- src/sys/ddb/db_examine.c:1.39	Tue Sep 10 09:32:05 2019
+++ src/sys/ddb/db_examine.c	Thu Sep 12 09:20:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_examine.c,v 1.39 2019/09/10 09:32:05 ryo Exp $	*/
+/*	$NetBSD: db_examine.c,v 1.40 2019/09/12 09:20:23 ryo Exp $	*/
 
 /*
  * Mach Operating System
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_examine.c,v 1.39 2019/09/10 09:32:05 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_examine.c,v 1.40 2019/09/12 09:20:23 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -70,7 +70,7 @@ static void
 db_examine(db_addr_t addr, char *fmt, int count)
 {
 	int		i, c;
-	db_expr_t	value;
+	quad_t		value;
 	int		size;
 	int		width;
 	int		bytes;
@@ -103,7 +103,7 @@ db_examine(db_addr_t addr, char *fmt, in
 				break;
 			case 'q':	/* quad-word */
 				size = 8;
-				width = 16;
+				width = 24;
 				break;
 			case 'L':	/* implementation maximum */
 				size = sizeof value;
@@ -114,27 +114,27 @@ db_examine(db_addr_t addr, char *fmt, in
 				break;
 			case 'p':
 				size = sizeof(void *);
-				value = db_get_value(addr, size, true);
+				value = db_get_value(addr, size, false);
 				addr += size;
 				db_printf("= 0x%lx ", (long)value);
 				db_printsym((db_addr_t)value, DB_STGY_ANY, db_printf);
 				db_printf("\n");
 				break;
 			case 'r':	/* signed, current radix */
-				value = db_get_value(addr, size, true);
+				value = db_get_qvalue(addr, size, true);
 				addr += size;
 				db_format_radix(tbuf, 24, value, false);
 				db_printf("%-*s", width, tbuf);
 				break;
 			case 'x':	/* unsigned hex */
-				value = db_get_value(addr, size, false);
+				value = db_get_qvalue(addr, size, false);
 				addr += size;
-				db_printf("%-*" DDB_EXPR_FMT "x", width, value);
+				db_printf("%-*" PRIx64, width, value);
 				break;
 			case 'm':	/* hex dump */
 				/*
 				 * Print off in chunks of size. Try to print 16
-				 * bytes at a time into 4 columns. This
+				 * bytes at a time into 16/size columns. This
 				 * loops modify's count extra times in order
 				 * to get the nicely formatted lines.
 				 */
@@ -152,7 +152,7 @@ db_examine(db_addr_t addr, char *fmt, in
 						    1, false);
 #endif
 						db_printf(
-						    "%02" DDB_EXPR_FMT "x",
+						    "%02" PRIx64,
 						    value);
 						bytes++;
 						if (!(bytes % size))
@@ -174,25 +174,25 @@ db_examine(db_addr_t addr, char *fmt, in
 				db_printf("\n");
 				break;
 			case 'z':	/* signed hex */
-				value = db_get_value(addr, size, true);
+				value = db_get_qvalue(addr, size, true);
 				addr += size;
 				db_format_hex(tbuf, 24, value, false);
 				db_printf("%-*s", width, tbuf);
 				break;
 			case 'd':	/* signed decimal */
-				value = db_get_value(addr, size, true);
+				value = db_get_qvalue(addr, size, true);
 				addr += size;
-				db_printf("%-*" DDB_EXPR_FMT "d", width, value);
+				db_printf("%-*" PRId64, width, value);
 				break;
 			case 'u':	/* unsigned decimal */
-				value = db_get_value(addr, size, false);
+				value = db_get_qvalue(addr, size, false);
 				addr += size;
-				db_printf("%-*" DDB_EXPR_FMT "u", width, value);
+				db_printf("%-*" PRIu64, width, value);
 				break;
 			case 'o':	/* unsigned octal */
-				value = db_get_value(addr, size, false);
+				value = db_get_qvalue(addr, size, false);
 				addr += size;
-				db_printf("%-*" DDB_EXPR_FMT "o", width, value);
+				db_printf("%-*" PRIo64, width, value);
 				break;
 			case 'c':	/* character */
 				value = db_get_value(addr, 1, false);

Reply via email to