Module Name: src Committed By: mlelstv Date: Sun Mar 4 07:14:51 UTC 2018
Modified Files: src/sys/ddb: db_command.c db_interface.h ddb.h files.ddb Added Files: src/sys/ddb: db_autoconf.c db_autoconf.h Log Message: Add command to print device list. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/ddb/db_autoconf.c src/sys/ddb/db_autoconf.h cvs rdiff -u -r1.148 -r1.149 src/sys/ddb/db_command.c cvs rdiff -u -r1.35 -r1.36 src/sys/ddb/db_interface.h cvs rdiff -u -r1.2 -r1.3 src/sys/ddb/ddb.h cvs rdiff -u -r1.11 -r1.12 src/sys/ddb/files.ddb 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_command.c diff -u src/sys/ddb/db_command.c:1.148 src/sys/ddb/db_command.c:1.149 --- src/sys/ddb/db_command.c:1.148 Wed Jan 11 12:17:34 2017 +++ src/sys/ddb/db_command.c Sun Mar 4 07:14:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.148 2017/01/11 12:17:34 joerg Exp $ */ +/* $NetBSD: db_command.c,v 1.149 2018/03/04 07:14:50 mlelstv Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.148 2017/01/11 12:17:34 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.149 2018/03/04 07:14:50 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -241,6 +241,7 @@ static const struct db_command db_show_c #endif { DDB_ADD_CMD("buf", db_buf_print_cmd, 0, "Print the struct buf at address.", "[/f] address",NULL) }, + { DDB_ADD_CMD("devices", db_show_all_devices, 0,NULL,NULL,NULL) }, { DDB_ADD_CMD("event", db_event_print_cmd, 0, "Print all the non-zero evcnt(9) event counters.", "[/fitm]",NULL) }, { DDB_ADD_CMD("files", db_show_files_cmd, 0, Index: src/sys/ddb/db_interface.h diff -u src/sys/ddb/db_interface.h:1.35 src/sys/ddb/db_interface.h:1.36 --- src/sys/ddb/db_interface.h:1.35 Fri Oct 27 12:25:15 2017 +++ src/sys/ddb/db_interface.h Sun Mar 4 07:14:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.h,v 1.35 2017/10/27 12:25:15 joerg Exp $ */ +/* $NetBSD: db_interface.h,v 1.36 2018/03/04 07:14:50 mlelstv Exp $ */ /*- * Copyright (c) 1995 The NetBSD Foundation, Inc. @@ -73,6 +73,13 @@ void db_show_module_cmd(db_expr_t, bool /* kern/subr_vmem.c */ void db_show_all_vmems(db_expr_t, bool, db_expr_t, const char *); +/* kern/subr_autoconf.c */ +void db_show_all_devices(db_expr_t, bool, db_expr_t, const char *); +void db_show_all_device(db_expr_t, bool, db_expr_t, const char *); + +/* kern/subr_disk.c, dev/dksubr.c */ +void db_show_disk(db_expr_t, bool, db_expr_t, const char *); + #define db_stacktrace() \ db_stack_trace_print((db_expr_t)(intptr_t)__builtin_frame_address(0), \ true, 65535, "", printf) Index: src/sys/ddb/ddb.h diff -u src/sys/ddb/ddb.h:1.2 src/sys/ddb/ddb.h:1.3 --- src/sys/ddb/ddb.h:1.2 Fri Apr 10 22:29:30 2009 +++ src/sys/ddb/ddb.h Sun Mar 4 07:14:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ddb.h,v 1.2 2009/04/10 22:29:30 ad Exp $ */ +/* $NetBSD: ddb.h,v 1.3 2018/03/04 07:14:50 mlelstv Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -49,5 +49,6 @@ #include <ddb/db_access.h> #include <ddb/db_proc.h> #include <ddb/db_cpu.h> +#include <ddb/db_autoconf.h> #endif /* _DDB_DDB_H_ */ Index: src/sys/ddb/files.ddb diff -u src/sys/ddb/files.ddb:1.11 src/sys/ddb/files.ddb:1.12 --- src/sys/ddb/files.ddb:1.11 Thu Dec 28 17:51:19 2017 +++ src/sys/ddb/files.ddb Sun Mar 4 07:14:50 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.ddb,v 1.11 2017/12/28 17:51:19 christos Exp $ +# $NetBSD: files.ddb,v 1.12 2018/03/04 07:14:50 mlelstv Exp $ # # DDB options @@ -10,6 +10,7 @@ defparam opt_ddbparam.h DDB_FROMCONSOLE define ddb file ddb/db_access.c ddb | kgdb +file ddb/db_autoconf.c ddb file ddb/db_break.c ddb file ddb/db_command.c ddb file ddb/db_cpu.c ddb Added files: Index: src/sys/ddb/db_autoconf.c diff -u /dev/null src/sys/ddb/db_autoconf.c:1.1 --- /dev/null Sun Mar 4 07:14:51 2018 +++ src/sys/ddb/db_autoconf.c Sun Mar 4 07:14:50 2018 @@ -0,0 +1,89 @@ +/* $NetBSD: db_autoconf.c,v 1.1 2018/03/04 07:14:50 mlelstv Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: db_autoconf.c,v 1.1 2018/03/04 07:14:50 mlelstv Exp $"); + +#ifndef _KERNEL +#include <stdbool.h> +#endif + +#include <sys/param.h> +#include <sys/device.h> + +#include <ddb/ddb.h> + +static const char *classnames[] = { + "dull", "cpu", "disk", "ifnet", "tape", "tty", + "audiodev", "displaydev", "bus", "virtual" +}; + +struct device * +db_device_first(void) +{ + + return db_read_ptr("alldevs"); +} + +struct device * +db_device_next(struct device *dv) +{ + + db_read_bytes((db_addr_t)&dv->dv_list.tqe_next, sizeof(dv), + (char *)&dv); + return dv; +} + +void +db_show_all_devices(db_expr_t addr, bool haddr, db_expr_t count, + const char *modif) +{ + struct device buf; + struct device *dv; + const char *cl; + + db_printf("%-16s %10s %4s %18s %18s\n", + "NAME","CLASS","UNIT","DEVICE_T","PRIVATE"); + + for (dv = db_device_first(); dv != NULL; dv = db_device_next(dv)) { + db_read_bytes((db_addr_t)dv, sizeof(buf), (char *)&buf); + + if (buf.dv_class < 0 || + buf.dv_class > __arraycount(classnames)) + cl = "????"; + else + cl = classnames[buf.dv_class]; + + db_printf("%-16.16s", buf.dv_xname); + db_printf(" %10s", cl); + db_printf(" %4u", buf.dv_unit); + db_printf(" %18" PRIxPTR, (uintptr_t)dv); + db_printf(" %18" PRIxPTR, (uintptr_t)buf.dv_private); + db_printf("\n"); + } +} Index: src/sys/ddb/db_autoconf.h diff -u /dev/null src/sys/ddb/db_autoconf.h:1.1 --- /dev/null Sun Mar 4 07:14:51 2018 +++ src/sys/ddb/db_autoconf.h Sun Mar 4 07:14:50 2018 @@ -0,0 +1,35 @@ +/* $NetBSD: db_autoconf.h,v 1.1 2018/03/04 07:14:50 mlelstv Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DDB_DB_AUTOCONF_H_ +#define _DDB_DB_AUTOCONF_H_ + +struct device *db_device_first(void); +struct device *db_device_next(struct device *); + +#endif /* _DDB_DB_AUTOCONF_H_ */