17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 260a47c91cSRobert Mustacchi /* 27*8f88a51fSJoshua M. Clulow * Copyright 2015 Joyent, Inc. 280a47c91cSRobert Mustacchi */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * User Process Target Intel 32-bit component 327c478bd9Sstevel@tonic-gate * 337c478bd9Sstevel@tonic-gate * This file provides the ISA-dependent portion of the user process target. 347c478bd9Sstevel@tonic-gate * For more details on the implementation refer to mdb_proc.c. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <mdb/mdb_proc.h> 387c478bd9Sstevel@tonic-gate #include <mdb/mdb_kreg.h> 397c478bd9Sstevel@tonic-gate #include <mdb/mdb_err.h> 407c478bd9Sstevel@tonic-gate #include <mdb/mdb_ia32util.h> 417c478bd9Sstevel@tonic-gate #include <mdb/mdb.h> 427c478bd9Sstevel@tonic-gate 43*8f88a51fSJoshua M. Clulow #include <sys/ucontext.h> 447c478bd9Sstevel@tonic-gate #include <sys/frame.h> 457c478bd9Sstevel@tonic-gate #include <libproc.h> 467c478bd9Sstevel@tonic-gate #include <sys/fp.h> 477c478bd9Sstevel@tonic-gate #include <ieeefp.h> 487c478bd9Sstevel@tonic-gate 49*8f88a51fSJoshua M. Clulow #include <stddef.h> 50*8f88a51fSJoshua M. Clulow 517c478bd9Sstevel@tonic-gate const mdb_tgt_regdesc_t pt_regdesc[] = { 527c478bd9Sstevel@tonic-gate { "gs", GS, MDB_TGT_R_EXPORT }, 537c478bd9Sstevel@tonic-gate { "fs", FS, MDB_TGT_R_EXPORT }, 547c478bd9Sstevel@tonic-gate { "es", ES, MDB_TGT_R_EXPORT }, 557c478bd9Sstevel@tonic-gate { "ds", DS, MDB_TGT_R_EXPORT }, 567c478bd9Sstevel@tonic-gate { "edi", EDI, MDB_TGT_R_EXPORT }, 570a47c91cSRobert Mustacchi { "di", EDI, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 587c478bd9Sstevel@tonic-gate { "esi", ESI, MDB_TGT_R_EXPORT }, 590a47c91cSRobert Mustacchi { "si", ESI, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 607c478bd9Sstevel@tonic-gate { "ebp", EBP, MDB_TGT_R_EXPORT }, 610a47c91cSRobert Mustacchi { "bp", EBP, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 627c478bd9Sstevel@tonic-gate { "kesp", ESP, MDB_TGT_R_EXPORT }, 630a47c91cSRobert Mustacchi { "ksp", ESP, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 647c478bd9Sstevel@tonic-gate { "ebx", EBX, MDB_TGT_R_EXPORT }, 650a47c91cSRobert Mustacchi { "bx", EBX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 660a47c91cSRobert Mustacchi { "bh", EBX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H }, 670a47c91cSRobert Mustacchi { "bl", EBX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L }, 687c478bd9Sstevel@tonic-gate { "edx", EDX, MDB_TGT_R_EXPORT }, 690a47c91cSRobert Mustacchi { "dx", EDX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 700a47c91cSRobert Mustacchi { "dh", EDX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H }, 710a47c91cSRobert Mustacchi { "dl", EDX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L }, 727c478bd9Sstevel@tonic-gate { "ecx", ECX, MDB_TGT_R_EXPORT }, 730a47c91cSRobert Mustacchi { "cx", ECX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 740a47c91cSRobert Mustacchi { "ch", ECX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H }, 750a47c91cSRobert Mustacchi { "cl", ECX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L }, 767c478bd9Sstevel@tonic-gate { "eax", EAX, MDB_TGT_R_EXPORT }, 770a47c91cSRobert Mustacchi { "ax", EAX, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 780a47c91cSRobert Mustacchi { "ah", EAX, MDB_TGT_R_EXPORT | MDB_TGT_R_8H }, 790a47c91cSRobert Mustacchi { "al", EAX, MDB_TGT_R_EXPORT | MDB_TGT_R_8L }, 807c478bd9Sstevel@tonic-gate { "trapno", TRAPNO, MDB_TGT_R_EXPORT }, 817c478bd9Sstevel@tonic-gate { "err", ERR, MDB_TGT_R_EXPORT }, 827c478bd9Sstevel@tonic-gate { "eip", EIP, MDB_TGT_R_EXPORT }, 837c478bd9Sstevel@tonic-gate { "cs", CS, MDB_TGT_R_EXPORT }, 847c478bd9Sstevel@tonic-gate { "eflags", EFL, MDB_TGT_R_EXPORT }, 857c478bd9Sstevel@tonic-gate { "esp", UESP, MDB_TGT_R_EXPORT }, 860a47c91cSRobert Mustacchi { "sp", UESP, MDB_TGT_R_EXPORT | MDB_TGT_R_16 }, 877c478bd9Sstevel@tonic-gate { "ss", SS, MDB_TGT_R_EXPORT }, 887c478bd9Sstevel@tonic-gate { NULL, 0, 0 } 897c478bd9Sstevel@tonic-gate }; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * We cannot rely on pr_instr, because if we hit a breakpoint or the user has 937c478bd9Sstevel@tonic-gate * artifically modified memory, it will no longer be correct. 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate static uint8_t 967c478bd9Sstevel@tonic-gate pt_read_instr(mdb_tgt_t *t) 977c478bd9Sstevel@tonic-gate { 987c478bd9Sstevel@tonic-gate const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp; 997c478bd9Sstevel@tonic-gate uint8_t ret = 0; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate (void) mdb_tgt_vread(t, &ret, sizeof (ret), psp->pr_reg[EIP]); 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate return (ret); 1047c478bd9Sstevel@tonic-gate } 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1077c478bd9Sstevel@tonic-gate int 1087c478bd9Sstevel@tonic-gate pt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1097c478bd9Sstevel@tonic-gate { 1107c478bd9Sstevel@tonic-gate mdb_tgt_t *t = mdb.m_target; 1117c478bd9Sstevel@tonic-gate mdb_tgt_tid_t tid; 1127c478bd9Sstevel@tonic-gate prgregset_t grs; 1137c478bd9Sstevel@tonic-gate prgreg_t eflags; 114*8f88a51fSJoshua M. Clulow boolean_t from_ucontext = B_FALSE; 1157c478bd9Sstevel@tonic-gate 116*8f88a51fSJoshua M. Clulow if (mdb_getopts(argc, argv, 117*8f88a51fSJoshua M. Clulow 'u', MDB_OPT_SETBITS, B_TRUE, &from_ucontext, NULL) != argc) { 1187c478bd9Sstevel@tonic-gate return (DCMD_USAGE); 119*8f88a51fSJoshua M. Clulow } 120*8f88a51fSJoshua M. Clulow 121*8f88a51fSJoshua M. Clulow if (from_ucontext) { 122*8f88a51fSJoshua M. Clulow int off; 123*8f88a51fSJoshua M. Clulow int o0, o1; 124*8f88a51fSJoshua M. Clulow 125*8f88a51fSJoshua M. Clulow if (!(flags & DCMD_ADDRSPEC)) { 126*8f88a51fSJoshua M. Clulow mdb_warn("-u requires a ucontext_t address\n"); 127*8f88a51fSJoshua M. Clulow return (DCMD_ERR); 128*8f88a51fSJoshua M. Clulow } 129*8f88a51fSJoshua M. Clulow 130*8f88a51fSJoshua M. Clulow o0 = mdb_ctf_offsetof_by_name("ucontext_t", "uc_mcontext"); 131*8f88a51fSJoshua M. Clulow o1 = mdb_ctf_offsetof_by_name("mcontext_t", "gregs"); 132*8f88a51fSJoshua M. Clulow if (o0 == -1 || o1 == -1) { 133*8f88a51fSJoshua M. Clulow off = offsetof(ucontext_t, uc_mcontext) + 134*8f88a51fSJoshua M. Clulow offsetof(mcontext_t, gregs); 135*8f88a51fSJoshua M. Clulow } else { 136*8f88a51fSJoshua M. Clulow off = o0 + o1; 137*8f88a51fSJoshua M. Clulow } 138*8f88a51fSJoshua M. Clulow 139*8f88a51fSJoshua M. Clulow if (mdb_vread(&grs, sizeof (grs), addr + off) != sizeof (grs)) { 140*8f88a51fSJoshua M. Clulow mdb_warn("failed to read from ucontext_t %p", addr); 141*8f88a51fSJoshua M. Clulow return (DCMD_ERR); 142*8f88a51fSJoshua M. Clulow } 143*8f88a51fSJoshua M. Clulow goto print_regs; 144*8f88a51fSJoshua M. Clulow } 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate if (t->t_pshandle == NULL || Pstate(t->t_pshandle) == PS_UNDEAD) { 1477c478bd9Sstevel@tonic-gate mdb_warn("no process active\n"); 1487c478bd9Sstevel@tonic-gate return (DCMD_ERR); 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate if (Pstate(t->t_pshandle) == PS_LOST) { 1527c478bd9Sstevel@tonic-gate mdb_warn("debugger has lost control of process\n"); 1537c478bd9Sstevel@tonic-gate return (DCMD_ERR); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate if (flags & DCMD_ADDRSPEC) 1577c478bd9Sstevel@tonic-gate tid = (mdb_tgt_tid_t)addr; 1587c478bd9Sstevel@tonic-gate else 1597c478bd9Sstevel@tonic-gate tid = PTL_TID(t); 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate if (PTL_GETREGS(t, tid, grs) != 0) { 1627c478bd9Sstevel@tonic-gate mdb_warn("failed to get current register set"); 1637c478bd9Sstevel@tonic-gate return (DCMD_ERR); 1647c478bd9Sstevel@tonic-gate } 1657c478bd9Sstevel@tonic-gate 166*8f88a51fSJoshua M. Clulow print_regs: 1677c478bd9Sstevel@tonic-gate eflags = grs[EFL]; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate mdb_printf("%%cs = 0x%04x\t\t%%eax = 0x%0?p %A\n", 1707c478bd9Sstevel@tonic-gate grs[CS], grs[EAX], grs[EAX]); 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate mdb_printf("%%ds = 0x%04x\t\t%%ebx = 0x%0?p %A\n", 1737c478bd9Sstevel@tonic-gate grs[DS], grs[EBX], grs[EBX]); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate mdb_printf("%%ss = 0x%04x\t\t%%ecx = 0x%0?p %A\n", 1767c478bd9Sstevel@tonic-gate grs[SS], grs[ECX], grs[ECX]); 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate mdb_printf("%%es = 0x%04x\t\t%%edx = 0x%0?p %A\n", 1797c478bd9Sstevel@tonic-gate grs[ES], grs[EDX], grs[EDX]); 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate mdb_printf("%%fs = 0x%04x\t\t%%esi = 0x%0?p %A\n", 1827c478bd9Sstevel@tonic-gate grs[FS], grs[ESI], grs[ESI]); 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate mdb_printf("%%gs = 0x%04x\t\t%%edi = 0x%0?p %A\n\n", 1857c478bd9Sstevel@tonic-gate grs[GS], grs[EDI], grs[EDI]); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate mdb_printf(" %%eip = 0x%0?p %A\n", grs[EIP], grs[EIP]); 1887c478bd9Sstevel@tonic-gate mdb_printf(" %%ebp = 0x%0?p\n", grs[EBP]); 1897c478bd9Sstevel@tonic-gate mdb_printf("%%kesp = 0x%0?p\n\n", grs[ESP]); 1907c478bd9Sstevel@tonic-gate mdb_printf("%%eflags = 0x%08x\n", eflags); 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate mdb_printf(" id=%u vip=%u vif=%u ac=%u vm=%u rf=%u nt=%u iopl=0x%x\n", 1937c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_ID_MASK) >> KREG_EFLAGS_ID_SHIFT, 1947c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_VIP_MASK) >> KREG_EFLAGS_VIP_SHIFT, 1957c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_VIF_MASK) >> KREG_EFLAGS_VIF_SHIFT, 1967c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_AC_MASK) >> KREG_EFLAGS_AC_SHIFT, 1977c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_VM_MASK) >> KREG_EFLAGS_VM_SHIFT, 1987c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_RF_MASK) >> KREG_EFLAGS_RF_SHIFT, 1997c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_NT_MASK) >> KREG_EFLAGS_NT_SHIFT, 2007c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_IOPL_MASK) >> KREG_EFLAGS_IOPL_SHIFT); 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate mdb_printf(" status=<%s,%s,%s,%s,%s,%s,%s,%s,%s>\n\n", 2037c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_OF_MASK) ? "OF" : "of", 2047c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_DF_MASK) ? "DF" : "df", 2057c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_IF_MASK) ? "IF" : "if", 2067c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_TF_MASK) ? "TF" : "tf", 2077c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_SF_MASK) ? "SF" : "sf", 2087c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_ZF_MASK) ? "ZF" : "zf", 2097c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_AF_MASK) ? "AF" : "af", 2107c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_PF_MASK) ? "PF" : "pf", 2117c478bd9Sstevel@tonic-gate (eflags & KREG_EFLAGS_CF_MASK) ? "CF" : "cf"); 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate mdb_printf(" %%esp = 0x%0?x\n", grs[UESP]); 2147c478bd9Sstevel@tonic-gate mdb_printf("%%trapno = 0x%x\n", grs[TRAPNO]); 2157c478bd9Sstevel@tonic-gate mdb_printf(" %%err = 0x%x\n", grs[ERR]); 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate return (DCMD_OK); 2187c478bd9Sstevel@tonic-gate } 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate static const char * 2217c478bd9Sstevel@tonic-gate fpcw2str(uint32_t cw, char *buf, size_t nbytes) 2227c478bd9Sstevel@tonic-gate { 2237c478bd9Sstevel@tonic-gate char *end = buf + nbytes; 2247c478bd9Sstevel@tonic-gate char *p = buf; 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate buf[0] = '\0'; 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate /* 2297c478bd9Sstevel@tonic-gate * Decode all masks in the 80387 control word. 2307c478bd9Sstevel@tonic-gate */ 2317c478bd9Sstevel@tonic-gate if (cw & FPIM) 2327c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|IM"); 2337c478bd9Sstevel@tonic-gate if (cw & FPDM) 2347c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|DM"); 2357c478bd9Sstevel@tonic-gate if (cw & FPZM) 2367c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|ZM"); 2377c478bd9Sstevel@tonic-gate if (cw & FPOM) 2387c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|OM"); 2397c478bd9Sstevel@tonic-gate if (cw & FPUM) 2407c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|UM"); 2417c478bd9Sstevel@tonic-gate if (cw & FPPM) 2427c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|PM"); 2437c478bd9Sstevel@tonic-gate if (cw & FPPC) 2447c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|PC"); 2457c478bd9Sstevel@tonic-gate if (cw & FPRC) 2467c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RC"); 2477c478bd9Sstevel@tonic-gate if (cw & FPIC) 2487c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|IC"); 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate /* 2517c478bd9Sstevel@tonic-gate * Decode precision, rounding, and infinity options in control word. 2527c478bd9Sstevel@tonic-gate */ 2537c478bd9Sstevel@tonic-gate if (cw & FPSIG24) 2547c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|SIG24"); 2557c478bd9Sstevel@tonic-gate if (cw & FPSIG53) 2567c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|SIG53"); 2577c478bd9Sstevel@tonic-gate if (cw & FPSIG64) 2587c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|SIG64"); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate if ((cw & FPRC) == (FPRD|FPRU)) 2617c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RTZ"); 2627c478bd9Sstevel@tonic-gate else if (cw & FPRD) 2637c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RD"); 2647c478bd9Sstevel@tonic-gate else if (cw & FPRU) 2657c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RU"); 2667c478bd9Sstevel@tonic-gate else 2677c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RTN"); 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate if (cw & FPA) 2707c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|A"); 2717c478bd9Sstevel@tonic-gate else 2727c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|P"); 2737c478bd9Sstevel@tonic-gate if (cw & WFPB17) 2747c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|WFPB17"); 2757c478bd9Sstevel@tonic-gate if (cw & WFPB24) 2767c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|WFPB24"); 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate if (buf[0] == '|') 2797c478bd9Sstevel@tonic-gate return (buf + 1); 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate return ("0"); 2827c478bd9Sstevel@tonic-gate } 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate static const char * 2857c478bd9Sstevel@tonic-gate fpsw2str(uint32_t cw, char *buf, size_t nbytes) 2867c478bd9Sstevel@tonic-gate { 2877c478bd9Sstevel@tonic-gate char *end = buf + nbytes; 2887c478bd9Sstevel@tonic-gate char *p = buf; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate buf[0] = '\0'; 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate * Decode all masks in the 80387 status word. 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate if (cw & FPS_IE) 2967c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|IE"); 2977c478bd9Sstevel@tonic-gate if (cw & FPS_DE) 2987c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|DE"); 2997c478bd9Sstevel@tonic-gate if (cw & FPS_ZE) 3007c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|ZE"); 3017c478bd9Sstevel@tonic-gate if (cw & FPS_OE) 3027c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|OE"); 3037c478bd9Sstevel@tonic-gate if (cw & FPS_UE) 3047c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|UE"); 3057c478bd9Sstevel@tonic-gate if (cw & FPS_PE) 3067c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|PE"); 3077c478bd9Sstevel@tonic-gate if (cw & FPS_SF) 3087c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|SF"); 3097c478bd9Sstevel@tonic-gate if (cw & FPS_ES) 3107c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|ES"); 3117c478bd9Sstevel@tonic-gate if (cw & FPS_C0) 3127c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|C0"); 3137c478bd9Sstevel@tonic-gate if (cw & FPS_C1) 3147c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|C1"); 3157c478bd9Sstevel@tonic-gate if (cw & FPS_C2) 3167c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|C2"); 3177c478bd9Sstevel@tonic-gate if (cw & FPS_C3) 3187c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|C3"); 3197c478bd9Sstevel@tonic-gate if (cw & FPS_B) 3207c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|B"); 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate if (buf[0] == '|') 3237c478bd9Sstevel@tonic-gate return (buf + 1); 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate return ("0"); 3267c478bd9Sstevel@tonic-gate } 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate static const char * 3297c478bd9Sstevel@tonic-gate fpmxcsr2str(uint32_t mxcsr, char *buf, size_t nbytes) 3307c478bd9Sstevel@tonic-gate { 3317c478bd9Sstevel@tonic-gate char *end = buf + nbytes; 3327c478bd9Sstevel@tonic-gate char *p = buf; 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate buf[0] = '\0'; 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate /* 3377c478bd9Sstevel@tonic-gate * Decode the MXCSR word 3387c478bd9Sstevel@tonic-gate */ 3397c478bd9Sstevel@tonic-gate if (mxcsr & SSE_IE) 3407c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|IE"); 3417c478bd9Sstevel@tonic-gate if (mxcsr & SSE_DE) 3427c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|DE"); 3437c478bd9Sstevel@tonic-gate if (mxcsr & SSE_ZE) 3447c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|ZE"); 3457c478bd9Sstevel@tonic-gate if (mxcsr & SSE_OE) 3467c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|OE"); 3477c478bd9Sstevel@tonic-gate if (mxcsr & SSE_UE) 3487c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|UE"); 3497c478bd9Sstevel@tonic-gate if (mxcsr & SSE_PE) 3507c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|PE"); 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate if (mxcsr & SSE_DAZ) 3537c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|DAZ"); 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate if (mxcsr & SSE_IM) 3567c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|IM"); 3577c478bd9Sstevel@tonic-gate if (mxcsr & SSE_DM) 3587c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|DM"); 3597c478bd9Sstevel@tonic-gate if (mxcsr & SSE_ZM) 3607c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|ZM"); 3617c478bd9Sstevel@tonic-gate if (mxcsr & SSE_OM) 3627c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|OM"); 3637c478bd9Sstevel@tonic-gate if (mxcsr & SSE_UM) 3647c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|UM"); 3657c478bd9Sstevel@tonic-gate if (mxcsr & SSE_PM) 3667c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|PM"); 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate if ((mxcsr & SSE_RC) == (SSE_RD|SSE_RU)) 3697c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RTZ"); 3707c478bd9Sstevel@tonic-gate else if (mxcsr & SSE_RD) 3717c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RD"); 3727c478bd9Sstevel@tonic-gate else if (mxcsr & SSE_RU) 3737c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RU"); 3747c478bd9Sstevel@tonic-gate else 3757c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|RTN"); 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate if (mxcsr & SSE_FZ) 3787c478bd9Sstevel@tonic-gate p += mdb_snprintf(p, (size_t)(end - p), "|FZ"); 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate if (buf[0] == '|') 3817c478bd9Sstevel@tonic-gate return (buf + 1); 3827c478bd9Sstevel@tonic-gate return ("0"); 3837c478bd9Sstevel@tonic-gate } 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 3867c478bd9Sstevel@tonic-gate int 3877c478bd9Sstevel@tonic-gate pt_fpregs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 3887c478bd9Sstevel@tonic-gate { 3897c478bd9Sstevel@tonic-gate mdb_tgt_t *t = mdb.m_target; 3907c478bd9Sstevel@tonic-gate mdb_tgt_tid_t tid; 3917c478bd9Sstevel@tonic-gate uint32_t hw = FP_NO; 3927c478bd9Sstevel@tonic-gate uint_t sse = 0; 3937c478bd9Sstevel@tonic-gate prfpregset_t fprs; 3947c478bd9Sstevel@tonic-gate struct _fpstate fps; 3957c478bd9Sstevel@tonic-gate char buf[256]; 3967c478bd9Sstevel@tonic-gate uint_t top; 3977c478bd9Sstevel@tonic-gate int i; 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate /* 4007c478bd9Sstevel@tonic-gate * Union for overlaying _fpreg structure on to quad-precision 4017c478bd9Sstevel@tonic-gate * floating-point value (long double). 4027c478bd9Sstevel@tonic-gate */ 4037c478bd9Sstevel@tonic-gate union { 4047c478bd9Sstevel@tonic-gate struct _fpreg reg; 4057c478bd9Sstevel@tonic-gate long double ld; 4067c478bd9Sstevel@tonic-gate } fpru; 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate /* 4097c478bd9Sstevel@tonic-gate * Array of strings corresponding to FPU tag word values (see 4107c478bd9Sstevel@tonic-gate * section 7.3.6 of the Intel Programmer's Reference Manual). 4117c478bd9Sstevel@tonic-gate */ 4127c478bd9Sstevel@tonic-gate const char *tag_strings[] = { "valid", "zero", "special", "empty" }; 4137c478bd9Sstevel@tonic-gate 4147c478bd9Sstevel@tonic-gate if (argc != 0) 4157c478bd9Sstevel@tonic-gate return (DCMD_USAGE); 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate if (t->t_pshandle == NULL || Pstate(t->t_pshandle) == PS_UNDEAD) { 4187c478bd9Sstevel@tonic-gate mdb_warn("no process active\n"); 4197c478bd9Sstevel@tonic-gate return (DCMD_ERR); 4207c478bd9Sstevel@tonic-gate } 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate if (Pstate(t->t_pshandle) == PS_LOST) { 4237c478bd9Sstevel@tonic-gate mdb_warn("debugger has lost control of process\n"); 4247c478bd9Sstevel@tonic-gate return (DCMD_ERR); 4257c478bd9Sstevel@tonic-gate } 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate if (flags & DCMD_ADDRSPEC) 4287c478bd9Sstevel@tonic-gate tid = (mdb_tgt_tid_t)addr; 4297c478bd9Sstevel@tonic-gate else 4307c478bd9Sstevel@tonic-gate tid = PTL_TID(t); 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &hw, 4337c478bd9Sstevel@tonic-gate sizeof (hw), "libc.so", "_fp_hw") < 0 && 4347c478bd9Sstevel@tonic-gate mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &hw, 4357c478bd9Sstevel@tonic-gate sizeof (hw), MDB_TGT_OBJ_EXEC, "_fp_hw") < 0) 4367c478bd9Sstevel@tonic-gate mdb_warn("failed to read _fp_hw value"); 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &sse, 4397c478bd9Sstevel@tonic-gate sizeof (sse), "libc.so", "_sse_hw") < 0 && 4407c478bd9Sstevel@tonic-gate mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &sse, 4417c478bd9Sstevel@tonic-gate sizeof (sse), MDB_TGT_OBJ_EXEC, "_sse_hw") < 0) 4427c478bd9Sstevel@tonic-gate mdb_warn("failed to read _sse_hw value"); 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate mdb_printf("_fp_hw 0x%02x (", hw); 4457c478bd9Sstevel@tonic-gate switch (hw) { 4467c478bd9Sstevel@tonic-gate case FP_SW: 4477c478bd9Sstevel@tonic-gate mdb_printf("80387 software emulator"); 4487c478bd9Sstevel@tonic-gate break; 4497c478bd9Sstevel@tonic-gate case FP_287: 4507c478bd9Sstevel@tonic-gate mdb_printf("80287 chip"); 4517c478bd9Sstevel@tonic-gate break; 4527c478bd9Sstevel@tonic-gate case FP_387: 4537c478bd9Sstevel@tonic-gate mdb_printf("80387 chip"); 4547c478bd9Sstevel@tonic-gate break; 4557c478bd9Sstevel@tonic-gate case FP_486: 4567c478bd9Sstevel@tonic-gate mdb_printf("80486 chip"); 4577c478bd9Sstevel@tonic-gate break; 4587c478bd9Sstevel@tonic-gate default: 4597c478bd9Sstevel@tonic-gate mdb_printf("no floating point support"); 4607c478bd9Sstevel@tonic-gate break; 4617c478bd9Sstevel@tonic-gate } 4627c478bd9Sstevel@tonic-gate if (sse) 4637c478bd9Sstevel@tonic-gate mdb_printf(" with SSE"); 4647c478bd9Sstevel@tonic-gate mdb_printf(")\n"); 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate if (!(hw & FP_HW)) 4677c478bd9Sstevel@tonic-gate return (DCMD_OK); /* just abort if no hardware present */ 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate if (PTL_GETFPREGS(t, tid, &fprs) != 0) { 4707c478bd9Sstevel@tonic-gate mdb_warn("failed to get floating point registers"); 4717c478bd9Sstevel@tonic-gate return (DCMD_ERR); 4727c478bd9Sstevel@tonic-gate } 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate bcopy(&fprs.fp_reg_set.fpchip_state, &fps, sizeof (fps)); 4757c478bd9Sstevel@tonic-gate 4767c478bd9Sstevel@tonic-gate fps.cw &= 0xffff; /* control word is really 16 bits */ 4777c478bd9Sstevel@tonic-gate fps.sw &= 0xffff; /* status word is really 16 bits */ 4787c478bd9Sstevel@tonic-gate fps.status &= 0xffff; /* saved status word is really 16 bits */ 4797c478bd9Sstevel@tonic-gate fps.cssel &= 0xffff; /* %cs is really 16-bits */ 4807c478bd9Sstevel@tonic-gate fps.datasel &= 0xffff; /* %ds is really 16-bits too */ 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate mdb_printf("cw 0x%04x (%s)\n", fps.cw, 4837c478bd9Sstevel@tonic-gate fpcw2str(fps.cw, buf, sizeof (buf))); 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate top = (fps.sw & FPS_TOP) >> 11; 4867c478bd9Sstevel@tonic-gate mdb_printf("sw 0x%04x (TOP=0t%u) (%s)\n", fps.sw, 4877c478bd9Sstevel@tonic-gate top, fpsw2str(fps.sw, buf, sizeof (buf))); 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate mdb_printf("xcp sw 0x%04x (%s)\n\n", fps.status, 4907c478bd9Sstevel@tonic-gate fpsw2str(fps.status, buf, sizeof (buf))); 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate mdb_printf("ipoff %a\n", fps.ipoff); 4937c478bd9Sstevel@tonic-gate mdb_printf("cssel 0x%x\n", fps.cssel); 4947c478bd9Sstevel@tonic-gate mdb_printf("dtoff %a\n", fps.dataoff); 4957c478bd9Sstevel@tonic-gate mdb_printf("dtsel 0x%x\n\n", fps.datasel); 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate for (i = 0; i < 8; i++) { 4987c478bd9Sstevel@tonic-gate /* 4997c478bd9Sstevel@tonic-gate * Recall that we need to use the current TOP-of-stack value to 5007c478bd9Sstevel@tonic-gate * associate the _st[] index back to a physical register number, 5017c478bd9Sstevel@tonic-gate * since tag word indices are physical register numbers. Then 5027c478bd9Sstevel@tonic-gate * to get the tag value, we shift over two bits for each tag 5037c478bd9Sstevel@tonic-gate * index, and then grab the bottom two bits. 5047c478bd9Sstevel@tonic-gate */ 5057c478bd9Sstevel@tonic-gate uint_t tag_index = (i + top) & 7; 5067c478bd9Sstevel@tonic-gate uint_t tag_value = (fps.tag >> (tag_index * 2)) & 3; 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate fpru.reg = fps._st[i]; 5097c478bd9Sstevel@tonic-gate mdb_printf("%%st%d 0x%04x.%04x%04x%04x%04x = %lg %s\n", 5107c478bd9Sstevel@tonic-gate i, fpru.reg.exponent, 5117c478bd9Sstevel@tonic-gate fpru.reg.significand[3], fpru.reg.significand[2], 5127c478bd9Sstevel@tonic-gate fpru.reg.significand[1], fpru.reg.significand[0], 5137c478bd9Sstevel@tonic-gate fpru.ld, tag_strings[tag_value]); 5147c478bd9Sstevel@tonic-gate } 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate if (!sse) 5177c478bd9Sstevel@tonic-gate return (DCMD_OK); 5187c478bd9Sstevel@tonic-gate 5197c478bd9Sstevel@tonic-gate mdb_printf("\nmxcsr 0x%04x (%s)\n", fps.mxcsr, 5207c478bd9Sstevel@tonic-gate fpmxcsr2str(fps.mxcsr, buf, sizeof (buf))); 5217c478bd9Sstevel@tonic-gate mdb_printf("xcp 0x%04x (%s)\n\n", fps.xstatus, 5227c478bd9Sstevel@tonic-gate fpmxcsr2str(fps.xstatus, buf, sizeof (buf))); 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate for (i = 0; i < 8; i++) 5257c478bd9Sstevel@tonic-gate mdb_printf("%%xmm%d 0x%08x%08x%08x%08x\n", i, 5267c478bd9Sstevel@tonic-gate fps.xmm[i][3], fps.xmm[i][2], 5277c478bd9Sstevel@tonic-gate fps.xmm[i][1], fps.xmm[i][0]); 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate return (DCMD_OK); 5307c478bd9Sstevel@tonic-gate } 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5337c478bd9Sstevel@tonic-gate int 5347c478bd9Sstevel@tonic-gate pt_getfpreg(mdb_tgt_t *t, mdb_tgt_tid_t tid, ushort_t rd_num, 5357c478bd9Sstevel@tonic-gate ushort_t rd_flags, mdb_tgt_reg_t *rp) 5367c478bd9Sstevel@tonic-gate { 5377c478bd9Sstevel@tonic-gate return (set_errno(ENOTSUP)); 5387c478bd9Sstevel@tonic-gate } 5397c478bd9Sstevel@tonic-gate 5407c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5417c478bd9Sstevel@tonic-gate int 5427c478bd9Sstevel@tonic-gate pt_putfpreg(mdb_tgt_t *t, mdb_tgt_tid_t tid, ushort_t rd_num, 5437c478bd9Sstevel@tonic-gate ushort_t rd_flags, mdb_tgt_reg_t rval) 5447c478bd9Sstevel@tonic-gate { 5457c478bd9Sstevel@tonic-gate return (set_errno(ENOTSUP)); 5467c478bd9Sstevel@tonic-gate } 5477c478bd9Sstevel@tonic-gate 5487c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5497c478bd9Sstevel@tonic-gate void 5507c478bd9Sstevel@tonic-gate pt_addfpregs(mdb_tgt_t *t) 5517c478bd9Sstevel@tonic-gate { 5527c478bd9Sstevel@tonic-gate /* not implemented */ 5537c478bd9Sstevel@tonic-gate } 5547c478bd9Sstevel@tonic-gate 5557c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5567c478bd9Sstevel@tonic-gate int 5577c478bd9Sstevel@tonic-gate pt_frameregs(void *arglim, uintptr_t pc, uint_t argc, const long *argv, 5587c478bd9Sstevel@tonic-gate const mdb_tgt_gregset_t *gregs, boolean_t pc_faked) 5597c478bd9Sstevel@tonic-gate { 5607c478bd9Sstevel@tonic-gate return (set_errno(ENOTSUP)); 5617c478bd9Sstevel@tonic-gate } 5627c478bd9Sstevel@tonic-gate 5637c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5647c478bd9Sstevel@tonic-gate const char * 5657c478bd9Sstevel@tonic-gate pt_disasm(const GElf_Ehdr *ehp) 5667c478bd9Sstevel@tonic-gate { 5677c478bd9Sstevel@tonic-gate return ("ia32"); 5687c478bd9Sstevel@tonic-gate } 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate /* 5717c478bd9Sstevel@tonic-gate * Determine the return address for the current frame. 5727c478bd9Sstevel@tonic-gate */ 5737c478bd9Sstevel@tonic-gate int 5747c478bd9Sstevel@tonic-gate pt_step_out(mdb_tgt_t *t, uintptr_t *p) 5757c478bd9Sstevel@tonic-gate { 5767c478bd9Sstevel@tonic-gate const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp; 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate if (Pstate(t->t_pshandle) != PS_STOP) 5797c478bd9Sstevel@tonic-gate return (set_errno(EMDB_TGTBUSY)); 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate return (mdb_ia32_step_out(t, p, psp->pr_reg[EIP], psp->pr_reg[EBP], 5827c478bd9Sstevel@tonic-gate psp->pr_reg[UESP], pt_read_instr(t))); 5837c478bd9Sstevel@tonic-gate } 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate /* 5867c478bd9Sstevel@tonic-gate * Return the address of the next instruction following a call, or return -1 5877c478bd9Sstevel@tonic-gate * and set errno to EAGAIN if the target should just single-step. 5887c478bd9Sstevel@tonic-gate */ 5897c478bd9Sstevel@tonic-gate int 5907c478bd9Sstevel@tonic-gate pt_next(mdb_tgt_t *t, uintptr_t *p) 5917c478bd9Sstevel@tonic-gate { 5927c478bd9Sstevel@tonic-gate const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp; 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate if (Pstate(t->t_pshandle) != PS_STOP) 5957c478bd9Sstevel@tonic-gate return (set_errno(EMDB_TGTBUSY)); 5967c478bd9Sstevel@tonic-gate 5977c478bd9Sstevel@tonic-gate return (mdb_ia32_next(t, p, psp->pr_reg[EIP], pt_read_instr(t))); 5987c478bd9Sstevel@tonic-gate } 599