Print this page
4229 mdb hangs on exit when long umem cache names exist
Reviewed by: Robert Mustacchi <rm@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/common/mdb/mdb_nv.h
+++ new/usr/src/cmd/mdb/common/mdb/mdb_nv.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 +/*
27 + * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
28 + */
26 29
27 30 #ifndef _MDB_NV_H
28 31 #define _MDB_NV_H
29 32
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 33 #include <sys/types.h>
33 34
34 35 #ifdef __cplusplus
35 36 extern "C" {
36 37 #endif
37 38
38 39 #ifdef _MDB
39 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 + */
40 46 #define MDB_NV_NAMELEN 31 /* Max variable name length including null */
41 47
42 48 /*
43 49 * These flags are stored inside each variable in v_flags:
44 50 */
45 51 #define MDB_NV_PERSIST 0x01 /* Variable is persistent (cannot be unset) */
46 52 #define MDB_NV_RDONLY 0x02 /* Variable is read-only (cannot insert over) */
47 53 #define MDB_NV_EXTNAME 0x04 /* Variable name is stored externally */
48 54 #define MDB_NV_TAGGED 0x08 /* Variable is tagged (user-defined) */
49 55 #define MDB_NV_OVERLOAD 0x10 /* Variable can be overloaded (multiple defs) */
50 56
51 57 /*
52 58 * These flags may be passed to mdb_nv_insert() but are not stored
53 59 * inside the variable (and thus use bits outside of 0x00 - 0xff):
54 60 */
55 61 #define MDB_NV_SILENT 0x100 /* Silence warnings about existing defs */
56 62 #define MDB_NV_INTERPOS 0x200 /* Interpose definition over previous defs */
57 63
58 64 struct mdb_var; /* Forward declaration */
59 65 struct mdb_walk_state; /* Forward declaration */
60 66
61 67 /*
62 68 * Each variable's behavior with respect to the get-value and set-value
63 69 * operations can be changed using a discipline: a pointer to an ops
64 70 * vector which can re-define these operations:
65 71 */
66 72 typedef struct mdb_nv_disc {
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
67 73 void (*disc_set)(struct mdb_var *, uintmax_t);
68 74 uintmax_t (*disc_get)(const struct mdb_var *);
69 75 } mdb_nv_disc_t;
70 76
71 77 /*
72 78 * Each variable is defined by the following variable-length structure.
73 79 * The debugger uses name/value collections to hash almost everything, so
74 80 * we make a few simple space optimizations:
75 81 *
76 82 * 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]).
83 + * MDB_NV_EXTNAME set), or it can be stored locally (bytes of storage are
84 + * allocated immediately after v_lname[0]).
79 85 *
80 86 * A variable may have multiple definitions (v_ndef chain), but this feature
81 87 * is mutually exclusive with MDB_NV_EXTNAME in order to save space.
82 88 */
83 89 typedef struct mdb_var {
84 90 uintmax_t v_uvalue; /* Value as unsigned integral type */
85 91 union {
86 92 const char *v_ename; /* Variable name if stored externally */
87 93 struct mdb_var *v_ndef; /* Variable's next definition */
88 94 } v_du;
89 95 const mdb_nv_disc_t *v_disc; /* Link to variable discipline */
90 96 struct mdb_var *v_next; /* Link to next var in hash chain */
91 97 uchar_t v_flags; /* Variable flags (see above) */
92 98 char v_lname[1]; /* Variable name if stored locally */
93 99 } mdb_var_t;
94 100
95 101 #define MDB_NV_VALUE(v) ((v)->v_uvalue)
96 102 #define MDB_NV_COOKIE(v) ((void *)(uintptr_t)((v)->v_uvalue))
97 103
98 104 #define v_ename v_du.v_ename
99 105 #define v_ndef v_du.v_ndef
100 106
101 107 /*
102 108 * The name/value collection itself is a simple array of hash buckets,
103 109 * as well as a persistent bucket index and pointer for iteration:
104 110 */
105 111 typedef struct mdb_nv {
106 112 mdb_var_t **nv_hash; /* Hash bucket array */
107 113 size_t nv_hashsz; /* Size of hash bucket array */
108 114 size_t nv_nelems; /* Total number of hashed elements */
109 115 mdb_var_t *nv_iter_elt; /* Iterator element pointer */
110 116 size_t nv_iter_bucket; /* Iterator bucket index */
111 117 uint_t nv_um_flags; /* Flags for the memory allocator */
112 118 } mdb_nv_t;
113 119
114 120 extern mdb_nv_t *mdb_nv_create(mdb_nv_t *, uint_t);
115 121 extern void mdb_nv_destroy(mdb_nv_t *);
116 122
117 123 extern mdb_var_t *mdb_nv_insert(mdb_nv_t *, const char *,
118 124 const mdb_nv_disc_t *, uintmax_t, uint_t);
119 125
120 126 extern mdb_var_t *mdb_nv_lookup(mdb_nv_t *, const char *);
121 127 extern void mdb_nv_remove(mdb_nv_t *, mdb_var_t *);
122 128
123 129 extern void mdb_nv_rewind(mdb_nv_t *);
124 130 extern mdb_var_t *mdb_nv_advance(mdb_nv_t *);
125 131 extern mdb_var_t *mdb_nv_peek(mdb_nv_t *);
126 132 extern size_t mdb_nv_size(mdb_nv_t *);
127 133
128 134 extern void mdb_nv_sort_iter(mdb_nv_t *,
129 135 int (*)(mdb_var_t *, void *), void *, uint_t);
130 136
131 137 extern void mdb_nv_defn_iter(mdb_var_t *,
132 138 int (*)(mdb_var_t *, void *), void *);
133 139
134 140 extern uintmax_t mdb_nv_get_value(const mdb_var_t *);
135 141 extern void mdb_nv_set_value(mdb_var_t *, uintmax_t);
136 142
137 143 extern void *mdb_nv_get_cookie(const mdb_var_t *);
138 144 extern void mdb_nv_set_cookie(mdb_var_t *, void *);
139 145
140 146 extern const char *mdb_nv_get_name(const mdb_var_t *);
141 147 extern mdb_var_t *mdb_nv_get_ndef(const mdb_var_t *);
142 148
143 149 #endif /* _MDB */
144 150
145 151 #ifdef __cplusplus
146 152 }
147 153 #endif
148 154
149 155 #endif /* _MDB_NV_H */
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX