10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
52565Sudpa * Common Development and Distribution License (the "License").
62565Sudpa * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*8834SDavid.Valin@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <mdb/mdb_modapi.h>
270Sstevel@tonic-gate #include <mdb/mdb_ks.h>
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/mman.h>
310Sstevel@tonic-gate #include <sys/project.h>
320Sstevel@tonic-gate #include <sys/ipc_impl.h>
330Sstevel@tonic-gate #include <sys/shm_impl.h>
340Sstevel@tonic-gate #include <sys/sem_impl.h>
350Sstevel@tonic-gate #include <sys/msg_impl.h>
360Sstevel@tonic-gate
370Sstevel@tonic-gate #include <vm/anon.h>
380Sstevel@tonic-gate
390Sstevel@tonic-gate #define CMN_HDR_START "%<u>"
400Sstevel@tonic-gate #define CMN_HDR_END "%</u>\n"
410Sstevel@tonic-gate #define CMN_INDENT (4)
420Sstevel@tonic-gate #define CMN_INACTIVE "%s facility inactive.\n"
430Sstevel@tonic-gate
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate * Bitmap data for page protection flags suitable for use with %b.
460Sstevel@tonic-gate */
470Sstevel@tonic-gate const mdb_bitmask_t prot_flag_bits[] = {
480Sstevel@tonic-gate { "PROT_READ", PROT_READ, PROT_READ },
490Sstevel@tonic-gate { "PROT_WRITE", PROT_WRITE, PROT_WRITE },
500Sstevel@tonic-gate { "PROT_EXEC", PROT_EXEC, PROT_EXEC },
510Sstevel@tonic-gate { "PROT_USER", PROT_USER, PROT_USER },
520Sstevel@tonic-gate { NULL, 0, 0 }
530Sstevel@tonic-gate };
540Sstevel@tonic-gate
550Sstevel@tonic-gate static void
printtime_nice(const char * str,time_t time)560Sstevel@tonic-gate printtime_nice(const char *str, time_t time)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate if (time)
590Sstevel@tonic-gate mdb_printf("%s%Y\n", str, time);
600Sstevel@tonic-gate else
610Sstevel@tonic-gate mdb_printf("%sn/a\n", str);
620Sstevel@tonic-gate }
630Sstevel@tonic-gate
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate * Print header common to all IPC types.
660Sstevel@tonic-gate */
670Sstevel@tonic-gate static void
ipcperm_header()680Sstevel@tonic-gate ipcperm_header()
690Sstevel@tonic-gate {
700Sstevel@tonic-gate mdb_printf(CMN_HDR_START "%?s %5s %5s %8s %5s %5s %6s %5s %5s %5s %5s"
710Sstevel@tonic-gate CMN_HDR_END, "ADDR", "REF", "ID", "KEY", "MODE", "PRJID", "ZONEID",
720Sstevel@tonic-gate "OWNER", "GROUP", "CREAT", "CGRP");
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
750Sstevel@tonic-gate /*
760Sstevel@tonic-gate * Print data common to all IPC types.
770Sstevel@tonic-gate */
780Sstevel@tonic-gate static void
ipcperm_print(uintptr_t addr,kipc_perm_t * perm)790Sstevel@tonic-gate ipcperm_print(uintptr_t addr, kipc_perm_t *perm)
800Sstevel@tonic-gate {
810Sstevel@tonic-gate kproject_t proj;
820Sstevel@tonic-gate int res;
830Sstevel@tonic-gate
840Sstevel@tonic-gate res = mdb_vread(&proj, sizeof (kproject_t), (uintptr_t)perm->ipc_proj);
850Sstevel@tonic-gate
860Sstevel@tonic-gate if (res == -1)
870Sstevel@tonic-gate mdb_warn("failed to read kproject_t at %#p", perm->ipc_proj);
880Sstevel@tonic-gate
890Sstevel@tonic-gate mdb_printf("%0?p %5d %5d", addr, perm->ipc_ref, perm->ipc_id);
900Sstevel@tonic-gate if (perm->ipc_key)
910Sstevel@tonic-gate mdb_printf(" %8x", perm->ipc_key);
920Sstevel@tonic-gate else
930Sstevel@tonic-gate mdb_printf(" %8s", "private");
940Sstevel@tonic-gate mdb_printf(" %5#o", perm->ipc_mode & 07777);
950Sstevel@tonic-gate if (res == -1)
960Sstevel@tonic-gate mdb_printf(" %5s %5s", "<flt>", "<flt>");
970Sstevel@tonic-gate else
980Sstevel@tonic-gate mdb_printf(" %5d %6d", proj.kpj_id, proj.kpj_zoneid);
990Sstevel@tonic-gate mdb_printf(" %5d %5d %5d %5d\n", perm->ipc_uid, perm->ipc_gid,
1000Sstevel@tonic-gate perm->ipc_cuid, perm->ipc_cgid);
1010Sstevel@tonic-gate
1020Sstevel@tonic-gate }
1030Sstevel@tonic-gate
1040Sstevel@tonic-gate /*ARGSUSED*/
1050Sstevel@tonic-gate static int
ipcperm(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1060Sstevel@tonic-gate ipcperm(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1070Sstevel@tonic-gate {
1080Sstevel@tonic-gate kipc_perm_t perm;
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC))
1110Sstevel@tonic-gate return (DCMD_USAGE);
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate if (DCMD_HDRSPEC(flags))
1140Sstevel@tonic-gate ipcperm_header();
1150Sstevel@tonic-gate
1160Sstevel@tonic-gate if (mdb_vread(&perm, sizeof (kipc_perm_t), addr) == -1) {
1170Sstevel@tonic-gate mdb_warn("failed to read kipc_perm_t at %#lx", addr);
1180Sstevel@tonic-gate return (DCMD_ERR);
1190Sstevel@tonic-gate }
1200Sstevel@tonic-gate
1210Sstevel@tonic-gate ipcperm_print(addr, &perm);
1220Sstevel@tonic-gate return (DCMD_OK);
1230Sstevel@tonic-gate }
1240Sstevel@tonic-gate
1254153Sdv142724
126*8834SDavid.Valin@Sun.COM #define MSG_SND_SIZE 0x1
1274153Sdv142724 static int
msgq_check_for_waiters(list_t * walk_this,int min,int max,int copy_wait,uintptr_t addr,int flag)128*8834SDavid.Valin@Sun.COM msgq_check_for_waiters(list_t *walk_this, int min, int max,
129*8834SDavid.Valin@Sun.COM int copy_wait, uintptr_t addr, int flag)
1304153Sdv142724
1314153Sdv142724 {
1324153Sdv142724 int found = 0;
1334153Sdv142724 int ii;
1344158Sdv142724 msgq_wakeup_t *walker, next;
1354153Sdv142724 uintptr_t head;
1364153Sdv142724
1374153Sdv142724 for (ii = min; ii < max; ii++) {
1384153Sdv142724 head = ((ulong_t)addr) + sizeof (list_t)*ii +
1394153Sdv142724 sizeof (list_node_t);
1404153Sdv142724 if (head != (uintptr_t)walk_this[ii].list_head.list_next) {
1414153Sdv142724 walker =
1424153Sdv142724 (msgq_wakeup_t *)walk_this[ii].list_head.list_next;
1434153Sdv142724 while (head != (uintptr_t)walker) {
1444153Sdv142724 if (mdb_vread(&next, sizeof (msgq_wakeup_t),
1454153Sdv142724 (uintptr_t)walker) == -1) {
1464153Sdv142724 mdb_warn(
1474153Sdv142724 "Failed to read message queue\n");
148*8834SDavid.Valin@Sun.COM return (found);
1494153Sdv142724 }
150*8834SDavid.Valin@Sun.COM
151*8834SDavid.Valin@Sun.COM if (flag & MSG_SND_SIZE) {
152*8834SDavid.Valin@Sun.COM mdb_printf("%15lx\t%6d\t%15lx\t%15d\n",
153*8834SDavid.Valin@Sun.COM next.msgw_thrd, next.msgw_type,
154*8834SDavid.Valin@Sun.COM walker + (uintptr_t)
155*8834SDavid.Valin@Sun.COM OFFSETOF(msgq_wakeup_t,
156*8834SDavid.Valin@Sun.COM msgw_wake_cv), next.msgw_snd_size);
157*8834SDavid.Valin@Sun.COM } else {
158*8834SDavid.Valin@Sun.COM mdb_printf("%15lx\t%6d\t%15lx\t%15s\n",
159*8834SDavid.Valin@Sun.COM next.msgw_thrd, next.msgw_type,
160*8834SDavid.Valin@Sun.COM walker + (uintptr_t)
161*8834SDavid.Valin@Sun.COM OFFSETOF(msgq_wakeup_t,
162*8834SDavid.Valin@Sun.COM msgw_wake_cv),
163*8834SDavid.Valin@Sun.COM (copy_wait ? "yes":"no"));
164*8834SDavid.Valin@Sun.COM }
1654153Sdv142724 found++;
1664153Sdv142724 walker =
1674153Sdv142724 (msgq_wakeup_t *)next.msgw_list.list_next;
1684153Sdv142724 }
1694153Sdv142724 }
1704153Sdv142724 }
1714153Sdv142724 return (found);
1724153Sdv142724 }
1734153Sdv142724
1740Sstevel@tonic-gate static void
msq_print(kmsqid_t * msqid,uintptr_t addr)1750Sstevel@tonic-gate msq_print(kmsqid_t *msqid, uintptr_t addr)
1760Sstevel@tonic-gate {
1774153Sdv142724 int total = 0;
1782565Sudpa
1790Sstevel@tonic-gate mdb_printf("&list: %-?p\n", addr + OFFSETOF(kmsqid_t, msg_list));
1800Sstevel@tonic-gate mdb_printf("cbytes: 0t%lu qnum: 0t%lu qbytes: 0t%lu"
1810Sstevel@tonic-gate " qmax: 0t%lu\n", msqid->msg_cbytes, msqid->msg_qnum,
1820Sstevel@tonic-gate msqid->msg_qbytes, msqid->msg_qmax);
1830Sstevel@tonic-gate mdb_printf("lspid: 0t%d lrpid: 0t%d\n",
1840Sstevel@tonic-gate (int)msqid->msg_lspid, (int)msqid->msg_lrpid);
1850Sstevel@tonic-gate printtime_nice("stime: ", msqid->msg_stime);
1860Sstevel@tonic-gate printtime_nice("rtime: ", msqid->msg_rtime);
1870Sstevel@tonic-gate printtime_nice("ctime: ", msqid->msg_ctime);
1882565Sudpa mdb_printf("snd_cnt: 0t%lld snd_cv: %hd (%p)\n",
1892565Sudpa msqid->msg_snd_cnt, msqid->msg_snd_cv._opaque,
1902565Sudpa addr + (uintptr_t)OFFSETOF(kmsqid_t, msg_snd_cv));
1914153Sdv142724 mdb_printf("Blocked recievers\n");
1924153Sdv142724 mdb_printf("%15s\t%6s\t%15s\t%15s\n", "Thread Addr",
1934153Sdv142724 "Type", "cv addr", "copyout-wait?");
194*8834SDavid.Valin@Sun.COM total += msgq_check_for_waiters(&msqid->msg_cpy_block,
195*8834SDavid.Valin@Sun.COM 0, 1, 1, addr + OFFSETOF(kmsqid_t, msg_cpy_block), 0);
196*8834SDavid.Valin@Sun.COM total += msgq_check_for_waiters(msqid->msg_wait_snd_ngt,
1974153Sdv142724 0, MSG_MAX_QNUM + 1, 0,
198*8834SDavid.Valin@Sun.COM addr + OFFSETOF(kmsqid_t, msg_wait_snd_ngt), 0);
199*8834SDavid.Valin@Sun.COM mdb_printf("Blocked senders\n");
200*8834SDavid.Valin@Sun.COM total += msgq_check_for_waiters(&msqid->msg_wait_rcv,
201*8834SDavid.Valin@Sun.COM 0, 1, 1, addr + OFFSETOF(kmsqid_t, msg_wait_rcv),
202*8834SDavid.Valin@Sun.COM MSG_SND_SIZE);
203*8834SDavid.Valin@Sun.COM mdb_printf("%15s\t%6s\t%15s\t%15s\n", "Thread Addr",
204*8834SDavid.Valin@Sun.COM "Type", "cv addr", "Msg Size");
205*8834SDavid.Valin@Sun.COM total += msgq_check_for_waiters(msqid->msg_wait_snd,
206*8834SDavid.Valin@Sun.COM 0, MSG_MAX_QNUM + 1, 0, addr + OFFSETOF(kmsqid_t,
207*8834SDavid.Valin@Sun.COM msg_wait_snd), 0);
2084153Sdv142724 mdb_printf("Total number of waiters: %d\n", total);
2090Sstevel@tonic-gate }
2100Sstevel@tonic-gate
2110Sstevel@tonic-gate
2120Sstevel@tonic-gate /*ARGSUSED1*/
2130Sstevel@tonic-gate static void
shm_print(kshmid_t * shmid,uintptr_t addr)2140Sstevel@tonic-gate shm_print(kshmid_t *shmid, uintptr_t addr)
2150Sstevel@tonic-gate {
2160Sstevel@tonic-gate shmatt_t nattch;
2170Sstevel@tonic-gate
2180Sstevel@tonic-gate nattch = shmid->shm_perm.ipc_ref - (IPC_FREE(&shmid->shm_perm) ? 0 : 1);
2190Sstevel@tonic-gate
2200Sstevel@tonic-gate mdb_printf(CMN_HDR_START "%10s %?s %5s %7s %7s %7s %7s" CMN_HDR_END,
2210Sstevel@tonic-gate "SEGSZ", "AMP", "LKCNT", "LPID", "CPID", "NATTCH", "CNATTCH");
2220Sstevel@tonic-gate mdb_printf("%10#lx %?p %5u %7d %7d %7lu %7lu\n",
2230Sstevel@tonic-gate shmid->shm_segsz, shmid->shm_amp, shmid->shm_lkcnt,
2240Sstevel@tonic-gate (int)shmid->shm_lpid, (int)shmid->shm_cpid, nattch,
2250Sstevel@tonic-gate shmid->shm_ismattch);
2260Sstevel@tonic-gate
2270Sstevel@tonic-gate printtime_nice("atime: ", shmid->shm_atime);
2280Sstevel@tonic-gate printtime_nice("dtime: ", shmid->shm_dtime);
2290Sstevel@tonic-gate printtime_nice("ctime: ", shmid->shm_ctime);
2300Sstevel@tonic-gate mdb_printf("sptinfo: %-?p sptseg: %-?p\n",
2310Sstevel@tonic-gate shmid->shm_sptinfo, shmid->shm_sptseg);
2320Sstevel@tonic-gate mdb_printf("sptprot: <%lb>\n", shmid->shm_sptprot, prot_flag_bits);
2330Sstevel@tonic-gate }
2340Sstevel@tonic-gate
2350Sstevel@tonic-gate
2360Sstevel@tonic-gate /*ARGSUSED1*/
2370Sstevel@tonic-gate static void
sem_print(ksemid_t * semid,uintptr_t addr)2380Sstevel@tonic-gate sem_print(ksemid_t *semid, uintptr_t addr)
2390Sstevel@tonic-gate {
2400Sstevel@tonic-gate mdb_printf("base: %-?p nsems: 0t%u\n",
2410Sstevel@tonic-gate semid->sem_base, semid->sem_nsems);
2420Sstevel@tonic-gate printtime_nice("otime: ", semid->sem_otime);
2430Sstevel@tonic-gate printtime_nice("ctime: ", semid->sem_ctime);
2440Sstevel@tonic-gate mdb_printf("binary: %s\n", semid->sem_binary ? "yes" : "no");
2450Sstevel@tonic-gate }
2460Sstevel@tonic-gate
2470Sstevel@tonic-gate typedef struct ipc_ops_vec {
2480Sstevel@tonic-gate char *iv_wcmd; /* walker name */
2490Sstevel@tonic-gate char *iv_ocmd; /* output dcmd */
2500Sstevel@tonic-gate char *iv_service; /* service pointer */
2510Sstevel@tonic-gate void (*iv_print)(void *, uintptr_t); /* output callback */
2520Sstevel@tonic-gate size_t iv_idsize;
2530Sstevel@tonic-gate } ipc_ops_vec_t;
2540Sstevel@tonic-gate
2550Sstevel@tonic-gate ipc_ops_vec_t msq_ops_vec = {
2560Sstevel@tonic-gate "msq",
2570Sstevel@tonic-gate "kmsqid",
2580Sstevel@tonic-gate "msq_svc",
2590Sstevel@tonic-gate (void(*)(void *, uintptr_t))msq_print,
2600Sstevel@tonic-gate sizeof (kmsqid_t)
2610Sstevel@tonic-gate };
2620Sstevel@tonic-gate
2630Sstevel@tonic-gate ipc_ops_vec_t shm_ops_vec = {
2640Sstevel@tonic-gate "shm",
2650Sstevel@tonic-gate "kshmid",
2660Sstevel@tonic-gate "shm_svc",
2670Sstevel@tonic-gate (void(*)(void *, uintptr_t))shm_print,
2680Sstevel@tonic-gate sizeof (kshmid_t)
2690Sstevel@tonic-gate };
2700Sstevel@tonic-gate
2710Sstevel@tonic-gate ipc_ops_vec_t sem_ops_vec = {
2720Sstevel@tonic-gate "sem",
2730Sstevel@tonic-gate "ksemid",
2740Sstevel@tonic-gate "sem_svc",
2750Sstevel@tonic-gate (void(*)(void *, uintptr_t))sem_print,
2760Sstevel@tonic-gate sizeof (ksemid_t)
2770Sstevel@tonic-gate };
2780Sstevel@tonic-gate
2790Sstevel@tonic-gate
2800Sstevel@tonic-gate /*
2810Sstevel@tonic-gate * Generic IPC data structure display code
2820Sstevel@tonic-gate */
2830Sstevel@tonic-gate static int
ds_print(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv,ipc_ops_vec_t * iv)2840Sstevel@tonic-gate ds_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
2850Sstevel@tonic-gate ipc_ops_vec_t *iv)
2860Sstevel@tonic-gate {
2870Sstevel@tonic-gate void *iddata;
2880Sstevel@tonic-gate
2890Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) {
2900Sstevel@tonic-gate uint_t oflags = 0;
2910Sstevel@tonic-gate
2920Sstevel@tonic-gate if (mdb_getopts(argc, argv, 'l', MDB_OPT_SETBITS, 1, &oflags,
2930Sstevel@tonic-gate NULL) != argc)
2940Sstevel@tonic-gate return (DCMD_USAGE);
2950Sstevel@tonic-gate
2960Sstevel@tonic-gate if (mdb_walk_dcmd(iv->iv_wcmd, oflags ? iv->iv_ocmd : "ipcperm",
2970Sstevel@tonic-gate argc, argv) == -1) {
2980Sstevel@tonic-gate mdb_warn("can't walk '%s'", iv->iv_wcmd);
2990Sstevel@tonic-gate return (DCMD_ERR);
3000Sstevel@tonic-gate }
3010Sstevel@tonic-gate return (DCMD_OK);
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate
3040Sstevel@tonic-gate iddata = mdb_alloc(iv->iv_idsize, UM_SLEEP | UM_GC);
3050Sstevel@tonic-gate if (mdb_vread(iddata, iv->iv_idsize, addr) == -1) {
3060Sstevel@tonic-gate mdb_warn("failed to read %s at %#lx", iv->iv_ocmd, addr);
3070Sstevel@tonic-gate return (DCMD_ERR);
3080Sstevel@tonic-gate }
3090Sstevel@tonic-gate
3100Sstevel@tonic-gate if (!DCMD_HDRSPEC(flags) && iv->iv_print)
3110Sstevel@tonic-gate mdb_printf("\n");
3120Sstevel@tonic-gate
3130Sstevel@tonic-gate if (DCMD_HDRSPEC(flags) || iv->iv_print)
3140Sstevel@tonic-gate ipcperm_header();
3150Sstevel@tonic-gate
3160Sstevel@tonic-gate ipcperm_print(addr, (struct kipc_perm *)iddata);
3170Sstevel@tonic-gate if (iv->iv_print) {
3180Sstevel@tonic-gate mdb_inc_indent(CMN_INDENT);
3190Sstevel@tonic-gate iv->iv_print(iddata, addr);
3200Sstevel@tonic-gate mdb_dec_indent(CMN_INDENT);
3210Sstevel@tonic-gate }
3220Sstevel@tonic-gate
3230Sstevel@tonic-gate return (DCMD_OK);
3240Sstevel@tonic-gate }
3250Sstevel@tonic-gate
3260Sstevel@tonic-gate
3270Sstevel@tonic-gate /*
3280Sstevel@tonic-gate * Stubs to call ds_print with the appropriate ops vector
3290Sstevel@tonic-gate */
3300Sstevel@tonic-gate static int
cmd_kshmid(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)3310Sstevel@tonic-gate cmd_kshmid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3320Sstevel@tonic-gate {
3330Sstevel@tonic-gate return (ds_print(addr, flags, argc, argv, &shm_ops_vec));
3340Sstevel@tonic-gate }
3350Sstevel@tonic-gate
3360Sstevel@tonic-gate
3370Sstevel@tonic-gate static int
cmd_kmsqid(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)3380Sstevel@tonic-gate cmd_kmsqid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3390Sstevel@tonic-gate {
3400Sstevel@tonic-gate return (ds_print(addr, flags, argc, argv, &msq_ops_vec));
3410Sstevel@tonic-gate }
3420Sstevel@tonic-gate
3430Sstevel@tonic-gate static int
cmd_ksemid(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)3440Sstevel@tonic-gate cmd_ksemid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3450Sstevel@tonic-gate {
3460Sstevel@tonic-gate return (ds_print(addr, flags, argc, argv, &sem_ops_vec));
3470Sstevel@tonic-gate }
3480Sstevel@tonic-gate
3490Sstevel@tonic-gate /*
3500Sstevel@tonic-gate * Generic IPC walker
3510Sstevel@tonic-gate */
3520Sstevel@tonic-gate
3530Sstevel@tonic-gate static int
ds_walk_init(mdb_walk_state_t * wsp)3540Sstevel@tonic-gate ds_walk_init(mdb_walk_state_t *wsp)
3550Sstevel@tonic-gate {
3560Sstevel@tonic-gate ipc_ops_vec_t *iv = wsp->walk_arg;
3570Sstevel@tonic-gate
3580Sstevel@tonic-gate if (wsp->walk_arg != NULL && wsp->walk_addr != NULL)
3590Sstevel@tonic-gate mdb_printf("ignoring provided address\n");
3600Sstevel@tonic-gate
3610Sstevel@tonic-gate if (wsp->walk_arg)
3620Sstevel@tonic-gate if (mdb_readvar(&wsp->walk_addr, iv->iv_service) == -1) {
3630Sstevel@tonic-gate mdb_printf("failed to read '%s'; module not present\n",
3640Sstevel@tonic-gate iv->iv_service);
3650Sstevel@tonic-gate return (WALK_DONE);
3660Sstevel@tonic-gate }
3670Sstevel@tonic-gate else
3680Sstevel@tonic-gate wsp->walk_addr = wsp->walk_addr +
3690Sstevel@tonic-gate OFFSETOF(ipc_service_t, ipcs_usedids);
3700Sstevel@tonic-gate
3710Sstevel@tonic-gate if (mdb_layered_walk("list", wsp) == -1)
3720Sstevel@tonic-gate return (WALK_ERR);
3730Sstevel@tonic-gate
3740Sstevel@tonic-gate return (WALK_NEXT);
3750Sstevel@tonic-gate }
3760Sstevel@tonic-gate
3770Sstevel@tonic-gate
3780Sstevel@tonic-gate static int
ds_walk_step(mdb_walk_state_t * wsp)3790Sstevel@tonic-gate ds_walk_step(mdb_walk_state_t *wsp)
3800Sstevel@tonic-gate {
3810Sstevel@tonic-gate return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
3820Sstevel@tonic-gate wsp->walk_cbdata));
3830Sstevel@tonic-gate }
3840Sstevel@tonic-gate
3850Sstevel@tonic-gate /*
3860Sstevel@tonic-gate * Generic IPC ID/key to pointer code
3870Sstevel@tonic-gate */
3880Sstevel@tonic-gate
3890Sstevel@tonic-gate static int
ipcid_impl(uintptr_t svcptr,uintptr_t id,uintptr_t * addr)3900Sstevel@tonic-gate ipcid_impl(uintptr_t svcptr, uintptr_t id, uintptr_t *addr)
3910Sstevel@tonic-gate {
3920Sstevel@tonic-gate ipc_service_t service;
3930Sstevel@tonic-gate kipc_perm_t perm;
3940Sstevel@tonic-gate ipc_slot_t slot;
3950Sstevel@tonic-gate uintptr_t slotptr;
3960Sstevel@tonic-gate uint_t index;
3970Sstevel@tonic-gate
3980Sstevel@tonic-gate if (id > INT_MAX) {
3990Sstevel@tonic-gate mdb_warn("id out of range\n");
4000Sstevel@tonic-gate return (DCMD_ERR);
4010Sstevel@tonic-gate }
4020Sstevel@tonic-gate
4030Sstevel@tonic-gate if (mdb_vread(&service, sizeof (ipc_service_t), svcptr) == -1) {
4040Sstevel@tonic-gate mdb_warn("failed to read ipc_service_t at %#lx", svcptr);
4050Sstevel@tonic-gate return (DCMD_ERR);
4060Sstevel@tonic-gate }
4070Sstevel@tonic-gate
4080Sstevel@tonic-gate index = (uint_t)id & (service.ipcs_tabsz - 1);
4090Sstevel@tonic-gate slotptr = (uintptr_t)(service.ipcs_table + index);
4100Sstevel@tonic-gate
4110Sstevel@tonic-gate if (mdb_vread(&slot, sizeof (ipc_slot_t), slotptr) == -1) {
4120Sstevel@tonic-gate mdb_warn("failed to read ipc_slot_t at %#lx", slotptr);
4130Sstevel@tonic-gate return (DCMD_ERR);
4140Sstevel@tonic-gate }
4150Sstevel@tonic-gate
4160Sstevel@tonic-gate if (slot.ipct_data == NULL)
4170Sstevel@tonic-gate return (DCMD_ERR);
4180Sstevel@tonic-gate
4190Sstevel@tonic-gate if (mdb_vread(&perm, sizeof (kipc_perm_t),
4200Sstevel@tonic-gate (uintptr_t)slot.ipct_data) == -1) {
4210Sstevel@tonic-gate mdb_warn("failed to read kipc_perm_t at %#p",
4220Sstevel@tonic-gate slot.ipct_data);
4230Sstevel@tonic-gate return (DCMD_ERR);
4240Sstevel@tonic-gate }
4250Sstevel@tonic-gate
4260Sstevel@tonic-gate if (perm.ipc_id != (uint_t)id)
4270Sstevel@tonic-gate return (DCMD_ERR);
4280Sstevel@tonic-gate
4290Sstevel@tonic-gate *addr = (uintptr_t)slot.ipct_data;
4300Sstevel@tonic-gate
4310Sstevel@tonic-gate return (DCMD_OK);
4320Sstevel@tonic-gate }
4330Sstevel@tonic-gate
4340Sstevel@tonic-gate
4350Sstevel@tonic-gate typedef struct findkey_data {
4360Sstevel@tonic-gate key_t fk_key;
4370Sstevel@tonic-gate uintptr_t fk_addr;
4380Sstevel@tonic-gate boolean_t fk_found;
4390Sstevel@tonic-gate } findkey_data_t;
4400Sstevel@tonic-gate
4410Sstevel@tonic-gate static int
findkey(uintptr_t addr,kipc_perm_t * perm,findkey_data_t * arg)4420Sstevel@tonic-gate findkey(uintptr_t addr, kipc_perm_t *perm, findkey_data_t *arg)
4430Sstevel@tonic-gate {
4440Sstevel@tonic-gate if (perm->ipc_key == arg->fk_key) {
4450Sstevel@tonic-gate arg->fk_found = B_TRUE;
4460Sstevel@tonic-gate arg->fk_addr = addr;
4470Sstevel@tonic-gate return (WALK_DONE);
4480Sstevel@tonic-gate }
4490Sstevel@tonic-gate return (WALK_NEXT);
4500Sstevel@tonic-gate }
4510Sstevel@tonic-gate
4520Sstevel@tonic-gate static int
ipckey_impl(uintptr_t svcptr,uintptr_t key,uintptr_t * addr)4530Sstevel@tonic-gate ipckey_impl(uintptr_t svcptr, uintptr_t key, uintptr_t *addr)
4540Sstevel@tonic-gate {
4550Sstevel@tonic-gate ipc_service_t service;
4560Sstevel@tonic-gate findkey_data_t fkdata;
4570Sstevel@tonic-gate
4580Sstevel@tonic-gate if ((key == IPC_PRIVATE) || (key > INT_MAX)) {
4590Sstevel@tonic-gate mdb_warn("key out of range\n");
4600Sstevel@tonic-gate return (DCMD_ERR);
4610Sstevel@tonic-gate }
4620Sstevel@tonic-gate
4630Sstevel@tonic-gate if (mdb_vread(&service, sizeof (ipc_service_t), svcptr) == -1) {
4640Sstevel@tonic-gate mdb_warn("failed to read ipc_service_t at %#lx", svcptr);
4650Sstevel@tonic-gate return (DCMD_ERR);
4660Sstevel@tonic-gate }
4670Sstevel@tonic-gate
4680Sstevel@tonic-gate fkdata.fk_key = (key_t)key;
4690Sstevel@tonic-gate fkdata.fk_found = B_FALSE;
4700Sstevel@tonic-gate if ((mdb_pwalk("avl", (mdb_walk_cb_t)findkey, &fkdata,
4710Sstevel@tonic-gate svcptr + OFFSETOF(ipc_service_t, ipcs_keys)) == -1) ||
4720Sstevel@tonic-gate !fkdata.fk_found)
4730Sstevel@tonic-gate return (DCMD_ERR);
4740Sstevel@tonic-gate
4750Sstevel@tonic-gate *addr = fkdata.fk_addr;
4760Sstevel@tonic-gate
4770Sstevel@tonic-gate return (DCMD_OK);
4780Sstevel@tonic-gate }
4790Sstevel@tonic-gate
4800Sstevel@tonic-gate static int
ipckeyid(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv,int (* fp)(uintptr_t,uintptr_t,uintptr_t *))4810Sstevel@tonic-gate ipckeyid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
4820Sstevel@tonic-gate int(*fp)(uintptr_t, uintptr_t, uintptr_t *))
4830Sstevel@tonic-gate {
4840Sstevel@tonic-gate uintmax_t val;
4850Sstevel@tonic-gate uintptr_t raddr;
4860Sstevel@tonic-gate int result;
4870Sstevel@tonic-gate
4880Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC) || (argc != 1))
4890Sstevel@tonic-gate return (DCMD_USAGE);
4900Sstevel@tonic-gate
4910Sstevel@tonic-gate if (argv[0].a_type == MDB_TYPE_IMMEDIATE)
4920Sstevel@tonic-gate val = argv[0].a_un.a_val;
4930Sstevel@tonic-gate else if (argv[0].a_type == MDB_TYPE_STRING)
4940Sstevel@tonic-gate val = mdb_strtoull(argv[0].a_un.a_str);
4950Sstevel@tonic-gate else
4960Sstevel@tonic-gate return (DCMD_USAGE);
4970Sstevel@tonic-gate
4980Sstevel@tonic-gate result = fp(addr, val, &raddr);
4990Sstevel@tonic-gate
5000Sstevel@tonic-gate if (result == DCMD_OK)
5010Sstevel@tonic-gate mdb_printf("%lx", raddr);
5020Sstevel@tonic-gate
5030Sstevel@tonic-gate return (result);
5040Sstevel@tonic-gate }
5050Sstevel@tonic-gate
5060Sstevel@tonic-gate static int
ipckey(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5070Sstevel@tonic-gate ipckey(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5080Sstevel@tonic-gate {
5090Sstevel@tonic-gate return (ipckeyid(addr, flags, argc, argv, ipckey_impl));
5100Sstevel@tonic-gate }
5110Sstevel@tonic-gate
5120Sstevel@tonic-gate static int
ipcid(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5130Sstevel@tonic-gate ipcid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5140Sstevel@tonic-gate {
5150Sstevel@tonic-gate return (ipckeyid(addr, flags, argc, argv, ipcid_impl));
5160Sstevel@tonic-gate }
5170Sstevel@tonic-gate
5180Sstevel@tonic-gate static int
ds_ptr(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv,ipc_ops_vec_t * iv)5190Sstevel@tonic-gate ds_ptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
5200Sstevel@tonic-gate ipc_ops_vec_t *iv)
5210Sstevel@tonic-gate {
5220Sstevel@tonic-gate uint_t kflag = FALSE;
5230Sstevel@tonic-gate uintptr_t svcptr, raddr;
5240Sstevel@tonic-gate int result;
5250Sstevel@tonic-gate
5260Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC))
5270Sstevel@tonic-gate return (DCMD_USAGE);
5280Sstevel@tonic-gate
5290Sstevel@tonic-gate if (mdb_getopts(argc, argv,
5300Sstevel@tonic-gate 'k', MDB_OPT_SETBITS, TRUE, &kflag, NULL) != argc)
5310Sstevel@tonic-gate return (DCMD_USAGE);
5320Sstevel@tonic-gate
5330Sstevel@tonic-gate if (mdb_readvar(&svcptr, iv->iv_service) == -1) {
5340Sstevel@tonic-gate mdb_warn("failed to read '%s'; module not present\n",
5350Sstevel@tonic-gate iv->iv_service);
5360Sstevel@tonic-gate return (DCMD_ERR);
5370Sstevel@tonic-gate }
5380Sstevel@tonic-gate
5390Sstevel@tonic-gate result = kflag ? ipckey_impl(svcptr, addr, &raddr) :
5400Sstevel@tonic-gate ipcid_impl(svcptr, addr, &raddr);
5410Sstevel@tonic-gate
5420Sstevel@tonic-gate if (result == DCMD_OK)
5430Sstevel@tonic-gate mdb_printf("%lx", raddr);
5440Sstevel@tonic-gate
5450Sstevel@tonic-gate return (result);
5460Sstevel@tonic-gate }
5470Sstevel@tonic-gate
5480Sstevel@tonic-gate /*
5490Sstevel@tonic-gate * Stubs to call ds_ptr with the appropriate ops vector
5500Sstevel@tonic-gate */
5510Sstevel@tonic-gate static int
id2shm(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5520Sstevel@tonic-gate id2shm(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5530Sstevel@tonic-gate {
5540Sstevel@tonic-gate return (ds_ptr(addr, flags, argc, argv, &shm_ops_vec));
5550Sstevel@tonic-gate }
5560Sstevel@tonic-gate
5570Sstevel@tonic-gate static int
id2msq(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5580Sstevel@tonic-gate id2msq(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5590Sstevel@tonic-gate {
5600Sstevel@tonic-gate return (ds_ptr(addr, flags, argc, argv, &msq_ops_vec));
5610Sstevel@tonic-gate }
5620Sstevel@tonic-gate
5630Sstevel@tonic-gate static int
id2sem(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5640Sstevel@tonic-gate id2sem(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5650Sstevel@tonic-gate {
5660Sstevel@tonic-gate return (ds_ptr(addr, flags, argc, argv, &sem_ops_vec));
5670Sstevel@tonic-gate }
5680Sstevel@tonic-gate
5690Sstevel@tonic-gate
5700Sstevel@tonic-gate /*
5710Sstevel@tonic-gate * The message queue contents walker
5720Sstevel@tonic-gate */
5730Sstevel@tonic-gate
5740Sstevel@tonic-gate static int
msg_walk_init(mdb_walk_state_t * wsp)5750Sstevel@tonic-gate msg_walk_init(mdb_walk_state_t *wsp)
5760Sstevel@tonic-gate {
5770Sstevel@tonic-gate wsp->walk_addr += OFFSETOF(kmsqid_t, msg_list);
5780Sstevel@tonic-gate if (mdb_layered_walk("list", wsp) == -1)
5790Sstevel@tonic-gate return (WALK_ERR);
5800Sstevel@tonic-gate
5810Sstevel@tonic-gate return (WALK_NEXT);
5820Sstevel@tonic-gate }
5830Sstevel@tonic-gate
5840Sstevel@tonic-gate static int
msg_walk_step(mdb_walk_state_t * wsp)5850Sstevel@tonic-gate msg_walk_step(mdb_walk_state_t *wsp)
5860Sstevel@tonic-gate {
5870Sstevel@tonic-gate return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
5880Sstevel@tonic-gate wsp->walk_cbdata));
5890Sstevel@tonic-gate }
5900Sstevel@tonic-gate
5910Sstevel@tonic-gate /*
5920Sstevel@tonic-gate * The "::ipcs" command itself. Just walks each IPC type in turn.
5930Sstevel@tonic-gate */
5940Sstevel@tonic-gate
5950Sstevel@tonic-gate /*ARGSUSED*/
5960Sstevel@tonic-gate static int
ipcs(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5970Sstevel@tonic-gate ipcs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5980Sstevel@tonic-gate {
5990Sstevel@tonic-gate uint_t oflags = 0;
6000Sstevel@tonic-gate
6010Sstevel@tonic-gate if ((flags & DCMD_ADDRSPEC) || mdb_getopts(argc, argv, 'l',
6020Sstevel@tonic-gate MDB_OPT_SETBITS, 1, &oflags, NULL) != argc)
6030Sstevel@tonic-gate return (DCMD_USAGE);
6040Sstevel@tonic-gate
6050Sstevel@tonic-gate mdb_printf("Message queues:\n");
6060Sstevel@tonic-gate if (mdb_walk_dcmd("msq", oflags ? "kmsqid" : "ipcperm", argc, argv) ==
6070Sstevel@tonic-gate -1) {
6080Sstevel@tonic-gate mdb_warn("can't walk 'msq'");
6090Sstevel@tonic-gate return (DCMD_ERR);
6100Sstevel@tonic-gate }
6110Sstevel@tonic-gate
6120Sstevel@tonic-gate mdb_printf("\nShared memory:\n");
6130Sstevel@tonic-gate if (mdb_walk_dcmd("shm", oflags ? "kshmid" : "ipcperm", argc, argv) ==
6140Sstevel@tonic-gate -1) {
6150Sstevel@tonic-gate mdb_warn("can't walk 'shm'");
6160Sstevel@tonic-gate return (DCMD_ERR);
6170Sstevel@tonic-gate }
6180Sstevel@tonic-gate
6190Sstevel@tonic-gate mdb_printf("\nSemaphores:\n");
6200Sstevel@tonic-gate if (mdb_walk_dcmd("sem", oflags ? "ksemid" : "ipcperm", argc, argv) ==
6210Sstevel@tonic-gate -1) {
6220Sstevel@tonic-gate mdb_warn("can't walk 'sem'");
6230Sstevel@tonic-gate return (DCMD_ERR);
6240Sstevel@tonic-gate }
6250Sstevel@tonic-gate
6260Sstevel@tonic-gate return (DCMD_OK);
6270Sstevel@tonic-gate }
6280Sstevel@tonic-gate
6290Sstevel@tonic-gate static int
msgprint(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)6300Sstevel@tonic-gate msgprint(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
6310Sstevel@tonic-gate {
6320Sstevel@tonic-gate struct msg message;
6330Sstevel@tonic-gate uint_t lflag = FALSE;
6340Sstevel@tonic-gate long type = 0;
6350Sstevel@tonic-gate char *tflag = NULL;
6360Sstevel@tonic-gate
6370Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC) || (mdb_getopts(argc, argv,
6380Sstevel@tonic-gate 'l', MDB_OPT_SETBITS, TRUE, &lflag,
6390Sstevel@tonic-gate 't', MDB_OPT_STR, &tflag, NULL) != argc))
6400Sstevel@tonic-gate return (DCMD_USAGE);
6410Sstevel@tonic-gate
6420Sstevel@tonic-gate /*
6430Sstevel@tonic-gate * Handle negative values.
6440Sstevel@tonic-gate */
6450Sstevel@tonic-gate if (tflag != NULL) {
6460Sstevel@tonic-gate if (*tflag == '-') {
6470Sstevel@tonic-gate tflag++;
6480Sstevel@tonic-gate type = -1;
6490Sstevel@tonic-gate } else {
6500Sstevel@tonic-gate type = 1;
6510Sstevel@tonic-gate }
6520Sstevel@tonic-gate type *= mdb_strtoull(tflag);
6530Sstevel@tonic-gate }
6540Sstevel@tonic-gate
6550Sstevel@tonic-gate if (DCMD_HDRSPEC(flags))
6560Sstevel@tonic-gate mdb_printf("%<u>%?s %?s %8s %8s %8s%</u>\n",
6570Sstevel@tonic-gate "ADDR", "TEXT", "SIZE", "TYPE", "REF");
6580Sstevel@tonic-gate
6590Sstevel@tonic-gate if (mdb_vread(&message, sizeof (struct msg), addr) == -1) {
6600Sstevel@tonic-gate mdb_warn("failed to read msg at %#lx", addr);
6610Sstevel@tonic-gate return (DCMD_ERR);
6620Sstevel@tonic-gate }
6630Sstevel@tonic-gate
6640Sstevel@tonic-gate /*
6650Sstevel@tonic-gate * If we are meeting our type contraints, display the message.
6660Sstevel@tonic-gate * If -l was specified, we will also display the message
6670Sstevel@tonic-gate * contents.
6680Sstevel@tonic-gate */
6690Sstevel@tonic-gate if ((type == 0) ||
6700Sstevel@tonic-gate (type > 0 && message.msg_type == type) ||
6710Sstevel@tonic-gate (type < 0 && message.msg_type <= -type)) {
6720Sstevel@tonic-gate
6730Sstevel@tonic-gate if (lflag && !DCMD_HDRSPEC(flags))
6740Sstevel@tonic-gate mdb_printf("\n");
6750Sstevel@tonic-gate
6760Sstevel@tonic-gate mdb_printf("%0?lx %?p %8ld %8ld %8ld\n", addr, message.msg_addr,
6770Sstevel@tonic-gate message.msg_size, message.msg_type, message.msg_copycnt);
6780Sstevel@tonic-gate
6790Sstevel@tonic-gate if (lflag) {
6800Sstevel@tonic-gate mdb_printf("\n");
6810Sstevel@tonic-gate mdb_inc_indent(CMN_INDENT);
6820Sstevel@tonic-gate if (mdb_dumpptr(
6830Sstevel@tonic-gate (uintptr_t)message.msg_addr, message.msg_size,
6840Sstevel@tonic-gate MDB_DUMP_RELATIVE | MDB_DUMP_TRIM |
6850Sstevel@tonic-gate MDB_DUMP_ASCII | MDB_DUMP_HEADER |
6860Sstevel@tonic-gate MDB_DUMP_GROUP(4),
6870Sstevel@tonic-gate (mdb_dumpptr_cb_t)mdb_vread, NULL)) {
6880Sstevel@tonic-gate mdb_dec_indent(CMN_INDENT);
6890Sstevel@tonic-gate return (DCMD_ERR);
6900Sstevel@tonic-gate }
6910Sstevel@tonic-gate mdb_dec_indent(CMN_INDENT);
6920Sstevel@tonic-gate }
6930Sstevel@tonic-gate }
6940Sstevel@tonic-gate
6950Sstevel@tonic-gate return (DCMD_OK);
6960Sstevel@tonic-gate }
6970Sstevel@tonic-gate
6980Sstevel@tonic-gate /*
6990Sstevel@tonic-gate * MDB module linkage
7000Sstevel@tonic-gate */
7010Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = {
7020Sstevel@tonic-gate /* Generic routines */
7030Sstevel@tonic-gate { "ipcperm", ":", "display an IPC perm structure", ipcperm },
7040Sstevel@tonic-gate { "ipcid", ":id", "perform an IPC id lookup", ipcid },
7050Sstevel@tonic-gate { "ipckey", ":key", "perform an IPC key lookup", ipckey },
7060Sstevel@tonic-gate
7070Sstevel@tonic-gate /* Specific routines */
7080Sstevel@tonic-gate { "kshmid", "?[-l]", "display a struct kshmid", cmd_kshmid },
7090Sstevel@tonic-gate { "kmsqid", "?[-l]", "display a struct kmsqid", cmd_kmsqid },
7100Sstevel@tonic-gate { "ksemid", "?[-l]", "display a struct ksemid", cmd_ksemid },
7110Sstevel@tonic-gate { "msg", ":[-l] [-t type]", "display contents of a message", msgprint },
7120Sstevel@tonic-gate
7130Sstevel@tonic-gate /* Convenience routines */
7140Sstevel@tonic-gate { "id2shm", ":[-k]", "convert shared memory ID to pointer", id2shm },
7150Sstevel@tonic-gate { "id2msq", ":[-k]", "convert message queue ID to pointer", id2msq },
7160Sstevel@tonic-gate { "id2sem", ":[-k]", "convert semaphore ID to pointer", id2sem },
7170Sstevel@tonic-gate
7180Sstevel@tonic-gate { "ipcs", "[-l]", "display System V IPC information", ipcs },
7190Sstevel@tonic-gate { NULL }
7200Sstevel@tonic-gate };
7210Sstevel@tonic-gate
7220Sstevel@tonic-gate static const mdb_walker_t walkers[] = {
7230Sstevel@tonic-gate { "ipcsvc", "walk a System V IPC service",
7240Sstevel@tonic-gate ds_walk_init, ds_walk_step },
7250Sstevel@tonic-gate { "shm", "walk the active shmid_ds structures",
7260Sstevel@tonic-gate ds_walk_init, ds_walk_step, NULL, &shm_ops_vec },
7270Sstevel@tonic-gate { "msq", "walk the active msqid_ds structures",
7280Sstevel@tonic-gate ds_walk_init, ds_walk_step, NULL, &msq_ops_vec },
7290Sstevel@tonic-gate { "sem", "walk the active semid_ds structures",
7300Sstevel@tonic-gate ds_walk_init, ds_walk_step, NULL, &sem_ops_vec },
7310Sstevel@tonic-gate { "msgqueue", "walk messages on a message queue",
7320Sstevel@tonic-gate msg_walk_init, msg_walk_step },
7330Sstevel@tonic-gate { NULL }
7340Sstevel@tonic-gate };
7350Sstevel@tonic-gate
7360Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
7370Sstevel@tonic-gate
7380Sstevel@tonic-gate const mdb_modinfo_t *
_mdb_init(void)7390Sstevel@tonic-gate _mdb_init(void)
7400Sstevel@tonic-gate {
7410Sstevel@tonic-gate return (&modinfo);
7420Sstevel@tonic-gate }
743