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 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _MDB_NV_H
28 #define _MDB_NV_H
29
30 #pragma ident "%Z%%M% %I% %E% SMI"
31
32 #include <sys/types.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #ifdef _MDB
39
40 #define MDB_NV_NAMELEN 31 /* Max variable name length including null */
41
42 /*
43 * These flags are stored inside each variable in v_flags:
44 */
45 #define MDB_NV_PERSIST 0x01 /* Variable is persistent (cannot be unset) */
46 #define MDB_NV_RDONLY 0x02 /* Variable is read-only (cannot insert over) */
47 #define MDB_NV_EXTNAME 0x04 /* Variable name is stored externally */
48 #define MDB_NV_TAGGED 0x08 /* Variable is tagged (user-defined) */
49 #define MDB_NV_OVERLOAD 0x10 /* Variable can be overloaded (multiple defs) */
50
51 /*
52 * These flags may be passed to mdb_nv_insert() but are not stored
53 * inside the variable (and thus use bits outside of 0x00 - 0xff):
54 */
55 #define MDB_NV_SILENT 0x100 /* Silence warnings about existing defs */
56 #define MDB_NV_INTERPOS 0x200 /* Interpose definition over previous defs */
57
58 struct mdb_var; /* Forward declaration */
59 struct mdb_walk_state; /* Forward declaration */
60
61 /*
62 * Each variable's behavior with respect to the get-value and set-value
63 * operations can be changed using a discipline: a pointer to an ops
64 * vector which can re-define these operations:
65 */
66 typedef struct mdb_nv_disc {
67 void (*disc_set)(struct mdb_var *, uintmax_t);
68 uintmax_t (*disc_get)(const struct mdb_var *);
69 } mdb_nv_disc_t;
70
71 /*
72 * Each variable is defined by the following variable-length structure.
73 * The debugger uses name/value collections to hash almost everything, so
74 * we make a few simple space optimizations:
75 *
76 * A variable's name can be a pointer to external storage (v_ename and
77 * MDB_NV_EXTNAME set), or it can be stored locally (MDB_NV_NAMELEN - 1
78 * bytes of storage are allocated immediately after v_lname[0]).
79 *
80 * A variable may have multiple definitions (v_ndef chain), but this feature
81 * is mutually exclusive with MDB_NV_EXTNAME in order to save space.
82 */
83 typedef struct mdb_var {
84 uintmax_t v_uvalue; /* Value as unsigned integral type */
85 union {
86 const char *v_ename; /* Variable name if stored externally */
87 struct mdb_var *v_ndef; /* Variable's next definition */
88 } v_du;
89 const mdb_nv_disc_t *v_disc; /* Link to variable discipline */
90 struct mdb_var *v_next; /* Link to next var in hash chain */
91 uchar_t v_flags; /* Variable flags (see above) */
92 char v_lname[1]; /* Variable name if stored locally */
93 } mdb_var_t;
94
95 #define MDB_NV_VALUE(v) ((v)->v_uvalue)
96 #define MDB_NV_COOKIE(v) ((void *)(uintptr_t)((v)->v_uvalue))
97
98 #define v_ename v_du.v_ename
|
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 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26 /*
27 * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
28 */
29
30 #ifndef _MDB_NV_H
31 #define _MDB_NV_H
32
33 #include <sys/types.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #ifdef _MDB
40
41 /*
42 * There used to be a cap (MDB_NV_NAMELEN bytes including null) on the
43 * length of variable names stored in-line. This cap is no longer there,
44 * however parts of mdb use the constant to sanitize input.
45 */
46 #define MDB_NV_NAMELEN 31 /* Max variable name length including null */
47
48 /*
49 * These flags are stored inside each variable in v_flags:
50 */
51 #define MDB_NV_PERSIST 0x01 /* Variable is persistent (cannot be unset) */
52 #define MDB_NV_RDONLY 0x02 /* Variable is read-only (cannot insert over) */
53 #define MDB_NV_EXTNAME 0x04 /* Variable name is stored externally */
54 #define MDB_NV_TAGGED 0x08 /* Variable is tagged (user-defined) */
55 #define MDB_NV_OVERLOAD 0x10 /* Variable can be overloaded (multiple defs) */
56
57 /*
58 * These flags may be passed to mdb_nv_insert() but are not stored
59 * inside the variable (and thus use bits outside of 0x00 - 0xff):
60 */
61 #define MDB_NV_SILENT 0x100 /* Silence warnings about existing defs */
62 #define MDB_NV_INTERPOS 0x200 /* Interpose definition over previous defs */
63
64 struct mdb_var; /* Forward declaration */
65 struct mdb_walk_state; /* Forward declaration */
66
67 /*
68 * Each variable's behavior with respect to the get-value and set-value
69 * operations can be changed using a discipline: a pointer to an ops
70 * vector which can re-define these operations:
71 */
72 typedef struct mdb_nv_disc {
73 void (*disc_set)(struct mdb_var *, uintmax_t);
74 uintmax_t (*disc_get)(const struct mdb_var *);
75 } mdb_nv_disc_t;
76
77 /*
78 * Each variable is defined by the following variable-length structure.
79 * The debugger uses name/value collections to hash almost everything, so
80 * we make a few simple space optimizations:
81 *
82 * A variable's name can be a pointer to external storage (v_ename and
83 * MDB_NV_EXTNAME set), or it can be stored locally (bytes of storage are
84 * allocated immediately after v_lname[0]).
85 *
86 * A variable may have multiple definitions (v_ndef chain), but this feature
87 * is mutually exclusive with MDB_NV_EXTNAME in order to save space.
88 */
89 typedef struct mdb_var {
90 uintmax_t v_uvalue; /* Value as unsigned integral type */
91 union {
92 const char *v_ename; /* Variable name if stored externally */
93 struct mdb_var *v_ndef; /* Variable's next definition */
94 } v_du;
95 const mdb_nv_disc_t *v_disc; /* Link to variable discipline */
96 struct mdb_var *v_next; /* Link to next var in hash chain */
97 uchar_t v_flags; /* Variable flags (see above) */
98 char v_lname[1]; /* Variable name if stored locally */
99 } mdb_var_t;
100
101 #define MDB_NV_VALUE(v) ((v)->v_uvalue)
102 #define MDB_NV_COOKIE(v) ((void *)(uintptr_t)((v)->v_uvalue))
103
104 #define v_ename v_du.v_ename
|