From 6e5e6fa95872363f0872a6cfb805e8df2d1dfc30 Mon Sep 17 00:00:00 2001 From: ryo Date: Thu, 12 Sep 2019 09:20:23 +0000 Subject: [PATCH] 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. --- sys/ddb/db_access.c | 24 ++++++++++++++++++++++-- sys/ddb/db_access.h | 3 ++- sys/ddb/db_examine.c | 34 +++++++++++++++++----------------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/sys/ddb/db_access.c b/sys/ddb/db_access.c index 7d8f15a60880..353e93ea0cd4 100644 --- a/sys/ddb/db_access.c +++ b/sys/ddb/db_access.c @@ -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 -__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, bool is_signed) 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) { diff --git a/sys/ddb/db_access.h b/sys/ddb/db_access.h index f564c7c01604..823d10359ff7 100644 --- a/sys/ddb/db_access.h +++ b/sys/ddb/db_access.h @@ -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 *); diff --git a/sys/ddb/db_examine.c b/sys/ddb/db_examine.c index 794a270484e7..e79ab61f02e6 100644 --- a/sys/ddb/db_examine.c +++ b/sys/ddb/db_examine.c @@ -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 -__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 #include @@ -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, int count) 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, int count) 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, int count) 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, int count) 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);