xref: /titanic_51/usr/src/cmd/mdb/common/modules/ipc/ipc.c (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <mdb/mdb_modapi.h>
30 #include <mdb/mdb_ks.h>
31 
32 #include <sys/types.h>
33 #include <sys/mman.h>
34 #include <sys/project.h>
35 #include <sys/ipc_impl.h>
36 #include <sys/shm_impl.h>
37 #include <sys/sem_impl.h>
38 #include <sys/msg_impl.h>
39 
40 #include <vm/anon.h>
41 
42 #define	CMN_HDR_START	"%<u>"
43 #define	CMN_HDR_END	"%</u>\n"
44 #define	CMN_INDENT	(4)
45 #define	CMN_INACTIVE	"%s facility inactive.\n"
46 
47 /*
48  * Bitmap data for page protection flags suitable for use with %b.
49  */
50 const mdb_bitmask_t prot_flag_bits[] = {
51 	{ "PROT_READ", PROT_READ, PROT_READ },
52 	{ "PROT_WRITE", PROT_WRITE, PROT_WRITE },
53 	{ "PROT_EXEC", PROT_EXEC, PROT_EXEC },
54 	{ "PROT_USER", PROT_USER, PROT_USER },
55 	{ NULL, 0, 0 }
56 };
57 
58 static void
59 printtime_nice(const char *str, time_t time)
60 {
61 	if (time)
62 		mdb_printf("%s%Y\n", str, time);
63 	else
64 		mdb_printf("%sn/a\n", str);
65 }
66 
67 /*
68  * Print header common to all IPC types.
69  */
70 static void
71 ipcperm_header()
72 {
73 	mdb_printf(CMN_HDR_START "%?s %5s %5s %8s %5s %5s %6s %5s %5s %5s %5s"
74 	    CMN_HDR_END, "ADDR", "REF", "ID", "KEY", "MODE", "PRJID", "ZONEID",
75 	    "OWNER", "GROUP", "CREAT", "CGRP");
76 }
77 
78 /*
79  * Print data common to all IPC types.
80  */
81 static void
82 ipcperm_print(uintptr_t addr, kipc_perm_t *perm)
83 {
84 	kproject_t proj;
85 	int res;
86 
87 	res = mdb_vread(&proj, sizeof (kproject_t), (uintptr_t)perm->ipc_proj);
88 
89 	if (res == -1)
90 		mdb_warn("failed to read kproject_t at %#p", perm->ipc_proj);
91 
92 	mdb_printf("%0?p %5d %5d", addr, perm->ipc_ref, perm->ipc_id);
93 	if (perm->ipc_key)
94 		mdb_printf(" %8x", perm->ipc_key);
95 	else
96 		mdb_printf(" %8s", "private");
97 	mdb_printf(" %5#o", perm->ipc_mode & 07777);
98 	if (res == -1)
99 		mdb_printf(" %5s %5s", "<flt>", "<flt>");
100 	else
101 		mdb_printf(" %5d %6d", proj.kpj_id, proj.kpj_zoneid);
102 	mdb_printf(" %5d %5d %5d %5d\n", perm->ipc_uid, perm->ipc_gid,
103 	    perm->ipc_cuid, perm->ipc_cgid);
104 
105 }
106 
107 /*ARGSUSED*/
108 static int
109 ipcperm(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
110 {
111 	kipc_perm_t perm;
112 
113 	if (!(flags & DCMD_ADDRSPEC))
114 		return (DCMD_USAGE);
115 
116 	if (DCMD_HDRSPEC(flags))
117 		ipcperm_header();
118 
119 	if (mdb_vread(&perm, sizeof (kipc_perm_t), addr) == -1) {
120 		mdb_warn("failed to read kipc_perm_t at %#lx", addr);
121 		return (DCMD_ERR);
122 	}
123 
124 	ipcperm_print(addr, &perm);
125 	return (DCMD_OK);
126 }
127 
128 static void
129 msq_print(kmsqid_t *msqid, uintptr_t addr)
130 {
131 	mdb_printf("&list: %-?p\n", addr + OFFSETOF(kmsqid_t, msg_list));
132 	mdb_printf("cbytes: 0t%lu    qnum: 0t%lu    qbytes: 0t%lu"
133 	    "    qmax: 0t%lu\n", msqid->msg_cbytes, msqid->msg_qnum,
134 	    msqid->msg_qbytes, msqid->msg_qmax);
135 	mdb_printf("lspid: 0t%d    lrpid: 0t%d\n",
136 	    (int)msqid->msg_lspid, (int)msqid->msg_lrpid);
137 	printtime_nice("stime: ", msqid->msg_stime);
138 	printtime_nice("rtime: ", msqid->msg_rtime);
139 	printtime_nice("ctime: ", msqid->msg_ctime);
140 	mdb_printf("snd_cnt: 0t%lld    rcv_cnt: 0t%lld\n",
141 	    msqid->msg_snd_cnt, msqid->msg_rcv_cnt);
142 	mdb_printf("snd_cv: %hd (%p)    rcv_cv: %hd (%p)\n",
143 	    msqid->msg_snd_cv._opaque,
144 	    addr + (uintptr_t)OFFSETOF(kmsqid_t, msg_snd_cv),
145 	    msqid->msg_rcv_cv._opaque,
146 	    addr + (uintptr_t)OFFSETOF(kmsqid_t, msg_rcv_cv));
147 }
148 
149 
150 /*ARGSUSED1*/
151 static void
152 shm_print(kshmid_t *shmid, uintptr_t addr)
153 {
154 	shmatt_t nattch;
155 
156 	nattch = shmid->shm_perm.ipc_ref - (IPC_FREE(&shmid->shm_perm) ? 0 : 1);
157 
158 	mdb_printf(CMN_HDR_START "%10s %?s %5s %7s %7s %7s %7s" CMN_HDR_END,
159 	    "SEGSZ", "AMP", "LKCNT", "LPID", "CPID", "NATTCH", "CNATTCH");
160 	mdb_printf("%10#lx %?p %5u %7d %7d %7lu %7lu\n",
161 	    shmid->shm_segsz, shmid->shm_amp, shmid->shm_lkcnt,
162 	    (int)shmid->shm_lpid, (int)shmid->shm_cpid, nattch,
163 	    shmid->shm_ismattch);
164 
165 	printtime_nice("atime: ", shmid->shm_atime);
166 	printtime_nice("dtime: ", shmid->shm_dtime);
167 	printtime_nice("ctime: ", shmid->shm_ctime);
168 	mdb_printf("sptinfo: %-?p    sptseg: %-?p\n",
169 	    shmid->shm_sptinfo, shmid->shm_sptseg);
170 	mdb_printf("sptprot: <%lb>\n", shmid->shm_sptprot, prot_flag_bits);
171 }
172 
173 
174 /*ARGSUSED1*/
175 static void
176 sem_print(ksemid_t *semid, uintptr_t addr)
177 {
178 	mdb_printf("base: %-?p    nsems: 0t%u\n",
179 	    semid->sem_base, semid->sem_nsems);
180 	printtime_nice("otime: ", semid->sem_otime);
181 	printtime_nice("ctime: ", semid->sem_ctime);
182 	mdb_printf("binary: %s\n", semid->sem_binary ? "yes" : "no");
183 }
184 
185 typedef struct ipc_ops_vec {
186 	char	*iv_wcmd;	/* walker name		*/
187 	char	*iv_ocmd;	/* output dcmd		*/
188 	char	*iv_service;	/* service pointer	*/
189 	void	(*iv_print)(void *, uintptr_t); /* output callback */
190 	size_t	iv_idsize;
191 } ipc_ops_vec_t;
192 
193 ipc_ops_vec_t msq_ops_vec = {
194 	"msq",
195 	"kmsqid",
196 	"msq_svc",
197 	(void(*)(void *, uintptr_t))msq_print,
198 	sizeof (kmsqid_t)
199 };
200 
201 ipc_ops_vec_t shm_ops_vec = {
202 	"shm",
203 	"kshmid",
204 	"shm_svc",
205 	(void(*)(void *, uintptr_t))shm_print,
206 	sizeof (kshmid_t)
207 };
208 
209 ipc_ops_vec_t sem_ops_vec = {
210 	"sem",
211 	"ksemid",
212 	"sem_svc",
213 	(void(*)(void *, uintptr_t))sem_print,
214 	sizeof (ksemid_t)
215 };
216 
217 
218 /*
219  * Generic IPC data structure display code
220  */
221 static int
222 ds_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
223     ipc_ops_vec_t *iv)
224 {
225 	void *iddata;
226 
227 	if (!(flags & DCMD_ADDRSPEC)) {
228 		uint_t oflags = 0;
229 
230 		if (mdb_getopts(argc, argv, 'l', MDB_OPT_SETBITS, 1, &oflags,
231 		    NULL) != argc)
232 			return (DCMD_USAGE);
233 
234 		if (mdb_walk_dcmd(iv->iv_wcmd, oflags ? iv->iv_ocmd : "ipcperm",
235 		    argc, argv) == -1) {
236 			mdb_warn("can't walk '%s'", iv->iv_wcmd);
237 			return (DCMD_ERR);
238 		}
239 		return (DCMD_OK);
240 	}
241 
242 	iddata = mdb_alloc(iv->iv_idsize, UM_SLEEP | UM_GC);
243 	if (mdb_vread(iddata, iv->iv_idsize, addr) == -1) {
244 		mdb_warn("failed to read %s at %#lx", iv->iv_ocmd, addr);
245 		return (DCMD_ERR);
246 	}
247 
248 	if (!DCMD_HDRSPEC(flags) && iv->iv_print)
249 		mdb_printf("\n");
250 
251 	if (DCMD_HDRSPEC(flags) || iv->iv_print)
252 		ipcperm_header();
253 
254 	ipcperm_print(addr, (struct kipc_perm *)iddata);
255 	if (iv->iv_print) {
256 		mdb_inc_indent(CMN_INDENT);
257 		iv->iv_print(iddata, addr);
258 		mdb_dec_indent(CMN_INDENT);
259 	}
260 
261 	return (DCMD_OK);
262 }
263 
264 
265 /*
266  * Stubs to call ds_print with the appropriate ops vector
267  */
268 static int
269 cmd_kshmid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
270 {
271 	return (ds_print(addr, flags, argc, argv, &shm_ops_vec));
272 }
273 
274 
275 static int
276 cmd_kmsqid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
277 {
278 	return (ds_print(addr, flags, argc, argv, &msq_ops_vec));
279 }
280 
281 static int
282 cmd_ksemid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
283 {
284 	return (ds_print(addr, flags, argc, argv, &sem_ops_vec));
285 }
286 
287 /*
288  * Generic IPC walker
289  */
290 
291 static int
292 ds_walk_init(mdb_walk_state_t *wsp)
293 {
294 	ipc_ops_vec_t	*iv = wsp->walk_arg;
295 
296 	if (wsp->walk_arg != NULL && wsp->walk_addr != NULL)
297 		mdb_printf("ignoring provided address\n");
298 
299 	if (wsp->walk_arg)
300 		if (mdb_readvar(&wsp->walk_addr, iv->iv_service) == -1) {
301 			mdb_printf("failed to read '%s'; module not present\n",
302 			    iv->iv_service);
303 			return (WALK_DONE);
304 		}
305 	else
306 		wsp->walk_addr = wsp->walk_addr +
307 		    OFFSETOF(ipc_service_t, ipcs_usedids);
308 
309 	if (mdb_layered_walk("list", wsp) == -1)
310 		return (WALK_ERR);
311 
312 	return (WALK_NEXT);
313 }
314 
315 
316 static int
317 ds_walk_step(mdb_walk_state_t *wsp)
318 {
319 	return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
320 	    wsp->walk_cbdata));
321 }
322 
323 /*
324  * Generic IPC ID/key to pointer code
325  */
326 
327 static int
328 ipcid_impl(uintptr_t svcptr, uintptr_t id, uintptr_t *addr)
329 {
330 	ipc_service_t service;
331 	kipc_perm_t perm;
332 	ipc_slot_t slot;
333 	uintptr_t slotptr;
334 	uint_t index;
335 
336 	if (id > INT_MAX) {
337 		mdb_warn("id out of range\n");
338 		return (DCMD_ERR);
339 	}
340 
341 	if (mdb_vread(&service, sizeof (ipc_service_t), svcptr) == -1) {
342 		mdb_warn("failed to read ipc_service_t at %#lx", svcptr);
343 		return (DCMD_ERR);
344 	}
345 
346 	index = (uint_t)id & (service.ipcs_tabsz - 1);
347 	slotptr = (uintptr_t)(service.ipcs_table + index);
348 
349 	if (mdb_vread(&slot, sizeof (ipc_slot_t), slotptr) == -1) {
350 		mdb_warn("failed to read ipc_slot_t at %#lx", slotptr);
351 		return (DCMD_ERR);
352 	}
353 
354 	if (slot.ipct_data == NULL)
355 		return (DCMD_ERR);
356 
357 	if (mdb_vread(&perm, sizeof (kipc_perm_t),
358 	    (uintptr_t)slot.ipct_data) == -1) {
359 		mdb_warn("failed to read kipc_perm_t at %#p",
360 		    slot.ipct_data);
361 		return (DCMD_ERR);
362 	}
363 
364 	if (perm.ipc_id != (uint_t)id)
365 		return (DCMD_ERR);
366 
367 	*addr = (uintptr_t)slot.ipct_data;
368 
369 	return (DCMD_OK);
370 }
371 
372 
373 typedef struct findkey_data {
374 	key_t fk_key;
375 	uintptr_t fk_addr;
376 	boolean_t fk_found;
377 } findkey_data_t;
378 
379 static int
380 findkey(uintptr_t addr, kipc_perm_t *perm, findkey_data_t *arg)
381 {
382 	if (perm->ipc_key == arg->fk_key) {
383 		arg->fk_found = B_TRUE;
384 		arg->fk_addr = addr;
385 		return (WALK_DONE);
386 	}
387 	return (WALK_NEXT);
388 }
389 
390 static int
391 ipckey_impl(uintptr_t svcptr, uintptr_t key, uintptr_t *addr)
392 {
393 	ipc_service_t	service;
394 	findkey_data_t	fkdata;
395 
396 	if ((key == IPC_PRIVATE) || (key > INT_MAX)) {
397 		mdb_warn("key out of range\n");
398 		return (DCMD_ERR);
399 	}
400 
401 	if (mdb_vread(&service, sizeof (ipc_service_t), svcptr) == -1) {
402 		mdb_warn("failed to read ipc_service_t at %#lx", svcptr);
403 		return (DCMD_ERR);
404 	}
405 
406 	fkdata.fk_key = (key_t)key;
407 	fkdata.fk_found = B_FALSE;
408 	if ((mdb_pwalk("avl", (mdb_walk_cb_t)findkey, &fkdata,
409 	    svcptr + OFFSETOF(ipc_service_t, ipcs_keys)) == -1) ||
410 	    !fkdata.fk_found)
411 		return (DCMD_ERR);
412 
413 	*addr = fkdata.fk_addr;
414 
415 	return (DCMD_OK);
416 }
417 
418 static int
419 ipckeyid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
420     int(*fp)(uintptr_t, uintptr_t, uintptr_t *))
421 {
422 	uintmax_t val;
423 	uintptr_t raddr;
424 	int result;
425 
426 	if (!(flags & DCMD_ADDRSPEC) || (argc != 1))
427 		return (DCMD_USAGE);
428 
429 	if (argv[0].a_type == MDB_TYPE_IMMEDIATE)
430 		val = argv[0].a_un.a_val;
431 	else if (argv[0].a_type == MDB_TYPE_STRING)
432 		val = mdb_strtoull(argv[0].a_un.a_str);
433 	else
434 		return (DCMD_USAGE);
435 
436 	result = fp(addr, val, &raddr);
437 
438 	if (result == DCMD_OK)
439 		mdb_printf("%lx", raddr);
440 
441 	return (result);
442 }
443 
444 static int
445 ipckey(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
446 {
447 	return (ipckeyid(addr, flags, argc, argv, ipckey_impl));
448 }
449 
450 static int
451 ipcid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
452 {
453 	return (ipckeyid(addr, flags, argc, argv, ipcid_impl));
454 }
455 
456 static int
457 ds_ptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
458     ipc_ops_vec_t *iv)
459 {
460 	uint_t		kflag = FALSE;
461 	uintptr_t	svcptr, raddr;
462 	int		result;
463 
464 	if (!(flags & DCMD_ADDRSPEC))
465 		return (DCMD_USAGE);
466 
467 	if (mdb_getopts(argc, argv,
468 	    'k', MDB_OPT_SETBITS, TRUE, &kflag, NULL) != argc)
469 		return (DCMD_USAGE);
470 
471 	if (mdb_readvar(&svcptr, iv->iv_service) == -1) {
472 		mdb_warn("failed to read '%s'; module not present\n",
473 		    iv->iv_service);
474 		return (DCMD_ERR);
475 	}
476 
477 	result = kflag ? ipckey_impl(svcptr, addr, &raddr) :
478 	    ipcid_impl(svcptr, addr, &raddr);
479 
480 	if (result == DCMD_OK)
481 		mdb_printf("%lx", raddr);
482 
483 	return (result);
484 }
485 
486 /*
487  * Stubs to call ds_ptr with the appropriate ops vector
488  */
489 static int
490 id2shm(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
491 {
492 	return (ds_ptr(addr, flags, argc, argv, &shm_ops_vec));
493 }
494 
495 static int
496 id2msq(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
497 {
498 	return (ds_ptr(addr, flags, argc, argv, &msq_ops_vec));
499 }
500 
501 static int
502 id2sem(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
503 {
504 	return (ds_ptr(addr, flags, argc, argv, &sem_ops_vec));
505 }
506 
507 
508 /*
509  * The message queue contents walker
510  */
511 
512 static int
513 msg_walk_init(mdb_walk_state_t *wsp)
514 {
515 	wsp->walk_addr += OFFSETOF(kmsqid_t, msg_list);
516 	if (mdb_layered_walk("list", wsp) == -1)
517 		return (WALK_ERR);
518 
519 	return (WALK_NEXT);
520 }
521 
522 static int
523 msg_walk_step(mdb_walk_state_t *wsp)
524 {
525 	return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
526 	    wsp->walk_cbdata));
527 }
528 
529 
530 /*
531  * The "::ipcs" command itself.  Just walks each IPC type in turn.
532  */
533 
534 /*ARGSUSED*/
535 static int
536 ipcs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
537 {
538 	uint_t	oflags = 0;
539 
540 	if ((flags & DCMD_ADDRSPEC) || mdb_getopts(argc, argv, 'l',
541 	    MDB_OPT_SETBITS, 1, &oflags, NULL) != argc)
542 		return (DCMD_USAGE);
543 
544 	mdb_printf("Message queues:\n");
545 	if (mdb_walk_dcmd("msq", oflags ? "kmsqid" : "ipcperm", argc, argv) ==
546 	    -1) {
547 		mdb_warn("can't walk 'msq'");
548 		return (DCMD_ERR);
549 	}
550 
551 	mdb_printf("\nShared memory:\n");
552 	if (mdb_walk_dcmd("shm", oflags ? "kshmid" : "ipcperm", argc, argv) ==
553 	    -1) {
554 		mdb_warn("can't walk 'shm'");
555 		return (DCMD_ERR);
556 	}
557 
558 	mdb_printf("\nSemaphores:\n");
559 	if (mdb_walk_dcmd("sem", oflags ? "ksemid" : "ipcperm", argc, argv) ==
560 	    -1) {
561 		mdb_warn("can't walk 'sem'");
562 		return (DCMD_ERR);
563 	}
564 
565 	return (DCMD_OK);
566 }
567 
568 static int
569 msgprint(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
570 {
571 	struct msg message;
572 	uint_t	lflag = FALSE;
573 	long	type = 0;
574 	char	*tflag = NULL;
575 
576 	if (!(flags & DCMD_ADDRSPEC) || (mdb_getopts(argc, argv,
577 	    'l', MDB_OPT_SETBITS, TRUE, &lflag,
578 	    't', MDB_OPT_STR, &tflag, NULL) != argc))
579 		return (DCMD_USAGE);
580 
581 	/*
582 	 * Handle negative values.
583 	 */
584 	if (tflag != NULL) {
585 		if (*tflag == '-') {
586 			tflag++;
587 			type = -1;
588 		} else {
589 			type = 1;
590 		}
591 		type *= mdb_strtoull(tflag);
592 	}
593 
594 	if (DCMD_HDRSPEC(flags))
595 		mdb_printf("%<u>%?s %?s %8s %8s %8s%</u>\n",
596 		    "ADDR", "TEXT", "SIZE", "TYPE", "REF");
597 
598 	if (mdb_vread(&message, sizeof (struct msg), addr) == -1) {
599 		mdb_warn("failed to read msg at %#lx", addr);
600 		return (DCMD_ERR);
601 	}
602 
603 	/*
604 	 * If we are meeting our type contraints, display the message.
605 	 * If -l was specified, we will also display the message
606 	 * contents.
607 	 */
608 	if ((type == 0) ||
609 	    (type > 0 && message.msg_type == type) ||
610 	    (type < 0 && message.msg_type <= -type)) {
611 
612 		if (lflag && !DCMD_HDRSPEC(flags))
613 			mdb_printf("\n");
614 
615 		mdb_printf("%0?lx %?p %8ld %8ld %8ld\n", addr, message.msg_addr,
616 		    message.msg_size, message.msg_type, message.msg_copycnt);
617 
618 		if (lflag) {
619 			mdb_printf("\n");
620 			mdb_inc_indent(CMN_INDENT);
621 			if (mdb_dumpptr(
622 			    (uintptr_t)message.msg_addr, message.msg_size,
623 			    MDB_DUMP_RELATIVE | MDB_DUMP_TRIM |
624 			    MDB_DUMP_ASCII | MDB_DUMP_HEADER |
625 			    MDB_DUMP_GROUP(4),
626 			    (mdb_dumpptr_cb_t)mdb_vread, NULL)) {
627 				mdb_dec_indent(CMN_INDENT);
628 				return (DCMD_ERR);
629 			}
630 			mdb_dec_indent(CMN_INDENT);
631 		}
632 	}
633 
634 	return (DCMD_OK);
635 }
636 
637 /*
638  * MDB module linkage
639  */
640 static const mdb_dcmd_t dcmds[] = {
641 	/* Generic routines */
642 	{ "ipcperm", ":", "display an IPC perm structure", ipcperm },
643 	{ "ipcid", ":id", "perform an IPC id lookup", ipcid },
644 	{ "ipckey", ":key", "perform an IPC key lookup", ipckey },
645 
646 	/* Specific routines */
647 	{ "kshmid", "?[-l]", "display a struct kshmid", cmd_kshmid },
648 	{ "kmsqid", "?[-l]", "display a struct kmsqid", cmd_kmsqid },
649 	{ "ksemid", "?[-l]", "display a struct ksemid", cmd_ksemid },
650 	{ "msg", ":[-l] [-t type]", "display contents of a message", msgprint },
651 
652 	/* Convenience routines */
653 	{ "id2shm", ":[-k]", "convert shared memory ID to pointer", id2shm },
654 	{ "id2msq", ":[-k]", "convert message queue ID to pointer", id2msq },
655 	{ "id2sem", ":[-k]", "convert semaphore ID to pointer", id2sem },
656 
657 	{ "ipcs", "[-l]", "display System V IPC information", ipcs },
658 	{ NULL }
659 };
660 
661 static const mdb_walker_t walkers[] = {
662 	{ "ipcsvc", "walk a System V IPC service",
663 		ds_walk_init, ds_walk_step },
664 	{ "shm", "walk the active shmid_ds structures",
665 		ds_walk_init, ds_walk_step, NULL, &shm_ops_vec },
666 	{ "msq", "walk the active msqid_ds structures",
667 		ds_walk_init, ds_walk_step, NULL, &msq_ops_vec },
668 	{ "sem", "walk the active semid_ds structures",
669 		ds_walk_init, ds_walk_step, NULL, &sem_ops_vec },
670 	{ "msgqueue", "walk messages on a message queue",
671 		msg_walk_init, msg_walk_step },
672 	{ NULL }
673 };
674 
675 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
676 
677 const mdb_modinfo_t *
678 _mdb_init(void)
679 {
680 	return (&modinfo);
681 }
682