Sat Oct 7 20:00:40 2023 UTC ()
Add db_print_timespec().


(ad)
diff -r1.36 -r1.37 src/sys/ddb/db_output.c
diff -r1.22 -r1.23 src/sys/ddb/db_output.h

cvs diff -r1.36 -r1.37 src/sys/ddb/db_output.c (expand / switch to unified diff)

--- src/sys/ddb/db_output.c 2020/01/26 01:42:55 1.36
+++ src/sys/ddb/db_output.c 2023/10/07 20:00:39 1.37
@@ -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
244void 244void
245db_format_hex(char *buf, size_t bufsiz, quad_t val, int altflag) 245db_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 */
 261void
 262db_print_timespec(struct timespec *ts)
 263{
 264
 265 db_printf("%" PRIu64 ".%09ld", (uint64_t)ts->tv_sec, ts->tv_nsec);
 266}

cvs diff -r1.22 -r1.23 src/sys/ddb/db_output.h (expand / switch to unified diff)

--- src/sys/ddb/db_output.h 2020/06/28 04:06:14 1.22
+++ src/sys/ddb/db_output.h 2023/10/07 20:00:39 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_output.h,v 1.22 2020/06/28 04:06:14 simonb Exp $ */ 1/* $NetBSD: db_output.h,v 1.23 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"
@@ -35,24 +35,25 @@ @@ -35,24 +35,25 @@
35#include <sys/stdarg.h> 35#include <sys/stdarg.h>
36 36
37/* 37/*
38 * Printing routines for kernel debugger. 38 * Printing routines for kernel debugger.
39 */ 39 */
40void db_force_whitespace(void); 40void db_force_whitespace(void);
41void db_putchar(int); 41void db_putchar(int);
42int db_print_position(void); 42int db_print_position(void);
43void db_printf(const char *, ...) __printflike(1, 2); 43void db_printf(const char *, ...) __printflike(1, 2);
44void db_vprintf(const char *, va_list) __printflike(1, 0); 44void db_vprintf(const char *, va_list) __printflike(1, 0);
45void db_format_radix(char *, size_t, quad_t, int); 45void db_format_radix(char *, size_t, quad_t, int);
46void db_format_hex(char *, size_t, quad_t, int); 46void db_format_hex(char *, size_t, quad_t, int);
47void db_end_line(void); 47void db_end_line(void);
 48void db_print_timespec(struct timespec *);
48 49
49extern int db_max_line; 50extern int db_max_line;
50extern int db_max_width; 51extern int db_max_width;
51extern int db_output_line; 52extern int db_output_line;
52extern int db_radix; 53extern int db_radix;
53extern int db_tab_stop_width; 54extern int db_tab_stop_width;
54 55
55#define DB_NEXT_TAB(i) \ 56#define DB_NEXT_TAB(i) \
56 ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width) 57 ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width)
57 58
58#endif /* _DDB_DB_OUTPUT_H_ */ 59#endif /* _DDB_DB_OUTPUT_H_ */