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.
   7  *
   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.
  12  *
  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]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #include <mdb/mdb_modapi.h>
  27 #include <mdb/mdb_ks.h>
  28 
  29 #include <sys/types.h>
  30 #include <sys/mman.h>
  31 #include <sys/project.h>
  32 #include <sys/ipc_impl.h>
  33 #include <sys/shm_impl.h>
  34 #include <sys/sem_impl.h>
  35 #include <sys/msg_impl.h>
  36 
  37 #include <vm/anon.h>
  38 
  39 #define CMN_HDR_START   "%<u>"
  40 #define CMN_HDR_END     "%</u>\n"
  41 #define CMN_INDENT      (4)
  42 #define CMN_INACTIVE    "%s facility inactive.\n"
  43 
 
 
 212 /*ARGSUSED1*/
 213 static void
 214 shm_print(kshmid_t *shmid, uintptr_t addr)
 215 {
 216         shmatt_t nattch;
 217 
 218         nattch = shmid->shm_perm.ipc_ref - (IPC_FREE(&shmid->shm_perm) ? 0 : 1);
 219 
 220         mdb_printf(CMN_HDR_START "%10s %?s %5s %7s %7s %7s %7s" CMN_HDR_END,
 221             "SEGSZ", "AMP", "LKCNT", "LPID", "CPID", "NATTCH", "CNATTCH");
 222         mdb_printf("%10#lx %?p %5u %7d %7d %7lu %7lu\n",
 223             shmid->shm_segsz, shmid->shm_amp, shmid->shm_lkcnt,
 224             (int)shmid->shm_lpid, (int)shmid->shm_cpid, nattch,
 225             shmid->shm_ismattch);
 226 
 227         printtime_nice("atime: ", shmid->shm_atime);
 228         printtime_nice("dtime: ", shmid->shm_dtime);
 229         printtime_nice("ctime: ", shmid->shm_ctime);
 230         mdb_printf("sptinfo: %-?p    sptseg: %-?p\n",
 231             shmid->shm_sptinfo, shmid->shm_sptseg);
 232         mdb_printf("sptprot: <%lb>\n", shmid->shm_sptprot, prot_flag_bits);
 233 }
 234 
 235 
 236 /*ARGSUSED1*/
 237 static void
 238 sem_print(ksemid_t *semid, uintptr_t addr)
 239 {
 240         mdb_printf("base: %-?p    nsems: 0t%u\n",
 241             semid->sem_base, semid->sem_nsems);
 242         printtime_nice("otime: ", semid->sem_otime);
 243         printtime_nice("ctime: ", semid->sem_ctime);
 244         mdb_printf("binary: %s\n", semid->sem_binary ? "yes" : "no");
 245 }
 246 
 247 typedef struct ipc_ops_vec {
 248         char    *iv_wcmd;       /* walker name          */
 249         char    *iv_ocmd;       /* output dcmd          */
 250         char    *iv_service;    /* service pointer      */
 251         void    (*iv_print)(void *, uintptr_t); /* output callback */
 252         size_t  iv_idsize;
 
 | 
 
 
   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.
   7  *
   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.
  12  *
  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]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2016 Joyent, Inc.
  25  */
  26 
  27 #include <mdb/mdb_modapi.h>
  28 #include <mdb/mdb_ks.h>
  29 
  30 #include <sys/types.h>
  31 #include <sys/mman.h>
  32 #include <sys/project.h>
  33 #include <sys/ipc_impl.h>
  34 #include <sys/shm_impl.h>
  35 #include <sys/sem_impl.h>
  36 #include <sys/msg_impl.h>
  37 
  38 #include <vm/anon.h>
  39 
  40 #define CMN_HDR_START   "%<u>"
  41 #define CMN_HDR_END     "%</u>\n"
  42 #define CMN_INDENT      (4)
  43 #define CMN_INACTIVE    "%s facility inactive.\n"
  44 
 
 
 213 /*ARGSUSED1*/
 214 static void
 215 shm_print(kshmid_t *shmid, uintptr_t addr)
 216 {
 217         shmatt_t nattch;
 218 
 219         nattch = shmid->shm_perm.ipc_ref - (IPC_FREE(&shmid->shm_perm) ? 0 : 1);
 220 
 221         mdb_printf(CMN_HDR_START "%10s %?s %5s %7s %7s %7s %7s" CMN_HDR_END,
 222             "SEGSZ", "AMP", "LKCNT", "LPID", "CPID", "NATTCH", "CNATTCH");
 223         mdb_printf("%10#lx %?p %5u %7d %7d %7lu %7lu\n",
 224             shmid->shm_segsz, shmid->shm_amp, shmid->shm_lkcnt,
 225             (int)shmid->shm_lpid, (int)shmid->shm_cpid, nattch,
 226             shmid->shm_ismattch);
 227 
 228         printtime_nice("atime: ", shmid->shm_atime);
 229         printtime_nice("dtime: ", shmid->shm_dtime);
 230         printtime_nice("ctime: ", shmid->shm_ctime);
 231         mdb_printf("sptinfo: %-?p    sptseg: %-?p\n",
 232             shmid->shm_sptinfo, shmid->shm_sptseg);
 233         mdb_printf("opts: rmpend: %d prot: <%b>\n",
 234             ((shmid->shm_opts & SHM_RM_PENDING) != 0),
 235             (shmid->shm_opts & SHM_PROT_MASK), prot_flag_bits);
 236 }
 237 
 238 
 239 /*ARGSUSED1*/
 240 static void
 241 sem_print(ksemid_t *semid, uintptr_t addr)
 242 {
 243         mdb_printf("base: %-?p    nsems: 0t%u\n",
 244             semid->sem_base, semid->sem_nsems);
 245         printtime_nice("otime: ", semid->sem_otime);
 246         printtime_nice("ctime: ", semid->sem_ctime);
 247         mdb_printf("binary: %s\n", semid->sem_binary ? "yes" : "no");
 248 }
 249 
 250 typedef struct ipc_ops_vec {
 251         char    *iv_wcmd;       /* walker name          */
 252         char    *iv_ocmd;       /* output dcmd          */
 253         char    *iv_service;    /* service pointer      */
 254         void    (*iv_print)(void *, uintptr_t); /* output callback */
 255         size_t  iv_idsize;
 
 |