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/sparc/mdb/kvm_v7dep.c
+++ new/usr/src/cmd/mdb/sparc/mdb/kvm_v7dep.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 * Libkvm Kernel Target SPARC v7 component
30 30 *
31 31 * This file provides the ISA-dependent portion of the libkvm kernel target.
32 32 * For more details on the implementation refer to mdb_kvm.c.
33 33 */
34 34
35 35 #include <sys/types.h>
36 36 #include <sys/machtypes.h>
37 37 #include <sys/regset.h>
38 38 #include <sys/frame.h>
39 39 #include <sys/stack.h>
40 40 #include <sys/sysmacros.h>
41 41 #include <sys/panic.h>
42 42 #include <strings.h>
43 43
44 44 #include <mdb/mdb_target_impl.h>
45 45 #include <mdb/mdb_disasm.h>
46 46 #include <mdb/mdb_modapi.h>
47 47 #include <mdb/mdb_conf.h>
48 48 #include <mdb/mdb_kreg.h>
49 49 #include <mdb/mdb_kvm.h>
50 50 #include <mdb/mdb_err.h>
51 51 #include <mdb/mdb_debug.h>
52 52 #include <mdb/mdb.h>
53 53
54 54 /*
55 55 * The mdb_tgt_gregset type is opaque to callers of the target interface
56 56 * and to our own target common code. We now can define it explicitly.
57 57 */
58 58 struct mdb_tgt_gregset {
59 59 kreg_t kregs[KREG_NGREG];
60 60 };
61 61
62 62 /*
63 63 * We also define an array of register names and their corresponding
64 64 * array indices. This is used by the getareg and putareg entry points,
65 65 * and also by our register variable discipline.
66 66 */
67 67 static const mdb_tgt_regdesc_t kt_sparcv7_regs[] = {
68 68 { "g0", KREG_G0, MDB_TGT_R_EXPORT },
69 69 { "g1", KREG_G1, MDB_TGT_R_EXPORT },
70 70 { "g2", KREG_G2, MDB_TGT_R_EXPORT },
71 71 { "g3", KREG_G3, MDB_TGT_R_EXPORT },
72 72 { "g4", KREG_G4, MDB_TGT_R_EXPORT },
73 73 { "g5", KREG_G5, MDB_TGT_R_EXPORT },
74 74 { "g6", KREG_G6, MDB_TGT_R_EXPORT },
75 75 { "g7", KREG_G7, MDB_TGT_R_EXPORT },
76 76 { "o0", KREG_O0, MDB_TGT_R_EXPORT },
77 77 { "o1", KREG_O1, MDB_TGT_R_EXPORT },
78 78 { "o2", KREG_O2, MDB_TGT_R_EXPORT },
79 79 { "o3", KREG_O3, MDB_TGT_R_EXPORT },
80 80 { "o4", KREG_O4, MDB_TGT_R_EXPORT },
81 81 { "o5", KREG_O5, MDB_TGT_R_EXPORT },
82 82 { "o6", KREG_O6, MDB_TGT_R_EXPORT },
83 83 { "o7", KREG_O7, MDB_TGT_R_EXPORT },
84 84 { "l0", KREG_L0, MDB_TGT_R_EXPORT },
85 85 { "l1", KREG_L1, MDB_TGT_R_EXPORT },
86 86 { "l2", KREG_L2, MDB_TGT_R_EXPORT },
87 87 { "l3", KREG_L3, MDB_TGT_R_EXPORT },
88 88 { "l4", KREG_L4, MDB_TGT_R_EXPORT },
89 89 { "l5", KREG_L5, MDB_TGT_R_EXPORT },
90 90 { "l6", KREG_L6, MDB_TGT_R_EXPORT },
91 91 { "l7", KREG_L7, MDB_TGT_R_EXPORT },
92 92 { "i0", KREG_I0, MDB_TGT_R_EXPORT },
93 93 { "i1", KREG_I1, MDB_TGT_R_EXPORT },
94 94 { "i2", KREG_I2, MDB_TGT_R_EXPORT },
95 95 { "i3", KREG_I3, MDB_TGT_R_EXPORT },
96 96 { "i4", KREG_I4, MDB_TGT_R_EXPORT },
97 97 { "i5", KREG_I5, MDB_TGT_R_EXPORT },
98 98 { "i6", KREG_I6, MDB_TGT_R_EXPORT },
99 99 { "i7", KREG_I7, MDB_TGT_R_EXPORT },
100 100 { "psr", KREG_PSR, MDB_TGT_R_EXPORT },
101 101 { "pc", KREG_PC, MDB_TGT_R_EXPORT },
102 102 { "npc", KREG_NPC, MDB_TGT_R_EXPORT },
103 103 { "y", KREG_Y, 0 },
104 104 { "wim", KREG_WIM, MDB_TGT_R_EXPORT | MDB_TGT_R_PRIV },
105 105 { "tbr", KREG_TBR, MDB_TGT_R_EXPORT | MDB_TGT_R_PRIV },
106 106 { "sp", KREG_SP, MDB_TGT_R_EXPORT | MDB_TGT_R_ALIAS },
107 107 { "fp", KREG_FP, MDB_TGT_R_EXPORT | MDB_TGT_R_ALIAS },
108 108 { NULL, 0, 0 }
109 109 };
110 110
111 111 static int
112 112 kt_getareg(mdb_tgt_t *t, mdb_tgt_tid_t tid,
113 113 const char *rname, mdb_tgt_reg_t *rp)
114 114 {
115 115 const mdb_tgt_regdesc_t *rdp;
116 116 kt_data_t *kt = t->t_data;
117 117
118 118 if (tid != kt->k_tid)
119 119 return (set_errno(EMDB_NOREGS));
120 120
121 121 for (rdp = kt->k_rds; rdp->rd_name != NULL; rdp++) {
122 122 if (strcmp(rname, rdp->rd_name) == 0) {
123 123 *rp = kt->k_regs->kregs[rdp->rd_num];
124 124 return (0);
125 125 }
126 126 }
127 127
128 128 return (set_errno(EMDB_BADREG));
129 129 }
130 130
131 131 static int
132 132 kt_putareg(mdb_tgt_t *t, mdb_tgt_tid_t tid, const char *rname, mdb_tgt_reg_t r)
133 133 {
134 134 const mdb_tgt_regdesc_t *rdp;
135 135 kt_data_t *kt = t->t_data;
136 136
137 137 if (tid != kt->k_tid)
138 138 return (set_errno(EMDB_NOREGS));
139 139
140 140 for (rdp = kt->k_rds; rdp->rd_name != NULL; rdp++) {
141 141 if (strcmp(rname, rdp->rd_name) == 0) {
142 142 kt->k_regs->kregs[rdp->rd_num] = r;
143 143 return (0);
144 144 }
145 145 }
146 146
147 147 return (set_errno(EMDB_BADREG));
148 148 }
149 149
150 150 static int
151 151 kt_stack_iter(mdb_tgt_t *t, const mdb_tgt_gregset_t *gsp,
152 152 mdb_tgt_stack_f *func, void *arg)
153 153 {
154 154 mdb_tgt_gregset_t gregs;
155 155 kreg_t *kregs = &gregs.kregs[0];
156 156 int got_pc = (gsp->kregs[KREG_PC] != 0);
157 157
158 158 struct rwindow rwin;
159 159 uintptr_t sp;
160 160 long argv[6];
161 161 int i;
162 162
163 163 bcopy(gsp, &gregs, sizeof (gregs));
164 164
165 165 for (;;) {
166 166 for (i = 0; i < 6; i++)
167 167 argv[i] = kregs[KREG_I0 + i];
168 168
169 169 if (got_pc && func(arg, kregs[KREG_PC], 6, argv, &gregs) != 0)
170 170 break;
171 171
172 172 kregs[KREG_PC] = kregs[KREG_I7];
173 173 kregs[KREG_NPC] = kregs[KREG_PC] + 4;
174 174
175 175 bcopy(&kregs[KREG_I0], &kregs[KREG_O0], 8 * sizeof (kreg_t));
176 176 got_pc |= (kregs[KREG_PC] != 0);
177 177
178 178 if ((sp = kregs[KREG_FP]) == 0)
179 179 break; /* Stop if we're at the end of the stack */
180 180
181 181 if (sp & (STACK_ALIGN - 1))
182 182 return (set_errno(EMDB_STKALIGN));
183 183
184 184 if (mdb_tgt_vread(t, &rwin, sizeof (rwin), sp) != sizeof (rwin))
185 185 return (-1); /* Failed to read frame */
186 186
187 187 for (i = 0; i < 8; i++)
188 188 kregs[KREG_L0 + i] = (uintptr_t)rwin.rw_local[i];
189 189 for (i = 0; i < 8; i++)
190 190 kregs[KREG_I0 + i] = (uintptr_t)rwin.rw_in[i];
191 191 }
192 192
193 193 return (0);
194 194 }
195 195
196 196 /*ARGSUSED*/
197 197 static int
198 198 kt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
199 199 {
200 200 mdb_tgt_gregset_t *k_regs = (mdb_tgt_gregset_t *)addr;
201 201 const kreg_t *kregs = &k_regs->kregs[0];
202 202
203 203 if (argc != 0 || (flags & DCMD_ADDRSPEC))
204 204 return (DCMD_USAGE);
205 205
206 206 #define GETREG2(x) ((uintptr_t)kregs[(x)]), ((uintptr_t)kregs[(x)])
207 207
208 208 mdb_printf("%%g0 = 0x%0?p %15A %%l0 = 0x%0?p %A\n",
209 209 GETREG2(KREG_G0), GETREG2(KREG_L0));
210 210
211 211 mdb_printf("%%g1 = 0x%0?p %15A %%l1 = 0x%0?p %A\n",
212 212 GETREG2(KREG_G1), GETREG2(KREG_L1));
213 213
214 214 mdb_printf("%%g2 = 0x%0?p %15A %%l2 = 0x%0?p %A\n",
215 215 GETREG2(KREG_G2), GETREG2(KREG_L2));
216 216
217 217 mdb_printf("%%g3 = 0x%0?p %15A %%l3 = 0x%0?p %A\n",
218 218 GETREG2(KREG_G3), GETREG2(KREG_L3));
219 219
220 220 mdb_printf("%%g4 = 0x%0?p %15A %%l4 = 0x%0?p %A\n",
221 221 GETREG2(KREG_G4), GETREG2(KREG_L4));
222 222
223 223 mdb_printf("%%g5 = 0x%0?p %15A %%l5 = 0x%0?p %A\n",
224 224 GETREG2(KREG_G5), GETREG2(KREG_L5));
225 225
226 226 mdb_printf("%%g6 = 0x%0?p %15A %%l6 = 0x%0?p %A\n",
227 227 GETREG2(KREG_G6), GETREG2(KREG_L6));
228 228
229 229 mdb_printf("%%g7 = 0x%0?p %15A %%l7 = 0x%0?p %A\n\n",
230 230 GETREG2(KREG_G7), GETREG2(KREG_L7));
231 231
232 232 mdb_printf("%%o0 = 0x%0?p %15A %%i0 = 0x%0?p %A\n",
233 233 GETREG2(KREG_O0), GETREG2(KREG_I0));
234 234
235 235 mdb_printf("%%o1 = 0x%0?p %15A %%i1 = 0x%0?p %A\n",
236 236 GETREG2(KREG_O1), GETREG2(KREG_I1));
237 237
238 238 mdb_printf("%%o2 = 0x%0?p %15A %%i2 = 0x%0?p %A\n",
239 239 GETREG2(KREG_O2), GETREG2(KREG_I2));
240 240
241 241 mdb_printf("%%o3 = 0x%0?p %15A %%i3 = 0x%0?p %A\n",
242 242 GETREG2(KREG_O3), GETREG2(KREG_I3));
243 243
244 244 mdb_printf("%%o4 = 0x%0?p %15A %%i4 = 0x%0?p %A\n",
245 245 GETREG2(KREG_O4), GETREG2(KREG_I4));
246 246
247 247 mdb_printf("%%o5 = 0x%0?p %15A %%i5 = 0x%0?p %A\n",
248 248 GETREG2(KREG_O5), GETREG2(KREG_I5));
249 249
250 250 mdb_printf("%%o6 = 0x%0?p %15A %%i6 = 0x%0?p %A\n",
251 251 GETREG2(KREG_O6), GETREG2(KREG_I6));
252 252
253 253 mdb_printf("%%o7 = 0x%0?p %15A %%i7 = 0x%0?p %A\n\n",
254 254 GETREG2(KREG_O7), GETREG2(KREG_I7));
255 255
256 256 mdb_printf(" %%psr = 0x%08x impl=0x%x ver=0x%x icc=%c%c%c%c\n"
257 257 " ec=%u ef=%u pil=%u s=%u ps=%u et=%u cwp=0x%x\n",
258 258 kregs[KREG_PSR],
259 259 (kregs[KREG_PSR] & KREG_PSR_IMPL_MASK) >> KREG_PSR_IMPL_SHIFT,
260 260 (kregs[KREG_PSR] & KREG_PSR_VER_MASK) >> KREG_PSR_VER_SHIFT,
261 261 (kregs[KREG_PSR] & KREG_PSR_ICC_N_MASK) ? 'N' : 'n',
262 262 (kregs[KREG_PSR] & KREG_PSR_ICC_Z_MASK) ? 'Z' : 'z',
263 263 (kregs[KREG_PSR] & KREG_PSR_ICC_V_MASK) ? 'V' : 'v',
264 264 (kregs[KREG_PSR] & KREG_PSR_ICC_C_MASK) ? 'C' : 'c',
265 265 kregs[KREG_PSR] & KREG_PSR_EC_MASK,
266 266 kregs[KREG_PSR] & KREG_PSR_EF_MASK,
267 267 (kregs[KREG_PSR] & KREG_PSR_PIL_MASK) >> KREG_PSR_PIL_SHIFT,
268 268 kregs[KREG_PSR] & KREG_PSR_S_MASK,
269 269 kregs[KREG_PSR] & KREG_PSR_PS_MASK,
270 270 kregs[KREG_PSR] & KREG_PSR_ET_MASK,
271 271 (kregs[KREG_PSR] & KREG_PSR_CWP_MASK) >> KREG_PSR_CWP_SHIFT);
272 272
273 273 mdb_printf(" %%y = 0x%0?p\n", kregs[KREG_Y]);
274 274
275 275 mdb_printf(" %%pc = 0x%0?p %A\n", GETREG2(KREG_PC));
276 276 mdb_printf(" %%npc = 0x%0?p %A\n", GETREG2(KREG_NPC));
277 277
278 278 mdb_printf(" %%sp = 0x%0?p\n", kregs[KREG_SP]);
279 279 mdb_printf(" %%fp = 0x%0?p\n\n", kregs[KREG_FP]);
280 280
281 281 mdb_printf(" %%wim = 0x%08lx\n", kregs[KREG_WIM]);
282 282 mdb_printf(" %%tbr = 0x%08lx\n", kregs[KREG_TBR]);
283 283
284 284 return (DCMD_OK);
285 285 }
286 286
287 287 /*ARGSUSED*/
288 288 static int
289 289 kt_frame(void *arglim, uintptr_t pc, uint_t argc, const long *argv,
290 290 const mdb_tgt_gregset_t *gregs)
291 291 {
292 292 argc = MIN(argc, (uint_t)arglim);
293 293 mdb_printf("%a(", pc);
294 294
295 295 if (argc != 0) {
296 296 mdb_printf("%lr", *argv++);
297 297 for (argc--; argc != 0; argc--)
298 298 mdb_printf(", %lr", *argv++);
299 299 }
300 300
301 301 mdb_printf(")\n");
302 302 return (0);
303 303 }
304 304
305 305 static int
306 306 kt_framev(void *arglim, uintptr_t pc, uint_t argc, const long *argv,
307 307 const mdb_tgt_gregset_t *gregs)
308 308 {
309 309 argc = MIN(argc, (uint_t)arglim);
310 310 mdb_printf("%0?lr %a(", gregs->kregs[KREG_SP], pc);
311 311
312 312 if (argc != 0) {
313 313 mdb_printf("%lr", *argv++);
314 314 for (argc--; argc != 0; argc--)
315 315 mdb_printf(", %lr", *argv++);
316 316 }
317 317
318 318 mdb_printf(")\n");
319 319 return (0);
320 320 }
321 321
322 322 static int
323 323 kt_stack_common(uintptr_t addr, uint_t flags, int argc,
324 324 const mdb_arg_t *argv, mdb_tgt_stack_f *func)
325 325 {
326 326 kt_data_t *kt = mdb.m_target->t_data;
327 327 void *arg = (void *)mdb.m_nargs;
328 328 mdb_tgt_gregset_t gregs, *grp;
329 329
330 330 if (flags & DCMD_ADDRSPEC) {
331 331 bzero(&gregs, sizeof (gregs));
332 332 gregs.kregs[KREG_FP] = addr;
333 333 grp = &gregs;
334 334 } else
335 335 grp = kt->k_regs;
336 336
337 337 if (argc != 0) {
338 338 if (argv->a_type == MDB_TYPE_CHAR || argc > 1)
339 339 return (DCMD_USAGE);
340 340
341 341 if (argv->a_type == MDB_TYPE_STRING)
342 342 arg = (void *)(uint_t)mdb_strtoull(argv->a_un.a_str);
343 343 else
344 344 arg = (void *)(uint_t)argv->a_un.a_val;
345 345 }
346 346
347 347 (void) kt_stack_iter(mdb.m_target, grp, func, arg);
348 348 return (DCMD_OK);
349 349 }
350 350
351 351 static int
352 352 kt_stack(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
353 353 {
354 354 return (kt_stack_common(addr, flags, argc, argv, kt_frame));
355 355 }
356 356
357 357 static int
358 358 kt_stackv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
359 359 {
360 360 return (kt_stack_common(addr, flags, argc, argv, kt_framev));
361 361 }
362 362
363 363 /*ARGSUSED*/
364 364 static int
365 365 kt_notsup(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
366 366 {
367 367 errno = EMDB_TGTNOTSUP;
368 368 return (DCMD_ERR);
369 369 }
370 370
371 371 const mdb_tgt_ops_t kt_sparcv7_ops = {
372 372 kt_setflags, /* t_setflags */
373 373 kt_setcontext, /* t_setcontext */
374 374 kt_activate, /* t_activate */
375 375 kt_deactivate, /* t_deactivate */
376 376 (void (*)()) mdb_tgt_nop, /* t_periodic */
377 377 kt_destroy, /* t_destroy */
378 378 kt_name, /* t_name */
379 379 (const char *(*)()) mdb_conf_isa, /* t_isa */
380 380 kt_platform, /* t_platform */
381 381 kt_uname, /* t_uname */
382 382 kt_dmodel, /* t_dmodel */
383 383 kt_aread, /* t_aread */
384 384 kt_awrite, /* t_awrite */
385 385 kt_vread, /* t_vread */
386 386 kt_vwrite, /* t_vwrite */
387 387 kt_pread, /* t_pread */
388 388 kt_pwrite, /* t_pwrite */
389 389 kt_fread, /* t_fread */
390 390 kt_fwrite, /* t_fwrite */
391 391 (ssize_t (*)()) mdb_tgt_notsup, /* t_ioread */
392 392 (ssize_t (*)()) mdb_tgt_notsup, /* t_iowrite */
393 393 kt_vtop, /* t_vtop */
394 394 kt_lookup_by_name, /* t_lookup_by_name */
395 395 kt_lookup_by_addr, /* t_lookup_by_addr */
396 396 kt_symbol_iter, /* t_symbol_iter */
↓ open down ↓ |
359 lines elided |
↑ open up ↑ |
397 397 kt_mapping_iter, /* t_mapping_iter */
398 398 kt_object_iter, /* t_object_iter */
399 399 kt_addr_to_map, /* t_addr_to_map */
400 400 kt_name_to_map, /* t_name_to_map */
401 401 kt_addr_to_ctf, /* t_addr_to_ctf */
402 402 kt_name_to_ctf, /* t_name_to_ctf */
403 403 kt_status, /* t_status */
404 404 (int (*)()) mdb_tgt_notsup, /* t_run */
405 405 (int (*)()) mdb_tgt_notsup, /* t_step */
406 406 (int (*)()) mdb_tgt_notsup, /* t_step_out */
407 - (int (*)()) mdb_tgt_notsup, /* t_step_branch */
408 407 (int (*)()) mdb_tgt_notsup, /* t_next */
409 408 (int (*)()) mdb_tgt_notsup, /* t_cont */
410 409 (int (*)()) mdb_tgt_notsup, /* t_signal */
411 410 (int (*)()) mdb_tgt_null, /* t_add_vbrkpt */
412 411 (int (*)()) mdb_tgt_null, /* t_add_sbrkpt */
413 412 (int (*)()) mdb_tgt_null, /* t_add_pwapt */
414 413 (int (*)()) mdb_tgt_null, /* t_add_vwapt */
415 414 (int (*)()) mdb_tgt_null, /* t_add_iowapt */
416 415 (int (*)()) mdb_tgt_null, /* t_add_sysenter */
417 416 (int (*)()) mdb_tgt_null, /* t_add_sysexit */
418 417 (int (*)()) mdb_tgt_null, /* t_add_signal */
419 418 (int (*)()) mdb_tgt_null, /* t_add_fault */
420 419 kt_getareg, /* t_getareg */
421 420 kt_putareg, /* t_putareg */
422 421 kt_stack_iter, /* t_stack_iter */
423 422 (int (*)()) mdb_tgt_notsup /* t_auxv */
424 423 };
425 424
426 425 void
427 426 kt_sparcv7_init(mdb_tgt_t *t)
428 427 {
429 428 kt_data_t *kt = t->t_data;
430 429
431 430 struct rwindow rwin;
432 431 panic_data_t pd;
433 432 label_t label;
434 433 kreg_t *kregs;
435 434
436 435 /*
437 436 * Initialize the machine-dependent parts of the kernel target
438 437 * structure. Once this is complete and we fill in the ops
439 438 * vector, the target is now fully constructed and we can use
440 439 * the target API itself to perform the rest of our initialization.
441 440 */
442 441 kt->k_rds = kt_sparcv7_regs;
443 442 kt->k_regs = mdb_zalloc(sizeof (mdb_tgt_gregset_t), UM_SLEEP);
444 443 kt->k_regsize = sizeof (mdb_tgt_gregset_t);
445 444 kt->k_dcmd_regs = kt_regs;
446 445 kt->k_dcmd_stack = kt_stack;
447 446 kt->k_dcmd_stackv = kt_stackv;
448 447 kt->k_dcmd_stackr = kt_stackv;
449 448 kt->k_dcmd_cpustack = kt_notsup;
450 449 kt->k_dcmd_cpuregs = kt_notsup;
451 450
452 451 t->t_ops = &kt_sparcv7_ops;
453 452 kregs = kt->k_regs->kregs;
454 453
455 454 (void) mdb_dis_select("v8");
456 455
457 456 /*
458 457 * Don't attempt to load any thread or register information if
459 458 * we're examining the live operating system.
460 459 */
461 460 if (strcmp(kt->k_symfile, "/dev/ksyms") == 0)
462 461 return;
463 462
464 463 /*
465 464 * If the panicbuf symbol is present and we can consume a panicbuf
466 465 * header of the appropriate version from this address, then
467 466 * we can initialize our current register set based on its contents:
468 467 */
469 468 if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &pd, sizeof (pd),
470 469 MDB_TGT_OBJ_EXEC, "panicbuf") == sizeof (pd) &&
471 470 pd.pd_version == PANICBUFVERS) {
472 471
473 472 size_t pd_size = MIN(PANICBUFSIZE, pd.pd_msgoff);
474 473 panic_data_t *pdp = mdb_zalloc(pd_size, UM_SLEEP);
475 474 uint_t i, n;
476 475
477 476 (void) mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, pdp, pd_size,
478 477 MDB_TGT_OBJ_EXEC, "panicbuf");
479 478
480 479 n = (pd_size - (sizeof (panic_data_t) -
481 480 sizeof (panic_nv_t))) / sizeof (panic_nv_t);
482 481
483 482 for (i = 0; i < n; i++) {
484 483 (void) kt_putareg(t, kt->k_tid,
485 484 pdp->pd_nvdata[i].pnv_name,
486 485 pdp->pd_nvdata[i].pnv_value);
487 486 }
488 487
489 488 mdb_free(pdp, pd_size);
490 489 }
491 490
492 491 /*
493 492 * Prior to the re-structuring of panicbuf, our only register data
494 493 * was the panic_regs label_t, into which a setjmp() was performed.
495 494 */
496 495 if (kregs[KREG_PC] == 0 && kregs[KREG_SP] == 0 &&
497 496 mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &label, sizeof (label),
498 497 MDB_TGT_OBJ_EXEC, "panic_regs") == sizeof (label)) {
499 498
500 499 kregs[KREG_PC] = label.val[0];
501 500 kregs[KREG_SP] = label.val[1];
502 501 }
503 502
504 503 /*
505 504 * If we can read a saved register window from the stack at %sp,
506 505 * we can also fill in the locals and inputs.
507 506 */
508 507 if (kregs[KREG_SP] != 0 && mdb_tgt_vread(t, &rwin, sizeof (rwin),
509 508 kregs[KREG_SP]) == sizeof (rwin)) {
510 509
511 510 kregs[KREG_L0] = rwin.rw_local[0];
512 511 kregs[KREG_L1] = rwin.rw_local[1];
513 512 kregs[KREG_L2] = rwin.rw_local[2];
514 513 kregs[KREG_L3] = rwin.rw_local[3];
515 514 kregs[KREG_L4] = rwin.rw_local[4];
516 515 kregs[KREG_L5] = rwin.rw_local[5];
517 516 kregs[KREG_L6] = rwin.rw_local[6];
518 517 kregs[KREG_L7] = rwin.rw_local[7];
519 518
520 519 kregs[KREG_I0] = rwin.rw_in[0];
521 520 kregs[KREG_I1] = rwin.rw_in[1];
522 521 kregs[KREG_I2] = rwin.rw_in[2];
523 522 kregs[KREG_I3] = rwin.rw_in[3];
524 523 kregs[KREG_I4] = rwin.rw_in[4];
525 524 kregs[KREG_I5] = rwin.rw_in[5];
526 525 kregs[KREG_I6] = rwin.rw_in[6];
527 526 kregs[KREG_I7] = rwin.rw_in[7];
528 527
529 528 } else if (kregs[KREG_SP] != 0) {
530 529 warn("failed to read rwindow at %p -- current "
531 530 "frame inputs will be unavailable\n",
532 531 (void *)kregs[KREG_SP]);
533 532 }
534 533 }
↓ open down ↓ |
117 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX