Sun Sep 22 12:57:34 2019 UTC ()
fix "show kernhist".

set addr = 0 if we don't have_addr and avoid using random garbage in addr.


(mrg)
diff -r1.160 -r1.161 src/sys/ddb/db_command.c

cvs diff -r1.160 -r1.161 src/sys/ddb/db_command.c (expand / switch to unified diff)

--- src/sys/ddb/db_command.c 2018/09/17 01:49:54 1.160
+++ src/sys/ddb/db_command.c 2019/09/22 12:57:34 1.161
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_command.c,v 1.160 2018/09/17 01:49:54 kre Exp $ */ 1/* $NetBSD: db_command.c,v 1.161 2019/09/22 12:57:34 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Adam Hamsik, and by Andrew Doran. 8 * by Adam Hamsik, and by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -50,27 +50,27 @@ @@ -50,27 +50,27 @@
50 * School of Computer Science 50 * School of Computer Science
51 * Carnegie Mellon University 51 * Carnegie Mellon University
52 * Pittsburgh PA 15213-3890 52 * Pittsburgh PA 15213-3890
53 * 53 *
54 * any improvements or extensions that they make and grant Carnegie the 54 * any improvements or extensions that they make and grant Carnegie the
55 * rights to redistribute these changes. 55 * rights to redistribute these changes.
56 */ 56 */
57 57
58/* 58/*
59 * Command dispatcher. 59 * Command dispatcher.
60 */ 60 */
61 61
62#include <sys/cdefs.h> 62#include <sys/cdefs.h>
63__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.160 2018/09/17 01:49:54 kre Exp $"); 63__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.161 2019/09/22 12:57:34 mrg Exp $");
64 64
65#ifdef _KERNEL_OPT 65#ifdef _KERNEL_OPT
66#include "opt_aio.h" 66#include "opt_aio.h"
67#include "opt_ddb.h" 67#include "opt_ddb.h"
68#include "opt_kgdb.h" 68#include "opt_kgdb.h"
69#include "opt_mqueue.h" 69#include "opt_mqueue.h"
70#include "opt_inet.h" 70#include "opt_inet.h"
71#include "opt_kernhist.h" 71#include "opt_kernhist.h"
72#include "opt_ddbparam.h" 72#include "opt_ddbparam.h"
73#include "opt_multiprocessor.h" 73#include "opt_multiprocessor.h"
74#endif 74#endif
75 75
76#include <sys/param.h> 76#include <sys/param.h>
@@ -1231,26 +1231,28 @@ db_socket_print_cmd(db_expr_t addr, bool @@ -1231,26 +1231,28 @@ db_socket_print_cmd(db_expr_t addr, bool
1231 1231
1232#ifdef _KERNEL /* XXX CRASH(8) */ 1232#ifdef _KERNEL /* XXX CRASH(8) */
1233 socket_print(modif, db_printf); 1233 socket_print(modif, db_printf);
1234#endif 1234#endif
1235} 1235}
1236 1236
1237#ifdef KERNHIST 1237#ifdef KERNHIST
1238/*ARGSUSED*/ 1238/*ARGSUSED*/
1239static void 1239static void
1240db_kernhist_print_cmd(db_expr_t addr, bool have_addr, 1240db_kernhist_print_cmd(db_expr_t addr, bool have_addr,
1241 db_expr_t count, const char *modif) 1241 db_expr_t count, const char *modif)
1242{ 1242{
1243 1243
 1244 if (!have_addr)
 1245 addr = 0;
1244 kernhist_print((void *)(uintptr_t)addr, count, modif, db_printf); 1246 kernhist_print((void *)(uintptr_t)addr, count, modif, db_printf);
1245} 1247}
1246#endif 1248#endif
1247 1249
1248/*ARGSUSED*/ 1250/*ARGSUSED*/
1249static void 1251static void
1250db_lock_print_cmd(db_expr_t addr, bool have_addr, 1252db_lock_print_cmd(db_expr_t addr, bool have_addr,
1251 db_expr_t count, const char *modif) 1253 db_expr_t count, const char *modif)
1252{ 1254{
1253 1255
1254#ifdef _KERNEL /* XXX CRASH(8) */ 1256#ifdef _KERNEL /* XXX CRASH(8) */
1255 lockdebug_lock_print(have_addr ? (void *)(uintptr_t)addr : NULL, 1257 lockdebug_lock_print(have_addr ? (void *)(uintptr_t)addr : NULL,
1256 db_printf); 1258 db_printf);