Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/common/mdb/mdb_value.c
+++ new/usr/src/cmd/mdb/common/mdb/mdb_value.c
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 (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + *
25 + * Copyright 2018 Joyent, Inc.
24 26 */
25 27
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 28 /*
29 29 * Immediate Value Target
30 30 *
31 31 * The immediate value target is used when the '=' verb is used to
32 32 * format an immediate value, or with ::print -i. The target is
33 33 * initialized with a specific value, and then simply copies bytes from
34 34 * this integer in its read routine. Two notes:
35 35 *
36 36 * (1) the address parameter of value_read is treated as an offset into
37 37 * the immediate value.
38 38 *
39 39 * (2) on big-endian systems, we need to be careful about the place we
40 40 * copy data from. If the caller specified a typesize in the argv array
41 41 * we use that for offsetting, otherwise we use the read size.
42 42 * If the user didn't specify the typesize, then 'addr' is ignored,
43 43 * and all reads are at an offset of 0 into the immediate value. This
44 44 * covers both the usage of ::print -i, and the semantics of adb
45 45 * commands like "0x1234=X", which should produce 0x1234 as a result;
46 46 * the adb model is for it to act like a cast down to the smaller
47 47 * integer type; this is handled as mentioned.
48 48 */
49 49
50 50 #include <mdb/mdb_target_impl.h>
51 51 #include <mdb/mdb_types.h>
52 52 #include <mdb/mdb_conf.h>
53 53 #include <mdb/mdb_err.h>
54 54
55 55 #include <sys/isa_defs.h>
56 56 #include <strings.h>
57 57
58 58 void mdb_value_tgt_destroy(mdb_tgt_t *);
59 59
60 60 typedef struct mdb_value_data {
61 61 uintmax_t mvd_data;
62 62 size_t mvd_typesize;
63 63 } mdb_value_data_t;
64 64
65 65 static ssize_t
66 66 value_read(mdb_tgt_t *t, void *dst, size_t nbytes, uintptr_t addr)
67 67 {
68 68 mdb_value_data_t *data = t->t_data;
69 69 size_t size = data->mvd_typesize;
70 70 const char *src = (const char *)&data->mvd_data;
71 71 size_t off;
72 72
73 73 /*
74 74 * If no output size was specified, use the current read size.
75 75 * In this case, "addr" is not an offset into the mvd_data,
76 76 * so we ignore it.
77 77 */
78 78 if (size == 0) {
79 79 size = nbytes;
80 80 addr = 0;
81 81 } else {
82 82 nbytes = MIN(size, nbytes);
83 83 }
84 84
85 85 off = addr;
86 86 #ifdef _BIG_ENDIAN
87 87 if (sizeof (uintmax_t) >= size)
88 88 off += sizeof (uintmax_t) - size;
89 89 #endif
90 90
91 91 if (off > sizeof (uintmax_t))
92 92 return (0);
93 93 if (off + nbytes > sizeof (uintmax_t))
94 94 nbytes = sizeof (uintmax_t) - off;
95 95
96 96 if (nbytes != 0)
97 97 bcopy(src + off, dst, nbytes);
98 98
99 99 return (nbytes);
100 100 }
101 101
102 102 /*ARGSUSED*/
103 103 static ssize_t
104 104 value_write(mdb_tgt_t *t, const void *buf, size_t nbytes, uintptr_t addr)
105 105 {
106 106 return (nbytes); /* We allow writes to silently fail */
107 107 }
108 108
109 109 static const mdb_tgt_ops_t value_ops = {
110 110 (int (*)()) mdb_tgt_notsup, /* t_setflags */
111 111 (int (*)()) mdb_tgt_notsup, /* t_setcontext */
112 112 (void (*)()) mdb_tgt_nop, /* t_activate */
113 113 (void (*)()) mdb_tgt_nop, /* t_deactivate */
114 114 (void (*)()) mdb_tgt_nop, /* t_periodic */
115 115 mdb_value_tgt_destroy, /* t_destroy */
116 116 (const char *(*)()) mdb_tgt_null, /* t_name */
117 117 (const char *(*)()) mdb_conf_isa, /* t_isa */
118 118 (const char *(*)()) mdb_conf_platform, /* t_platform */
119 119 (int (*)()) mdb_tgt_notsup, /* t_uname */
120 120 (int (*)()) mdb_tgt_notsup, /* t_dmodel */
121 121 (ssize_t (*)()) mdb_tgt_notsup, /* t_aread */
122 122 (ssize_t (*)()) mdb_tgt_notsup, /* t_awrite */
123 123 value_read, /* t_vread */
124 124 value_write, /* t_vwrite */
125 125 (ssize_t (*)()) mdb_tgt_notsup, /* t_pread */
126 126 (ssize_t (*)()) mdb_tgt_notsup, /* t_pwrite */
127 127 value_read, /* t_fread */
128 128 value_write, /* t_fwrite */
129 129 value_read, /* t_ioread */
130 130 value_write, /* t_iowrite */
131 131 (int (*)()) mdb_tgt_notsup, /* t_vtop */
132 132 (int (*)()) mdb_tgt_notsup, /* t_lookup_by_name */
133 133 (int (*)()) mdb_tgt_notsup, /* t_lookup_by_addr */
134 134 (int (*)()) mdb_tgt_notsup, /* t_symbol_iter */
↓ open down ↓ |
97 lines elided |
↑ open up ↑ |
135 135 (int (*)()) mdb_tgt_notsup, /* t_mapping_iter */
136 136 (int (*)()) mdb_tgt_notsup, /* t_object_iter */
137 137 (const mdb_map_t *(*)()) mdb_tgt_null, /* t_addr_to_map */
138 138 (const mdb_map_t *(*)()) mdb_tgt_null, /* t_name_to_map */
139 139 (struct ctf_file *(*)()) mdb_tgt_null, /* t_addr_to_ctf */
140 140 (struct ctf_file *(*)()) mdb_tgt_null, /* t_name_to_ctf */
141 141 (int (*)()) mdb_tgt_notsup, /* t_status */
142 142 (int (*)()) mdb_tgt_notsup, /* t_run */
143 143 (int (*)()) mdb_tgt_notsup, /* t_step */
144 144 (int (*)()) mdb_tgt_notsup, /* t_step_out */
145 - (int (*)()) mdb_tgt_notsup, /* t_step_branch */
146 145 (int (*)()) mdb_tgt_notsup, /* t_next */
147 146 (int (*)()) mdb_tgt_notsup, /* t_cont */
148 147 (int (*)()) mdb_tgt_notsup, /* t_signal */
149 148 (int (*)()) mdb_tgt_null, /* t_add_vbrkpt */
150 149 (int (*)()) mdb_tgt_null, /* t_add_sbrkpt */
151 150 (int (*)()) mdb_tgt_null, /* t_add_pwapt */
152 151 (int (*)()) mdb_tgt_null, /* t_add_vwapt */
153 152 (int (*)()) mdb_tgt_null, /* t_add_iowapt */
154 153 (int (*)()) mdb_tgt_null, /* t_add_sysenter */
155 154 (int (*)()) mdb_tgt_null, /* t_add_sysexit */
156 155 (int (*)()) mdb_tgt_null, /* t_add_signal */
157 156 (int (*)()) mdb_tgt_null, /* t_add_fault */
158 157 (int (*)()) mdb_tgt_notsup, /* t_getareg */
159 158 (int (*)()) mdb_tgt_notsup, /* t_putareg */
160 159 (int (*)()) mdb_tgt_nop, /* t_stack_iter */
161 160 (int (*)()) mdb_tgt_notsup /* t_auxv */
162 161 };
163 162
164 163 int
165 164 mdb_value_tgt_create(mdb_tgt_t *t, int argc, const char *argv[])
166 165 {
167 166 mdb_value_data_t *data;
168 167
169 168 if (argc < 1 || argv[0] == NULL)
170 169 return (set_errno(EINVAL));
171 170 if (argc == 2 && argv[1] == NULL)
172 171 return (set_errno(EINVAL));
173 172 if (argc > 2)
174 173 return (set_errno(EINVAL));
175 174
176 175 t->t_ops = &value_ops;
177 176 data = mdb_zalloc(sizeof (mdb_value_data_t), UM_SLEEP);
178 177 t->t_data = data;
179 178 data->mvd_data = *((uintmax_t *)(void *)argv[0]);
180 179 if (argc == 2)
181 180 data->mvd_typesize = *((size_t *)(void *)argv[1]);
182 181
183 182 return (0);
184 183 }
185 184
186 185 void
187 186 mdb_value_tgt_destroy(mdb_tgt_t *t)
188 187 {
189 188 mdb_free(t->t_data, sizeof (mdb_value_data_t));
190 189 }
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX