3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2017 Joyent, Inc.
24 */
25
26 /*
27 * Mdb kernel support module. This module is loaded automatically when the
28 * kvm target is initialized. Any global functions declared here are exported
29 * for the resolution of symbols in subsequently loaded modules.
30 *
31 * WARNING: Do not assume that static variables in mdb_ks will be initialized
32 * to zero.
33 */
34
35 #include <mdb/mdb_target.h>
36 #include <mdb/mdb_param.h>
37 #include <mdb/mdb_modapi.h>
38 #include <mdb/mdb_ks.h>
39
40 #include <sys/types.h>
41 #include <sys/procfs.h>
42 #include <sys/proc.h>
43 #include <sys/dnlc.h>
1792 */
1793 if ((ts = mdb_gethrtime()) <= 0)
1794 return (0);
1795
1796 /*
1797 * Load the time spent in kmdb, if any.
1798 */
1799 if (mdb_readvar(&ptr, "lb_info") == -1)
1800 return (0);
1801
1802 if (mdb_vread(&lbi, sizeof (lbolt_info_t), ptr) !=
1803 sizeof (lbolt_info_t))
1804 return (0);
1805
1806 if (mdb_readvar(&nsec, "nsec_per_tick") == -1 || nsec == 0) {
1807 mdb_warn("failed to read 'nsec_per_tick'");
1808 return (-1);
1809 }
1810
1811 return ((ts/nsec) - lbi.lbi_debug_time);
1812 }
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2019 Joyent, Inc.
24 */
25
26 /*
27 * Mdb kernel support module. This module is loaded automatically when the
28 * kvm target is initialized. Any global functions declared here are exported
29 * for the resolution of symbols in subsequently loaded modules.
30 *
31 * WARNING: Do not assume that static variables in mdb_ks will be initialized
32 * to zero.
33 */
34
35 #include <mdb/mdb_target.h>
36 #include <mdb/mdb_param.h>
37 #include <mdb/mdb_modapi.h>
38 #include <mdb/mdb_ks.h>
39
40 #include <sys/types.h>
41 #include <sys/procfs.h>
42 #include <sys/proc.h>
43 #include <sys/dnlc.h>
1792 */
1793 if ((ts = mdb_gethrtime()) <= 0)
1794 return (0);
1795
1796 /*
1797 * Load the time spent in kmdb, if any.
1798 */
1799 if (mdb_readvar(&ptr, "lb_info") == -1)
1800 return (0);
1801
1802 if (mdb_vread(&lbi, sizeof (lbolt_info_t), ptr) !=
1803 sizeof (lbolt_info_t))
1804 return (0);
1805
1806 if (mdb_readvar(&nsec, "nsec_per_tick") == -1 || nsec == 0) {
1807 mdb_warn("failed to read 'nsec_per_tick'");
1808 return (-1);
1809 }
1810
1811 return ((ts/nsec) - lbi.lbi_debug_time);
1812 }
1813
1814 void
1815 mdb_print_buildversion(void)
1816 {
1817 GElf_Sym sym;
1818
1819 if (mdb_lookup_by_name("buildversion", &sym) != 0)
1820 return;
1821
1822 char *str = mdb_zalloc(4096, UM_SLEEP | UM_GC);
1823
1824 if (mdb_readstr(str, 4096, sym.st_value) < 1)
1825 return;
1826
1827 mdb_printf("build version: %s\n", str);
1828 }
|