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