1 /* $NetBSD: db_xxx.c,v 1.61 2009/05/24 21:41:25 ad Exp $ */
4 * Copyright (c) 1982, 1986, 1989, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * from: kern_proc.c 8.4 (Berkeley) 1/4/94
35 * Miscellaneous DDB functions that are intimate (xxx) with various
36 * data structures and functions used by the kernel (proc, callout).
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.61 2009/05/24 21:41:25 ad Exp $");
45 #include "opt_mqueue.h"
52 #include <sys/param.h>
53 #include <sys/systm.h>
54 #include <sys/kernel.h>
56 #include <sys/msgbuf.h>
57 #include <sys/callout.h>
59 #include <sys/filedesc.h>
60 #include <sys/lockdebug.h>
61 #include <sys/signalvar.h>
62 #include <sys/resourcevar.h>
65 #include <sys/kauth.h>
66 #include <sys/mqueue.h>
67 #include <sys/vnode.h>
68 #include <sys/module.h>
73 #include <ddb/db_user.h>
80 db_kill_proc(db_expr_t addr
, bool haddr
,
81 db_expr_t count
, const char *modif
)
84 db_printf("This command is not currently supported.\n");
89 db_kgdb_cmd(db_expr_t addr
, bool haddr
,
90 db_expr_t count
, const char *modif
)
93 kgdb_trap(db_trap_type
, DDB_REGS
);
99 db_show_files_cmd(db_expr_t addr
, bool haddr
,
100 db_expr_t count
, const char *modif
)
102 #ifdef _KERNEL /* XXX CRASH(8) */
115 p
= (struct proc
*) (uintptr_t) addr
;
119 for (i
= 0; i
< dt
->dt_nfiles
; i
++) {
120 if ((ff
= dt
->dt_ff
[i
]) == NULL
)
125 /* Only look at vnodes... */
126 if ((fp
!= NULL
) && (fp
->f_type
== DTYPE_VNODE
)) {
127 if (fp
->f_data
!= NULL
) {
128 vn
= (struct vnode
*) fp
->f_data
;
129 vfs_vnode_print(vn
, full
, db_printf
);
132 db_printf("\nv_uobj.vmobjlock lock details:\n");
133 lockdebug_lock_print(&(vn
->v_uobj
.vmobjlock
),
145 db_show_aio_jobs(db_expr_t addr
, bool haddr
,
146 db_expr_t count
, const char *modif
)
149 aio_print_jobs(db_printf
);
155 db_show_mqueue_cmd(db_expr_t addr
, bool haddr
,
156 db_expr_t count
, const char *modif
)
159 #ifdef _KERNEL /* XXX CRASH(8) */
160 mqueue_print_list(db_printf
);
166 db_show_module_cmd(db_expr_t addr
, bool haddr
,
167 db_expr_t count
, const char *modif
)
170 #ifdef _KERNEL /* XXX CRASH(8) */
171 module_print_list(db_printf
);
176 db_show_all_pools(db_expr_t addr
, bool haddr
,
177 db_expr_t count
, const char *modif
)
180 #ifdef _KERNEL /* XXX CRASH(8) */
181 pool_printall(modif
, db_printf
);
186 db_show_all_vmems(db_expr_t addr
, bool have_addr
,
187 db_expr_t count
, const char *modif
)
190 #ifdef _KERNEL /* XXX CRASH(8) */
191 vmem_printall(modif
, db_printf
);
196 db_dmesg(db_expr_t addr
, bool haddr
, db_expr_t count
, const char *modif
)
198 struct kern_msgbuf mb
, *mbp
;
201 char *p
, *bufdata
, ch
;
203 if (!db_read_int("msgbufenabled")) {
204 db_printf("message buffer not available\n");
207 mbp
= (struct kern_msgbuf
*)db_read_ptr("msgbufp");
208 db_read_bytes((db_addr_t
)mbp
, sizeof(mb
), (char *)&mb
);
209 if (mb
.msg_magic
!= MSG_MAGIC
) {
210 db_printf("message buffer not available\n");
214 bufdata
= &mbp
->msg_bufc
[0];
216 if (haddr
&& addr
< mb
.msg_bufs
)
221 for (newl
= skip
= i
= 0, p
= bufdata
+ mb
.msg_bufx
;
222 i
< mb
.msg_bufs
; i
++, p
++) {
223 if (p
== bufdata
+ mb
.msg_bufs
)
225 if (i
< mb
.msg_bufs
- print
) {
228 db_read_bytes((db_addr_t
)p
, sizeof(ch
), &ch
);
229 /* Skip "\n<.*>" syslog sequences. */
235 if (newl
&& ch
== '<') {
249 db_show_sched_qs(db_expr_t addr
, bool haddr
,
250 db_expr_t count
, const char *modif
)
253 #ifdef _KERNEL /* XXX CRASH(8) */
254 sched_print_runqueue(db_printf
);