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 2003 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 #include <sys/logindmux_impl.h> 32 33 /* 34 * Print our peer's upper queue pointer, and our lower queue pointer. 35 */ 36 void 37 logdmux_uqinfo(const queue_t *q, char *buf, size_t nbytes) 38 { 39 struct tmx tmx; 40 uintptr_t peer, lower; 41 queue_t lq; 42 43 /* 44 * First, get the pointer to our lower write queue. 45 */ 46 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr); 47 lower = (uintptr_t)tmx.muxq; 48 49 /* 50 * Now read in the lower's peer, and follow that to up to our peer. 51 */ 52 (void) mdb_vread(&lq, sizeof (lq), (uintptr_t)tmx.peerq); 53 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)lq.q_ptr); 54 peer = (uintptr_t)tmx.rdq; 55 56 (void) mdb_snprintf(buf, nbytes, "peer rq : %p\nlower wq : %p", 57 peer, lower); 58 } 59 60 /* 61 * Print our peer's lower queue pointer, and our upper queue pointer. 62 */ 63 void 64 logdmux_lqinfo(const queue_t *q, char *buf, size_t nbytes) 65 { 66 struct tmx tmx; 67 68 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr); 69 (void) mdb_snprintf(buf, nbytes, "peer wq : %p\nupper rq : %p", 70 (uintptr_t)tmx.peerq, (uintptr_t)tmx.rdq); 71 } 72 73 uintptr_t 74 logdmux_lrnext(const queue_t *q) 75 { 76 struct tmx tmx; 77 78 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr); 79 return ((uintptr_t)tmx.rdq); 80 } 81 82 uintptr_t 83 logdmux_uwnext(const queue_t *q) 84 { 85 struct tmx tmx; 86 87 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr); 88 return ((uintptr_t)tmx.muxq); 89 } 90 91 static const mdb_qops_t logdmux_uqops = { 92 logdmux_uqinfo, mdb_qrnext_default, logdmux_uwnext 93 }; 94 95 static const mdb_qops_t logdmux_lqops = { 96 logdmux_lqinfo, logdmux_lrnext, mdb_qwnext_default 97 }; 98 99 static const mdb_modinfo_t modinfo = { MDB_API_VERSION }; 100 101 const mdb_modinfo_t * 102 _mdb_init(void) 103 { 104 GElf_Sym sym; 105 106 if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0) 107 mdb_qops_install(&logdmux_uqops, (uintptr_t)sym.st_value); 108 if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0) 109 mdb_qops_install(&logdmux_lqops, (uintptr_t)sym.st_value); 110 111 return (&modinfo); 112 } 113 114 void 115 _mdb_fini(void) 116 { 117 GElf_Sym sym; 118 119 if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0) 120 mdb_qops_remove(&logdmux_uqops, (uintptr_t)sym.st_value); 121 if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0) 122 mdb_qops_remove(&logdmux_lqops, (uintptr_t)sym.st_value); 123 } 124