Print this page
10132 smatch fixes for MDB
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c
+++ new/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.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, 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.
16 16 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
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 26 /*
27 - * Copyright 2015 Joyent, Inc.
27 + * Copyright (c) 2018, Joyent, Inc.
28 28 */
29 29
30 30 /*
31 31 * User Process Target Intel 32-bit component
32 32 *
33 33 * This file provides the ISA-dependent portion of the user process target.
34 34 * For more details on the implementation refer to mdb_proc.c.
35 35 */
36 36
37 37 #include <mdb/mdb_proc.h>
38 38 #include <mdb/mdb_kreg.h>
39 39 #include <mdb/mdb_err.h>
40 40 #include <mdb/mdb_ia32util.h>
41 41 #include <mdb/mdb.h>
42 42
43 43 #include <sys/ucontext.h>
44 44 #include <sys/frame.h>
45 45 #include <libproc.h>
46 46 #include <sys/fp.h>
47 47 #include <ieeefp.h>
48 48
49 49 #include <stddef.h>
50 50
51 51 const mdb_tgt_regdesc_t pt_regdesc[] = {
52 52 { "gs", GS, MDB_TGT_R_EXPORT },
53 53 { "fs", FS, MDB_TGT_R_EXPORT },
54 54 { "es", ES, MDB_TGT_R_EXPORT },
55 55 { "ds", DS, MDB_TGT_R_EXPORT },
56 56 { "edi", EDI, MDB_TGT_R_EXPORT },
57 57 { "di", EDI, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
58 58 { "esi", ESI, MDB_TGT_R_EXPORT },
59 59 { "si", ESI, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
60 60 { "ebp", EBP, MDB_TGT_R_EXPORT },
61 61 { "bp", EBP, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
62 62 { "kesp", ESP, MDB_TGT_R_EXPORT },
63 63 { "ksp", ESP, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
64 64 { "ebx", EBX, MDB_TGT_R_EXPORT },
65 65 { "bx", EBX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
66 66 { "bh", EBX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H },
67 67 { "bl", EBX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L },
68 68 { "edx", EDX, MDB_TGT_R_EXPORT },
69 69 { "dx", EDX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
70 70 { "dh", EDX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H },
71 71 { "dl", EDX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L },
72 72 { "ecx", ECX, MDB_TGT_R_EXPORT },
73 73 { "cx", ECX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
74 74 { "ch", ECX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H },
75 75 { "cl", ECX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L },
76 76 { "eax", EAX, MDB_TGT_R_EXPORT },
77 77 { "ax", EAX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
78 78 { "ah", EAX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H },
79 79 { "al", EAX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L },
80 80 { "trapno", TRAPNO, MDB_TGT_R_EXPORT },
81 81 { "err", ERR, MDB_TGT_R_EXPORT },
82 82 { "eip", EIP, MDB_TGT_R_EXPORT },
83 83 { "cs", CS, MDB_TGT_R_EXPORT },
84 84 { "eflags", EFL, MDB_TGT_R_EXPORT },
85 85 { "esp", UESP, MDB_TGT_R_EXPORT },
86 86 { "sp", UESP, MDB_TGT_R_EXPORT | MDB_TGT_R_16 },
87 87 { "ss", SS, MDB_TGT_R_EXPORT },
88 88 { NULL, 0, 0 }
89 89 };
90 90
91 91 /*
92 92 * We cannot rely on pr_instr, because if we hit a breakpoint or the user has
93 93 * artifically modified memory, it will no longer be correct.
94 94 */
95 95 static uint8_t
96 96 pt_read_instr(mdb_tgt_t *t)
97 97 {
98 98 const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp;
99 99 uint8_t ret = 0;
100 100
101 101 (void) mdb_tgt_vread(t, &ret, sizeof (ret), psp->pr_reg[EIP]);
102 102
103 103 return (ret);
104 104 }
105 105
106 106 /*ARGSUSED*/
107 107 int
108 108 pt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
109 109 {
110 110 mdb_tgt_t *t = mdb.m_target;
111 111 mdb_tgt_tid_t tid;
112 112 prgregset_t grs;
113 113 prgreg_t eflags;
114 114 boolean_t from_ucontext = B_FALSE;
115 115
116 116 if (mdb_getopts(argc, argv,
117 117 'u', MDB_OPT_SETBITS, B_TRUE, &from_ucontext, NULL) != argc) {
118 118 return (DCMD_USAGE);
119 119 }
120 120
121 121 if (from_ucontext) {
122 122 int off;
123 123 int o0, o1;
124 124
125 125 if (!(flags & DCMD_ADDRSPEC)) {
126 126 mdb_warn("-u requires a ucontext_t address\n");
127 127 return (DCMD_ERR);
128 128 }
129 129
130 130 o0 = mdb_ctf_offsetof_by_name("ucontext_t", "uc_mcontext");
131 131 o1 = mdb_ctf_offsetof_by_name("mcontext_t", "gregs");
132 132 if (o0 == -1 || o1 == -1) {
133 133 off = offsetof(ucontext_t, uc_mcontext) +
134 134 offsetof(mcontext_t, gregs);
135 135 } else {
136 136 off = o0 + o1;
137 137 }
138 138
139 139 if (mdb_vread(&grs, sizeof (grs), addr + off) != sizeof (grs)) {
140 140 mdb_warn("failed to read from ucontext_t %p", addr);
141 141 return (DCMD_ERR);
142 142 }
143 143 goto print_regs;
144 144 }
145 145
146 146 if (t->t_pshandle == NULL || Pstate(t->t_pshandle) == PS_UNDEAD) {
147 147 mdb_warn("no process active\n");
148 148 return (DCMD_ERR);
149 149 }
150 150
151 151 if (Pstate(t->t_pshandle) == PS_LOST) {
152 152 mdb_warn("debugger has lost control of process\n");
153 153 return (DCMD_ERR);
154 154 }
155 155
156 156 if (flags & DCMD_ADDRSPEC)
157 157 tid = (mdb_tgt_tid_t)addr;
158 158 else
159 159 tid = PTL_TID(t);
160 160
161 161 if (PTL_GETREGS(t, tid, grs) != 0) {
162 162 mdb_warn("failed to get current register set");
163 163 return (DCMD_ERR);
164 164 }
165 165
166 166 print_regs:
167 167 eflags = grs[EFL];
168 168
169 169 mdb_printf("%%cs = 0x%04x\t\t%%eax = 0x%0?p %A\n",
170 170 grs[CS], grs[EAX], grs[EAX]);
171 171
172 172 mdb_printf("%%ds = 0x%04x\t\t%%ebx = 0x%0?p %A\n",
173 173 grs[DS], grs[EBX], grs[EBX]);
174 174
175 175 mdb_printf("%%ss = 0x%04x\t\t%%ecx = 0x%0?p %A\n",
176 176 grs[SS], grs[ECX], grs[ECX]);
177 177
178 178 mdb_printf("%%es = 0x%04x\t\t%%edx = 0x%0?p %A\n",
179 179 grs[ES], grs[EDX], grs[EDX]);
180 180
181 181 mdb_printf("%%fs = 0x%04x\t\t%%esi = 0x%0?p %A\n",
182 182 grs[FS], grs[ESI], grs[ESI]);
183 183
184 184 mdb_printf("%%gs = 0x%04x\t\t%%edi = 0x%0?p %A\n\n",
185 185 grs[GS], grs[EDI], grs[EDI]);
186 186
187 187 mdb_printf(" %%eip = 0x%0?p %A\n", grs[EIP], grs[EIP]);
188 188 mdb_printf(" %%ebp = 0x%0?p\n", grs[EBP]);
189 189 mdb_printf("%%kesp = 0x%0?p\n\n", grs[ESP]);
190 190 mdb_printf("%%eflags = 0x%08x\n", eflags);
191 191
192 192 mdb_printf(" id=%u vip=%u vif=%u ac=%u vm=%u rf=%u nt=%u iopl=0x%x\n",
193 193 (eflags & KREG_EFLAGS_ID_MASK) >> KREG_EFLAGS_ID_SHIFT,
194 194 (eflags & KREG_EFLAGS_VIP_MASK) >> KREG_EFLAGS_VIP_SHIFT,
195 195 (eflags & KREG_EFLAGS_VIF_MASK) >> KREG_EFLAGS_VIF_SHIFT,
196 196 (eflags & KREG_EFLAGS_AC_MASK) >> KREG_EFLAGS_AC_SHIFT,
197 197 (eflags & KREG_EFLAGS_VM_MASK) >> KREG_EFLAGS_VM_SHIFT,
198 198 (eflags & KREG_EFLAGS_RF_MASK) >> KREG_EFLAGS_RF_SHIFT,
199 199 (eflags & KREG_EFLAGS_NT_MASK) >> KREG_EFLAGS_NT_SHIFT,
200 200 (eflags & KREG_EFLAGS_IOPL_MASK) >> KREG_EFLAGS_IOPL_SHIFT);
201 201
202 202 mdb_printf(" status=<%s,%s,%s,%s,%s,%s,%s,%s,%s>\n\n",
203 203 (eflags & KREG_EFLAGS_OF_MASK) ? "OF" : "of",
204 204 (eflags & KREG_EFLAGS_DF_MASK) ? "DF" : "df",
205 205 (eflags & KREG_EFLAGS_IF_MASK) ? "IF" : "if",
206 206 (eflags & KREG_EFLAGS_TF_MASK) ? "TF" : "tf",
207 207 (eflags & KREG_EFLAGS_SF_MASK) ? "SF" : "sf",
208 208 (eflags & KREG_EFLAGS_ZF_MASK) ? "ZF" : "zf",
209 209 (eflags & KREG_EFLAGS_AF_MASK) ? "AF" : "af",
210 210 (eflags & KREG_EFLAGS_PF_MASK) ? "PF" : "pf",
211 211 (eflags & KREG_EFLAGS_CF_MASK) ? "CF" : "cf");
212 212
213 213 mdb_printf(" %%esp = 0x%0?x\n", grs[UESP]);
214 214 mdb_printf("%%trapno = 0x%x\n", grs[TRAPNO]);
215 215 mdb_printf(" %%err = 0x%x\n", grs[ERR]);
216 216
217 217 return (DCMD_OK);
218 218 }
219 219
220 220 static const char *
221 221 fpcw2str(uint32_t cw, char *buf, size_t nbytes)
222 222 {
223 223 char *end = buf + nbytes;
224 224 char *p = buf;
225 225
226 226 buf[0] = '\0';
227 227
228 228 /*
229 229 * Decode all masks in the 80387 control word.
230 230 */
231 231 if (cw & FPIM)
232 232 p += mdb_snprintf(p, (size_t)(end - p), "|IM");
233 233 if (cw & FPDM)
234 234 p += mdb_snprintf(p, (size_t)(end - p), "|DM");
235 235 if (cw & FPZM)
236 236 p += mdb_snprintf(p, (size_t)(end - p), "|ZM");
237 237 if (cw & FPOM)
238 238 p += mdb_snprintf(p, (size_t)(end - p), "|OM");
239 239 if (cw & FPUM)
240 240 p += mdb_snprintf(p, (size_t)(end - p), "|UM");
241 241 if (cw & FPPM)
242 242 p += mdb_snprintf(p, (size_t)(end - p), "|PM");
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
243 243 if (cw & FPPC)
244 244 p += mdb_snprintf(p, (size_t)(end - p), "|PC");
245 245 if (cw & FPRC)
246 246 p += mdb_snprintf(p, (size_t)(end - p), "|RC");
247 247 if (cw & FPIC)
248 248 p += mdb_snprintf(p, (size_t)(end - p), "|IC");
249 249
250 250 /*
251 251 * Decode precision, rounding, and infinity options in control word.
252 252 */
253 - if (cw & FPSIG24)
254 - p += mdb_snprintf(p, (size_t)(end - p), "|SIG24");
255 253 if (cw & FPSIG53)
256 254 p += mdb_snprintf(p, (size_t)(end - p), "|SIG53");
257 255 if (cw & FPSIG64)
258 256 p += mdb_snprintf(p, (size_t)(end - p), "|SIG64");
259 257
260 258 if ((cw & FPRC) == (FPRD|FPRU))
261 259 p += mdb_snprintf(p, (size_t)(end - p), "|RTZ");
262 260 else if (cw & FPRD)
263 261 p += mdb_snprintf(p, (size_t)(end - p), "|RD");
264 262 else if (cw & FPRU)
265 263 p += mdb_snprintf(p, (size_t)(end - p), "|RU");
266 264 else
267 265 p += mdb_snprintf(p, (size_t)(end - p), "|RTN");
268 266
269 267 if (cw & FPA)
270 268 p += mdb_snprintf(p, (size_t)(end - p), "|A");
271 269 else
272 270 p += mdb_snprintf(p, (size_t)(end - p), "|P");
273 271 if (cw & WFPB17)
274 272 p += mdb_snprintf(p, (size_t)(end - p), "|WFPB17");
275 273 if (cw & WFPB24)
276 274 p += mdb_snprintf(p, (size_t)(end - p), "|WFPB24");
277 275
278 276 if (buf[0] == '|')
279 277 return (buf + 1);
280 278
281 279 return ("0");
282 280 }
283 281
284 282 static const char *
285 283 fpsw2str(uint32_t cw, char *buf, size_t nbytes)
286 284 {
287 285 char *end = buf + nbytes;
288 286 char *p = buf;
289 287
290 288 buf[0] = '\0';
291 289
292 290 /*
293 291 * Decode all masks in the 80387 status word.
294 292 */
295 293 if (cw & FPS_IE)
296 294 p += mdb_snprintf(p, (size_t)(end - p), "|IE");
297 295 if (cw & FPS_DE)
298 296 p += mdb_snprintf(p, (size_t)(end - p), "|DE");
299 297 if (cw & FPS_ZE)
300 298 p += mdb_snprintf(p, (size_t)(end - p), "|ZE");
301 299 if (cw & FPS_OE)
302 300 p += mdb_snprintf(p, (size_t)(end - p), "|OE");
303 301 if (cw & FPS_UE)
304 302 p += mdb_snprintf(p, (size_t)(end - p), "|UE");
305 303 if (cw & FPS_PE)
306 304 p += mdb_snprintf(p, (size_t)(end - p), "|PE");
307 305 if (cw & FPS_SF)
308 306 p += mdb_snprintf(p, (size_t)(end - p), "|SF");
309 307 if (cw & FPS_ES)
310 308 p += mdb_snprintf(p, (size_t)(end - p), "|ES");
311 309 if (cw & FPS_C0)
312 310 p += mdb_snprintf(p, (size_t)(end - p), "|C0");
313 311 if (cw & FPS_C1)
314 312 p += mdb_snprintf(p, (size_t)(end - p), "|C1");
315 313 if (cw & FPS_C2)
316 314 p += mdb_snprintf(p, (size_t)(end - p), "|C2");
317 315 if (cw & FPS_C3)
318 316 p += mdb_snprintf(p, (size_t)(end - p), "|C3");
319 317 if (cw & FPS_B)
320 318 p += mdb_snprintf(p, (size_t)(end - p), "|B");
321 319
322 320 if (buf[0] == '|')
323 321 return (buf + 1);
324 322
325 323 return ("0");
326 324 }
327 325
328 326 static const char *
329 327 fpmxcsr2str(uint32_t mxcsr, char *buf, size_t nbytes)
330 328 {
331 329 char *end = buf + nbytes;
332 330 char *p = buf;
333 331
334 332 buf[0] = '\0';
335 333
336 334 /*
337 335 * Decode the MXCSR word
338 336 */
339 337 if (mxcsr & SSE_IE)
340 338 p += mdb_snprintf(p, (size_t)(end - p), "|IE");
341 339 if (mxcsr & SSE_DE)
342 340 p += mdb_snprintf(p, (size_t)(end - p), "|DE");
343 341 if (mxcsr & SSE_ZE)
344 342 p += mdb_snprintf(p, (size_t)(end - p), "|ZE");
345 343 if (mxcsr & SSE_OE)
346 344 p += mdb_snprintf(p, (size_t)(end - p), "|OE");
347 345 if (mxcsr & SSE_UE)
348 346 p += mdb_snprintf(p, (size_t)(end - p), "|UE");
349 347 if (mxcsr & SSE_PE)
350 348 p += mdb_snprintf(p, (size_t)(end - p), "|PE");
351 349
352 350 if (mxcsr & SSE_DAZ)
353 351 p += mdb_snprintf(p, (size_t)(end - p), "|DAZ");
354 352
355 353 if (mxcsr & SSE_IM)
356 354 p += mdb_snprintf(p, (size_t)(end - p), "|IM");
357 355 if (mxcsr & SSE_DM)
358 356 p += mdb_snprintf(p, (size_t)(end - p), "|DM");
359 357 if (mxcsr & SSE_ZM)
360 358 p += mdb_snprintf(p, (size_t)(end - p), "|ZM");
361 359 if (mxcsr & SSE_OM)
362 360 p += mdb_snprintf(p, (size_t)(end - p), "|OM");
363 361 if (mxcsr & SSE_UM)
364 362 p += mdb_snprintf(p, (size_t)(end - p), "|UM");
365 363 if (mxcsr & SSE_PM)
366 364 p += mdb_snprintf(p, (size_t)(end - p), "|PM");
367 365
368 366 if ((mxcsr & SSE_RC) == (SSE_RD|SSE_RU))
369 367 p += mdb_snprintf(p, (size_t)(end - p), "|RTZ");
370 368 else if (mxcsr & SSE_RD)
371 369 p += mdb_snprintf(p, (size_t)(end - p), "|RD");
372 370 else if (mxcsr & SSE_RU)
373 371 p += mdb_snprintf(p, (size_t)(end - p), "|RU");
374 372 else
375 373 p += mdb_snprintf(p, (size_t)(end - p), "|RTN");
376 374
377 375 if (mxcsr & SSE_FZ)
378 376 p += mdb_snprintf(p, (size_t)(end - p), "|FZ");
379 377
380 378 if (buf[0] == '|')
381 379 return (buf + 1);
382 380 return ("0");
383 381 }
384 382
385 383 /*ARGSUSED*/
386 384 int
387 385 pt_fpregs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
388 386 {
389 387 mdb_tgt_t *t = mdb.m_target;
390 388 mdb_tgt_tid_t tid;
391 389 uint32_t hw = FP_NO;
392 390 uint_t sse = 0;
393 391 prfpregset_t fprs;
394 392 struct _fpstate fps;
395 393 char buf[256];
396 394 uint_t top;
397 395 int i;
398 396
399 397 /*
400 398 * Union for overlaying _fpreg structure on to quad-precision
401 399 * floating-point value (long double).
402 400 */
403 401 union {
404 402 struct _fpreg reg;
405 403 long double ld;
406 404 } fpru;
407 405
408 406 /*
409 407 * Array of strings corresponding to FPU tag word values (see
410 408 * section 7.3.6 of the Intel Programmer's Reference Manual).
411 409 */
412 410 const char *tag_strings[] = { "valid", "zero", "special", "empty" };
413 411
414 412 if (argc != 0)
415 413 return (DCMD_USAGE);
416 414
417 415 if (t->t_pshandle == NULL || Pstate(t->t_pshandle) == PS_UNDEAD) {
418 416 mdb_warn("no process active\n");
419 417 return (DCMD_ERR);
420 418 }
421 419
422 420 if (Pstate(t->t_pshandle) == PS_LOST) {
423 421 mdb_warn("debugger has lost control of process\n");
424 422 return (DCMD_ERR);
425 423 }
426 424
427 425 if (flags & DCMD_ADDRSPEC)
428 426 tid = (mdb_tgt_tid_t)addr;
429 427 else
430 428 tid = PTL_TID(t);
431 429
432 430 if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &hw,
433 431 sizeof (hw), "libc.so", "_fp_hw") < 0 &&
434 432 mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &hw,
435 433 sizeof (hw), MDB_TGT_OBJ_EXEC, "_fp_hw") < 0)
436 434 mdb_warn("failed to read _fp_hw value");
437 435
438 436 if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &sse,
439 437 sizeof (sse), "libc.so", "_sse_hw") < 0 &&
440 438 mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &sse,
441 439 sizeof (sse), MDB_TGT_OBJ_EXEC, "_sse_hw") < 0)
442 440 mdb_warn("failed to read _sse_hw value");
443 441
444 442 mdb_printf("_fp_hw 0x%02x (", hw);
445 443 switch (hw) {
446 444 case FP_SW:
447 445 mdb_printf("80387 software emulator");
448 446 break;
449 447 case FP_287:
450 448 mdb_printf("80287 chip");
451 449 break;
452 450 case FP_387:
453 451 mdb_printf("80387 chip");
454 452 break;
455 453 case FP_486:
456 454 mdb_printf("80486 chip");
457 455 break;
458 456 default:
459 457 mdb_printf("no floating point support");
460 458 break;
461 459 }
462 460 if (sse)
463 461 mdb_printf(" with SSE");
464 462 mdb_printf(")\n");
465 463
466 464 if (!(hw & FP_HW))
467 465 return (DCMD_OK); /* just abort if no hardware present */
468 466
469 467 if (PTL_GETFPREGS(t, tid, &fprs) != 0) {
470 468 mdb_warn("failed to get floating point registers");
471 469 return (DCMD_ERR);
472 470 }
473 471
474 472 bcopy(&fprs.fp_reg_set.fpchip_state, &fps, sizeof (fps));
475 473
476 474 fps.cw &= 0xffff; /* control word is really 16 bits */
477 475 fps.sw &= 0xffff; /* status word is really 16 bits */
478 476 fps.status &= 0xffff; /* saved status word is really 16 bits */
479 477 fps.cssel &= 0xffff; /* %cs is really 16-bits */
480 478 fps.datasel &= 0xffff; /* %ds is really 16-bits too */
481 479
482 480 mdb_printf("cw 0x%04x (%s)\n", fps.cw,
483 481 fpcw2str(fps.cw, buf, sizeof (buf)));
484 482
485 483 top = (fps.sw & FPS_TOP) >> 11;
486 484 mdb_printf("sw 0x%04x (TOP=0t%u) (%s)\n", fps.sw,
487 485 top, fpsw2str(fps.sw, buf, sizeof (buf)));
488 486
489 487 mdb_printf("xcp sw 0x%04x (%s)\n\n", fps.status,
490 488 fpsw2str(fps.status, buf, sizeof (buf)));
491 489
492 490 mdb_printf("ipoff %a\n", fps.ipoff);
493 491 mdb_printf("cssel 0x%x\n", fps.cssel);
494 492 mdb_printf("dtoff %a\n", fps.dataoff);
495 493 mdb_printf("dtsel 0x%x\n\n", fps.datasel);
496 494
497 495 for (i = 0; i < 8; i++) {
498 496 /*
499 497 * Recall that we need to use the current TOP-of-stack value to
500 498 * associate the _st[] index back to a physical register number,
501 499 * since tag word indices are physical register numbers. Then
502 500 * to get the tag value, we shift over two bits for each tag
503 501 * index, and then grab the bottom two bits.
504 502 */
505 503 uint_t tag_index = (i + top) & 7;
506 504 uint_t tag_value = (fps.tag >> (tag_index * 2)) & 3;
507 505
508 506 fpru.reg = fps._st[i];
509 507 mdb_printf("%%st%d 0x%04x.%04x%04x%04x%04x = %lg %s\n",
510 508 i, fpru.reg.exponent,
511 509 fpru.reg.significand[3], fpru.reg.significand[2],
512 510 fpru.reg.significand[1], fpru.reg.significand[0],
513 511 fpru.ld, tag_strings[tag_value]);
514 512 }
515 513
516 514 if (!sse)
517 515 return (DCMD_OK);
518 516
519 517 mdb_printf("\nmxcsr 0x%04x (%s)\n", fps.mxcsr,
520 518 fpmxcsr2str(fps.mxcsr, buf, sizeof (buf)));
521 519 mdb_printf("xcp 0x%04x (%s)\n\n", fps.xstatus,
522 520 fpmxcsr2str(fps.xstatus, buf, sizeof (buf)));
523 521
524 522 for (i = 0; i < 8; i++)
525 523 mdb_printf("%%xmm%d 0x%08x%08x%08x%08x\n", i,
526 524 fps.xmm[i][3], fps.xmm[i][2],
527 525 fps.xmm[i][1], fps.xmm[i][0]);
528 526
529 527 return (DCMD_OK);
530 528 }
531 529
532 530 /*ARGSUSED*/
533 531 int
534 532 pt_getfpreg(mdb_tgt_t *t, mdb_tgt_tid_t tid, ushort_t rd_num,
535 533 ushort_t rd_flags, mdb_tgt_reg_t *rp)
536 534 {
537 535 return (set_errno(ENOTSUP));
538 536 }
539 537
540 538 /*ARGSUSED*/
541 539 int
542 540 pt_putfpreg(mdb_tgt_t *t, mdb_tgt_tid_t tid, ushort_t rd_num,
543 541 ushort_t rd_flags, mdb_tgt_reg_t rval)
544 542 {
545 543 return (set_errno(ENOTSUP));
546 544 }
547 545
548 546 /*ARGSUSED*/
549 547 void
550 548 pt_addfpregs(mdb_tgt_t *t)
551 549 {
552 550 /* not implemented */
553 551 }
554 552
555 553 /*ARGSUSED*/
556 554 int
557 555 pt_frameregs(void *arglim, uintptr_t pc, uint_t argc, const long *argv,
558 556 const mdb_tgt_gregset_t *gregs, boolean_t pc_faked)
559 557 {
560 558 return (set_errno(ENOTSUP));
561 559 }
562 560
563 561 /*ARGSUSED*/
564 562 const char *
565 563 pt_disasm(const GElf_Ehdr *ehp)
566 564 {
567 565 return ("ia32");
568 566 }
569 567
570 568 /*
571 569 * Determine the return address for the current frame.
572 570 */
573 571 int
574 572 pt_step_out(mdb_tgt_t *t, uintptr_t *p)
575 573 {
576 574 const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp;
577 575
578 576 if (Pstate(t->t_pshandle) != PS_STOP)
579 577 return (set_errno(EMDB_TGTBUSY));
580 578
581 579 return (mdb_ia32_step_out(t, p, psp->pr_reg[EIP], psp->pr_reg[EBP],
582 580 psp->pr_reg[UESP], pt_read_instr(t)));
583 581 }
584 582
585 583 /*
586 584 * Return the address of the next instruction following a call, or return -1
587 585 * and set errno to EAGAIN if the target should just single-step.
588 586 */
589 587 int
590 588 pt_next(mdb_tgt_t *t, uintptr_t *p)
591 589 {
592 590 const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp;
593 591
594 592 if (Pstate(t->t_pshandle) != PS_STOP)
595 593 return (set_errno(EMDB_TGTBUSY));
596 594
597 595 return (mdb_ia32_next(t, p, psp->pr_reg[EIP], pt_read_instr(t)));
598 596 }
↓ open down ↓ |
334 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX