4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 Joyent, Inc.
25 * Copyright (c) 2013 by Delphix. All rights reserved.
28 #include <mdb/mdb_param.h>
29 #include <mdb/mdb_modapi.h>
30 #include <mdb/mdb_ks.h>
31 #include <mdb/mdb_ctf.h>
33 #include <sys/types.h>
34 #include <sys/thread.h>
35 #include <sys/session.h>
39 #include <sys/t_lock.h>
40 #include <sys/callo.h>
41 #include <sys/priocntl.h>
42 #include <sys/class.h>
43 #include <sys/regset.h>
44 #include <sys/stack.h>
45 #include <sys/cpuvar.h>
46 #include <sys/vnode.h>
48 #include <sys/flock_impl.h>
49 #include <sys/kmem_impl.h>
50 #include <sys/vmem_impl.h>
51 #include <sys/kstat.h>
52 #include <sys/dditypes.h>
53 #include <sys/ddi_impldefs.h>
54 #include <sys/sysmacros.h>
55 #include <sys/sysconf.h>
57 #include <sys/project.h>
58 #include <sys/errorq_impl.h>
59 #include <sys/cred_impl.h>
61 #include <sys/panic.h>
63 #include <sys/port_impl.h>
70 #include "cpupart_mdb.h"
75 #include "ddi_periodic.h"
78 #include "findstack.h"
94 #include "ndievents.h"
102 #include "sysevent.h"
106 #include "typegraph.h"
112 * Surely this is defined somewhere...
125 pstat2ch(uchar_t state
)
128 case SSLEEP
: return ('S');
129 case SRUN
: return ('R');
130 case SZOMB
: return ('Z');
131 case SIDL
: return ('I');
132 case SONPROC
: return ('O');
133 case SSTOP
: return ('T');
134 case SWAIT
: return ('W');
135 default: return ('?');
139 #define PS_PRTTHREADS 0x1
140 #define PS_PRTLWPS 0x2
141 #define PS_PSARGS 0x4
143 #define PS_PROJECTS 0x10
144 #define PS_ZONES 0x20
147 ps_threadprint(uintptr_t addr
, const void *data
, void *private)
149 const kthread_t
*t
= (const kthread_t
*)data
;
150 uint_t prt_flags
= *((uint_t
*)private);
152 static const mdb_bitmask_t t_state_bits
[] = {
153 { "TS_FREE", UINT_MAX
, TS_FREE
},
154 { "TS_SLEEP", TS_SLEEP
, TS_SLEEP
},
155 { "TS_RUN", TS_RUN
, TS_RUN
},
156 { "TS_ONPROC", TS_ONPROC
, TS_ONPROC
},
157 { "TS_ZOMB", TS_ZOMB
, TS_ZOMB
},
158 { "TS_STOPPED", TS_STOPPED
, TS_STOPPED
},
159 { "TS_WAIT", TS_WAIT
, TS_WAIT
},
163 if (prt_flags
& PS_PRTTHREADS
)
164 mdb_printf("\tT %?a <%b>\n", addr
, t
->t_state
, t_state_bits
);
166 if (prt_flags
& PS_PRTLWPS
)
167 mdb_printf("\tL %?a ID: %u\n", t
->t_lwp
, t
->t_tid
);
172 typedef struct mdb_pflags_proc
{
180 pflags(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
182 mdb_pflags_proc_t pr
;
185 static const mdb_bitmask_t p_flag_bits
[] = {
186 { "SSYS", SSYS
, SSYS
},
187 { "SEXITING", SEXITING
, SEXITING
},
188 { "SITBUSY", SITBUSY
, SITBUSY
},
189 { "SFORKING", SFORKING
, SFORKING
},
190 { "SWATCHOK", SWATCHOK
, SWATCHOK
},
191 { "SKILLED", SKILLED
, SKILLED
},
192 { "SSCONT", SSCONT
, SSCONT
},
193 { "SZONETOP", SZONETOP
, SZONETOP
},
194 { "SEXTKILLED", SEXTKILLED
, SEXTKILLED
},
195 { "SUGID", SUGID
, SUGID
},
196 { "SEXECED", SEXECED
, SEXECED
},
197 { "SJCTL", SJCTL
, SJCTL
},
198 { "SNOWAIT", SNOWAIT
, SNOWAIT
},
199 { "SVFORK", SVFORK
, SVFORK
},
200 { "SVFWAIT", SVFWAIT
, SVFWAIT
},
201 { "SEXITLWPS", SEXITLWPS
, SEXITLWPS
},
202 { "SHOLDFORK", SHOLDFORK
, SHOLDFORK
},
203 { "SHOLDFORK1", SHOLDFORK1
, SHOLDFORK1
},
204 { "SCOREDUMP", SCOREDUMP
, SCOREDUMP
},
205 { "SMSACCT", SMSACCT
, SMSACCT
},
206 { "SLWPWRAP", SLWPWRAP
, SLWPWRAP
},
207 { "SAUTOLPG", SAUTOLPG
, SAUTOLPG
},
208 { "SNOCD", SNOCD
, SNOCD
},
209 { "SHOLDWATCH", SHOLDWATCH
, SHOLDWATCH
},
210 { "SMSFORK", SMSFORK
, SMSFORK
},
211 { "SDOCORE", SDOCORE
, SDOCORE
},
215 static const mdb_bitmask_t p_pidflag_bits
[] = {
216 { "CLDPEND", CLDPEND
, CLDPEND
},
217 { "CLDCONT", CLDCONT
, CLDCONT
},
218 { "CLDNOSIGCHLD", CLDNOSIGCHLD
, CLDNOSIGCHLD
},
219 { "CLDWAITPID", CLDWAITPID
, CLDWAITPID
},
223 static const mdb_bitmask_t p_proc_flag_bits
[] = {
224 { "P_PR_TRACE", P_PR_TRACE
, P_PR_TRACE
},
225 { "P_PR_PTRACE", P_PR_PTRACE
, P_PR_PTRACE
},
226 { "P_PR_FORK", P_PR_FORK
, P_PR_FORK
},
227 { "P_PR_LOCK", P_PR_LOCK
, P_PR_LOCK
},
228 { "P_PR_ASYNC", P_PR_ASYNC
, P_PR_ASYNC
},
229 { "P_PR_EXEC", P_PR_EXEC
, P_PR_EXEC
},
230 { "P_PR_BPTADJ", P_PR_BPTADJ
, P_PR_BPTADJ
},
231 { "P_PR_RUNLCL", P_PR_RUNLCL
, P_PR_RUNLCL
},
232 { "P_PR_KILLCL", P_PR_KILLCL
, P_PR_KILLCL
},
236 if (!(flags
& DCMD_ADDRSPEC
)) {
237 if (mdb_walk_dcmd("proc", "pflags", argc
, argv
) == -1) {
238 mdb_warn("can't walk 'proc'");
244 if (mdb_ctf_vread(&pr
, "proc_t", "mdb_pflags_proc_t", addr
, 0) == -1 ||
245 mdb_vread(&pid
, sizeof (pid
), (uintptr_t)pr
.p_pidp
) == -1) {
246 mdb_warn("cannot read proc_t or pid");
250 mdb_printf("%p [pid %d]:\n", addr
, pid
.pid_id
);
251 mdb_printf("\tp_flag: %08x <%b>\n", pr
.p_flag
, pr
.p_flag
,
253 mdb_printf("\tp_pidflag: %08x <%b>\n", pr
.p_pidflag
, pr
.p_pidflag
,
255 mdb_printf("\tp_proc_flag: %08x <%b>\n", pr
.p_proc_flag
, pr
.p_proc_flag
,
261 typedef struct mdb_ps_proc
{
266 struct sess
*p_sessp
;
272 char u_comm
[MAXCOMLEN
+ 1];
273 char u_psargs
[PSARGSZ
];
278 ps(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
280 uint_t prt_flags
= 0;
282 struct pid pid
, pgid
, sid
;
289 if (!(flags
& DCMD_ADDRSPEC
)) {
290 if (mdb_walk_dcmd("proc", "ps", argc
, argv
) == -1) {
291 mdb_warn("can't walk 'proc'");
297 if (mdb_getopts(argc
, argv
,
298 'f', MDB_OPT_SETBITS
, PS_PSARGS
, &prt_flags
,
299 'l', MDB_OPT_SETBITS
, PS_PRTLWPS
, &prt_flags
,
300 'T', MDB_OPT_SETBITS
, PS_TASKS
, &prt_flags
,
301 'P', MDB_OPT_SETBITS
, PS_PROJECTS
, &prt_flags
,
302 'z', MDB_OPT_SETBITS
, PS_ZONES
, &prt_flags
,
303 't', MDB_OPT_SETBITS
, PS_PRTTHREADS
, &prt_flags
, NULL
) != argc
)
306 if (DCMD_HDRSPEC(flags
)) {
307 mdb_printf("%<u>%1s %6s %6s %6s %6s ",
308 "S", "PID", "PPID", "PGID", "SID");
309 if (prt_flags
& PS_TASKS
)
310 mdb_printf("%5s ", "TASK");
311 if (prt_flags
& PS_PROJECTS
)
312 mdb_printf("%5s ", "PROJ");
313 if (prt_flags
& PS_ZONES
)
314 mdb_printf("%5s ", "ZONE");
315 mdb_printf("%6s %10s %?s %s%</u>\n",
316 "UID", "FLAGS", "ADDR", "NAME");
319 if (mdb_ctf_vread(&pr
, "proc_t", "mdb_ps_proc_t", addr
, 0) == -1)
322 mdb_vread(&pid
, sizeof (pid
), (uintptr_t)pr
.p_pidp
);
323 mdb_vread(&pgid
, sizeof (pgid
), (uintptr_t)pr
.p_pgidp
);
324 mdb_vread(&cred
, sizeof (cred
), (uintptr_t)pr
.p_cred
);
325 mdb_vread(&session
, sizeof (session
), (uintptr_t)pr
.p_sessp
);
326 mdb_vread(&sid
, sizeof (sid
), (uintptr_t)session
.s_sidp
);
327 if (prt_flags
& (PS_TASKS
| PS_PROJECTS
))
328 mdb_vread(&tk
, sizeof (tk
), (uintptr_t)pr
.p_task
);
329 if (prt_flags
& PS_PROJECTS
)
330 mdb_vread(&pj
, sizeof (pj
), (uintptr_t)tk
.tk_proj
);
331 if (prt_flags
& PS_ZONES
)
332 mdb_vread(&zn
, sizeof (zn
), (uintptr_t)pr
.p_zone
);
334 mdb_printf("%c %6d %6d %6d %6d ",
335 pstat2ch(pr
.p_stat
), pid
.pid_id
, pr
.p_ppid
, pgid
.pid_id
,
337 if (prt_flags
& PS_TASKS
)
338 mdb_printf("%5d ", tk
.tk_tkid
);
339 if (prt_flags
& PS_PROJECTS
)
340 mdb_printf("%5d ", pj
.kpj_id
);
341 if (prt_flags
& PS_ZONES
)
342 mdb_printf("%5d ", zn
.zone_id
);
343 mdb_printf("%6d 0x%08x %0?p %s\n",
344 cred
.cr_uid
, pr
.p_flag
, addr
,
345 (prt_flags
& PS_PSARGS
) ? pr
.p_user
.u_psargs
: pr
.p_user
.u_comm
);
347 if (prt_flags
& ~PS_PSARGS
)
348 (void) mdb_pwalk("thread", ps_threadprint
, &prt_flags
, addr
);
353 #define PG_NEWEST 0x0001
354 #define PG_OLDEST 0x0002
355 #define PG_PIPE_OUT 0x0004
356 #define PG_EXACT_MATCH 0x0008
358 typedef struct pgrep_data
{
369 typedef struct mdb_pgrep_proc
{
372 char u_comm
[MAXCOMLEN
+ 1];
378 pgrep_cb(uintptr_t addr
, const void *ignored
, void *data
)
381 pgrep_data_t
*pgp
= data
;
386 if (mdb_ctf_vread(&p
, "proc_t", "mdb_pgrep_proc_t", addr
, 0) == -1)
390 * kmdb doesn't have access to the reg* functions, so we fall back
394 if ((pgp
->pg_flags
& PG_EXACT_MATCH
) ?
395 (strcmp(p
.p_user
.u_comm
, pgp
->pg_pat
) != 0) :
396 (strstr(p
.p_user
.u_comm
, pgp
->pg_pat
) == NULL
))
399 if (regexec(&pgp
->pg_reg
, p
.p_user
.u_comm
, 1, &pmatch
, 0) != 0)
402 if ((pgp
->pg_flags
& PG_EXACT_MATCH
) &&
403 (pmatch
.rm_so
!= 0 || p
.p_user
.u_comm
[pmatch
.rm_eo
] != '\0'))
407 if (pgp
->pg_flags
& (PG_NEWEST
| PG_OLDEST
)) {
410 start
= (hrtime_t
)p
.p_user
.u_start
.tv_sec
* NANOSEC
+
411 p
.p_user
.u_start
.tv_nsec
;
413 if (pgp
->pg_flags
& PG_NEWEST
) {
414 if (pgp
->pg_xaddr
== (uintptr_t)NULL
||
415 start
> pgp
->pg_xstart
) {
416 pgp
->pg_xaddr
= addr
;
417 pgp
->pg_xstart
= start
;
420 if (pgp
->pg_xaddr
== (uintptr_t)NULL
||
421 start
< pgp
->pg_xstart
) {
422 pgp
->pg_xaddr
= addr
;
423 pgp
->pg_xstart
= start
;
427 } else if (pgp
->pg_flags
& PG_PIPE_OUT
) {
428 mdb_printf("%p\n", addr
);
431 if (mdb_call_dcmd("ps", addr
, pgp
->pg_psflags
, 0, NULL
) != 0) {
432 mdb_warn("can't invoke 'ps'");
435 pgp
->pg_psflags
&= ~DCMD_LOOPFIRST
;
443 pgrep(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
451 if (flags
& DCMD_ADDRSPEC
)
455 pg
.pg_xaddr
= (uintptr_t)NULL
;
457 i
= mdb_getopts(argc
, argv
,
458 'n', MDB_OPT_SETBITS
, PG_NEWEST
, &pg
.pg_flags
,
459 'o', MDB_OPT_SETBITS
, PG_OLDEST
, &pg
.pg_flags
,
460 'x', MDB_OPT_SETBITS
, PG_EXACT_MATCH
, &pg
.pg_flags
,
470 * -n and -o are mutually exclusive.
472 if ((pg
.pg_flags
& PG_NEWEST
) && (pg
.pg_flags
& PG_OLDEST
))
475 if (argv
->a_type
!= MDB_TYPE_STRING
)
478 if (flags
& DCMD_PIPE_OUT
)
479 pg
.pg_flags
|= PG_PIPE_OUT
;
481 pg
.pg_pat
= argv
->a_un
.a_str
;
482 if (DCMD_HDRSPEC(flags
))
483 pg
.pg_psflags
= DCMD_ADDRSPEC
| DCMD_LOOP
| DCMD_LOOPFIRST
;
485 pg
.pg_psflags
= DCMD_ADDRSPEC
| DCMD_LOOP
;
488 if ((err
= regcomp(&pg
.pg_reg
, pg
.pg_pat
, REG_EXTENDED
)) != 0) {
492 nbytes
= regerror(err
, &pg
.pg_reg
, NULL
, 0);
493 buf
= mdb_alloc(nbytes
+ 1, UM_SLEEP
| UM_GC
);
494 (void) regerror(err
, &pg
.pg_reg
, buf
, nbytes
);
495 mdb_warn("%s\n", buf
);
501 if (mdb_walk("proc", pgrep_cb
, &pg
) != 0) {
502 mdb_warn("can't walk 'proc'");
506 if (pg
.pg_xaddr
!= (uintptr_t)NULL
&&
507 (pg
.pg_flags
& (PG_NEWEST
| PG_OLDEST
))) {
508 if (pg
.pg_flags
& PG_PIPE_OUT
) {
509 mdb_printf("%p\n", pg
.pg_xaddr
);
511 if (mdb_call_dcmd("ps", pg
.pg_xaddr
, pg
.pg_psflags
,
513 mdb_warn("can't invoke 'ps'");
523 task(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
528 if (!(flags
& DCMD_ADDRSPEC
)) {
529 if (mdb_walk_dcmd("task_cache", "task", argc
, argv
) == -1) {
530 mdb_warn("can't walk task_cache");
535 if (DCMD_HDRSPEC(flags
)) {
536 mdb_printf("%<u>%?s %6s %6s %6s %6s %10s%</u>\n",
537 "ADDR", "TASKID", "PROJID", "ZONEID", "REFCNT", "FLAGS");
539 if (mdb_vread(&tk
, sizeof (task_t
), addr
) == -1) {
540 mdb_warn("can't read task_t structure at %p", addr
);
543 if (mdb_vread(&pj
, sizeof (kproject_t
), (uintptr_t)tk
.tk_proj
) == -1) {
544 mdb_warn("can't read project_t structure at %p", addr
);
547 mdb_printf("%0?p %6d %6d %6d %6u 0x%08x\n",
548 addr
, tk
.tk_tkid
, pj
.kpj_id
, pj
.kpj_zoneid
, tk
.tk_hold_count
,
554 project(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
558 if (!(flags
& DCMD_ADDRSPEC
)) {
559 if (mdb_walk_dcmd("projects", "project", argc
, argv
) == -1) {
560 mdb_warn("can't walk projects");
565 if (DCMD_HDRSPEC(flags
)) {
566 mdb_printf("%<u>%?s %6s %6s %6s%</u>\n",
567 "ADDR", "PROJID", "ZONEID", "REFCNT");
569 if (mdb_vread(&pj
, sizeof (kproject_t
), addr
) == -1) {
570 mdb_warn("can't read kproject_t structure at %p", addr
);
573 mdb_printf("%0?p %6d %6d %6u\n", addr
, pj
.kpj_id
, pj
.kpj_zoneid
,
578 /* walk callouts themselves, either by list or id hash. */
580 callout_walk_init(mdb_walk_state_t
*wsp
)
582 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
583 mdb_warn("callout doesn't support global walk");
586 wsp
->walk_data
= mdb_alloc(sizeof (callout_t
), UM_SLEEP
);
590 #define CALLOUT_WALK_BYLIST 0
591 #define CALLOUT_WALK_BYID 1
593 /* the walker arg switches between walking by list (0) and walking by id (1). */
595 callout_walk_step(mdb_walk_state_t
*wsp
)
599 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
602 if (mdb_vread(wsp
->walk_data
, sizeof (callout_t
),
603 wsp
->walk_addr
) == -1) {
604 mdb_warn("failed to read callout at %p", wsp
->walk_addr
);
607 retval
= wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_data
,
610 if ((ulong_t
)wsp
->walk_arg
== CALLOUT_WALK_BYID
) {
612 (uintptr_t)(((callout_t
*)wsp
->walk_data
)->c_idnext
);
615 (uintptr_t)(((callout_t
*)wsp
->walk_data
)->c_clnext
);
622 callout_walk_fini(mdb_walk_state_t
*wsp
)
624 mdb_free(wsp
->walk_data
, sizeof (callout_t
));
628 * walker for callout lists. This is different from hashes and callouts.
629 * Thankfully, it's also simpler.
632 callout_list_walk_init(mdb_walk_state_t
*wsp
)
634 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
635 mdb_warn("callout list doesn't support global walk");
638 wsp
->walk_data
= mdb_alloc(sizeof (callout_list_t
), UM_SLEEP
);
643 callout_list_walk_step(mdb_walk_state_t
*wsp
)
647 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
650 if (mdb_vread(wsp
->walk_data
, sizeof (callout_list_t
),
651 wsp
->walk_addr
) != sizeof (callout_list_t
)) {
652 mdb_warn("failed to read callout_list at %p", wsp
->walk_addr
);
655 retval
= wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_data
,
658 wsp
->walk_addr
= (uintptr_t)
659 (((callout_list_t
*)wsp
->walk_data
)->cl_next
);
665 callout_list_walk_fini(mdb_walk_state_t
*wsp
)
667 mdb_free(wsp
->walk_data
, sizeof (callout_list_t
));
670 /* routines/structs to walk callout table(s) */
671 typedef struct cot_data
{
672 callout_table_t
*ct0
;
674 callout_hash_t cot_idhash
[CALLOUT_BUCKETS
];
675 callout_hash_t cot_clhash
[CALLOUT_BUCKETS
];
676 kstat_named_t ct_kstat_data
[CALLOUT_NUM_STATS
];
682 callout_table_walk_init(mdb_walk_state_t
*wsp
)
685 cot_data_t
*cot_walk_data
;
687 cot_walk_data
= mdb_alloc(sizeof (cot_data_t
), UM_SLEEP
);
689 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
690 if (mdb_readvar(&cot_walk_data
->ct0
, "callout_table") == -1) {
691 mdb_warn("failed to read 'callout_table'");
694 if (mdb_readvar(&max_ncpus
, "max_ncpus") == -1) {
695 mdb_warn("failed to get callout_table array size");
698 cot_walk_data
->cotsize
= CALLOUT_NTYPES
* max_ncpus
;
699 wsp
->walk_addr
= (uintptr_t)cot_walk_data
->ct0
;
701 /* not a global walk */
702 cot_walk_data
->cotsize
= 1;
705 cot_walk_data
->cotndx
= 0;
706 wsp
->walk_data
= cot_walk_data
;
712 callout_table_walk_step(mdb_walk_state_t
*wsp
)
715 cot_data_t
*cotwd
= (cot_data_t
*)wsp
->walk_data
;
718 if (cotwd
->cotndx
>= cotwd
->cotsize
) {
721 if (mdb_vread(&(cotwd
->ct
), sizeof (callout_table_t
),
722 wsp
->walk_addr
) != sizeof (callout_table_t
)) {
723 mdb_warn("failed to read callout_table at %p", wsp
->walk_addr
);
727 size
= sizeof (callout_hash_t
) * CALLOUT_BUCKETS
;
728 if (cotwd
->ct
.ct_idhash
!= NULL
) {
729 if (mdb_vread(cotwd
->cot_idhash
, size
,
730 (uintptr_t)(cotwd
->ct
.ct_idhash
)) != size
) {
731 mdb_warn("failed to read id_hash at %p",
732 cotwd
->ct
.ct_idhash
);
736 if (cotwd
->ct
.ct_clhash
!= NULL
) {
737 if (mdb_vread(&(cotwd
->cot_clhash
), size
,
738 (uintptr_t)cotwd
->ct
.ct_clhash
) == -1) {
739 mdb_warn("failed to read cl_hash at %p",
740 cotwd
->ct
.ct_clhash
);
744 size
= sizeof (kstat_named_t
) * CALLOUT_NUM_STATS
;
745 if (cotwd
->ct
.ct_kstat_data
!= NULL
) {
746 if (mdb_vread(&(cotwd
->ct_kstat_data
), size
,
747 (uintptr_t)cotwd
->ct
.ct_kstat_data
) == -1) {
748 mdb_warn("failed to read kstats at %p",
749 cotwd
->ct
.ct_kstat_data
);
753 retval
= wsp
->walk_callback(wsp
->walk_addr
, (void *)cotwd
,
757 if (cotwd
->cotndx
>= cotwd
->cotsize
) {
760 wsp
->walk_addr
= (uintptr_t)((char *)wsp
->walk_addr
+
761 sizeof (callout_table_t
));
767 callout_table_walk_fini(mdb_walk_state_t
*wsp
)
769 mdb_free(wsp
->walk_data
, sizeof (cot_data_t
));
772 static const char *co_typenames
[] = { "R", "N" };
774 #define CO_PLAIN_ID(xid) ((xid) & CALLOUT_ID_MASK)
776 #define TABLE_TO_SEQID(x) ((x) >> CALLOUT_TYPE_BITS)
778 /* callout flags, in no particular order */
779 #define COF_REAL 0x00000001
780 #define COF_NORM 0x00000002
781 #define COF_LONG 0x00000004
782 #define COF_SHORT 0x00000008
783 #define COF_EMPTY 0x00000010
784 #define COF_TIME 0x00000020
785 #define COF_BEFORE 0x00000040
786 #define COF_AFTER 0x00000080
787 #define COF_SEQID 0x00000100
788 #define COF_FUNC 0x00000200
789 #define COF_ADDR 0x00000400
790 #define COF_EXEC 0x00000800
791 #define COF_HIRES 0x00001000
792 #define COF_ABS 0x00002000
793 #define COF_TABLE 0x00004000
794 #define COF_BYIDH 0x00008000
795 #define COF_FREE 0x00010000
796 #define COF_LIST 0x00020000
797 #define COF_EXPREL 0x00040000
798 #define COF_HDR 0x00080000
799 #define COF_VERBOSE 0x00100000
800 #define COF_LONGLIST 0x00200000
801 #define COF_THDR 0x00400000
802 #define COF_LHDR 0x00800000
803 #define COF_CHDR 0x01000000
804 #define COF_PARAM 0x02000000
805 #define COF_DECODE 0x04000000
806 #define COF_HEAP 0x08000000
807 #define COF_QUEUE 0x10000000
809 /* show real and normal, short and long, expired and unexpired. */
810 #define COF_DEFAULT (COF_REAL | COF_NORM | COF_LONG | COF_SHORT)
812 #define COF_LIST_FLAGS \
813 (CALLOUT_LIST_FLAG_HRESTIME | CALLOUT_LIST_FLAG_ABSOLUTE)
815 /* private callout data for callback functions */
816 typedef struct callout_data
{
817 uint_t flags
; /* COF_* */
818 cpu_t
*cpu
; /* cpu pointer if given */
819 int seqid
; /* cpu seqid, or -1 */
820 hrtime_t time
; /* expiration time value */
821 hrtime_t atime
; /* expiration before value */
822 hrtime_t btime
; /* expiration after value */
823 uintptr_t funcaddr
; /* function address or NULL */
824 uintptr_t param
; /* parameter to function or NULL */
825 hrtime_t now
; /* current system time */
826 int nsec_per_tick
; /* for conversions */
827 ulong_t ctbits
; /* for decoding xid */
828 callout_table_t
*co_table
; /* top of callout table array */
829 int ndx
; /* table index. */
830 int bucket
; /* which list/id bucket are we in */
831 hrtime_t exp
; /* expire time */
832 int list_flags
; /* copy of cl_flags */
835 /* this callback does the actual callback itself (finally). */
838 callouts_cb(uintptr_t addr
, const void *data
, void *priv
)
840 callout_data_t
*coargs
= (callout_data_t
*)priv
;
841 callout_t
*co
= (callout_t
*)data
;
842 int tableid
, list_flags
;
845 if ((coargs
== NULL
) || (co
== NULL
)) {
849 if ((coargs
->flags
& COF_FREE
) && !(co
->c_xid
& CALLOUT_ID_FREE
)) {
851 * The callout must have been reallocated. No point in
856 if (!(coargs
->flags
& COF_FREE
) && (co
->c_xid
& CALLOUT_ID_FREE
)) {
858 * The callout must have been freed. No point in
863 if ((coargs
->flags
& COF_FUNC
) &&
864 (coargs
->funcaddr
!= (uintptr_t)co
->c_func
)) {
867 if ((coargs
->flags
& COF_PARAM
) &&
868 (coargs
->param
!= (uintptr_t)co
->c_arg
)) {
871 if (!(coargs
->flags
& COF_LONG
) && (co
->c_xid
& CALLOUT_LONGTERM
)) {
874 if (!(coargs
->flags
& COF_SHORT
) && !(co
->c_xid
& CALLOUT_LONGTERM
)) {
877 if ((coargs
->flags
& COF_EXEC
) && !(co
->c_xid
& CALLOUT_EXECUTING
)) {
880 /* it is possible we don't have the exp time or flags */
881 if (coargs
->flags
& COF_BYIDH
) {
882 if (!(coargs
->flags
& COF_FREE
)) {
883 /* we have to fetch the expire time ourselves. */
884 if (mdb_vread(&coargs
->exp
, sizeof (hrtime_t
),
885 (uintptr_t)co
->c_list
+ offsetof(callout_list_t
,
886 cl_expiration
)) == -1) {
887 mdb_warn("failed to read expiration "
888 "time from %p", co
->c_list
);
892 if (mdb_vread(&coargs
->list_flags
, sizeof (int),
893 (uintptr_t)co
->c_list
+ offsetof(callout_list_t
,
895 mdb_warn("failed to read list flags"
896 "from %p", co
->c_list
);
897 coargs
->list_flags
= 0;
900 /* free callouts can't use list pointer. */
902 coargs
->list_flags
= 0;
904 if (coargs
->exp
!= 0) {
905 if ((coargs
->flags
& COF_TIME
) &&
906 (coargs
->exp
!= coargs
->time
)) {
909 if ((coargs
->flags
& COF_BEFORE
) &&
910 (coargs
->exp
> coargs
->btime
)) {
913 if ((coargs
->flags
& COF_AFTER
) &&
914 (coargs
->exp
< coargs
->atime
)) {
918 /* tricky part, since both HIRES and ABS can be set */
919 list_flags
= coargs
->list_flags
;
920 if ((coargs
->flags
& COF_HIRES
) && (coargs
->flags
& COF_ABS
)) {
921 /* both flags are set, only skip "regular" ones */
922 if (! (list_flags
& COF_LIST_FLAGS
)) {
926 /* individual flags, or no flags */
927 if ((coargs
->flags
& COF_HIRES
) &&
928 !(list_flags
& CALLOUT_LIST_FLAG_HRESTIME
)) {
931 if ((coargs
->flags
& COF_ABS
) &&
932 !(list_flags
& CALLOUT_LIST_FLAG_ABSOLUTE
)) {
937 * We do the checks for COF_HEAP and COF_QUEUE here only if we
938 * are traversing BYIDH. If the traversal is by callout list,
939 * we do this check in callout_list_cb() to be more
942 if ((coargs
->flags
& COF_HEAP
) &&
943 !(list_flags
& CALLOUT_LIST_FLAG_HEAPED
)) {
947 if ((coargs
->flags
& COF_QUEUE
) &&
948 !(list_flags
& CALLOUT_LIST_FLAG_QUEUED
)) {
953 #define callout_table_mask ((1 << coargs->ctbits) - 1)
954 tableid
= CALLOUT_ID_TO_TABLE(co
->c_xid
);
955 #undef callout_table_mask
956 coid
= CO_PLAIN_ID(co
->c_xid
);
958 if ((coargs
->flags
& COF_CHDR
) && !(coargs
->flags
& COF_ADDR
)) {
960 * We need to print the headers. If walking by id, then
961 * the list header isn't printed, so we must include
964 if (!(coargs
->flags
& COF_VERBOSE
)) {
965 mdb_printf("%<u>%3s %-1s %-14s %</u>",
967 } else if (coargs
->flags
& COF_BYIDH
) {
968 mdb_printf("%<u>%-14s %</u>", "EXP");
970 mdb_printf("%<u>%-4s %-?s %-20s%</u>",
971 "XHAL", "XID", "FUNC(ARG)");
972 if (coargs
->flags
& COF_LONGLIST
) {
973 mdb_printf("%<u> %-?s %-?s %-?s %-?s%</u>",
974 "PREVID", "NEXTID", "PREVL", "NEXTL");
975 mdb_printf("%<u> %-?s %-4s %-?s%</u>",
976 "DONE", "UTOS", "THREAD");
979 coargs
->flags
&= ~COF_CHDR
;
980 coargs
->flags
|= (COF_THDR
| COF_LHDR
);
983 if (!(coargs
->flags
& COF_ADDR
)) {
984 if (!(coargs
->flags
& COF_VERBOSE
)) {
985 mdb_printf("%-3d %1s %-14llx ",
986 TABLE_TO_SEQID(tableid
),
987 co_typenames
[tableid
& CALLOUT_TYPE_MASK
],
988 (coargs
->flags
& COF_EXPREL
) ?
989 coargs
->exp
- coargs
->now
: coargs
->exp
);
990 } else if (coargs
->flags
& COF_BYIDH
) {
992 (coargs
->flags
& COF_EXPREL
) ?
993 coargs
->exp
- coargs
->now
: coargs
->exp
);
995 list_flags
= coargs
->list_flags
;
996 mdb_printf("%1s%1s%1s%1s %-?llx %a(%p)",
997 (co
->c_xid
& CALLOUT_EXECUTING
) ? "X" : " ",
998 (list_flags
& CALLOUT_LIST_FLAG_HRESTIME
) ? "H" : " ",
999 (list_flags
& CALLOUT_LIST_FLAG_ABSOLUTE
) ? "A" : " ",
1000 (co
->c_xid
& CALLOUT_LONGTERM
) ? "L" : " ",
1001 (long long)coid
, co
->c_func
, co
->c_arg
);
1002 if (coargs
->flags
& COF_LONGLIST
) {
1003 mdb_printf(" %-?p %-?p %-?p %-?p",
1004 co
->c_idprev
, co
->c_idnext
, co
->c_clprev
,
1006 mdb_printf(" %-?p %-4d %-0?p",
1007 co
->c_done
, co
->c_waiting
, co
->c_executor
);
1011 mdb_printf("%-0p", addr
);
1017 /* this callback is for callout list handling. idhash is done by callout_t_cb */
1020 callout_list_cb(uintptr_t addr
, const void *data
, void *priv
)
1022 callout_data_t
*coargs
= (callout_data_t
*)priv
;
1023 callout_list_t
*cl
= (callout_list_t
*)data
;
1027 if ((coargs
== NULL
) || (cl
== NULL
)) {
1031 coargs
->exp
= cl
->cl_expiration
;
1032 coargs
->list_flags
= cl
->cl_flags
;
1033 if ((coargs
->flags
& COF_FREE
) &&
1034 !(cl
->cl_flags
& CALLOUT_LIST_FLAG_FREE
)) {
1036 * The callout list must have been reallocated. No point in
1041 if (!(coargs
->flags
& COF_FREE
) &&
1042 (cl
->cl_flags
& CALLOUT_LIST_FLAG_FREE
)) {
1044 * The callout list must have been freed. No point in
1049 if ((coargs
->flags
& COF_TIME
) &&
1050 (cl
->cl_expiration
!= coargs
->time
)) {
1053 if ((coargs
->flags
& COF_BEFORE
) &&
1054 (cl
->cl_expiration
> coargs
->btime
)) {
1057 if ((coargs
->flags
& COF_AFTER
) &&
1058 (cl
->cl_expiration
< coargs
->atime
)) {
1061 if (!(coargs
->flags
& COF_EMPTY
) &&
1062 (cl
->cl_callouts
.ch_head
== NULL
)) {
1065 /* FOUR cases, each different, !A!B, !AB, A!B, AB */
1066 if ((coargs
->flags
& COF_HIRES
) && (coargs
->flags
& COF_ABS
)) {
1067 /* both flags are set, only skip "regular" ones */
1068 if (! (cl
->cl_flags
& COF_LIST_FLAGS
)) {
1072 if ((coargs
->flags
& COF_HIRES
) &&
1073 !(cl
->cl_flags
& CALLOUT_LIST_FLAG_HRESTIME
)) {
1076 if ((coargs
->flags
& COF_ABS
) &&
1077 !(cl
->cl_flags
& CALLOUT_LIST_FLAG_ABSOLUTE
)) {
1082 if ((coargs
->flags
& COF_HEAP
) &&
1083 !(coargs
->list_flags
& CALLOUT_LIST_FLAG_HEAPED
)) {
1087 if ((coargs
->flags
& COF_QUEUE
) &&
1088 !(coargs
->list_flags
& CALLOUT_LIST_FLAG_QUEUED
)) {
1092 if ((coargs
->flags
& COF_LHDR
) && !(coargs
->flags
& COF_ADDR
) &&
1093 (coargs
->flags
& (COF_LIST
| COF_VERBOSE
))) {
1094 if (!(coargs
->flags
& COF_VERBOSE
)) {
1095 /* don't be redundant again */
1096 mdb_printf("%<u>SEQ T %</u>");
1098 mdb_printf("%<u>EXP HA BUCKET "
1101 if (coargs
->flags
& COF_LONGLIST
) {
1102 mdb_printf("%<u> %-?s %-?s%</u>",
1106 coargs
->flags
&= ~COF_LHDR
;
1107 coargs
->flags
|= (COF_THDR
| COF_CHDR
);
1109 if (coargs
->flags
& (COF_LIST
| COF_VERBOSE
)) {
1110 if (!(coargs
->flags
& COF_ADDR
)) {
1111 if (!(coargs
->flags
& COF_VERBOSE
)) {
1112 mdb_printf("%3d %1s ",
1113 TABLE_TO_SEQID(coargs
->ndx
),
1114 co_typenames
[coargs
->ndx
&
1115 CALLOUT_TYPE_MASK
]);
1118 list_flags
= coargs
->list_flags
;
1119 mdb_printf("%-14llx %1s%1s %-6d %-0?p ",
1120 (coargs
->flags
& COF_EXPREL
) ?
1121 coargs
->exp
- coargs
->now
: coargs
->exp
,
1122 (list_flags
& CALLOUT_LIST_FLAG_HRESTIME
) ?
1124 (list_flags
& CALLOUT_LIST_FLAG_ABSOLUTE
) ?
1126 coargs
->bucket
, cl
->cl_callouts
.ch_head
);
1128 if (coargs
->flags
& COF_LONGLIST
) {
1129 mdb_printf(" %-?p %-?p",
1130 cl
->cl_prev
, cl
->cl_next
);
1134 mdb_printf("%-0p", addr
);
1137 if (coargs
->flags
& COF_LIST
) {
1141 /* yet another layer as we walk the actual callouts via list. */
1142 if (cl
->cl_callouts
.ch_head
== NULL
) {
1145 /* free list structures do not have valid callouts off of them. */
1146 if (coargs
->flags
& COF_FREE
) {
1149 coptr
= (callout_t
*)cl
->cl_callouts
.ch_head
;
1151 if (coargs
->flags
& COF_VERBOSE
) {
1155 * walk callouts using yet another callback routine.
1156 * we use callouts_bytime because id hash is handled via
1157 * the callout_t_cb callback.
1159 if (mdb_pwalk("callouts_bytime", callouts_cb
, coargs
,
1160 (uintptr_t)coptr
) == -1) {
1161 mdb_warn("cannot walk callouts at %p", coptr
);
1164 if (coargs
->flags
& COF_VERBOSE
) {
1171 /* this callback handles the details of callout table walking. */
1173 callout_t_cb(uintptr_t addr
, const void *data
, void *priv
)
1175 callout_data_t
*coargs
= (callout_data_t
*)priv
;
1176 cot_data_t
*cotwd
= (cot_data_t
*)data
;
1177 callout_table_t
*ct
= &(cotwd
->ct
);
1178 int index
, seqid
, cotype
;
1180 callout_list_t
*clptr
;
1183 if ((coargs
== NULL
) || (ct
== NULL
) || (coargs
->co_table
== NULL
)) {
1187 index
= ((char *)addr
- (char *)coargs
->co_table
) /
1188 sizeof (callout_table_t
);
1189 cotype
= index
& CALLOUT_TYPE_MASK
;
1190 seqid
= TABLE_TO_SEQID(index
);
1192 if ((coargs
->flags
& COF_SEQID
) && (coargs
->seqid
!= seqid
)) {
1196 if (!(coargs
->flags
& COF_REAL
) && (cotype
== CALLOUT_REALTIME
)) {
1200 if (!(coargs
->flags
& COF_NORM
) && (cotype
== CALLOUT_NORMAL
)) {
1204 if (!(coargs
->flags
& COF_EMPTY
) && (
1205 (ct
->ct_heap
== NULL
) || (ct
->ct_cyclic
== (uintptr_t)NULL
))) {
1209 if ((coargs
->flags
& COF_THDR
) && !(coargs
->flags
& COF_ADDR
) &&
1210 (coargs
->flags
& (COF_TABLE
| COF_VERBOSE
))) {
1211 /* print table hdr */
1212 mdb_printf("%<u>%-3s %-1s %-?s %-?s %-?s %-?s%</u>",
1213 "SEQ", "T", "FREE", "LFREE", "CYCLIC", "HEAP");
1214 coargs
->flags
&= ~COF_THDR
;
1215 coargs
->flags
|= (COF_LHDR
| COF_CHDR
);
1216 if (coargs
->flags
& COF_LONGLIST
) {
1218 mdb_printf("%<u> %-T%-7s %-7s %-?s %-?s %-?s"
1219 " %-?s %-?s %-?s%</u>",
1220 "HEAPNUM", "HEAPMAX", "TASKQ", "EXPQ", "QUE",
1221 "PEND", "FREE", "LOCK");
1225 if (coargs
->flags
& (COF_TABLE
| COF_VERBOSE
)) {
1226 if (!(coargs
->flags
& COF_ADDR
)) {
1227 mdb_printf("%-3d %-1s %-0?p %-0?p %-0?p %-?p",
1228 seqid
, co_typenames
[cotype
],
1229 ct
->ct_free
, ct
->ct_lfree
, ct
->ct_cyclic
,
1231 if (coargs
->flags
& COF_LONGLIST
) {
1233 mdb_printf(" %-7d %-7d %-?p %-?p %-?p"
1234 " %-?lld %-?lld %-?p",
1235 ct
->ct_heap_num
, ct
->ct_heap_max
,
1236 ct
->ct_taskq
, ct
->ct_expired
.ch_head
,
1237 ct
->ct_queue
.ch_head
,
1238 cotwd
->ct_timeouts_pending
,
1239 cotwd
->ct_allocations
-
1240 cotwd
->ct_timeouts_pending
,
1245 mdb_printf("%-0?p", addr
);
1248 if (coargs
->flags
& COF_TABLE
) {
1253 coargs
->ndx
= index
;
1254 if (coargs
->flags
& COF_VERBOSE
) {
1258 if (!(coargs
->flags
& COF_BYIDH
)) {
1259 /* walk the list hash table */
1260 if (coargs
->flags
& COF_FREE
) {
1261 clptr
= ct
->ct_lfree
;
1263 if (clptr
== NULL
) {
1266 if (mdb_pwalk("callout_list", callout_list_cb
, coargs
,
1267 (uintptr_t)clptr
) == -1) {
1268 mdb_warn("cannot walk callout free list at %p",
1273 /* first print the expired list. */
1274 clptr
= (callout_list_t
*)ct
->ct_expired
.ch_head
;
1275 if (clptr
!= NULL
) {
1276 coargs
->bucket
= -1;
1277 if (mdb_pwalk("callout_list", callout_list_cb
,
1278 coargs
, (uintptr_t)clptr
) == -1) {
1279 mdb_warn("cannot walk callout_list"
1284 /* then, print the callout queue */
1285 clptr
= (callout_list_t
*)ct
->ct_queue
.ch_head
;
1286 if (clptr
!= NULL
) {
1287 coargs
->bucket
= -1;
1288 if (mdb_pwalk("callout_list", callout_list_cb
,
1289 coargs
, (uintptr_t)clptr
) == -1) {
1290 mdb_warn("cannot walk callout_list"
1295 for (i
= 0; i
< CALLOUT_BUCKETS
; i
++) {
1296 if (ct
->ct_clhash
== NULL
) {
1300 if (cotwd
->cot_clhash
[i
].ch_head
== NULL
) {
1303 clptr
= (callout_list_t
*)
1304 cotwd
->cot_clhash
[i
].ch_head
;
1306 /* walk list with callback routine. */
1307 if (mdb_pwalk("callout_list", callout_list_cb
,
1308 coargs
, (uintptr_t)clptr
) == -1) {
1309 mdb_warn("cannot walk callout_list"
1316 /* walk the id hash table. */
1317 if (coargs
->flags
& COF_FREE
) {
1318 coptr
= ct
->ct_free
;
1320 if (coptr
== NULL
) {
1323 if (mdb_pwalk("callouts_byid", callouts_cb
, coargs
,
1324 (uintptr_t)coptr
) == -1) {
1325 mdb_warn("cannot walk callout id free list"
1330 for (i
= 0; i
< CALLOUT_BUCKETS
; i
++) {
1331 if (ct
->ct_idhash
== NULL
) {
1334 coptr
= (callout_t
*)
1335 cotwd
->cot_idhash
[i
].ch_head
;
1336 if (coptr
== NULL
) {
1342 * walk callouts directly by id. For id
1343 * chain, the callout list is just a header,
1344 * so there's no need to walk it.
1346 if (mdb_pwalk("callouts_byid", callouts_cb
,
1347 coargs
, (uintptr_t)coptr
) == -1) {
1348 mdb_warn("cannot walk callouts at %p",
1355 if (coargs
->flags
& COF_VERBOSE
) {
1362 * initialize some common info for both callout dcmds.
1365 callout_common_init(callout_data_t
*coargs
)
1367 /* we need a couple of things */
1368 if (mdb_readvar(&(coargs
->co_table
), "callout_table") == -1) {
1369 mdb_warn("failed to read 'callout_table'");
1372 /* need to get now in nsecs. Approximate with hrtime vars */
1373 if (mdb_readsym(&(coargs
->now
), sizeof (hrtime_t
), "hrtime_last") !=
1374 sizeof (hrtime_t
)) {
1375 if (mdb_readsym(&(coargs
->now
), sizeof (hrtime_t
),
1376 "hrtime_base") != sizeof (hrtime_t
)) {
1377 mdb_warn("Could not determine current system time");
1382 if (mdb_readvar(&(coargs
->ctbits
), "callout_table_bits") == -1) {
1383 mdb_warn("failed to read 'callout_table_bits'");
1386 if (mdb_readvar(&(coargs
->nsec_per_tick
), "nsec_per_tick") == -1) {
1387 mdb_warn("failed to read 'nsec_per_tick'");
1394 * dcmd to print callouts. Optional addr limits to specific table.
1395 * Parses lots of options that get passed to callbacks for walkers.
1396 * Has it's own help function.
1400 callout(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1402 callout_data_t coargs
;
1403 /* getopts doesn't help much with stuff like this */
1404 boolean_t Sflag
, Cflag
, tflag
, aflag
, bflag
, dflag
, kflag
;
1405 char *funcname
= NULL
;
1406 char *paramstr
= NULL
;
1407 uintptr_t Stmp
, Ctmp
; /* for getopt. */
1410 coargs
.flags
= COF_DEFAULT
;
1411 Sflag
= Cflag
= tflag
= bflag
= aflag
= dflag
= kflag
= FALSE
;
1414 if (mdb_getopts(argc
, argv
,
1415 'r', MDB_OPT_CLRBITS
, COF_NORM
, &coargs
.flags
,
1416 'n', MDB_OPT_CLRBITS
, COF_REAL
, &coargs
.flags
,
1417 'l', MDB_OPT_CLRBITS
, COF_SHORT
, &coargs
.flags
,
1418 's', MDB_OPT_CLRBITS
, COF_LONG
, &coargs
.flags
,
1419 'x', MDB_OPT_SETBITS
, COF_EXEC
, &coargs
.flags
,
1420 'h', MDB_OPT_SETBITS
, COF_HIRES
, &coargs
.flags
,
1421 'B', MDB_OPT_SETBITS
, COF_ABS
, &coargs
.flags
,
1422 'E', MDB_OPT_SETBITS
, COF_EMPTY
, &coargs
.flags
,
1423 'd', MDB_OPT_SETBITS
, 1, &dflag
,
1424 'C', MDB_OPT_UINTPTR_SET
, &Cflag
, &Ctmp
,
1425 'S', MDB_OPT_UINTPTR_SET
, &Sflag
, &Stmp
,
1426 't', MDB_OPT_UINTPTR_SET
, &tflag
, (uintptr_t *)&coargs
.time
,
1427 'a', MDB_OPT_UINTPTR_SET
, &aflag
, (uintptr_t *)&coargs
.atime
,
1428 'b', MDB_OPT_UINTPTR_SET
, &bflag
, (uintptr_t *)&coargs
.btime
,
1429 'k', MDB_OPT_SETBITS
, 1, &kflag
,
1430 'f', MDB_OPT_STR
, &funcname
,
1431 'p', MDB_OPT_STR
, ¶mstr
,
1432 'T', MDB_OPT_SETBITS
, COF_TABLE
, &coargs
.flags
,
1433 'D', MDB_OPT_SETBITS
, COF_EXPREL
, &coargs
.flags
,
1434 'L', MDB_OPT_SETBITS
, COF_LIST
, &coargs
.flags
,
1435 'V', MDB_OPT_SETBITS
, COF_VERBOSE
, &coargs
.flags
,
1436 'v', MDB_OPT_SETBITS
, COF_LONGLIST
, &coargs
.flags
,
1437 'i', MDB_OPT_SETBITS
, COF_BYIDH
, &coargs
.flags
,
1438 'F', MDB_OPT_SETBITS
, COF_FREE
, &coargs
.flags
,
1439 'H', MDB_OPT_SETBITS
, COF_HEAP
, &coargs
.flags
,
1440 'Q', MDB_OPT_SETBITS
, COF_QUEUE
, &coargs
.flags
,
1441 'A', MDB_OPT_SETBITS
, COF_ADDR
, &coargs
.flags
,
1443 return (DCMD_USAGE
);
1446 /* initialize from kernel variables */
1447 if ((retval
= callout_common_init(&coargs
)) != DCMD_OK
) {
1451 /* do some option post-processing */
1453 coargs
.time
*= coargs
.nsec_per_tick
;
1454 coargs
.atime
*= coargs
.nsec_per_tick
;
1455 coargs
.btime
*= coargs
.nsec_per_tick
;
1459 coargs
.time
+= coargs
.now
;
1460 coargs
.atime
+= coargs
.now
;
1461 coargs
.btime
+= coargs
.now
;
1464 if (flags
& DCMD_ADDRSPEC
) {
1465 mdb_printf("-S option conflicts with explicit"
1467 return (DCMD_USAGE
);
1469 coargs
.flags
|= COF_SEQID
;
1470 coargs
.seqid
= (int)Stmp
;
1473 if (flags
& DCMD_ADDRSPEC
) {
1474 mdb_printf("-C option conflicts with explicit"
1476 return (DCMD_USAGE
);
1478 if (coargs
.flags
& COF_SEQID
) {
1479 mdb_printf("-C and -S are mutually exclusive\n");
1480 return (DCMD_USAGE
);
1482 coargs
.cpu
= (cpu_t
*)Ctmp
;
1483 if (mdb_vread(&coargs
.seqid
, sizeof (processorid_t
),
1484 (uintptr_t)&(coargs
.cpu
->cpu_seqid
)) == -1) {
1485 mdb_warn("failed to read cpu_t at %p", Ctmp
);
1488 coargs
.flags
|= COF_SEQID
;
1490 /* avoid null outputs. */
1491 if (!(coargs
.flags
& (COF_REAL
| COF_NORM
))) {
1492 coargs
.flags
|= COF_REAL
| COF_NORM
;
1494 if (!(coargs
.flags
& (COF_LONG
| COF_SHORT
))) {
1495 coargs
.flags
|= COF_LONG
| COF_SHORT
;
1498 if (aflag
|| bflag
) {
1499 mdb_printf("-t and -a|b are mutually exclusive\n");
1500 return (DCMD_USAGE
);
1502 coargs
.flags
|= COF_TIME
;
1505 coargs
.flags
|= COF_AFTER
;
1508 coargs
.flags
|= COF_BEFORE
;
1510 if ((aflag
&& bflag
) && (coargs
.btime
<= coargs
.atime
)) {
1511 mdb_printf("value for -a must be earlier than the value"
1513 return (DCMD_USAGE
);
1516 if ((coargs
.flags
& COF_HEAP
) && (coargs
.flags
& COF_QUEUE
)) {
1517 mdb_printf("-H and -Q are mutually exclusive\n");
1518 return (DCMD_USAGE
);
1521 if (funcname
!= NULL
) {
1524 if (mdb_lookup_by_name(funcname
, &sym
) != 0) {
1525 coargs
.funcaddr
= mdb_strtoull(funcname
);
1527 coargs
.funcaddr
= sym
.st_value
;
1529 coargs
.flags
|= COF_FUNC
;
1532 if (paramstr
!= NULL
) {
1535 if (mdb_lookup_by_name(paramstr
, &sym
) != 0) {
1536 coargs
.param
= mdb_strtoull(paramstr
);
1538 coargs
.param
= sym
.st_value
;
1540 coargs
.flags
|= COF_PARAM
;
1543 if (!(flags
& DCMD_ADDRSPEC
)) {
1544 /* don't pass "dot" if no addr. */
1545 addr
= (uintptr_t)NULL
;
1547 if (addr
!= (uintptr_t)NULL
) {
1549 * a callout table was specified. Ignore -r|n option
1550 * to avoid null output.
1552 coargs
.flags
|= (COF_REAL
| COF_NORM
);
1555 if (DCMD_HDRSPEC(flags
) || (coargs
.flags
& COF_VERBOSE
)) {
1556 coargs
.flags
|= COF_THDR
| COF_LHDR
| COF_CHDR
;
1558 if (coargs
.flags
& COF_FREE
) {
1559 coargs
.flags
|= COF_EMPTY
;
1560 /* -F = free callouts, -FL = free lists */
1561 if (!(coargs
.flags
& COF_LIST
)) {
1562 coargs
.flags
|= COF_BYIDH
;
1566 /* walk table, using specialized callback routine. */
1567 if (mdb_pwalk("callout_table", callout_t_cb
, &coargs
, addr
) == -1) {
1568 mdb_warn("cannot walk callout_table");
1576 * Given an extended callout id, dump its information.
1580 calloutid(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1582 callout_data_t coargs
;
1583 callout_table_t
*ctptr
;
1591 const mdb_arg_t
*arg
;
1593 callout_hash_t cot_idhash
[CALLOUT_BUCKETS
];
1595 coargs
.flags
= COF_DEFAULT
| COF_BYIDH
;
1596 i
= mdb_getopts(argc
, argv
,
1597 'd', MDB_OPT_SETBITS
, COF_DECODE
, &coargs
.flags
,
1598 'v', MDB_OPT_SETBITS
, COF_LONGLIST
, &coargs
.flags
,
1604 return (DCMD_USAGE
);
1608 if (arg
->a_type
== MDB_TYPE_IMMEDIATE
) {
1609 xid
= arg
->a_un
.a_val
;
1611 xid
= (callout_id_t
)mdb_strtoull(arg
->a_un
.a_str
);
1614 if (DCMD_HDRSPEC(flags
)) {
1615 coargs
.flags
|= COF_CHDR
;
1619 /* initialize from kernel variables */
1620 if ((retval
= callout_common_init(&coargs
)) != DCMD_OK
) {
1624 /* we must massage the environment so that the macros will play nice */
1625 #define callout_table_mask ((1 << coargs.ctbits) - 1)
1626 #define callout_table_bits coargs.ctbits
1627 #define nsec_per_tick coargs.nsec_per_tick
1628 tableid
= CALLOUT_ID_TO_TABLE(xid
);
1629 idhash
= CALLOUT_IDHASH(xid
);
1630 #undef callouts_table_bits
1631 #undef callout_table_mask
1632 #undef nsec_per_tick
1633 coid
= CO_PLAIN_ID(xid
);
1635 if (flags
& DCMD_ADDRSPEC
) {
1636 mdb_printf("calloutid does not accept explicit address.\n");
1637 return (DCMD_USAGE
);
1640 if (coargs
.flags
& COF_DECODE
) {
1641 if (DCMD_HDRSPEC(flags
)) {
1642 mdb_printf("%<u>%3s %1s %2s %-?s %-6s %</u>\n",
1643 "SEQ", "T", "XL", "XID", "IDHASH");
1645 mdb_printf("%-3d %1s %1s%1s %-?llx %-6d\n",
1646 TABLE_TO_SEQID(tableid
),
1647 co_typenames
[tableid
& CALLOUT_TYPE_MASK
],
1648 (xid
& CALLOUT_EXECUTING
) ? "X" : " ",
1649 (xid
& CALLOUT_LONGTERM
) ? "L" : " ",
1650 (long long)coid
, idhash
);
1654 /* get our table. Note this relies on the types being correct */
1655 ctptr
= coargs
.co_table
+ tableid
;
1656 if (mdb_vread(&ct
, sizeof (callout_table_t
), (uintptr_t)ctptr
) == -1) {
1657 mdb_warn("failed to read callout_table at %p", ctptr
);
1660 size
= sizeof (callout_hash_t
) * CALLOUT_BUCKETS
;
1661 if (ct
.ct_idhash
!= NULL
) {
1662 if (mdb_vread(&(cot_idhash
), size
,
1663 (uintptr_t)ct
.ct_idhash
) == -1) {
1664 mdb_warn("failed to read id_hash at %p",
1670 /* callout at beginning of hash chain */
1671 if (ct
.ct_idhash
== NULL
) {
1672 mdb_printf("id hash chain for this xid is empty\n");
1675 coptr
= (callout_t
*)cot_idhash
[idhash
].ch_head
;
1676 if (coptr
== NULL
) {
1677 mdb_printf("id hash chain for this xid is empty\n");
1681 coargs
.ndx
= tableid
;
1682 coargs
.bucket
= idhash
;
1684 /* use the walker, luke */
1685 if (mdb_pwalk("callouts_byid", callouts_cb
, &coargs
,
1686 (uintptr_t)coptr
) == -1) {
1687 mdb_warn("cannot walk callouts at %p", coptr
);
1697 mdb_printf("callout: display callouts.\n"
1698 "Given a callout table address, display callouts from table.\n"
1699 "Without an address, display callouts from all tables.\n"
1701 " -r|n : limit display to (r)ealtime or (n)ormal type callouts\n"
1702 " -s|l : limit display to (s)hort-term ids or (l)ong-term ids\n"
1703 " -x : limit display to callouts which are executing\n"
1704 " -h : limit display to callouts based on hrestime\n"
1705 " -B : limit display to callouts based on absolute time\n"
1706 " -t|a|b nsec: limit display to callouts that expire a(t) time,"
1707 " (a)fter time,\n or (b)efore time. Use -a and -b together "
1708 " to specify a range.\n For \"now\", use -d[t|a|b] 0.\n"
1709 " -d : interpret time option to -t|a|b as delta from current time\n"
1710 " -k : use ticks instead of nanoseconds as arguments to"
1711 " -t|a|b. Note that\n ticks are less accurate and may not"
1712 " match other tick times (ie: lbolt).\n"
1713 " -D : display exiration time as delta from current time\n"
1714 " -S seqid : limit display to callouts for this cpu sequence id\n"
1715 " -C addr : limit display to callouts for this cpu pointer\n"
1716 " -f name|addr : limit display to callouts with this function\n"
1717 " -p name|addr : limit display to callouts functions with this"
1719 " -T : display the callout table itself, instead of callouts\n"
1720 " -L : display callout lists instead of callouts\n"
1721 " -E : with -T or L, display empty data structures.\n"
1722 " -i : traverse callouts by id hash instead of list hash\n"
1723 " -F : walk free callout list (free list with -i) instead\n"
1724 " -v : display more info for each item\n"
1725 " -V : show details of each level of info as it is traversed\n"
1726 " -H : limit display to callouts in the callout heap\n"
1727 " -Q : limit display to callouts in the callout queue\n"
1728 " -A : show only addresses. Useful for pipelines.\n");
1732 calloutid_help(void)
1734 mdb_printf("calloutid: display callout by id.\n"
1735 "Given an extended callout id, display the callout infomation.\n"
1737 " -d : do not dereference callout, just decode the id.\n"
1738 " -v : verbose display more info about the callout\n");
1743 class(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1745 long num_classes
, i
;
1746 sclass_t
*class_tbl
;
1748 char class_name
[PC_CLNMSZ
];
1751 if (mdb_lookup_by_name("sclass", &g_sclass
) == -1) {
1752 mdb_warn("failed to find symbol sclass\n");
1756 tbl_size
= (size_t)g_sclass
.st_size
;
1757 num_classes
= tbl_size
/ (sizeof (sclass_t
));
1758 class_tbl
= mdb_alloc(tbl_size
, UM_SLEEP
| UM_GC
);
1760 if (mdb_readsym(class_tbl
, tbl_size
, "sclass") == -1) {
1761 mdb_warn("failed to read sclass");
1765 mdb_printf("%<u>%4s %-10s %-24s %-24s%</u>\n", "SLOT", "NAME",
1766 "INIT FCN", "CLASS FCN");
1768 for (i
= 0; i
< num_classes
; i
++) {
1769 if (mdb_vread(class_name
, sizeof (class_name
),
1770 (uintptr_t)class_tbl
[i
].cl_name
) == -1)
1771 (void) strcpy(class_name
, "???");
1773 mdb_printf("%4ld %-10s %-24a %-24a\n", i
, class_name
,
1774 class_tbl
[i
].cl_init
, class_tbl
[i
].cl_funcs
);
1780 #define FSNAMELEN 32 /* Max len of FS name we read from vnodeops */
1783 vnode2path(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1787 char buf
[MAXPATHLEN
];
1789 uint_t opt_F
= FALSE
;
1791 if (mdb_getopts(argc
, argv
,
1792 'F', MDB_OPT_SETBITS
, TRUE
, &opt_F
, NULL
) != argc
)
1793 return (DCMD_USAGE
);
1795 if (!(flags
& DCMD_ADDRSPEC
)) {
1796 mdb_warn("expected explicit vnode_t address before ::\n");
1797 return (DCMD_USAGE
);
1800 if (mdb_readvar(&rootdir
, "rootdir") == -1) {
1801 mdb_warn("failed to read rootdir");
1805 if (mdb_vnode2path(addr
, buf
, sizeof (buf
)) == -1)
1813 mdb_printf("%s", buf
);
1814 if (opt_F
&& buf
[strlen(buf
)-1] != '/' &&
1815 mdb_vread(&vn
, sizeof (vn
), addr
) == sizeof (vn
))
1816 mdb_printf("%c", mdb_vtype2chr(vn
.v_type
, 0));
1823 ld_walk_init(mdb_walk_state_t
*wsp
)
1825 wsp
->walk_data
= (void *)wsp
->walk_addr
;
1830 ld_walk_step(mdb_walk_state_t
*wsp
)
1833 lock_descriptor_t ld
;
1835 if (mdb_vread(&ld
, sizeof (lock_descriptor_t
), wsp
->walk_addr
) == -1) {
1836 mdb_warn("couldn't read lock_descriptor_t at %p\n",
1841 status
= wsp
->walk_callback(wsp
->walk_addr
, &ld
, wsp
->walk_cbdata
);
1842 if (status
== WALK_ERR
)
1845 wsp
->walk_addr
= (uintptr_t)ld
.l_next
;
1846 if (wsp
->walk_addr
== (uintptr_t)wsp
->walk_data
)
1853 lg_walk_init(mdb_walk_state_t
*wsp
)
1857 if (mdb_lookup_by_name("lock_graph", &sym
) == -1) {
1858 mdb_warn("failed to find symbol 'lock_graph'\n");
1862 wsp
->walk_addr
= (uintptr_t)sym
.st_value
;
1863 wsp
->walk_data
= (void *)(uintptr_t)(sym
.st_value
+ sym
.st_size
);
1868 typedef struct lg_walk_data
{
1869 uintptr_t startaddr
;
1870 mdb_walk_cb_t callback
;
1875 * We can't use ::walk lock_descriptor directly, because the head of each graph
1876 * is really a dummy lock. Rather than trying to dynamically determine if this
1877 * is a dummy node or not, we just filter out the initial element of the
1881 lg_walk_cb(uintptr_t addr
, const void *data
, void *priv
)
1883 lg_walk_data_t
*lw
= priv
;
1885 if (addr
!= lw
->startaddr
)
1886 return (lw
->callback(addr
, data
, lw
->data
));
1892 lg_walk_step(mdb_walk_state_t
*wsp
)
1897 if (wsp
->walk_addr
>= (uintptr_t)wsp
->walk_data
)
1900 if (mdb_vread(&graph
, sizeof (graph
), wsp
->walk_addr
) == -1) {
1901 mdb_warn("failed to read graph_t at %p", wsp
->walk_addr
);
1905 wsp
->walk_addr
+= sizeof (graph
);
1910 lw
.callback
= wsp
->walk_callback
;
1911 lw
.data
= wsp
->walk_cbdata
;
1913 lw
.startaddr
= (uintptr_t)&(graph
->active_locks
);
1914 if (mdb_pwalk("lock_descriptor", lg_walk_cb
, &lw
, lw
.startaddr
)) {
1915 mdb_warn("couldn't walk lock_descriptor at %p\n", lw
.startaddr
);
1919 lw
.startaddr
= (uintptr_t)&(graph
->sleeping_locks
);
1920 if (mdb_pwalk("lock_descriptor", lg_walk_cb
, &lw
, lw
.startaddr
)) {
1921 mdb_warn("couldn't walk lock_descriptor at %p\n", lw
.startaddr
);
1929 * The space available for the path corresponding to the locked vnode depends
1930 * on whether we are printing 32- or 64-bit addresses.
1933 #define LM_VNPATHLEN 20
1935 #define LM_VNPATHLEN 30
1938 typedef struct mdb_lminfo_proc
{
1940 char u_comm
[MAXCOMLEN
+ 1];
1942 } mdb_lminfo_proc_t
;
1946 lminfo_cb(uintptr_t addr
, const void *data
, void *priv
)
1948 const lock_descriptor_t
*ld
= data
;
1949 char buf
[LM_VNPATHLEN
];
1950 mdb_lminfo_proc_t p
;
1951 uintptr_t paddr
= 0;
1953 if (ld
->l_flock
.l_pid
!= 0)
1954 paddr
= mdb_pid2proc(ld
->l_flock
.l_pid
, NULL
);
1957 mdb_ctf_vread(&p
, "proc_t", "mdb_lminfo_proc_t", paddr
, 0);
1959 mdb_printf("%-?p %2s %04x %6d %-16s %-?p ",
1960 addr
, ld
->l_type
== F_RDLCK
? "RD" :
1961 ld
->l_type
== F_WRLCK
? "WR" : "??",
1962 ld
->l_state
, ld
->l_flock
.l_pid
,
1963 ld
->l_flock
.l_pid
== 0 ? "<kernel>" :
1964 paddr
== 0 ? "<defunct>" : p
.p_user
.u_comm
, ld
->l_vnode
);
1966 mdb_vnode2path((uintptr_t)ld
->l_vnode
, buf
,
1968 mdb_printf("%s\n", buf
);
1975 lminfo(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1977 if (DCMD_HDRSPEC(flags
))
1978 mdb_printf("%<u>%-?s %2s %4s %6s %-16s %-?s %s%</u>\n",
1979 "ADDR", "TP", "FLAG", "PID", "COMM", "VNODE", "PATH");
1981 return (mdb_pwalk("lock_graph", lminfo_cb
, NULL
, (uintptr_t)NULL
));
1986 whereopen_fwalk(uintptr_t addr
, struct file
*f
, uintptr_t *target
)
1988 if ((uintptr_t)f
->f_vnode
== *target
) {
1989 mdb_printf("file %p\n", addr
);
1990 *target
= (uintptr_t)NULL
;
1998 whereopen_pwalk(uintptr_t addr
, void *ignored
, uintptr_t *target
)
2000 uintptr_t t
= *target
;
2002 if (mdb_pwalk("file", (mdb_walk_cb_t
)whereopen_fwalk
, &t
, addr
) == -1) {
2003 mdb_warn("couldn't file walk proc %p", addr
);
2007 if (t
== (uintptr_t)NULL
)
2008 mdb_printf("%p\n", addr
);
2015 whereopen(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2017 uintptr_t target
= addr
;
2019 if (!(flags
& DCMD_ADDRSPEC
) || addr
== (uintptr_t)NULL
)
2020 return (DCMD_USAGE
);
2022 if (mdb_walk("proc", (mdb_walk_cb_t
)whereopen_pwalk
, &target
) == -1) {
2023 mdb_warn("can't proc walk");
2030 typedef struct datafmt
{
2037 static datafmt_t kmemfmt
[] = {
2038 { "cache ", "name ",
2039 "-------------------------", "%-25s " },
2040 { " buf", " size", "------", "%6u " },
2041 { " buf", "in use", "------", "%6u " },
2042 { " buf", " total", "------", "%6u " },
2043 { " memory", " in use", "----------", "%10lu%c " },
2044 { " alloc", " succeed", "---------", "%9u " },
2045 { "alloc", " fail", "-----", "%5u " },
2046 { NULL
, NULL
, NULL
, NULL
}
2049 static datafmt_t vmemfmt
[] = {
2051 "-------------------------", "%-*s " },
2052 { " memory", " in use", "----------", "%9llu%c " },
2053 { " memory", " total", "-----------", "%10llu%c " },
2054 { " memory", " import", "----------", "%9llu%c " },
2055 { " alloc", " succeed", "---------", "%9llu " },
2056 { "alloc", " fail", "-----", "%5llu " },
2057 { NULL
, NULL
, NULL
, NULL
}
2062 kmastat_cpu_avail(uintptr_t addr
, const kmem_cpu_cache_t
*ccp
, int *avail
)
2064 short rounds
, prounds
;
2066 if (KMEM_DUMPCC(ccp
)) {
2067 rounds
= ccp
->cc_dump_rounds
;
2068 prounds
= ccp
->cc_dump_prounds
;
2070 rounds
= ccp
->cc_rounds
;
2071 prounds
= ccp
->cc_prounds
;
2083 kmastat_cpu_alloc(uintptr_t addr
, const kmem_cpu_cache_t
*ccp
, int *alloc
)
2085 *alloc
+= ccp
->cc_alloc
;
2092 kmastat_slab_avail(uintptr_t addr
, const kmem_slab_t
*sp
, int *avail
)
2094 *avail
+= sp
->slab_chunks
- sp
->slab_refcnt
;
2099 typedef struct kmastat_vmem
{
2101 struct kmastat_vmem
*kv_next
;
2107 typedef struct kmastat_args
{
2108 kmastat_vmem_t
**ka_kvpp
;
2113 kmastat_cache(uintptr_t addr
, const kmem_cache_t
*cp
, kmastat_args_t
*kap
)
2115 kmastat_vmem_t
**kvpp
= kap
->ka_kvpp
;
2117 datafmt_t
*dfp
= kmemfmt
;
2120 int avail
, alloc
, total
;
2121 size_t meminuse
= (cp
->cache_slab_create
- cp
->cache_slab_destroy
) *
2124 mdb_walk_cb_t cpu_avail
= (mdb_walk_cb_t
)kmastat_cpu_avail
;
2125 mdb_walk_cb_t cpu_alloc
= (mdb_walk_cb_t
)kmastat_cpu_alloc
;
2126 mdb_walk_cb_t slab_avail
= (mdb_walk_cb_t
)kmastat_slab_avail
;
2128 magsize
= kmem_get_magsize(cp
);
2130 alloc
= cp
->cache_slab_alloc
+ cp
->cache_full
.ml_alloc
;
2131 avail
= cp
->cache_full
.ml_total
* magsize
;
2132 total
= cp
->cache_buftotal
;
2134 (void) mdb_pwalk("kmem_cpu_cache", cpu_alloc
, &alloc
, addr
);
2135 (void) mdb_pwalk("kmem_cpu_cache", cpu_avail
, &avail
, addr
);
2136 (void) mdb_pwalk("kmem_slab_partial", slab_avail
, &avail
, addr
);
2138 for (kv
= *kvpp
; kv
!= NULL
; kv
= kv
->kv_next
) {
2139 if (kv
->kv_addr
== (uintptr_t)cp
->cache_arena
)
2143 kv
= mdb_zalloc(sizeof (kmastat_vmem_t
), UM_SLEEP
| UM_GC
);
2144 kv
->kv_next
= *kvpp
;
2145 kv
->kv_addr
= (uintptr_t)cp
->cache_arena
;
2148 kv
->kv_meminuse
+= meminuse
;
2149 kv
->kv_alloc
+= alloc
;
2150 kv
->kv_fail
+= cp
->cache_alloc_fail
;
2152 mdb_printf((dfp
++)->fmt
, cp
->cache_name
);
2153 mdb_printf((dfp
++)->fmt
, cp
->cache_bufsize
);
2154 mdb_printf((dfp
++)->fmt
, total
- avail
);
2155 mdb_printf((dfp
++)->fmt
, total
);
2156 mdb_printf((dfp
++)->fmt
, meminuse
>> kap
->ka_shift
,
2157 kap
->ka_shift
== GIGS
? 'G' : kap
->ka_shift
== MEGS
? 'M' :
2158 kap
->ka_shift
== KILOS
? 'K' : 'B');
2159 mdb_printf((dfp
++)->fmt
, alloc
);
2160 mdb_printf((dfp
++)->fmt
, cp
->cache_alloc_fail
);
2167 kmastat_vmem_totals(uintptr_t addr
, const vmem_t
*v
, kmastat_args_t
*kap
)
2169 kmastat_vmem_t
*kv
= *kap
->ka_kvpp
;
2172 while (kv
!= NULL
&& kv
->kv_addr
!= addr
)
2175 if (kv
== NULL
|| kv
->kv_alloc
== 0)
2178 len
= MIN(17, strlen(v
->vm_name
));
2180 mdb_printf("Total [%s]%*s %6s %6s %6s %10lu%c %9u %5u\n", v
->vm_name
,
2181 17 - len
, "", "", "", "",
2182 kv
->kv_meminuse
>> kap
->ka_shift
,
2183 kap
->ka_shift
== GIGS
? 'G' : kap
->ka_shift
== MEGS
? 'M' :
2184 kap
->ka_shift
== KILOS
? 'K' : 'B', kv
->kv_alloc
, kv
->kv_fail
);
2191 kmastat_vmem(uintptr_t addr
, const vmem_t
*v
, const uint_t
*shiftp
)
2193 datafmt_t
*dfp
= vmemfmt
;
2194 const vmem_kstat_t
*vkp
= &v
->vm_kstat
;
2199 for (paddr
= (uintptr_t)v
->vm_source
; paddr
!= (uintptr_t)NULL
;
2201 if (mdb_vread(&parent
, sizeof (parent
), paddr
) == -1) {
2202 mdb_warn("couldn't trace %p's ancestry", addr
);
2206 paddr
= (uintptr_t)parent
.vm_source
;
2209 mdb_printf("%*s", ident
, "");
2210 mdb_printf((dfp
++)->fmt
, 25 - ident
, v
->vm_name
);
2211 mdb_printf((dfp
++)->fmt
, vkp
->vk_mem_inuse
.value
.ui64
>> *shiftp
,
2212 *shiftp
== GIGS
? 'G' : *shiftp
== MEGS
? 'M' :
2213 *shiftp
== KILOS
? 'K' : 'B');
2214 mdb_printf((dfp
++)->fmt
, vkp
->vk_mem_total
.value
.ui64
>> *shiftp
,
2215 *shiftp
== GIGS
? 'G' : *shiftp
== MEGS
? 'M' :
2216 *shiftp
== KILOS
? 'K' : 'B');
2217 mdb_printf((dfp
++)->fmt
, vkp
->vk_mem_import
.value
.ui64
>> *shiftp
,
2218 *shiftp
== GIGS
? 'G' : *shiftp
== MEGS
? 'M' :
2219 *shiftp
== KILOS
? 'K' : 'B');
2220 mdb_printf((dfp
++)->fmt
, vkp
->vk_alloc
.value
.ui64
);
2221 mdb_printf((dfp
++)->fmt
, vkp
->vk_fail
.value
.ui64
);
2230 kmastat(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2232 kmastat_vmem_t
*kv
= NULL
;
2237 if (mdb_getopts(argc
, argv
,
2238 'k', MDB_OPT_SETBITS
, KILOS
, &ka
.ka_shift
,
2239 'm', MDB_OPT_SETBITS
, MEGS
, &ka
.ka_shift
,
2240 'g', MDB_OPT_SETBITS
, GIGS
, &ka
.ka_shift
, NULL
) != argc
)
2241 return (DCMD_USAGE
);
2243 for (dfp
= kmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2244 mdb_printf("%s ", dfp
->hdr1
);
2247 for (dfp
= kmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2248 mdb_printf("%s ", dfp
->hdr2
);
2251 for (dfp
= kmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2252 mdb_printf("%s ", dfp
->dashes
);
2256 if (mdb_walk("kmem_cache", (mdb_walk_cb_t
)kmastat_cache
, &ka
) == -1) {
2257 mdb_warn("can't walk 'kmem_cache'");
2261 for (dfp
= kmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2262 mdb_printf("%s ", dfp
->dashes
);
2265 if (mdb_walk("vmem", (mdb_walk_cb_t
)kmastat_vmem_totals
, &ka
) == -1) {
2266 mdb_warn("can't walk 'vmem'");
2270 for (dfp
= kmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2271 mdb_printf("%s ", dfp
->dashes
);
2276 for (dfp
= vmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2277 mdb_printf("%s ", dfp
->hdr1
);
2280 for (dfp
= vmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2281 mdb_printf("%s ", dfp
->hdr2
);
2284 for (dfp
= vmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2285 mdb_printf("%s ", dfp
->dashes
);
2288 if (mdb_walk("vmem", (mdb_walk_cb_t
)kmastat_vmem
, &ka
.ka_shift
) == -1) {
2289 mdb_warn("can't walk 'vmem'");
2293 for (dfp
= vmemfmt
; dfp
->hdr1
!= NULL
; dfp
++)
2294 mdb_printf("%s ", dfp
->dashes
);
2300 * Our ::kgrep callback scans the entire kernel VA space (kas). kas is made
2301 * up of a set of 'struct seg's. We could just scan each seg en masse, but
2302 * unfortunately, a few of the segs are both large and sparse, so we could
2303 * spend quite a bit of time scanning VAs which have no backing pages.
2305 * So for the few very sparse segs, we skip the segment itself, and scan
2306 * the allocated vmem_segs in the vmem arena which manages that part of kas.
2307 * Currently, we do this for:
2311 * kvseg32 heap32_arena
2312 * kvseg_core heap_core_arena
2314 * In addition, we skip the segkpm segment in its entirety, since it is very
2315 * sparse, and contains no new kernel data.
2317 typedef struct kgrep_walk_data
{
2318 kgrep_cb_func
*kg_cb
;
2321 uintptr_t kg_kvseg32
;
2322 uintptr_t kg_kvseg_core
;
2323 uintptr_t kg_segkpm
;
2324 uintptr_t kg_heap_lp_base
;
2325 uintptr_t kg_heap_lp_end
;
2326 } kgrep_walk_data_t
;
2329 kgrep_walk_seg(uintptr_t addr
, const struct seg
*seg
, kgrep_walk_data_t
*kg
)
2331 uintptr_t base
= (uintptr_t)seg
->s_base
;
2333 if (addr
== kg
->kg_kvseg
|| addr
== kg
->kg_kvseg32
||
2334 addr
== kg
->kg_kvseg_core
)
2337 if ((uintptr_t)seg
->s_ops
== kg
->kg_segkpm
)
2340 return (kg
->kg_cb(base
, base
+ seg
->s_size
, kg
->kg_cbdata
));
2345 kgrep_walk_vseg(uintptr_t addr
, const vmem_seg_t
*seg
, kgrep_walk_data_t
*kg
)
2348 * skip large page heap address range - it is scanned by walking
2349 * allocated vmem_segs in the heap_lp_arena
2351 if (seg
->vs_start
== kg
->kg_heap_lp_base
&&
2352 seg
->vs_end
== kg
->kg_heap_lp_end
)
2355 return (kg
->kg_cb(seg
->vs_start
, seg
->vs_end
, kg
->kg_cbdata
));
2360 kgrep_xwalk_vseg(uintptr_t addr
, const vmem_seg_t
*seg
, kgrep_walk_data_t
*kg
)
2362 return (kg
->kg_cb(seg
->vs_start
, seg
->vs_end
, kg
->kg_cbdata
));
2366 kgrep_walk_vmem(uintptr_t addr
, const vmem_t
*vmem
, kgrep_walk_data_t
*kg
)
2368 mdb_walk_cb_t walk_vseg
= (mdb_walk_cb_t
)kgrep_walk_vseg
;
2370 if (strcmp(vmem
->vm_name
, "heap") != 0 &&
2371 strcmp(vmem
->vm_name
, "heap32") != 0 &&
2372 strcmp(vmem
->vm_name
, "heap_core") != 0 &&
2373 strcmp(vmem
->vm_name
, "heap_lp") != 0)
2376 if (strcmp(vmem
->vm_name
, "heap_lp") == 0)
2377 walk_vseg
= (mdb_walk_cb_t
)kgrep_xwalk_vseg
;
2379 if (mdb_pwalk("vmem_alloc", walk_vseg
, kg
, addr
) == -1) {
2380 mdb_warn("couldn't walk vmem_alloc for vmem %p", addr
);
2388 kgrep_subr(kgrep_cb_func
*cb
, void *cbdata
)
2390 GElf_Sym kas
, kvseg
, kvseg32
, kvseg_core
, segkpm
;
2391 kgrep_walk_data_t kg
;
2393 if (mdb_get_state() == MDB_STATE_RUNNING
) {
2394 mdb_warn("kgrep can only be run on a system "
2395 "dump or under kmdb; see dumpadm(8)\n");
2399 if (mdb_lookup_by_name("kas", &kas
) == -1) {
2400 mdb_warn("failed to locate 'kas' symbol\n");
2404 if (mdb_lookup_by_name("kvseg", &kvseg
) == -1) {
2405 mdb_warn("failed to locate 'kvseg' symbol\n");
2409 if (mdb_lookup_by_name("kvseg32", &kvseg32
) == -1) {
2410 mdb_warn("failed to locate 'kvseg32' symbol\n");
2414 if (mdb_lookup_by_name("kvseg_core", &kvseg_core
) == -1) {
2415 mdb_warn("failed to locate 'kvseg_core' symbol\n");
2419 if (mdb_lookup_by_name("segkpm_ops", &segkpm
) == -1) {
2420 mdb_warn("failed to locate 'segkpm_ops' symbol\n");
2424 if (mdb_readvar(&kg
.kg_heap_lp_base
, "heap_lp_base") == -1) {
2425 mdb_warn("failed to read 'heap_lp_base'\n");
2429 if (mdb_readvar(&kg
.kg_heap_lp_end
, "heap_lp_end") == -1) {
2430 mdb_warn("failed to read 'heap_lp_end'\n");
2435 kg
.kg_cbdata
= cbdata
;
2436 kg
.kg_kvseg
= (uintptr_t)kvseg
.st_value
;
2437 kg
.kg_kvseg32
= (uintptr_t)kvseg32
.st_value
;
2438 kg
.kg_kvseg_core
= (uintptr_t)kvseg_core
.st_value
;
2439 kg
.kg_segkpm
= (uintptr_t)segkpm
.st_value
;
2441 if (mdb_pwalk("seg", (mdb_walk_cb_t
)kgrep_walk_seg
,
2442 &kg
, kas
.st_value
) == -1) {
2443 mdb_warn("failed to walk kas segments");
2447 if (mdb_walk("vmem", (mdb_walk_cb_t
)kgrep_walk_vmem
, &kg
) == -1) {
2448 mdb_warn("failed to walk heap/heap32 vmem arenas");
2456 kgrep_subr_pagesize(void)
2461 typedef struct file_walk_data
{
2462 struct uf_entry
*fw_flist
;
2468 typedef struct mdb_file_proc
{
2472 uf_entry_t
*volatile fi_list
;
2478 file_walk_init(mdb_walk_state_t
*wsp
)
2480 file_walk_data_t
*fw
;
2483 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
2484 mdb_warn("file walk doesn't support global walks\n");
2488 fw
= mdb_alloc(sizeof (file_walk_data_t
), UM_SLEEP
);
2490 if (mdb_ctf_vread(&p
, "proc_t", "mdb_file_proc_t",
2491 wsp
->walk_addr
, 0) == -1) {
2492 mdb_free(fw
, sizeof (file_walk_data_t
));
2493 mdb_warn("failed to read proc structure at %p", wsp
->walk_addr
);
2497 if (p
.p_user
.u_finfo
.fi_nfiles
== 0) {
2498 mdb_free(fw
, sizeof (file_walk_data_t
));
2502 fw
->fw_nofiles
= p
.p_user
.u_finfo
.fi_nfiles
;
2503 fw
->fw_flistsz
= sizeof (struct uf_entry
) * fw
->fw_nofiles
;
2504 fw
->fw_flist
= mdb_alloc(fw
->fw_flistsz
, UM_SLEEP
);
2506 if (mdb_vread(fw
->fw_flist
, fw
->fw_flistsz
,
2507 (uintptr_t)p
.p_user
.u_finfo
.fi_list
) == -1) {
2508 mdb_warn("failed to read file array at %p",
2509 p
.p_user
.u_finfo
.fi_list
);
2510 mdb_free(fw
->fw_flist
, fw
->fw_flistsz
);
2511 mdb_free(fw
, sizeof (file_walk_data_t
));
2516 wsp
->walk_data
= fw
;
2522 file_walk_step(mdb_walk_state_t
*wsp
)
2524 file_walk_data_t
*fw
= (file_walk_data_t
*)wsp
->walk_data
;
2529 if (fw
->fw_ndx
== fw
->fw_nofiles
)
2532 if ((fp
= (uintptr_t)fw
->fw_flist
[fw
->fw_ndx
++].uf_file
) ==
2536 (void) mdb_vread(&file
, sizeof (file
), (uintptr_t)fp
);
2537 return (wsp
->walk_callback(fp
, &file
, wsp
->walk_cbdata
));
2541 allfile_walk_step(mdb_walk_state_t
*wsp
)
2543 file_walk_data_t
*fw
= (file_walk_data_t
*)wsp
->walk_data
;
2547 if (fw
->fw_ndx
== fw
->fw_nofiles
)
2550 if ((fp
= (uintptr_t)fw
->fw_flist
[fw
->fw_ndx
++].uf_file
) !=
2552 (void) mdb_vread(&file
, sizeof (file
), (uintptr_t)fp
);
2554 bzero(&file
, sizeof (file
));
2556 return (wsp
->walk_callback(fp
, &file
, wsp
->walk_cbdata
));
2560 file_walk_fini(mdb_walk_state_t
*wsp
)
2562 file_walk_data_t
*fw
= (file_walk_data_t
*)wsp
->walk_data
;
2564 mdb_free(fw
->fw_flist
, fw
->fw_flistsz
);
2565 mdb_free(fw
, sizeof (file_walk_data_t
));
2569 port_walk_init(mdb_walk_state_t
*wsp
)
2571 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
2572 mdb_warn("port walk doesn't support global walks\n");
2576 if (mdb_layered_walk("file", wsp
) == -1) {
2577 mdb_warn("couldn't walk 'file'");
2584 port_walk_step(mdb_walk_state_t
*wsp
)
2591 vp
= (uintptr_t)((struct file
*)wsp
->walk_layer
)->f_vnode
;
2592 if (mdb_vread(&vn
, sizeof (vn
), vp
) == -1) {
2593 mdb_warn("failed to read vnode_t at %p", vp
);
2596 if (vn
.v_type
!= VPORT
)
2599 pp
= (uintptr_t)vn
.v_data
;
2600 if (mdb_vread(&port
, sizeof (port
), pp
) == -1) {
2601 mdb_warn("failed to read port_t at %p", pp
);
2604 return (wsp
->walk_callback(pp
, &port
, wsp
->walk_cbdata
));
2607 typedef struct portev_walk_data
{
2608 list_node_t
*pev_node
;
2609 list_node_t
*pev_last
;
2611 } portev_walk_data_t
;
2614 portev_walk_init(mdb_walk_state_t
*wsp
)
2616 portev_walk_data_t
*pevd
;
2622 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
2623 mdb_warn("portev walk doesn't support global walks\n");
2627 pevd
= mdb_alloc(sizeof (portev_walk_data_t
), UM_SLEEP
);
2629 if (mdb_vread(&port
, sizeof (port
), wsp
->walk_addr
) == -1) {
2630 mdb_free(pevd
, sizeof (portev_walk_data_t
));
2631 mdb_warn("failed to read port structure at %p", wsp
->walk_addr
);
2635 vp
= (uintptr_t)port
.port_vnode
;
2636 if (mdb_vread(&vn
, sizeof (vn
), vp
) == -1) {
2637 mdb_free(pevd
, sizeof (portev_walk_data_t
));
2638 mdb_warn("failed to read vnode_t at %p", vp
);
2642 if (vn
.v_type
!= VPORT
) {
2643 mdb_free(pevd
, sizeof (portev_walk_data_t
));
2644 mdb_warn("input address (%p) does not point to an event port",
2649 if (port
.port_queue
.portq_nent
== 0) {
2650 mdb_free(pevd
, sizeof (portev_walk_data_t
));
2653 list
= &port
.port_queue
.portq_list
;
2654 pevd
->pev_offset
= list
->list_offset
;
2655 pevd
->pev_last
= list
->list_head
.list_prev
;
2656 pevd
->pev_node
= list
->list_head
.list_next
;
2657 wsp
->walk_data
= pevd
;
2662 portev_walk_step(mdb_walk_state_t
*wsp
)
2664 portev_walk_data_t
*pevd
;
2665 struct port_kevent ev
;
2668 pevd
= (portev_walk_data_t
*)wsp
->walk_data
;
2670 if (pevd
->pev_last
== NULL
)
2672 if (pevd
->pev_node
== pevd
->pev_last
)
2673 pevd
->pev_last
= NULL
; /* last round */
2675 evp
= ((uintptr_t)(((char *)pevd
->pev_node
) - pevd
->pev_offset
));
2676 if (mdb_vread(&ev
, sizeof (ev
), evp
) == -1) {
2677 mdb_warn("failed to read port_kevent at %p", evp
);
2680 pevd
->pev_node
= ev
.portkev_node
.list_next
;
2681 return (wsp
->walk_callback(evp
, &ev
, wsp
->walk_cbdata
));
2685 portev_walk_fini(mdb_walk_state_t
*wsp
)
2687 portev_walk_data_t
*pevd
= (portev_walk_data_t
*)wsp
->walk_data
;
2690 mdb_free(pevd
, sizeof (portev_walk_data_t
));
2693 typedef struct proc_walk_data
{
2694 uintptr_t *pw_stack
;
2700 proc_walk_init(mdb_walk_state_t
*wsp
)
2703 proc_walk_data_t
*pw
;
2705 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
2706 if (mdb_lookup_by_name("p0", &sym
) == -1) {
2707 mdb_warn("failed to read 'practive'");
2710 wsp
->walk_addr
= (uintptr_t)sym
.st_value
;
2713 pw
= mdb_zalloc(sizeof (proc_walk_data_t
), UM_SLEEP
);
2715 if (mdb_readvar(&pw
->pw_max
, "nproc") == -1) {
2716 mdb_warn("failed to read 'nproc'");
2717 mdb_free(pw
, sizeof (pw
));
2721 pw
->pw_stack
= mdb_alloc(pw
->pw_max
* sizeof (uintptr_t), UM_SLEEP
);
2722 wsp
->walk_data
= pw
;
2727 typedef struct mdb_walk_proc
{
2728 struct proc
*p_child
;
2729 struct proc
*p_sibling
;
2733 proc_walk_step(mdb_walk_state_t
*wsp
)
2735 proc_walk_data_t
*pw
= wsp
->walk_data
;
2736 uintptr_t addr
= wsp
->walk_addr
;
2741 if (mdb_ctf_vread(&pr
, "proc_t", "mdb_walk_proc_t",
2743 mdb_warn("failed to read proc at %p", addr
);
2747 cld
= (uintptr_t)pr
.p_child
;
2748 sib
= (uintptr_t)pr
.p_sibling
;
2750 if (pw
->pw_depth
> 0 && addr
== pw
->pw_stack
[pw
->pw_depth
- 1]) {
2756 * Always pass NULL as the local copy pointer. Consumers
2757 * should use mdb_ctf_vread() to read their own minimal
2758 * version of proc_t. Thus minimizing the chance of breakage
2759 * with older crash dumps.
2761 status
= wsp
->walk_callback(addr
, NULL
, wsp
->walk_cbdata
);
2763 if (status
!= WALK_NEXT
)
2766 if ((wsp
->walk_addr
= cld
) != (uintptr_t)NULL
) {
2767 if (mdb_ctf_vread(&pr
, "proc_t", "mdb_walk_proc_t",
2769 mdb_warn("proc %p has invalid p_child %p; skipping\n",
2774 pw
->pw_stack
[pw
->pw_depth
++] = addr
;
2776 if (pw
->pw_depth
== pw
->pw_max
) {
2777 mdb_warn("depth %d exceeds max depth; try again\n",
2786 * We know that p0 has no siblings, and if another starting proc
2787 * was given, we don't want to walk its siblings anyway.
2789 if (pw
->pw_depth
== 0)
2792 if (sib
!= (uintptr_t)NULL
&&
2793 mdb_ctf_vread(&pr
, "proc_t", "mdb_walk_proc_t", sib
, 0) == -1) {
2794 mdb_warn("proc %p has invalid p_sibling %p; skipping\n",
2796 sib
= (uintptr_t)NULL
;
2799 if ((wsp
->walk_addr
= sib
) == (uintptr_t)NULL
) {
2800 if (pw
->pw_depth
> 0) {
2801 wsp
->walk_addr
= pw
->pw_stack
[pw
->pw_depth
- 1];
2811 proc_walk_fini(mdb_walk_state_t
*wsp
)
2813 proc_walk_data_t
*pw
= wsp
->walk_data
;
2815 mdb_free(pw
->pw_stack
, pw
->pw_max
* sizeof (uintptr_t));
2816 mdb_free(pw
, sizeof (proc_walk_data_t
));
2820 task_walk_init(mdb_walk_state_t
*wsp
)
2824 if (mdb_vread(&task
, sizeof (task_t
), wsp
->walk_addr
) == -1) {
2825 mdb_warn("failed to read task at %p", wsp
->walk_addr
);
2828 wsp
->walk_addr
= (uintptr_t)task
.tk_memb_list
;
2829 wsp
->walk_data
= task
.tk_memb_list
;
2833 typedef struct mdb_task_proc
{
2834 struct proc
*p_tasknext
;
2838 task_walk_step(mdb_walk_state_t
*wsp
)
2840 mdb_task_proc_t proc
;
2843 if (mdb_ctf_vread(&proc
, "proc_t", "mdb_task_proc_t",
2844 wsp
->walk_addr
, 0) == -1) {
2845 mdb_warn("failed to read proc at %p", wsp
->walk_addr
);
2849 status
= wsp
->walk_callback(wsp
->walk_addr
, NULL
, wsp
->walk_cbdata
);
2851 if (proc
.p_tasknext
== wsp
->walk_data
)
2854 wsp
->walk_addr
= (uintptr_t)proc
.p_tasknext
;
2859 project_walk_init(mdb_walk_state_t
*wsp
)
2861 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
2862 if (mdb_readvar(&wsp
->walk_addr
, "proj0p") == -1) {
2863 mdb_warn("failed to read 'proj0p'");
2867 wsp
->walk_data
= (void *)wsp
->walk_addr
;
2872 project_walk_step(mdb_walk_state_t
*wsp
)
2874 uintptr_t addr
= wsp
->walk_addr
;
2878 if (mdb_vread(&pj
, sizeof (kproject_t
), addr
) == -1) {
2879 mdb_warn("failed to read project at %p", addr
);
2882 status
= wsp
->walk_callback(addr
, &pj
, wsp
->walk_cbdata
);
2883 if (status
!= WALK_NEXT
)
2885 wsp
->walk_addr
= (uintptr_t)pj
.kpj_next
;
2886 if ((void *)wsp
->walk_addr
== wsp
->walk_data
)
2892 generic_walk_step(mdb_walk_state_t
*wsp
)
2894 return (wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_layer
,
2899 cpu_walk_cmp(const void *l
, const void *r
)
2901 uintptr_t lhs
= *((uintptr_t *)l
);
2902 uintptr_t rhs
= *((uintptr_t *)r
);
2905 (void) mdb_vread(&lcpu
, sizeof (lcpu
), lhs
);
2906 (void) mdb_vread(&rcpu
, sizeof (rcpu
), rhs
);
2908 if (lcpu
.cpu_id
< rcpu
.cpu_id
)
2911 if (lcpu
.cpu_id
> rcpu
.cpu_id
)
2917 typedef struct cpu_walk
{
2918 uintptr_t *cw_array
;
2923 cpu_walk_init(mdb_walk_state_t
*wsp
)
2926 int max_ncpus
, i
= 0;
2927 uintptr_t current
, first
;
2928 cpu_t cpu
, panic_cpu
;
2929 uintptr_t panicstr
, addr
;
2932 cw
= mdb_zalloc(sizeof (cpu_walk_t
), UM_SLEEP
| UM_GC
);
2934 if (mdb_readvar(&max_ncpus
, "max_ncpus") == -1) {
2935 mdb_warn("failed to read 'max_ncpus'");
2939 if (mdb_readvar(&panicstr
, "panicstr") == -1) {
2940 mdb_warn("failed to read 'panicstr'");
2944 if (panicstr
!= (uintptr_t)NULL
) {
2945 if (mdb_lookup_by_name("panic_cpu", &sym
) == -1) {
2946 mdb_warn("failed to find 'panic_cpu'");
2950 addr
= (uintptr_t)sym
.st_value
;
2952 if (mdb_vread(&panic_cpu
, sizeof (cpu_t
), addr
) == -1) {
2953 mdb_warn("failed to read 'panic_cpu'");
2959 * Unfortunately, there is no platform-independent way to walk
2960 * CPUs in ID order. We therefore loop through in cpu_next order,
2961 * building an array of CPU pointers which will subsequently be
2965 mdb_zalloc((max_ncpus
+ 1) * sizeof (uintptr_t), UM_SLEEP
| UM_GC
);
2967 if (mdb_readvar(&first
, "cpu_list") == -1) {
2968 mdb_warn("failed to read 'cpu_list'");
2974 if (mdb_vread(&cpu
, sizeof (cpu
), current
) == -1) {
2975 mdb_warn("failed to read cpu at %p", current
);
2979 if (panicstr
!= (uintptr_t)NULL
&&
2980 panic_cpu
.cpu_id
== cpu
.cpu_id
) {
2981 cw
->cw_array
[i
++] = addr
;
2983 cw
->cw_array
[i
++] = current
;
2985 } while ((current
= (uintptr_t)cpu
.cpu_next
) != first
);
2987 qsort(cw
->cw_array
, i
, sizeof (uintptr_t), cpu_walk_cmp
);
2988 wsp
->walk_data
= cw
;
2994 cpu_walk_step(mdb_walk_state_t
*wsp
)
2996 cpu_walk_t
*cw
= wsp
->walk_data
;
2998 uintptr_t addr
= cw
->cw_array
[cw
->cw_ndx
++];
3000 if (addr
== (uintptr_t)NULL
)
3003 if (mdb_vread(&cpu
, sizeof (cpu
), addr
) == -1) {
3004 mdb_warn("failed to read cpu at %p", addr
);
3008 return (wsp
->walk_callback(addr
, &cpu
, wsp
->walk_cbdata
));
3011 typedef struct cpuinfo_data
{
3013 uintptr_t **cid_ithr
;
3014 char cid_print_head
;
3016 char cid_print_ithr
;
3017 char cid_print_flags
;
3021 cpuinfo_walk_ithread(uintptr_t addr
, const kthread_t
*thr
, cpuinfo_data_t
*cid
)
3027 if (!(thr
->t_flag
& T_INTR_THREAD
) || thr
->t_state
== TS_FREE
)
3030 if (thr
->t_bound_cpu
== NULL
) {
3031 mdb_warn("thr %p is intr thread w/out a CPU\n", addr
);
3035 (void) mdb_vread(&c
, sizeof (c
), (uintptr_t)thr
->t_bound_cpu
);
3037 if ((id
= c
.cpu_id
) >= NCPU
) {
3038 mdb_warn("CPU %p has id (%d) greater than NCPU (%d)\n",
3039 thr
->t_bound_cpu
, id
, NCPU
);
3043 if ((pil
= thr
->t_pil
) >= NINTR
) {
3044 mdb_warn("thread %p has pil (%d) greater than %d\n",
3049 if (cid
->cid_ithr
[id
][pil
] != 0) {
3050 mdb_warn("CPU %d has multiple threads at pil %d (at least "
3051 "%p and %p)\n", id
, pil
, addr
, cid
->cid_ithr
[id
][pil
]);
3055 cid
->cid_ithr
[id
][pil
] = addr
;
3060 #define CPUINFO_IDWIDTH 3
3061 #define CPUINFO_FLAGWIDTH 9
3064 #if defined(__amd64)
3065 #define CPUINFO_TWIDTH 16
3066 #define CPUINFO_CPUWIDTH 16
3068 #define CPUINFO_CPUWIDTH 11
3069 #define CPUINFO_TWIDTH 11
3072 #define CPUINFO_CPUWIDTH 8
3073 #define CPUINFO_TWIDTH 8
3076 #define CPUINFO_THRDELT (CPUINFO_IDWIDTH + CPUINFO_CPUWIDTH + 9)
3077 #define CPUINFO_FLAGDELT (CPUINFO_IDWIDTH + CPUINFO_CPUWIDTH + 4)
3078 #define CPUINFO_ITHRDELT 4
3080 #define CPUINFO_INDENT mdb_printf("%*s", CPUINFO_THRDELT, \
3081 flagline < nflaglines ? flagbuf[flagline++] : "")
3083 typedef struct mdb_cpuinfo_proc
{
3085 char u_comm
[MAXCOMLEN
+ 1];
3087 } mdb_cpuinfo_proc_t
;
3090 cpuinfo_walk_cpu(uintptr_t addr
, const cpu_t
*cpu
, cpuinfo_data_t
*cid
)
3094 mdb_cpuinfo_proc_t p
;
3097 int nflaglines
= 0, flagline
= 0, bspl
, rval
= WALK_NEXT
;
3099 const char *flags
[] = {
3100 "RUNNING", "READY", "QUIESCED", "EXISTS",
3101 "ENABLE", "OFFLINE", "POWEROFF", "FROZEN",
3102 "SPARE", "FAULTED", NULL
3105 if (cid
->cid_cpu
!= -1) {
3106 if (addr
!= cid
->cid_cpu
&& cpu
->cpu_id
!= cid
->cid_cpu
)
3110 * Set cid_cpu to -1 to indicate that we found a matching CPU.
3116 if (cid
->cid_print_head
) {
3117 mdb_printf("%3s %-*s %3s %4s %4s %3s %4s %5s %-6s %-*s %s\n",
3118 "ID", CPUINFO_CPUWIDTH
, "ADDR", "FLG", "NRUN", "BSPL",
3119 "PRI", "RNRN", "KRNRN", "SWITCH", CPUINFO_TWIDTH
, "THREAD",
3121 cid
->cid_print_head
= FALSE
;
3124 bspl
= cpu
->cpu_base_spl
;
3126 if (mdb_vread(&disp
, sizeof (disp_t
), (uintptr_t)cpu
->cpu_disp
) == -1) {
3127 mdb_warn("failed to read disp_t at %p", cpu
->cpu_disp
);
3131 mdb_printf("%3d %0*p %3x %4d %4d ",
3132 cpu
->cpu_id
, CPUINFO_CPUWIDTH
, addr
, cpu
->cpu_flags
,
3133 disp
.disp_nrunnable
, bspl
);
3135 if (mdb_vread(&t
, sizeof (t
), (uintptr_t)cpu
->cpu_thread
) != -1) {
3136 mdb_printf("%3d ", t
.t_pri
);
3138 mdb_printf("%3s ", "-");
3141 mdb_printf("%4s %5s ", cpu
->cpu_runrun
? "yes" : "no",
3142 cpu
->cpu_kprunrun
? "yes" : "no");
3144 if (cpu
->cpu_last_swtch
) {
3145 mdb_printf("t-%-4d ",
3146 (clock_t)mdb_get_lbolt() - cpu
->cpu_last_swtch
);
3148 mdb_printf("%-6s ", "-");
3151 mdb_printf("%0*p", CPUINFO_TWIDTH
, cpu
->cpu_thread
);
3153 if (cpu
->cpu_thread
== cpu
->cpu_idle_thread
)
3154 mdb_printf(" (idle)\n");
3155 else if (cpu
->cpu_thread
== NULL
)
3158 if (mdb_ctf_vread(&p
, "proc_t", "mdb_cpuinfo_proc_t",
3159 (uintptr_t)t
.t_procp
, 0) != -1) {
3160 mdb_printf(" %s\n", p
.p_user
.u_comm
);
3166 flagbuf
= mdb_zalloc(sizeof (flags
), UM_SLEEP
| UM_GC
);
3168 if (cid
->cid_print_flags
) {
3169 int first
= 1, i
, j
, k
;
3172 cid
->cid_print_head
= TRUE
;
3174 for (i
= 1, j
= 0; flags
[j
] != NULL
; i
<<= 1, j
++) {
3175 if (!(cpu
->cpu_flags
& i
))
3179 s
= mdb_alloc(CPUINFO_THRDELT
+ 1,
3182 (void) mdb_snprintf(s
, CPUINFO_THRDELT
+ 1,
3183 "%*s|%*s", CPUINFO_FLAGDELT
, "",
3184 CPUINFO_THRDELT
- 1 - CPUINFO_FLAGDELT
, "");
3185 flagbuf
[nflaglines
++] = s
;
3188 s
= mdb_alloc(CPUINFO_THRDELT
+ 1, UM_GC
| UM_SLEEP
);
3189 (void) mdb_snprintf(s
, CPUINFO_THRDELT
+ 1, "%*s%*s %s",
3190 CPUINFO_IDWIDTH
+ CPUINFO_CPUWIDTH
-
3191 CPUINFO_FLAGWIDTH
, "", CPUINFO_FLAGWIDTH
, flags
[j
],
3192 first
? "<--+" : "");
3194 for (k
= strlen(s
); k
< CPUINFO_THRDELT
; k
++)
3198 flagbuf
[nflaglines
++] = s
;
3203 if (cid
->cid_print_ithr
) {
3204 int i
, found_one
= FALSE
;
3205 int print_thr
= disp
.disp_nrunnable
&& cid
->cid_print_thr
;
3207 for (i
= NINTR
- 1; i
>= 0; i
--) {
3208 uintptr_t iaddr
= cid
->cid_ithr
[cpu
->cpu_id
][i
];
3210 if (iaddr
== (uintptr_t)NULL
)
3217 mdb_printf("%c%*s|\n", print_thr
? '|' : ' ',
3218 CPUINFO_ITHRDELT
, "");
3221 mdb_printf("%c%*s+--> %3s %s\n",
3222 print_thr
? '|' : ' ', CPUINFO_ITHRDELT
,
3223 "", "PIL", "THREAD");
3226 if (mdb_vread(&t
, sizeof (t
), iaddr
) == -1) {
3227 mdb_warn("failed to read kthread_t at %p",
3233 mdb_printf("%c%*s %3d %0*p\n",
3234 print_thr
? '|' : ' ', CPUINFO_ITHRDELT
, "",
3235 t
.t_pil
, CPUINFO_TWIDTH
, iaddr
);
3237 pinned
= (uintptr_t)t
.t_intr
;
3240 if (found_one
&& pinned
!= 0) {
3241 cid
->cid_print_head
= TRUE
;
3242 (void) strcpy(p
.p_user
.u_comm
, "?");
3244 if (mdb_vread(&t
, sizeof (t
),
3245 (uintptr_t)pinned
) == -1) {
3246 mdb_warn("failed to read kthread_t at %p",
3250 if (mdb_ctf_vread(&p
, "proc_t", "mdb_cpuinfo_proc_t",
3251 (uintptr_t)t
.t_procp
, 0) == -1) {
3252 mdb_warn("failed to read proc_t at %p",
3258 mdb_printf("%c%*s %3s %0*p %s\n",
3259 print_thr
? '|' : ' ', CPUINFO_ITHRDELT
, "", "-",
3260 CPUINFO_TWIDTH
, pinned
,
3261 pinned
== (uintptr_t)cpu
->cpu_idle_thread
?
3262 "(idle)" : p
.p_user
.u_comm
);
3266 if (disp
.disp_nrunnable
&& cid
->cid_print_thr
) {
3269 int i
, npri
= disp
.disp_npri
;
3271 dq
= mdb_alloc(sizeof (dispq_t
) * npri
, UM_SLEEP
| UM_GC
);
3273 if (mdb_vread(dq
, sizeof (dispq_t
) * npri
,
3274 (uintptr_t)disp
.disp_q
) == -1) {
3275 mdb_warn("failed to read dispq_t at %p", disp
.disp_q
);
3283 mdb_printf("+--> %3s %-*s %s\n", "PRI",
3284 CPUINFO_TWIDTH
, "THREAD", "PROC");
3286 for (i
= npri
- 1; i
>= 0; i
--) {
3287 uintptr_t taddr
= (uintptr_t)dq
[i
].dq_first
;
3289 while (taddr
!= (uintptr_t)NULL
) {
3290 if (mdb_vread(&t
, sizeof (t
), taddr
) == -1) {
3291 mdb_warn("failed to read kthread_t "
3295 if (mdb_ctf_vread(&p
, "proc_t",
3296 "mdb_cpuinfo_proc_t",
3297 (uintptr_t)t
.t_procp
, 0) == -1) {
3298 mdb_warn("failed to read proc_t at %p",
3304 mdb_printf(" %3d %0*p %s\n", t
.t_pri
,
3305 CPUINFO_TWIDTH
, taddr
, p
.p_user
.u_comm
);
3307 taddr
= (uintptr_t)t
.t_link
;
3310 cid
->cid_print_head
= TRUE
;
3313 while (flagline
< nflaglines
)
3314 mdb_printf("%s\n", flagbuf
[flagline
++]);
3316 if (cid
->cid_print_head
)
3323 cpuinfo(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3325 uint_t verbose
= FALSE
;
3328 cid
.cid_print_ithr
= FALSE
;
3329 cid
.cid_print_thr
= FALSE
;
3330 cid
.cid_print_flags
= FALSE
;
3331 cid
.cid_print_head
= DCMD_HDRSPEC(flags
) ? TRUE
: FALSE
;
3334 if (flags
& DCMD_ADDRSPEC
)
3337 if (mdb_getopts(argc
, argv
,
3338 'v', MDB_OPT_SETBITS
, TRUE
, &verbose
, NULL
) != argc
)
3339 return (DCMD_USAGE
);
3342 cid
.cid_print_ithr
= TRUE
;
3343 cid
.cid_print_thr
= TRUE
;
3344 cid
.cid_print_flags
= TRUE
;
3345 cid
.cid_print_head
= TRUE
;
3348 if (cid
.cid_print_ithr
) {
3351 cid
.cid_ithr
= mdb_alloc(sizeof (uintptr_t **)
3352 * NCPU
, UM_SLEEP
| UM_GC
);
3354 for (i
= 0; i
< NCPU
; i
++)
3355 cid
.cid_ithr
[i
] = mdb_zalloc(sizeof (uintptr_t *) *
3356 NINTR
, UM_SLEEP
| UM_GC
);
3358 if (mdb_walk("thread", (mdb_walk_cb_t
)cpuinfo_walk_ithread
,
3360 mdb_warn("couldn't walk thread");
3365 if (mdb_walk("cpu", (mdb_walk_cb_t
)cpuinfo_walk_cpu
, &cid
) == -1) {
3366 mdb_warn("can't walk cpus");
3370 if (cid
.cid_cpu
!= -1) {
3372 * We didn't find this CPU when we walked through the CPUs
3373 * (i.e. the address specified doesn't show up in the "cpu"
3374 * walk). However, the specified address may still correspond
3375 * to a valid cpu_t (for example, if the specified address is
3376 * the actual panicking cpu_t and not the cached panic_cpu).
3377 * Point is: even if we didn't find it, we still want to try
3378 * to print the specified address as a cpu_t.
3382 if (mdb_vread(&cpu
, sizeof (cpu
), cid
.cid_cpu
) == -1) {
3383 mdb_warn("%p is neither a valid CPU ID nor a "
3384 "valid cpu_t address\n", cid
.cid_cpu
);
3388 (void) cpuinfo_walk_cpu(cid
.cid_cpu
, &cpu
, &cid
);
3396 flipone(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3400 if (!(flags
& DCMD_ADDRSPEC
))
3401 return (DCMD_USAGE
);
3403 for (i
= 0; i
< sizeof (addr
) * NBBY
; i
++)
3404 mdb_printf("%p\n", addr
^ (1UL << i
));
3409 typedef struct mdb_as2proc_proc
{
3411 } mdb_as2proc_proc_t
;
3415 as2proc_walk(uintptr_t addr
, const void *ignored
, struct as
**asp
)
3417 mdb_as2proc_proc_t p
;
3419 mdb_ctf_vread(&p
, "proc_t", "mdb_as2proc_proc_t", addr
, 0);
3422 mdb_printf("%p\n", addr
);
3428 as2proc(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3430 if (!(flags
& DCMD_ADDRSPEC
) || argc
!= 0)
3431 return (DCMD_USAGE
);
3433 if (mdb_walk("proc", (mdb_walk_cb_t
)as2proc_walk
, &addr
) == -1) {
3434 mdb_warn("failed to walk proc");
3441 typedef struct mdb_ptree_proc
{
3442 struct proc
*p_parent
;
3444 char u_comm
[MAXCOMLEN
+ 1];
3450 ptree_walk(uintptr_t addr
, const void *ignored
, void *data
)
3452 mdb_ptree_proc_t proc
;
3453 mdb_ptree_proc_t parent
;
3457 mdb_ctf_vread(&proc
, "proc_t", "mdb_ptree_proc_t", addr
, 0);
3459 for (paddr
= (uintptr_t)proc
.p_parent
; paddr
!= (uintptr_t)NULL
; ident
+= 5) {
3460 mdb_ctf_vread(&parent
, "proc_t", "mdb_ptree_proc_t", paddr
, 0);
3461 paddr
= (uintptr_t)parent
.p_parent
;
3464 mdb_inc_indent(ident
);
3465 mdb_printf("%0?p %s\n", addr
, proc
.p_user
.u_comm
);
3466 mdb_dec_indent(ident
);
3472 ptree_ancestors(uintptr_t addr
, uintptr_t start
)
3476 if (mdb_ctf_vread(&p
, "proc_t", "mdb_ptree_proc_t", addr
, 0) == -1) {
3477 mdb_warn("couldn't read ancestor at %p", addr
);
3481 if (p
.p_parent
!= NULL
)
3482 ptree_ancestors((uintptr_t)p
.p_parent
, start
);
3485 (void) ptree_walk(addr
, &p
, NULL
);
3490 ptree(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3492 if (!(flags
& DCMD_ADDRSPEC
))
3493 addr
= (uintptr_t)NULL
;
3495 ptree_ancestors(addr
, addr
);
3497 if (mdb_pwalk("proc", (mdb_walk_cb_t
)ptree_walk
, NULL
, addr
) == -1) {
3498 mdb_warn("couldn't walk 'proc'");
3505 typedef struct mdb_fd_proc
{
3509 uf_entry_t
*volatile fi_list
;
3516 fd(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3519 const mdb_arg_t
*argp
= &argv
[0];
3523 if ((flags
& DCMD_ADDRSPEC
) == 0) {
3524 mdb_warn("fd doesn't give global information\n");
3528 return (DCMD_USAGE
);
3530 if (argp
->a_type
== MDB_TYPE_IMMEDIATE
)
3531 fdnum
= argp
->a_un
.a_val
;
3533 fdnum
= mdb_strtoull(argp
->a_un
.a_str
);
3535 if (mdb_ctf_vread(&p
, "proc_t", "mdb_fd_proc_t", addr
, 0) == -1) {
3536 mdb_warn("couldn't read proc_t at %p", addr
);
3539 if (fdnum
> p
.p_user
.u_finfo
.fi_nfiles
) {
3540 mdb_warn("process %p only has %d files open.\n",
3541 addr
, p
.p_user
.u_finfo
.fi_nfiles
);
3544 if (mdb_vread(&uf
, sizeof (uf_entry_t
),
3545 (uintptr_t)&p
.p_user
.u_finfo
.fi_list
[fdnum
]) == -1) {
3546 mdb_warn("couldn't read uf_entry_t at %p",
3547 &p
.p_user
.u_finfo
.fi_list
[fdnum
]);
3551 mdb_printf("%p\n", uf
.uf_file
);
3557 pid2proc(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3559 pid_t pid
= (pid_t
)addr
;
3562 return (DCMD_USAGE
);
3564 if ((addr
= mdb_pid2proc(pid
, NULL
)) == (uintptr_t)NULL
) {
3565 mdb_warn("PID 0t%d not found\n", pid
);
3569 mdb_printf("%p\n", addr
);
3573 static char *sysfile_cmd
[] = {
3586 static char *sysfile_ops
[] = { "", "=", "&", "|" };
3590 sysfile_vmem_seg(uintptr_t addr
, const vmem_seg_t
*vsp
, void **target
)
3592 if (vsp
->vs_type
== VMEM_ALLOC
&& (void *)vsp
->vs_start
== *target
) {
3601 sysfile(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3603 struct sysparam
*sysp
, sys
;
3608 vmem_t
*mod_sysfile_arena
;
3611 if (mdb_readvar(&sysp
, "sysparam_hd") == -1) {
3612 mdb_warn("failed to read sysparam_hd");
3616 if (mdb_readvar(&mod_sysfile_arena
, "mod_sysfile_arena") == -1) {
3617 mdb_warn("failed to read mod_sysfile_arena");
3621 while (sysp
!= NULL
) {
3625 if (mdb_vread(&sys
, sizeof (sys
), (uintptr_t)sysp
) == -1) {
3626 mdb_warn("couldn't read sysparam %p", sysp
);
3629 if (sys
.sys_modnam
!= NULL
&&
3630 mdb_readstr(modname
, 256,
3631 (uintptr_t)sys
.sys_modnam
) == -1) {
3632 mdb_warn("couldn't read modname in %p", sysp
);
3635 if (sys
.sys_ptr
!= NULL
&&
3636 mdb_readstr(var
, 256, (uintptr_t)sys
.sys_ptr
) == -1) {
3637 mdb_warn("couldn't read ptr in %p", sysp
);
3640 if (sys
.sys_op
!= SETOP_NONE
) {
3642 * Is this an int or a string? We determine this
3643 * by checking whether straddr is contained in
3644 * mod_sysfile_arena. If so, the walker will set
3647 straddr
= (void *)(uintptr_t)sys
.sys_info
;
3648 if (sys
.sys_op
== SETOP_ASSIGN
&&
3649 sys
.sys_info
!= 0 &&
3650 mdb_pwalk("vmem_seg",
3651 (mdb_walk_cb_t
)sysfile_vmem_seg
, &straddr
,
3652 (uintptr_t)mod_sysfile_arena
) == 0 &&
3654 mdb_readstr(strval
, 256,
3655 (uintptr_t)sys
.sys_info
) != -1) {
3656 (void) mdb_snprintf(val
, sizeof (val
), "\"%s\"",
3659 (void) mdb_snprintf(val
, sizeof (val
),
3660 "0x%llx [0t%llu]", sys
.sys_info
,
3664 mdb_printf("%s %s%s%s%s%s\n", sysfile_cmd
[sys
.sys_type
],
3665 modname
, modname
[0] == '\0' ? "" : ":",
3666 var
, sysfile_ops
[sys
.sys_op
], val
);
3668 sysp
= sys
.sys_next
;
3675 didmatch(uintptr_t addr
, const kthread_t
*thr
, kt_did_t
*didp
)
3678 if (*didp
== thr
->t_did
) {
3679 mdb_printf("%p\n", addr
);
3687 did2thread(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3689 const mdb_arg_t
*argp
= &argv
[0];
3693 return (DCMD_USAGE
);
3695 did
= (kt_did_t
)mdb_strtoull(argp
->a_un
.a_str
);
3697 if (mdb_walk("thread", (mdb_walk_cb_t
)didmatch
, (void *)&did
) == -1) {
3698 mdb_warn("failed to walk thread");
3707 errorq_walk_init(mdb_walk_state_t
*wsp
)
3709 if (wsp
->walk_addr
== (uintptr_t)NULL
&&
3710 mdb_readvar(&wsp
->walk_addr
, "errorq_list") == -1) {
3711 mdb_warn("failed to read errorq_list");
3719 errorq_walk_step(mdb_walk_state_t
*wsp
)
3721 uintptr_t addr
= wsp
->walk_addr
;
3724 if (addr
== (uintptr_t)NULL
)
3727 if (mdb_vread(&eq
, sizeof (eq
), addr
) == -1) {
3728 mdb_warn("failed to read errorq at %p", addr
);
3732 wsp
->walk_addr
= (uintptr_t)eq
.eq_next
;
3733 return (wsp
->walk_callback(addr
, &eq
, wsp
->walk_cbdata
));
3736 typedef struct eqd_walk_data
{
3737 uintptr_t *eqd_stack
;
3745 * In order to walk the list of pending error queue elements, we push the
3746 * addresses of the corresponding data buffers in to the eqd_stack array.
3747 * The error lists are in reverse chronological order when iterating using
3748 * eqe_prev, so we then pop things off the top in eqd_walk_step so that the
3749 * walker client gets addresses in order from oldest error to newest error.
3752 eqd_push_list(eqd_walk_data_t
*eqdp
, uintptr_t addr
)
3756 while (addr
!= (uintptr_t)NULL
) {
3757 if (mdb_vread(&eqe
, sizeof (eqe
), addr
) != sizeof (eqe
)) {
3758 mdb_warn("failed to read errorq element at %p", addr
);
3762 if (eqdp
->eqd_qpos
== eqdp
->eqd_qlen
) {
3763 mdb_warn("errorq is overfull -- more than %lu "
3764 "elems found\n", eqdp
->eqd_qlen
);
3768 eqdp
->eqd_stack
[eqdp
->eqd_qpos
++] = (uintptr_t)eqe
.eqe_data
;
3769 addr
= (uintptr_t)eqe
.eqe_prev
;
3774 eqd_walk_init(mdb_walk_state_t
*wsp
)
3776 eqd_walk_data_t
*eqdp
;
3777 errorq_elem_t eqe
, *addr
;
3781 if (mdb_vread(&eq
, sizeof (eq
), wsp
->walk_addr
) == -1) {
3782 mdb_warn("failed to read errorq at %p", wsp
->walk_addr
);
3786 if (eq
.eq_ptail
!= NULL
&&
3787 mdb_vread(&eqe
, sizeof (eqe
), (uintptr_t)eq
.eq_ptail
) == -1) {
3788 mdb_warn("failed to read errorq element at %p", eq
.eq_ptail
);
3792 eqdp
= mdb_alloc(sizeof (eqd_walk_data_t
), UM_SLEEP
);
3793 wsp
->walk_data
= eqdp
;
3795 eqdp
->eqd_stack
= mdb_zalloc(sizeof (uintptr_t) * eq
.eq_qlen
, UM_SLEEP
);
3796 eqdp
->eqd_buf
= mdb_alloc(eq
.eq_size
, UM_SLEEP
);
3797 eqdp
->eqd_qlen
= eq
.eq_qlen
;
3799 eqdp
->eqd_size
= eq
.eq_size
;
3802 * The newest elements in the queue are on the pending list, so we
3803 * push those on to our stack first.
3805 eqd_push_list(eqdp
, (uintptr_t)eq
.eq_pend
);
3808 * If eq_ptail is set, it may point to a subset of the errors on the
3809 * pending list in the event a atomic_cas_ptr() failed; if ptail's
3810 * data is already in our stack, NULL out eq_ptail and ignore it.
3812 if (eq
.eq_ptail
!= NULL
) {
3813 for (i
= 0; i
< eqdp
->eqd_qpos
; i
++) {
3814 if (eqdp
->eqd_stack
[i
] == (uintptr_t)eqe
.eqe_data
) {
3822 * If eq_phead is set, it has the processing list in order from oldest
3823 * to newest. Use this to recompute eq_ptail as best we can and then
3824 * we nicely fall into eqd_push_list() of eq_ptail below.
3826 for (addr
= eq
.eq_phead
; addr
!= NULL
&& mdb_vread(&eqe
, sizeof (eqe
),
3827 (uintptr_t)addr
) == sizeof (eqe
); addr
= eqe
.eqe_next
)
3831 * The oldest elements in the queue are on the processing list, subject
3832 * to machinations in the if-clauses above. Push any such elements.
3834 eqd_push_list(eqdp
, (uintptr_t)eq
.eq_ptail
);
3839 eqd_walk_step(mdb_walk_state_t
*wsp
)
3841 eqd_walk_data_t
*eqdp
= wsp
->walk_data
;
3844 if (eqdp
->eqd_qpos
== 0)
3847 addr
= eqdp
->eqd_stack
[--eqdp
->eqd_qpos
];
3849 if (mdb_vread(eqdp
->eqd_buf
, eqdp
->eqd_size
, addr
) != eqdp
->eqd_size
) {
3850 mdb_warn("failed to read errorq data at %p", addr
);
3854 return (wsp
->walk_callback(addr
, eqdp
->eqd_buf
, wsp
->walk_cbdata
));
3858 eqd_walk_fini(mdb_walk_state_t
*wsp
)
3860 eqd_walk_data_t
*eqdp
= wsp
->walk_data
;
3862 mdb_free(eqdp
->eqd_stack
, sizeof (uintptr_t) * eqdp
->eqd_qlen
);
3863 mdb_free(eqdp
->eqd_buf
, eqdp
->eqd_size
);
3864 mdb_free(eqdp
, sizeof (eqd_walk_data_t
));
3867 #define EQKSVAL(eqv, what) (eqv.eq_kstat.what.value.ui64)
3870 errorq(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3874 uint_t opt_v
= FALSE
;
3876 if (!(flags
& DCMD_ADDRSPEC
)) {
3877 if (mdb_walk_dcmd("errorq", "errorq", argc
, argv
) == -1) {
3878 mdb_warn("can't walk 'errorq'");
3884 i
= mdb_getopts(argc
, argv
, 'v', MDB_OPT_SETBITS
, TRUE
, &opt_v
, NULL
);
3889 return (DCMD_USAGE
);
3891 if (opt_v
|| DCMD_HDRSPEC(flags
)) {
3892 mdb_printf("%<u>%-11s %-16s %1s %1s %1s ",
3893 "ADDR", "NAME", "S", "V", "N");
3895 mdb_printf("%7s %7s %7s%</u>\n",
3896 "ACCEPT", "DROP", "LOG");
3898 mdb_printf("%5s %6s %6s %3s %16s%</u>\n",
3899 "KSTAT", "QLEN", "SIZE", "IPL", "FUNC");
3903 if (mdb_vread(&eq
, sizeof (eq
), addr
) != sizeof (eq
)) {
3904 mdb_warn("failed to read errorq at %p", addr
);
3908 mdb_printf("%-11p %-16s %c %c %c ", addr
, eq
.eq_name
,
3909 (eq
.eq_flags
& ERRORQ_ACTIVE
) ? '+' : '-',
3910 (eq
.eq_flags
& ERRORQ_VITAL
) ? '!' : ' ',
3911 (eq
.eq_flags
& ERRORQ_NVLIST
) ? '*' : ' ');
3914 mdb_printf("%7llu %7llu %7llu\n",
3915 EQKSVAL(eq
, eqk_dispatched
) + EQKSVAL(eq
, eqk_committed
),
3916 EQKSVAL(eq
, eqk_dropped
) + EQKSVAL(eq
, eqk_reserve_fail
) +
3917 EQKSVAL(eq
, eqk_commit_fail
), EQKSVAL(eq
, eqk_logged
));
3919 mdb_printf("%5s %6lu %6lu %3u %a\n",
3920 " | ", eq
.eq_qlen
, eq
.eq_size
, eq
.eq_ipl
, eq
.eq_func
);
3921 mdb_printf("%38s\n%41s"
3931 "DISPATCHED", EQKSVAL(eq
, eqk_dispatched
),
3932 "DROPPED", EQKSVAL(eq
, eqk_dropped
),
3933 "LOGGED", EQKSVAL(eq
, eqk_logged
),
3934 "RESERVED", EQKSVAL(eq
, eqk_reserved
),
3935 "RESERVE FAIL", EQKSVAL(eq
, eqk_reserve_fail
),
3936 "COMMITTED", EQKSVAL(eq
, eqk_committed
),
3937 "COMMIT FAIL", EQKSVAL(eq
, eqk_commit_fail
),
3938 "CANCELLED", EQKSVAL(eq
, eqk_cancelled
));
3946 panicinfo(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
3949 kthread_t
*panic_thread
;
3954 if (!mdb_prop_postmortem
) {
3955 mdb_warn("panicinfo can only be run on a system "
3956 "dump; see dumpadm(8)\n");
3960 if (flags
& DCMD_ADDRSPEC
|| argc
!= 0)
3961 return (DCMD_USAGE
);
3963 if (mdb_readsym(&panic_cpu
, sizeof (cpu_t
), "panic_cpu") == -1)
3964 mdb_warn("failed to read 'panic_cpu'");
3966 mdb_printf("%16s %?d\n", "cpu", panic_cpu
.cpu_id
);
3968 if (mdb_readvar(&panic_thread
, "panic_thread") == -1)
3969 mdb_warn("failed to read 'panic_thread'");
3971 mdb_printf("%16s %?p\n", "thread", panic_thread
);
3973 buf
= mdb_alloc(PANICBUFSIZE
, UM_SLEEP
);
3974 pd
= (panic_data_t
*)buf
;
3976 if (mdb_readsym(buf
, PANICBUFSIZE
, "panicbuf") == -1 ||
3977 pd
->pd_version
!= PANICBUFVERS
) {
3978 mdb_warn("failed to read 'panicbuf'");
3979 mdb_free(buf
, PANICBUFSIZE
);
3983 mdb_printf("%16s %s\n", "message", (char *)buf
+ pd
->pd_msgoff
);
3985 n
= (pd
->pd_msgoff
- (sizeof (panic_data_t
) -
3986 sizeof (panic_nv_t
))) / sizeof (panic_nv_t
);
3988 for (i
= 0; i
< n
; i
++)
3989 mdb_printf("%16s %?llx\n",
3990 pd
->pd_nvdata
[i
].pnv_name
, pd
->pd_nvdata
[i
].pnv_value
);
3992 mdb_free(buf
, PANICBUFSIZE
);
3997 * ::time dcmd, which will print a hires timestamp of when we entered the
3998 * debugger, or the lbolt value if used with the -l option.
4003 time(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
4005 uint_t opt_dec
= FALSE
;
4006 uint_t opt_lbolt
= FALSE
;
4007 uint_t opt_hex
= FALSE
;
4011 if (mdb_getopts(argc
, argv
,
4012 'd', MDB_OPT_SETBITS
, TRUE
, &opt_dec
,
4013 'l', MDB_OPT_SETBITS
, TRUE
, &opt_lbolt
,
4014 'x', MDB_OPT_SETBITS
, TRUE
, &opt_hex
,
4016 return (DCMD_USAGE
);
4018 if (opt_dec
&& opt_hex
)
4019 return (DCMD_USAGE
);
4021 result
= opt_lbolt
? mdb_get_lbolt() : mdb_gethrtime();
4023 opt_hex
? "0x%llx\n" :
4024 opt_dec
? "0t%lld\n" : "%#llr\n";
4026 mdb_printf(fmt
, result
);
4033 mdb_printf("Prints the system time in nanoseconds.\n\n"
4034 "::time will return the timestamp at which we dropped into, \n"
4035 "if called from, kmdb(1); the core dump's high resolution \n"
4036 "time if inspecting one; or the running hires time if we're \n"
4037 "looking at a live system.\n\n"
4039 " -d report times in decimal\n"
4040 " -l prints the number of clock ticks since system boot\n"
4041 " -x report times in hexadecimal\n");
4044 static const mdb_dcmd_t dcmds
[] = {
4046 /* from genunix.c */
4047 { "as2proc", ":", "convert as to proc_t address", as2proc
},
4048 { "binding_hash_entry", ":", "print driver names hash table entry",
4049 binding_hash_entry
},
4050 { "callout", "?[-r|n] [-s|l] [-xhB] [-t | -ab nsec [-dkD]]"
4051 " [-C addr | -S seqid] [-f name|addr] [-p name| addr] [-T|L [-E]]"
4053 "display callouts", callout
, callout_help
},
4054 { "calloutid", "[-d|v] xid", "print callout by extended id",
4055 calloutid
, calloutid_help
},
4056 { "class", NULL
, "print process scheduler classes", class },
4057 { "cpuinfo", "?[-v]", "print CPUs and runnable threads", cpuinfo
},
4058 { "did2thread", "? kt_did", "find kernel thread for this id",
4060 { "errorq", "?[-v]", "display kernel error queues", errorq
},
4061 { "fd", ":[fd num]", "get a file pointer from an fd", fd
},
4062 { "flipone", ":", "the vik_rev_level 2 special", flipone
},
4063 { "lminfo", NULL
, "print lock manager information", lminfo
},
4064 { "ndi_event_hdl", "?", "print ndi_event_hdl", ndi_event_hdl
},
4065 { "panicinfo", NULL
, "print panic information", panicinfo
},
4066 { "pid2proc", "?", "convert PID to proc_t address", pid2proc
},
4067 { "project", NULL
, "display kernel project(s)", project
},
4068 { "ps", "[-fltzTP]", "list processes (and associated thr,lwp)", ps
},
4069 { "pflags", NULL
, "display various proc_t flags", pflags
},
4070 { "pgrep", "[-x] [-n | -o] pattern",
4071 "pattern match against all processes", pgrep
},
4072 { "ptree", NULL
, "print process tree", ptree
},
4073 { "sysevent", "?[-sv]", "print sysevent pending or sent queue",
4075 { "sysevent_channel", "?", "print sysevent channel database",
4077 { "sysevent_class_list", ":", "print sysevent class list",
4078 sysevent_class_list
},
4079 { "sysevent_subclass_list", ":",
4080 "print sysevent subclass list", sysevent_subclass_list
},
4081 { "system", NULL
, "print contents of /etc/system file", sysfile
},
4082 { "task", NULL
, "display kernel task(s)", task
},
4083 { "time", "[-dlx]", "display system time", time
, time_help
},
4084 { "vnode2path", ":[-F]", "vnode address to pathname", vnode2path
},
4085 { "whereopen", ":", "given a vnode, dumps procs which have it open",
4089 { "bufpagefind", ":addr", "find page_t on buf_t list", bufpagefind
},
4092 { "bitset", ":", "display a bitset", bitset
, bitset_help
},
4094 /* from contract.c */
4095 { "contract", "?", "display a contract", cmd_contract
},
4096 { "ctevent", ":", "display a contract event", cmd_ctevent
},
4097 { "ctid", ":", "convert id to a contract pointer", cmd_ctid
},
4099 /* from cpupart.c */
4100 { "cpupart", "?[-v]", "print cpu partition info", cpupart
},
4103 { "cred", ":[-v]", "display a credential", cmd_cred
},
4104 { "credgrp", ":[-v]", "display cred_t groups", cmd_credgrp
},
4105 { "credsid", ":[-v]", "display a credsid_t", cmd_credsid
},
4106 { "ksidlist", ":[-v]", "display a ksidlist_t", cmd_ksidlist
},
4109 { "cyccover", NULL
, "dump cyclic coverage information", cyccover
},
4110 { "cycid", "?", "dump a cyclic id", cycid
},
4111 { "cycinfo", "?", "dump cyc_cpu info", cycinfo
},
4112 { "cyclic", ":", "developer information", cyclic
},
4113 { "cyctrace", "?", "dump cyclic trace buffer", cyctrace
},
4116 { "damap", ":", "display a damap_t", damap
, damap_help
},
4118 /* from ddi_periodic.c */
4119 { "ddi_periodic", "?[-v]", "dump ddi_periodic_impl_t info", dprinfo
},
4121 /* from devinfo.c */
4122 { "devbindings", "?[-qs] [device-name | major-num]",
4123 "print devinfo nodes bound to device-name or major-num",
4124 devbindings
, devinfo_help
},
4125 { "devinfo", ":[-qs]", "detailed devinfo of one node", devinfo
,
4127 { "devinfo_audit", ":[-v]", "devinfo configuration audit record",
4129 { "devinfo_audit_log", "?[-v]", "system wide devinfo configuration log",
4130 devinfo_audit_log
},
4131 { "devinfo_audit_node", ":[-v]", "devinfo node configuration history",
4132 devinfo_audit_node
},
4133 { "devinfo2driver", ":", "find driver name for this devinfo node",
4135 { "devnames", "?[-vm] [num]", "print devnames array", devnames
},
4136 { "dev2major", "?<dev_t>", "convert dev_t to a major number",
4138 { "dev2minor", "?<dev_t>", "convert dev_t to a minor number",
4140 { "devt", "?<dev_t>", "display a dev_t's major and minor numbers",
4142 { "major2name", "?<major-num>", "convert major number to dev name",
4144 { "minornodes", ":", "given a devinfo node, print its minor nodes",
4146 { "modctl2devinfo", ":", "given a modctl, list its devinfos",
4148 { "name2major", "<dev-name>", "convert dev name to major number",
4150 { "prtconf", "?[-vpc] [-d driver]", "print devinfo tree", prtconf
,
4152 { "softstate", ":<instance>", "retrieve soft-state pointer",
4154 { "devinfo_fm", ":", "devinfo fault managment configuration",
4156 { "devinfo_fmce", ":", "devinfo fault managment cache entry",
4159 /* from findstack.c */
4160 { "findstack", ":[-v]", "find kernel thread stack", findstack
},
4161 { "findstack_debug", NULL
, "toggle findstack debugging",
4163 { "stacks", "?[-afiv] [-c func] [-C func] [-m module] [-M module] "
4164 "[-s sobj | -S sobj] [-t tstate | -T tstate]",
4165 "print unique kernel thread stacks",
4166 stacks
, stacks_help
},
4169 { "ereport", "[-v]", "print ereports logged in dump",
4173 { "group", "?[-q]", "display a group", group
},
4175 /* from hotplug.c */
4176 { "hotplug", "?[-p]", "display a registered hotplug attachment",
4177 hotplug
, hotplug_help
},
4180 { "irmpools", NULL
, "display interrupt pools", irmpools_dcmd
},
4181 { "irmreqs", NULL
, "display interrupt requests in an interrupt pool",
4183 { "irmreq", NULL
, "display an interrupt request", irmreq_dcmd
},
4185 /* from kgrep.c + genunix.c */
4186 { "kgrep", KGREP_USAGE
, "search kernel as for a pointer", kgrep
,
4190 { "allocdby", ":", "given a thread, print its allocated buffers",
4192 { "bufctl", ":[-vh] [-a addr] [-c caller] [-e earliest] [-l latest] "
4193 "[-t thd]", "print or filter a bufctl", bufctl
, bufctl_help
},
4194 { "freedby", ":", "given a thread, print its freed buffers", freedby
},
4195 { "kmalog", "?[ fail | slab ]",
4196 "display kmem transaction log and stack traces", kmalog
},
4197 { "kmastat", "[-kmg]", "kernel memory allocator stats",
4199 { "kmausers", "?[-ef] [cache ...]", "current medium and large users "
4200 "of the kmem allocator", kmausers
, kmausers_help
},
4201 { "kmem_cache", "?[-n name]",
4202 "print kernel memory caches", kmem_cache
, kmem_cache_help
},
4203 { "kmem_slabs", "?[-v] [-n cache] [-N cache] [-b maxbins] "
4204 "[-B minbinsize]", "display slab usage per kmem cache",
4205 kmem_slabs
, kmem_slabs_help
},
4206 { "kmem_debug", NULL
, "toggle kmem dcmd/walk debugging", kmem_debug
},
4207 { "kmem_log", "?[-b]", "dump kmem transaction log", kmem_log
},
4208 { "kmem_verify", "?", "check integrity of kmem-managed memory",
4210 { "vmem", "?", "print a vmem_t", vmem
},
4211 { "vmem_seg", ":[-sv] [-c caller] [-e earliest] [-l latest] "
4212 "[-m minsize] [-M maxsize] [-t thread] [-T type]",
4213 "print or filter a vmem_seg", vmem_seg
, vmem_seg_help
},
4214 { "whatthread", ":[-v]", "print threads whose stack contains the "
4215 "given address", whatthread
},
4218 { "ldi_handle", "?[-i]", "display a layered driver handle",
4219 ldi_handle
, ldi_handle_help
},
4220 { "ldi_ident", NULL
, "display a layered driver identifier",
4221 ldi_ident
, ldi_ident_help
},
4223 /* from leaky.c + leaky_subr.c */
4224 { "findleaks", FINDLEAKS_USAGE
,
4225 "search for potential kernel memory leaks", findleaks
,
4229 { "lgrp", "?[-q] [-p | -Pih]", "display an lgrp", lgrp
},
4230 { "lgrp_set", "", "display bitmask of lgroups as a list", lgrp_set
},
4233 { "msgbuf", "?[-v]", "print most recent console messages", msgbuf
},
4236 { "mdipi", NULL
, "given a path, dump mdi_pathinfo "
4237 "and detailed pi_prop list", mdipi
},
4238 { "mdiprops", NULL
, "given a pi_prop, dump the pi_prop list",
4240 { "mdiphci", NULL
, "given a phci, dump mdi_phci and "
4241 "list all paths", mdiphci
},
4242 { "mdivhci", NULL
, "given a vhci, dump mdi_vhci and list "
4243 "all phcis", mdivhci
},
4244 { "mdiclient_paths", NULL
, "given a path, walk mdi_pathinfo "
4245 "client links", mdiclient_paths
},
4246 { "mdiphci_paths", NULL
, "given a path, walk through mdi_pathinfo "
4247 "phci links", mdiphci_paths
},
4248 { "mdiphcis", NULL
, "given a phci, walk through mdi_phci ph_next links",
4252 { "addr2smap", ":[offset]", "translate address to smap", addr2smap
},
4253 { "memlist", "?[-iav]", "display a struct memlist", memlist
},
4254 { "memstat", NULL
, "display memory usage summary", memstat
},
4255 { "page", "?", "display a summarized page_t", page
},
4256 { "pagelookup", "?[-v vp] [-o offset]",
4257 "find the page_t with the name {vp, offset}",
4258 pagelookup
, pagelookup_help
},
4259 { "page_num2pp", ":", "find the page_t for a given page frame number",
4261 { "pmap", ":[-q]", "print process memory map", pmap
},
4262 { "seg", ":", "print address space segment", seg
},
4263 { "swapinfo", "?", "display a struct swapinfo", swapinfof
},
4264 { "vnode2smap", ":[offset]", "translate vnode to smap", vnode2smap
},
4267 { "multidata", ":[-sv]", "display a summarized multidata_t",
4269 { "pattbl", ":", "display a summarized multidata attribute table",
4271 { "pattr2multidata", ":", "print multidata pointer from pattr_t",
4273 { "pdesc2slab", ":", "print pdesc slab pointer from pdesc_t",
4275 { "pdesc_verify", ":", "verify integrity of a pdesc_t", pdesc_verify
},
4276 { "slab2multidata", ":", "print multidata pointer from pdesc_slab_t",
4279 /* from modhash.c */
4280 { "modhash", "?[-ceht] [-k key] [-v val] [-i index]",
4281 "display information about one or all mod_hash structures",
4282 modhash
, modhash_help
},
4283 { "modent", ":[-k | -v | -t type]",
4284 "display information about a mod_hash_entry", modent
,
4288 { "dladm", "?<sub-command> [flags]", "show data link information",
4289 dladm
, dladm_help
},
4290 { "mi", ":[-p] [-d | -m]", "filter and display MI object or payload",
4292 { "netstat", "[-arv] [-f inet | inet6 | unix] [-P tcp | udp | icmp]",
4293 "show network statistics", netstat
},
4294 { "sonode", "?[-f inet | inet6 | unix | #] "
4295 "[-t stream | dgram | raw | #] [-p #]",
4296 "filter and display sonode", sonode
},
4298 /* from netstack.c */
4299 { "netstack", "", "show stack instances", netstack
},
4300 { "netstackid2netstack", ":",
4301 "translate a netstack id to its netstack_t",
4302 netstackid2netstack
},
4305 { NVPAIR_DCMD_NAME
, NVPAIR_DCMD_USAGE
, NVPAIR_DCMD_DESCR
,
4307 { NVLIST_DCMD_NAME
, NVLIST_DCMD_USAGE
, NVLIST_DCMD_DESCR
,
4311 { "pg", "?[-q]", "display a pg", pg
},
4314 { "rctl_dict", "?", "print systemwide default rctl definitions",
4316 { "rctl_list", ":[handle]", "print rctls for the given proc",
4318 { "rctl", ":[handle]", "print a rctl_t, only if it matches the handle",
4320 { "rctl_validate", ":[-v] [-n #]", "test resource control value "
4321 "sequence", rctl_validate
},
4324 { "rwlock", ":", "dump out a readers/writer lock", rwlock
},
4325 { "mutex", ":[-f]", "dump out an adaptive or spin mutex", mutex
,
4327 { "sobj2ts", ":", "perform turnstile lookup on synch object", sobj2ts
},
4328 { "wchaninfo", "?[-v]", "dump condition variable", wchaninfo
},
4329 { "turnstile", "?", "display a turnstile", turnstile
},
4332 { "mblk", ":[-q|v] [-f|F flag] [-t|T type] [-l|L|B len] [-d dbaddr]",
4333 "print an mblk", mblk_prt
, mblk_help
},
4334 { "mblk_verify", "?", "verify integrity of an mblk", mblk_verify
},
4335 { "mblk2dblk", ":", "convert mblk_t address to dblk_t address",
4337 { "q2otherq", ":", "print peer queue for a given queue", q2otherq
},
4338 { "q2rdq", ":", "print read queue for a given queue", q2rdq
},
4339 { "q2syncq", ":", "print syncq for a given queue", q2syncq
},
4340 { "q2stream", ":", "print stream pointer for a given queue", q2stream
},
4341 { "q2wrq", ":", "print write queue for a given queue", q2wrq
},
4342 { "queue", ":[-q|v] [-m mod] [-f flag] [-F flag] [-s syncq_addr]",
4343 "filter and display STREAM queue", queue
, queue_help
},
4344 { "stdata", ":[-q|v] [-f flag] [-F flag]",
4345 "filter and display STREAM head", stdata
, stdata_help
},
4346 { "str2mate", ":", "print mate of this stream", str2mate
},
4347 { "str2wrq", ":", "print write queue of this stream", str2wrq
},
4348 { "stream", ":", "display STREAM", stream
},
4349 { "strftevent", ":", "print STREAMS flow trace event", strftevent
},
4350 { "syncq", ":[-q|v] [-f flag] [-F flag] [-t type] [-T type]",
4351 "filter and display STREAM sync queue", syncq
, syncq_help
},
4352 { "syncq2q", ":", "print queue for a given syncq", syncq2q
},
4355 { "taskq", ":[-atT] [-m min_maxq] [-n name]",
4356 "display a taskq", taskq
, taskq_help
},
4357 { "taskq_entry", ":", "display a taskq_ent_t", taskq_ent
},
4360 { "thread", "?[-bdfimps]", "display a summarized kthread_t", thread
,
4362 { "threadlist", "?[-t] [-v [count]]",
4363 "display threads and associated C stack traces", threadlist
,
4365 { "stackinfo", "?[-h|-a]", "display kthread_t stack usage", stackinfo
,
4369 { "tsd", ":-k key", "print tsd[key-1] for this thread", ttotsd
},
4370 { "tsdtot", ":", "find thread with this tsd", tsdtot
},
4373 * typegraph does not work under kmdb, as it requires too much memory
4374 * for its internal data structures.
4377 /* from typegraph.c */
4378 { "findlocks", ":", "find locks held by specified thread", findlocks
},
4379 { "findfalse", "?[-v]", "find potentially falsely shared structures",
4381 { "typegraph", NULL
, "build type graph", typegraph
},
4382 { "istype", ":type", "manually set object type", istype
},
4383 { "notype", ":", "manually clear object type", notype
},
4384 { "whattype", ":", "determine object type", whattype
},
4388 { "fsinfo", "?[-v]", "print mounted filesystems", fsinfo
},
4389 { "pfiles", ":[-fp]", "print process file information", pfiles
,
4393 { "zid2zone", ":", "find the zone_t with the given zone id",
4395 { "zone", "?[-r [-v]]", "display kernel zone(s)", zoneprt
},
4396 { "zsd", ":[-v] [zsd_key]", "display zone-specific-data entries for "
4397 "selected zones", zsd
},
4400 { "gcore", NULL
, "generate a user core for the given process",
4407 static const mdb_walker_t walkers
[] = {
4409 /* from genunix.c */
4410 { "callouts_bytime", "walk callouts by list chain (expiration time)",
4411 callout_walk_init
, callout_walk_step
, callout_walk_fini
,
4412 (void *)CALLOUT_WALK_BYLIST
},
4413 { "callouts_byid", "walk callouts by id hash chain",
4414 callout_walk_init
, callout_walk_step
, callout_walk_fini
,
4415 (void *)CALLOUT_WALK_BYID
},
4416 { "callout_list", "walk a callout list", callout_list_walk_init
,
4417 callout_list_walk_step
, callout_list_walk_fini
},
4418 { "callout_table", "walk callout table array", callout_table_walk_init
,
4419 callout_table_walk_step
, callout_table_walk_fini
},
4420 { "cpu", "walk cpu structures", cpu_walk_init
, cpu_walk_step
},
4421 { "dnlc", "walk dnlc entries",
4422 dnlc_walk_init
, dnlc_walk_step
, dnlc_walk_fini
},
4423 { "ereportq_dump", "walk list of ereports in dump error queue",
4424 ereportq_dump_walk_init
, ereportq_dump_walk_step
, NULL
},
4425 { "ereportq_pend", "walk list of ereports in pending error queue",
4426 ereportq_pend_walk_init
, ereportq_pend_walk_step
, NULL
},
4427 { "errorq", "walk list of system error queues",
4428 errorq_walk_init
, errorq_walk_step
, NULL
},
4429 { "errorq_data", "walk pending error queue data buffers",
4430 eqd_walk_init
, eqd_walk_step
, eqd_walk_fini
},
4431 { "allfile", "given a proc pointer, list all file pointers",
4432 file_walk_init
, allfile_walk_step
, file_walk_fini
},
4433 { "file", "given a proc pointer, list of open file pointers",
4434 file_walk_init
, file_walk_step
, file_walk_fini
},
4435 { "lock_descriptor", "walk lock_descriptor_t structures",
4436 ld_walk_init
, ld_walk_step
, NULL
},
4437 { "lock_graph", "walk lock graph",
4438 lg_walk_init
, lg_walk_step
, NULL
},
4439 { "port", "given a proc pointer, list of created event ports",
4440 port_walk_init
, port_walk_step
, NULL
},
4441 { "portev", "given a port pointer, list of events in the queue",
4442 portev_walk_init
, portev_walk_step
, portev_walk_fini
},
4443 { "proc", "list of active proc_t structures",
4444 proc_walk_init
, proc_walk_step
, proc_walk_fini
},
4445 { "projects", "walk a list of kernel projects",
4446 project_walk_init
, project_walk_step
, NULL
},
4447 { "sysevent_pend", "walk sysevent pending queue",
4448 sysevent_pend_walk_init
, sysevent_walk_step
,
4449 sysevent_walk_fini
},
4450 { "sysevent_sent", "walk sysevent sent queue", sysevent_sent_walk_init
,
4451 sysevent_walk_step
, sysevent_walk_fini
},
4452 { "sysevent_channel", "walk sysevent channel subscriptions",
4453 sysevent_channel_walk_init
, sysevent_channel_walk_step
,
4454 sysevent_channel_walk_fini
},
4455 { "sysevent_class_list", "walk sysevent subscription's class list",
4456 sysevent_class_list_walk_init
, sysevent_class_list_walk_step
,
4457 sysevent_class_list_walk_fini
},
4458 { "sysevent_subclass_list",
4459 "walk sysevent subscription's subclass list",
4460 sysevent_subclass_list_walk_init
,
4461 sysevent_subclass_list_walk_step
,
4462 sysevent_subclass_list_walk_fini
},
4463 { "task", "given a task pointer, walk its processes",
4464 task_walk_init
, task_walk_step
, NULL
},
4467 { AVL_WALK_NAME
, AVL_WALK_DESC
,
4468 avl_walk_init
, avl_walk_step
, avl_walk_fini
},
4471 { "buf", "walk the bio buf hash",
4472 buf_walk_init
, buf_walk_step
, buf_walk_fini
},
4474 /* from contract.c */
4475 { "contract", "walk all contracts, or those of the specified type",
4476 ct_walk_init
, generic_walk_step
, NULL
},
4477 { "ct_event", "walk events on a contract event queue",
4478 ct_event_walk_init
, generic_walk_step
, NULL
},
4479 { "ct_listener", "walk contract event queue listeners",
4480 ct_listener_walk_init
, generic_walk_step
, NULL
},
4482 /* from cpupart.c */
4483 { "cpupart_cpulist", "given an cpupart_t, walk cpus in partition",
4484 cpupart_cpulist_walk_init
, cpupart_cpulist_walk_step
,
4486 { "cpupart_walk", "walk the set of cpu partitions",
4487 cpupart_walk_init
, cpupart_walk_step
, NULL
},
4490 { "ctxop", "walk list of context ops on a thread",
4491 ctxop_walk_init
, ctxop_walk_step
, ctxop_walk_fini
},
4494 { "cyccpu", "walk per-CPU cyc_cpu structures",
4495 cyccpu_walk_init
, cyccpu_walk_step
, NULL
},
4496 { "cycomni", "for an omnipresent cyclic, walk cyc_omni_cpu list",
4497 cycomni_walk_init
, cycomni_walk_step
, NULL
},
4498 { "cyctrace", "walk cyclic trace buffer",
4499 cyctrace_walk_init
, cyctrace_walk_step
, cyctrace_walk_fini
},
4501 /* from devinfo.c */
4502 { "binding_hash", "walk all entries in binding hash table",
4503 binding_hash_walk_init
, binding_hash_walk_step
, NULL
},
4504 { "devinfo", "walk devinfo tree or subtree",
4505 devinfo_walk_init
, devinfo_walk_step
, devinfo_walk_fini
},
4506 { "devinfo_audit_log", "walk devinfo audit system-wide log",
4507 devinfo_audit_log_walk_init
, devinfo_audit_log_walk_step
,
4508 devinfo_audit_log_walk_fini
},
4509 { "devinfo_audit_node", "walk per-devinfo audit history",
4510 devinfo_audit_node_walk_init
, devinfo_audit_node_walk_step
,
4511 devinfo_audit_node_walk_fini
},
4512 { "devinfo_children", "walk children of devinfo node",
4513 devinfo_children_walk_init
, devinfo_children_walk_step
,
4514 devinfo_children_walk_fini
},
4515 { "devinfo_parents", "walk ancestors of devinfo node",
4516 devinfo_parents_walk_init
, devinfo_parents_walk_step
,
4517 devinfo_parents_walk_fini
},
4518 { "devinfo_siblings", "walk siblings of devinfo node",
4519 devinfo_siblings_walk_init
, devinfo_siblings_walk_step
, NULL
},
4520 { "devi_next", "walk devinfo list",
4521 NULL
, devi_next_walk_step
, NULL
},
4522 { "devnames", "walk devnames array",
4523 devnames_walk_init
, devnames_walk_step
, devnames_walk_fini
},
4524 { "minornode", "given a devinfo node, walk minor nodes",
4525 minornode_walk_init
, minornode_walk_step
, NULL
},
4527 "given an i_ddi_soft_state*, list all in-use driver stateps",
4528 soft_state_walk_init
, soft_state_walk_step
,
4531 "given an i_ddi_soft_state*, list all driver stateps",
4532 soft_state_walk_init
, soft_state_all_walk_step
,
4535 "walk a fault management handle cache active list",
4536 devinfo_fmc_walk_init
, devinfo_fmc_walk_step
, NULL
},
4539 { "group", "walk all elements of a group",
4540 group_walk_init
, group_walk_step
, NULL
},
4543 { "irmpools", "walk global list of interrupt pools",
4544 irmpools_walk_init
, list_walk_step
, list_walk_fini
},
4545 { "irmreqs", "walk list of interrupt requests in an interrupt pool",
4546 irmreqs_walk_init
, list_walk_step
, list_walk_fini
},
4549 { "allocdby", "given a thread, walk its allocated bufctls",
4550 allocdby_walk_init
, allocdby_walk_step
, allocdby_walk_fini
},
4551 { "bufctl", "walk a kmem cache's bufctls",
4552 bufctl_walk_init
, kmem_walk_step
, kmem_walk_fini
},
4553 { "bufctl_history", "walk the available history of a bufctl",
4554 bufctl_history_walk_init
, bufctl_history_walk_step
,
4555 bufctl_history_walk_fini
},
4556 { "freedby", "given a thread, walk its freed bufctls",
4557 freedby_walk_init
, allocdby_walk_step
, allocdby_walk_fini
},
4558 { "freectl", "walk a kmem cache's free bufctls",
4559 freectl_walk_init
, kmem_walk_step
, kmem_walk_fini
},
4560 { "freectl_constructed", "walk a kmem cache's constructed free bufctls",
4561 freectl_constructed_walk_init
, kmem_walk_step
, kmem_walk_fini
},
4562 { "freemem", "walk a kmem cache's free memory",
4563 freemem_walk_init
, kmem_walk_step
, kmem_walk_fini
},
4564 { "freemem_constructed", "walk a kmem cache's constructed free memory",
4565 freemem_constructed_walk_init
, kmem_walk_step
, kmem_walk_fini
},
4566 { "kmem", "walk a kmem cache",
4567 kmem_walk_init
, kmem_walk_step
, kmem_walk_fini
},
4568 { "kmem_cpu_cache", "given a kmem cache, walk its per-CPU caches",
4569 kmem_cpu_cache_walk_init
, kmem_cpu_cache_walk_step
, NULL
},
4570 { "kmem_hash", "given a kmem cache, walk its allocated hash table",
4571 kmem_hash_walk_init
, kmem_hash_walk_step
, kmem_hash_walk_fini
},
4572 { "kmem_log", "walk the kmem transaction log",
4573 kmem_log_walk_init
, kmem_log_walk_step
, kmem_log_walk_fini
},
4574 { "kmem_slab", "given a kmem cache, walk its slabs",
4575 kmem_slab_walk_init
, combined_walk_step
, combined_walk_fini
},
4576 { "kmem_slab_partial",
4577 "given a kmem cache, walk its partially allocated slabs (min 1)",
4578 kmem_slab_walk_partial_init
, combined_walk_step
,
4579 combined_walk_fini
},
4580 { "vmem", "walk vmem structures in pre-fix, depth-first order",
4581 vmem_walk_init
, vmem_walk_step
, vmem_walk_fini
},
4582 { "vmem_alloc", "given a vmem_t, walk its allocated vmem_segs",
4583 vmem_alloc_walk_init
, vmem_seg_walk_step
, vmem_seg_walk_fini
},
4584 { "vmem_free", "given a vmem_t, walk its free vmem_segs",
4585 vmem_free_walk_init
, vmem_seg_walk_step
, vmem_seg_walk_fini
},
4586 { "vmem_postfix", "walk vmem structures in post-fix, depth-first order",
4587 vmem_walk_init
, vmem_postfix_walk_step
, vmem_walk_fini
},
4588 { "vmem_seg", "given a vmem_t, walk all of its vmem_segs",
4589 vmem_seg_walk_init
, vmem_seg_walk_step
, vmem_seg_walk_fini
},
4590 { "vmem_span", "given a vmem_t, walk its spanning vmem_segs",
4591 vmem_span_walk_init
, vmem_seg_walk_step
, vmem_seg_walk_fini
},
4594 { "ldi_handle", "walk the layered driver handle hash",
4595 ldi_handle_walk_init
, ldi_handle_walk_step
, NULL
},
4596 { "ldi_ident", "walk the layered driver identifier hash",
4597 ldi_ident_walk_init
, ldi_ident_walk_step
, NULL
},
4599 /* from leaky.c + leaky_subr.c */
4600 { "leak", "given a leaked bufctl or vmem_seg, find leaks w/ same "
4602 leaky_walk_init
, leaky_walk_step
, leaky_walk_fini
},
4603 { "leakbuf", "given a leaked bufctl or vmem_seg, walk buffers for "
4604 "leaks w/ same stack trace",
4605 leaky_walk_init
, leaky_buf_walk_step
, leaky_walk_fini
},
4608 { "lgrp_cpulist", "walk CPUs in a given lgroup",
4609 lgrp_cpulist_walk_init
, lgrp_cpulist_walk_step
, NULL
},
4610 { "lgrptbl", "walk lgroup table",
4611 lgrp_walk_init
, lgrp_walk_step
, NULL
},
4612 { "lgrp_parents", "walk up lgroup lineage from given lgroup",
4613 lgrp_parents_walk_init
, lgrp_parents_walk_step
, NULL
},
4614 { "lgrp_rsrc_mem", "walk lgroup memory resources of given lgroup",
4615 lgrp_rsrc_mem_walk_init
, lgrp_set_walk_step
, NULL
},
4616 { "lgrp_rsrc_cpu", "walk lgroup CPU resources of given lgroup",
4617 lgrp_rsrc_cpu_walk_init
, lgrp_set_walk_step
, NULL
},
4620 { LIST_WALK_NAME
, LIST_WALK_DESC
,
4621 list_walk_init
, list_walk_step
, list_walk_fini
},
4624 { "mdipi_client_list", "Walker for mdi_pathinfo pi_client_link",
4625 mdi_pi_client_link_walk_init
,
4626 mdi_pi_client_link_walk_step
,
4627 mdi_pi_client_link_walk_fini
},
4628 { "mdipi_phci_list", "Walker for mdi_pathinfo pi_phci_link",
4629 mdi_pi_phci_link_walk_init
,
4630 mdi_pi_phci_link_walk_step
,
4631 mdi_pi_phci_link_walk_fini
},
4632 { "mdiphci_list", "Walker for mdi_phci ph_next link",
4633 mdi_phci_ph_next_walk_init
,
4634 mdi_phci_ph_next_walk_step
,
4635 mdi_phci_ph_next_walk_fini
},
4638 { "allpages", "walk all pages, including free pages",
4639 allpages_walk_init
, allpages_walk_step
, allpages_walk_fini
},
4640 { "anon", "given an amp, list allocated anon structures",
4641 anon_walk_init
, anon_walk_step
, anon_walk_fini
,
4643 { "anon_all", "given an amp, list contents of all anon slots",
4644 anon_walk_init
, anon_walk_step
, anon_walk_fini
,
4646 { "memlist", "walk specified memlist",
4647 NULL
, memlist_walk_step
, NULL
},
4648 { "page", "walk all pages, or those from the specified vnode",
4649 page_walk_init
, page_walk_step
, page_walk_fini
},
4650 { "seg", "given an as, list of segments",
4651 seg_walk_init
, avl_walk_step
, avl_walk_fini
},
4653 "given a struct segvn_data, list allocated anon structures",
4654 segvn_anon_walk_init
, anon_walk_step
, anon_walk_fini
,
4657 "given a struct segvn_data, list contents of all anon slots",
4658 segvn_anon_walk_init
, anon_walk_step
, anon_walk_fini
,
4661 "given a struct segvn_data, list resident pages in "
4663 segvn_pages_walk_init
, segvn_pages_walk_step
,
4664 segvn_pages_walk_fini
, SEGVN_PAGES_RESIDENT
},
4665 { "segvn_pages_all",
4666 "for each offset in a struct segvn_data, give page_t pointer "
4667 "(if resident), or NULL.",
4668 segvn_pages_walk_init
, segvn_pages_walk_step
,
4669 segvn_pages_walk_fini
, SEGVN_PAGES_ALL
},
4670 { "swapinfo", "walk swapinfo structures",
4671 swap_walk_init
, swap_walk_step
, NULL
},
4674 { "pattr", "walk pattr_t structures", pattr_walk_init
,
4675 mmdq_walk_step
, mmdq_walk_fini
},
4676 { "pdesc", "walk pdesc_t structures",
4677 pdesc_walk_init
, mmdq_walk_step
, mmdq_walk_fini
},
4678 { "pdesc_slab", "walk pdesc_slab_t structures",
4679 pdesc_slab_walk_init
, mmdq_walk_step
, mmdq_walk_fini
},
4681 /* from modhash.c */
4682 { "modhash", "walk list of mod_hash structures", modhash_walk_init
,
4683 modhash_walk_step
, NULL
},
4684 { "modent", "walk list of entries in a given mod_hash",
4685 modent_walk_init
, modent_walk_step
, modent_walk_fini
},
4686 { "modchain", "walk list of entries in a given mod_hash_entry",
4687 NULL
, modchain_walk_step
, NULL
},
4690 { "icmp", "walk ICMP control structures using MI for all stacks",
4691 mi_payload_walk_init
, mi_payload_walk_step
, NULL
,
4693 { "mi", "given a MI_O, walk the MI",
4694 mi_walk_init
, mi_walk_step
, mi_walk_fini
, NULL
},
4695 { "sonode", "given a sonode, walk its children",
4696 sonode_walk_init
, sonode_walk_step
, sonode_walk_fini
, NULL
},
4697 { "icmp_stacks", "walk all the icmp_stack_t",
4698 icmp_stacks_walk_init
, icmp_stacks_walk_step
, NULL
},
4699 { "tcp_stacks", "walk all the tcp_stack_t",
4700 tcp_stacks_walk_init
, tcp_stacks_walk_step
, NULL
},
4701 { "udp_stacks", "walk all the udp_stack_t",
4702 udp_stacks_walk_init
, udp_stacks_walk_step
, NULL
},
4704 /* from netstack.c */
4705 { "netstack", "walk a list of kernel netstacks",
4706 netstack_walk_init
, netstack_walk_step
, NULL
},
4709 { NVPAIR_WALKER_NAME
, NVPAIR_WALKER_DESCR
,
4710 nvpair_walk_init
, nvpair_walk_step
, NULL
},
4713 { "rctl_dict_list", "walk all rctl_dict_entry_t's from rctl_lists",
4714 rctl_dict_walk_init
, rctl_dict_walk_step
, NULL
},
4715 { "rctl_set", "given a rctl_set, walk all rctls", rctl_set_walk_init
,
4716 rctl_set_walk_step
, NULL
},
4717 { "rctl_val", "given a rctl_t, walk all rctl_val entries associated",
4718 rctl_val_walk_init
, rctl_val_walk_step
},
4721 { "blocked", "walk threads blocked on a given sobj",
4722 blocked_walk_init
, blocked_walk_step
, NULL
},
4723 { "wchan", "given a wchan, list of blocked threads",
4724 wchan_walk_init
, wchan_walk_step
, wchan_walk_fini
},
4727 { "b_cont", "walk mblk_t list using b_cont",
4728 mblk_walk_init
, b_cont_step
, mblk_walk_fini
},
4729 { "b_next", "walk mblk_t list using b_next",
4730 mblk_walk_init
, b_next_step
, mblk_walk_fini
},
4731 { "qlink", "walk queue_t list using q_link",
4732 queue_walk_init
, queue_link_step
, queue_walk_fini
},
4733 { "qnext", "walk queue_t list using q_next",
4734 queue_walk_init
, queue_next_step
, queue_walk_fini
},
4735 { "strftblk", "given a dblk_t, walk STREAMS flow trace event list",
4736 strftblk_walk_init
, strftblk_step
, strftblk_walk_fini
},
4737 { "readq", "walk read queue side of stdata",
4738 str_walk_init
, strr_walk_step
, str_walk_fini
},
4739 { "writeq", "walk write queue side of stdata",
4740 str_walk_init
, strw_walk_step
, str_walk_fini
},
4743 { "taskq_thread", "given a taskq_t, list all of its threads",
4744 taskq_thread_walk_init
,
4745 taskq_thread_walk_step
,
4746 taskq_thread_walk_fini
},
4747 { "taskq_entry", "given a taskq_t*, list all taskq_ent_t in the list",
4748 taskq_ent_walk_init
, taskq_ent_walk_step
, NULL
},
4751 { "deathrow", "walk threads on both lwp_ and thread_deathrow",
4752 deathrow_walk_init
, deathrow_walk_step
, NULL
},
4753 { "cpu_dispq", "given a cpu_t, walk threads in dispatcher queues",
4754 cpu_dispq_walk_init
, dispq_walk_step
, dispq_walk_fini
},
4756 "given a cpupart_t, walk threads in dispatcher queues",
4757 cpupart_dispq_walk_init
, dispq_walk_step
, dispq_walk_fini
},
4758 { "lwp_deathrow", "walk lwp_deathrow",
4759 lwp_deathrow_walk_init
, deathrow_walk_step
, NULL
},
4760 { "thread", "global or per-process kthread_t structures",
4761 thread_walk_init
, thread_walk_step
, thread_walk_fini
},
4762 { "thread_deathrow", "walk threads on thread_deathrow",
4763 thread_deathrow_walk_init
, deathrow_walk_step
, NULL
},
4766 { "tsd", "walk list of thread-specific data",
4767 tsd_walk_init
, tsd_walk_step
, tsd_walk_fini
},
4770 * typegraph does not work under kmdb, as it requires too much memory
4771 * for its internal data structures.
4774 /* from typegraph.c */
4775 { "typeconflict", "walk buffers with conflicting type inferences",
4776 typegraph_walk_init
, typeconflict_walk_step
},
4777 { "typeunknown", "walk buffers with unknown types",
4778 typegraph_walk_init
, typeunknown_walk_step
},
4782 { "vfs", "walk file system list",
4783 vfs_walk_init
, vfs_walk_step
},
4786 { "zone", "walk a list of kernel zones",
4787 zone_walk_init
, zone_walk_step
, NULL
},
4788 { "zsd", "walk list of zsd entries for a zone",
4789 zsd_walk_init
, zsd_walk_step
, NULL
},
4794 static const mdb_modinfo_t modinfo
= { MDB_API_VERSION
, dcmds
, walkers
};
4798 genunix_statechange_cb(void *ignored
)
4801 * Force ::findleaks and ::stacks to let go any cached state.
4806 kmem_statechange(); /* notify kmem */
4809 const mdb_modinfo_t
*
4814 (void) mdb_callback_add(MDB_CALLBACK_STCHG
,
4815 genunix_statechange_cb
, NULL
);