xref: /titanic_41/usr/src/cmd/mdb/common/modules/md/metaset.c (revision 355b4669e025ff377602b6fc7caaf30dbc218371)
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 "mdinclude.h"
30 
31 mddb_set_t set_db;
32 
33 /* print out the correct set */
34 int
35 print_set(uintptr_t addr)
36 {
37 	char		machine[1024];
38 
39 	if (mdb_vread(&set_db, sizeof (mddb_set_t), addr) == -1) {
40 		if (addr != NULL) {
41 			mdb_warn("failed to read mddb_set_t at 0x%p\n", addr);
42 			return (DCMD_ERR);
43 		} else {
44 			return (DCMD_OK);
45 		}
46 	}
47 
48 	if (set_db.s_setname != 0) {
49 		if (mdb_readstr(machine, 1024,
50 			(uintptr_t)set_db.s_setname) == -1) {
51 			mdb_warn("failed to read setname at 0x%p\n",
52 			    set_db.s_setname);
53 		} else {
54 			mdb_printf("Setname: %s Setno: %u\t%p\n",
55 			    machine, set_db.s_setno, addr);
56 		}
57 	} else {
58 		mdb_printf("Setname: NULL Setno: %u\t%p\n",
59 		    set_db.s_setno, addr);
60 	}
61 
62 	mdb_inc_indent(2);
63 	mdb_printf("s_un = %p\n", mdset[set_db.s_setno].s_un);
64 	mdb_printf("s_hsp = %p\n", mdset[set_db.s_setno].s_hsp);
65 	mdb_dec_indent(2);
66 	return (DCMD_OK);
67 }
68 
69 /*
70  * print all sets or the specified set with -s option
71  * usage: ::metaset
72  */
73 /* ARGSUSED */
74 int
75 metaset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
76 {
77 	snarf_sets();
78 
79 	if (!(flags & DCMD_ADDRSPEC)) {
80 		if (mdb_walk_dcmd("md_sets", "metaset", argc,
81 		    argv) == -1) {
82 			mdb_warn("failed to walk sets");
83 			return (DCMD_ERR);
84 		}
85 		return (DCMD_OK);
86 	}
87 	print_set(addr);
88 
89 	return (DCMD_OK);
90 }
91