xref: /titanic_53/usr/src/cmd/mdb/common/modules/logindmux/logindmux.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #include <mdb/mdb_modapi.h>
30*7c478bd9Sstevel@tonic-gate #include <mdb/mdb_ks.h>
31*7c478bd9Sstevel@tonic-gate #include <sys/logindmux_impl.h>
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate /*
34*7c478bd9Sstevel@tonic-gate  * Print our peer's upper queue pointer, and our lower queue pointer.
35*7c478bd9Sstevel@tonic-gate  */
36*7c478bd9Sstevel@tonic-gate void
logdmux_uqinfo(const queue_t * q,char * buf,size_t nbytes)37*7c478bd9Sstevel@tonic-gate logdmux_uqinfo(const queue_t *q, char *buf, size_t nbytes)
38*7c478bd9Sstevel@tonic-gate {
39*7c478bd9Sstevel@tonic-gate 	struct tmx tmx;
40*7c478bd9Sstevel@tonic-gate 	uintptr_t peer, lower;
41*7c478bd9Sstevel@tonic-gate 	queue_t lq;
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate 	/*
44*7c478bd9Sstevel@tonic-gate 	 * First, get the pointer to our lower write queue.
45*7c478bd9Sstevel@tonic-gate 	 */
46*7c478bd9Sstevel@tonic-gate 	(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
47*7c478bd9Sstevel@tonic-gate 	lower = (uintptr_t)tmx.muxq;
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate 	/*
50*7c478bd9Sstevel@tonic-gate 	 * Now read in the lower's peer, and follow that to up to our peer.
51*7c478bd9Sstevel@tonic-gate 	 */
52*7c478bd9Sstevel@tonic-gate 	(void) mdb_vread(&lq, sizeof (lq), (uintptr_t)tmx.peerq);
53*7c478bd9Sstevel@tonic-gate 	(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)lq.q_ptr);
54*7c478bd9Sstevel@tonic-gate 	peer = (uintptr_t)tmx.rdq;
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate 	(void) mdb_snprintf(buf, nbytes, "peer rq    : %p\nlower wq   : %p",
57*7c478bd9Sstevel@tonic-gate 	    peer, lower);
58*7c478bd9Sstevel@tonic-gate }
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /*
61*7c478bd9Sstevel@tonic-gate  * Print our peer's lower queue pointer, and our upper queue pointer.
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate void
logdmux_lqinfo(const queue_t * q,char * buf,size_t nbytes)64*7c478bd9Sstevel@tonic-gate logdmux_lqinfo(const queue_t *q, char *buf, size_t nbytes)
65*7c478bd9Sstevel@tonic-gate {
66*7c478bd9Sstevel@tonic-gate 	struct tmx tmx;
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate 	(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
69*7c478bd9Sstevel@tonic-gate 	(void) mdb_snprintf(buf, nbytes, "peer wq    : %p\nupper rq   : %p",
70*7c478bd9Sstevel@tonic-gate 	    (uintptr_t)tmx.peerq, (uintptr_t)tmx.rdq);
71*7c478bd9Sstevel@tonic-gate }
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate uintptr_t
logdmux_lrnext(const queue_t * q)74*7c478bd9Sstevel@tonic-gate logdmux_lrnext(const queue_t *q)
75*7c478bd9Sstevel@tonic-gate {
76*7c478bd9Sstevel@tonic-gate 	struct tmx tmx;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate 	(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
79*7c478bd9Sstevel@tonic-gate 	return ((uintptr_t)tmx.rdq);
80*7c478bd9Sstevel@tonic-gate }
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate uintptr_t
logdmux_uwnext(const queue_t * q)83*7c478bd9Sstevel@tonic-gate logdmux_uwnext(const queue_t *q)
84*7c478bd9Sstevel@tonic-gate {
85*7c478bd9Sstevel@tonic-gate 	struct tmx tmx;
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate 	(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
88*7c478bd9Sstevel@tonic-gate 	return ((uintptr_t)tmx.muxq);
89*7c478bd9Sstevel@tonic-gate }
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate static const mdb_qops_t logdmux_uqops = {
92*7c478bd9Sstevel@tonic-gate 	logdmux_uqinfo, mdb_qrnext_default, logdmux_uwnext
93*7c478bd9Sstevel@tonic-gate };
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate static const mdb_qops_t logdmux_lqops = {
96*7c478bd9Sstevel@tonic-gate 	logdmux_lqinfo, logdmux_lrnext, mdb_qwnext_default
97*7c478bd9Sstevel@tonic-gate };
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION };
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate const mdb_modinfo_t *
_mdb_init(void)102*7c478bd9Sstevel@tonic-gate _mdb_init(void)
103*7c478bd9Sstevel@tonic-gate {
104*7c478bd9Sstevel@tonic-gate 	GElf_Sym sym;
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 	if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0)
107*7c478bd9Sstevel@tonic-gate 		mdb_qops_install(&logdmux_uqops, (uintptr_t)sym.st_value);
108*7c478bd9Sstevel@tonic-gate 	if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0)
109*7c478bd9Sstevel@tonic-gate 		mdb_qops_install(&logdmux_lqops, (uintptr_t)sym.st_value);
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate 	return (&modinfo);
112*7c478bd9Sstevel@tonic-gate }
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate void
_mdb_fini(void)115*7c478bd9Sstevel@tonic-gate _mdb_fini(void)
116*7c478bd9Sstevel@tonic-gate {
117*7c478bd9Sstevel@tonic-gate 	GElf_Sym sym;
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate 	if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0)
120*7c478bd9Sstevel@tonic-gate 		mdb_qops_remove(&logdmux_uqops, (uintptr_t)sym.st_value);
121*7c478bd9Sstevel@tonic-gate 	if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0)
122*7c478bd9Sstevel@tonic-gate 		mdb_qops_remove(&logdmux_lqops, (uintptr_t)sym.st_value);
123*7c478bd9Sstevel@tonic-gate }
124