| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: db_output.c,v 1.36 2020/01/26 01:42:55 uwe Exp $ */ | | 1 | /* $NetBSD: db_output.c,v 1.37 2023/10/07 20:00:39 ad Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Mach Operating System | | 4 | * Mach Operating System |
5 | * Copyright (c) 1991,1990 Carnegie Mellon University | | 5 | * Copyright (c) 1991,1990 Carnegie Mellon University |
6 | * All Rights Reserved. | | 6 | * All Rights Reserved. |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify and distribute this software and its | | 8 | * Permission to use, copy, modify and distribute this software and its |
9 | * documentation is hereby granted, provided that both the copyright | | 9 | * documentation is hereby granted, provided that both the copyright |
10 | * notice and this permission notice appear in all copies of the | | 10 | * notice and this permission notice appear in all copies of the |
11 | * software, derivative works or modified versions, and any portions | | 11 | * software, derivative works or modified versions, and any portions |
12 | * thereof, and that both notices appear in supporting documentation. | | 12 | * thereof, and that both notices appear in supporting documentation. |
13 | * | | 13 | * |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * any improvements or extensions that they make and grant Carnegie the | | 25 | * any improvements or extensions that they make and grant Carnegie the |
26 | * rights to redistribute these changes. | | 26 | * rights to redistribute these changes. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * Printf and character output for debugger. | | 30 | * Printf and character output for debugger. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #ifdef _KERNEL_OPT | | 33 | #ifdef _KERNEL_OPT |
34 | #include "opt_ddbparam.h" | | 34 | #include "opt_ddbparam.h" |
35 | #endif | | 35 | #endif |
36 | | | 36 | |
37 | #include <sys/cdefs.h> | | 37 | #include <sys/cdefs.h> |
38 | __KERNEL_RCSID(0, "$NetBSD: db_output.c,v 1.36 2020/01/26 01:42:55 uwe Exp $"); | | 38 | __KERNEL_RCSID(0, "$NetBSD: db_output.c,v 1.37 2023/10/07 20:00:39 ad Exp $"); |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/systm.h> | | 41 | #include <sys/systm.h> |
42 | #include <sys/stdarg.h> | | 42 | #include <sys/stdarg.h> |
43 | | | 43 | |
44 | #include <dev/cons.h> | | 44 | #include <dev/cons.h> |
45 | | | 45 | |
46 | #include <ddb/ddb.h> | | 46 | #include <ddb/ddb.h> |
47 | | | 47 | |
48 | /* | | 48 | /* |
49 | * Character output - tracks position in line. | | 49 | * Character output - tracks position in line. |
50 | * To do this correctly, we should know how wide | | 50 | * To do this correctly, we should know how wide |
51 | * the output device is - then we could zero | | 51 | * the output device is - then we could zero |
| @@ -244,13 +244,23 @@ db_format_radix(char *buf, size_t bufsiz | | | @@ -244,13 +244,23 @@ db_format_radix(char *buf, size_t bufsiz |
244 | void | | 244 | void |
245 | db_format_hex(char *buf, size_t bufsiz, quad_t val, int altflag) | | 245 | db_format_hex(char *buf, size_t bufsiz, quad_t val, int altflag) |
246 | { | | 246 | { |
247 | /* Only use alternate form if val is nonzero. */ | | 247 | /* Only use alternate form if val is nonzero. */ |
248 | const char *fmt = (altflag && val) ? "-%#qx" : "-%qx"; | | 248 | const char *fmt = (altflag && val) ? "-%#qx" : "-%qx"; |
249 | | | 249 | |
250 | if (val < 0) | | 250 | if (val < 0) |
251 | val = -val; | | 251 | val = -val; |
252 | else | | 252 | else |
253 | ++fmt; | | 253 | ++fmt; |
254 | | | 254 | |
255 | snprintf(buf, bufsiz, fmt, val); | | 255 | snprintf(buf, bufsiz, fmt, val); |
256 | } | | 256 | } |
| | | 257 | |
| | | 258 | /* |
| | | 259 | * Print out a timespec value. |
| | | 260 | */ |
| | | 261 | void |
| | | 262 | db_print_timespec(struct timespec *ts) |
| | | 263 | { |
| | | 264 | |
| | | 265 | db_printf("%" PRIu64 ".%09ld", (uint64_t)ts->tv_sec, ts->tv_nsec); |
| | | 266 | } |