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
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.
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]
23 * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/mdb_modapi.h>
30 #include <sys/sysinfo.h>
33 * simple_echo dcmd - Demonstrate some simple argument processing by iterating
34 * through the argument array and printing back each argument.
37 simple_echo(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
39 if (flags
& DCMD_ADDRSPEC
)
40 mdb_printf("You specified address %p\n", addr
);
42 mdb_printf("Current address is %p\n", addr
);
45 if (argv
->a_type
== MDB_TYPE_STRING
)
46 mdb_printf("%s ", argv
->a_un
.a_str
);
48 mdb_printf("%llr ", argv
->a_un
.a_val
);
57 * vminfo dcmd - Print out the global vminfo structure, nicely formatted.
58 * This function illustrates one of the functions for reading data from
59 * the target program (or core file): mdb_readvar(). The vminfo_t
60 * structure contains cumulative counters for various system virtual
61 * memory statistics. Each second, these are incremented by the current
62 * values of freemem and the other corresponding statistical counters.
66 vminfo(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
70 if ((flags
& DCMD_ADDRSPEC
) || argc
!= 0)
73 if (mdb_readvar(&vm
, "vminfo") == -1) {
75 * If the mdb_warn string does not end in a \n, mdb will
76 * automatically append the reason for the failure.
78 mdb_warn("failed to read vminfo structure");
82 mdb_printf("Cumulative memory statistics:\n");
83 mdb_printf("%8llu pages of free memory\n", vm
.freemem
);
84 mdb_printf("%8llu pages of reserved swap\n", vm
.swap_resv
);
85 mdb_printf("%8llu pages of allocated swap\n", vm
.swap_alloc
);
86 mdb_printf("%8llu pages of unreserved swap\n", vm
.swap_avail
);
87 mdb_printf("%8llu pages of unallocated swap\n", vm
.swap_free
);
93 * MDB module linkage information:
95 * We declare a list of structures describing our dcmds, and a function
96 * named _mdb_init to return a pointer to our module information.
99 static const mdb_dcmd_t dcmds
[] = {
100 { "simple_echo", "[ args ... ]", "echo back arguments", simple_echo
},
101 { "vminfo", NULL
, "print vm information", vminfo
},
105 static const mdb_modinfo_t modinfo
= {
106 MDB_API_VERSION
, dcmds
, NULL
109 const mdb_modinfo_t
*