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 5004388ebScasper * Common Development and Distribution License (the "License"). 6004388ebScasper * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21657b1f3dSraf 227c478bd9Sstevel@tonic-gate /* 23bc5ed3ddSRoger A. Faulkner * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*f971a346SBryan Cantrill /* 28*f971a346SBryan Cantrill * Copyright (c) 2013, Joyent, Inc. All rights reserved. 29*f971a346SBryan Cantrill */ 30*f971a346SBryan Cantrill 317c478bd9Sstevel@tonic-gate #include <stdio.h> 32004388ebScasper #include <stdio_ext.h> 337c478bd9Sstevel@tonic-gate #include <stdlib.h> 347c478bd9Sstevel@tonic-gate #include <unistd.h> 357c478bd9Sstevel@tonic-gate #include <ctype.h> 367c478bd9Sstevel@tonic-gate #include <fcntl.h> 377c478bd9Sstevel@tonic-gate #include <strings.h> 387c478bd9Sstevel@tonic-gate #include <dirent.h> 397c478bd9Sstevel@tonic-gate #include <errno.h> 407c478bd9Sstevel@tonic-gate #include <sys/types.h> 417c478bd9Sstevel@tonic-gate #include <sys/int_fmtio.h> 427c478bd9Sstevel@tonic-gate #include <libproc.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate typedef struct look_arg { 457c478bd9Sstevel@tonic-gate int pflags; 467c478bd9Sstevel@tonic-gate const char *lwps; 477c478bd9Sstevel@tonic-gate int count; 487c478bd9Sstevel@tonic-gate } look_arg_t; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate static int look(char *); 517c478bd9Sstevel@tonic-gate static int lwplook(look_arg_t *, const lwpstatus_t *, const lwpsinfo_t *); 527c478bd9Sstevel@tonic-gate static char *prflags(int); 537c478bd9Sstevel@tonic-gate static char *prwhy(int); 547c478bd9Sstevel@tonic-gate static char *prwhat(int, int); 557c478bd9Sstevel@tonic-gate static void dumpregs(const prgregset_t, int); 567c478bd9Sstevel@tonic-gate #if defined(__sparc) && defined(_ILP32) 577c478bd9Sstevel@tonic-gate static void dumpregs_v8p(const prgregset_t, const prxregset_t *, int); 587c478bd9Sstevel@tonic-gate #endif 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate static char *command; 617c478bd9Sstevel@tonic-gate static struct ps_prochandle *Pr; 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate static int is64; /* Is current process 64-bit? */ 647c478bd9Sstevel@tonic-gate static int rflag; /* Show registers? */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define LWPFLAGS \ 677c478bd9Sstevel@tonic-gate (PR_STOPPED|PR_ISTOP|PR_DSTOP|PR_ASLEEP|PR_PCINVAL|PR_STEP \ 68657b1f3dSraf |PR_AGENT|PR_DETACH|PR_DAEMON) 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate #define PROCFLAGS \ 71657b1f3dSraf (PR_ISSYS|PR_VFORKP|PR_ORPHAN|PR_NOSIGCHLD|PR_WAITPID \ 72657b1f3dSraf |PR_FORK|PR_RLC|PR_KLC|PR_ASYNC|PR_BPTADJ|PR_MSACCT|PR_MSFORK|PR_PTRACE) 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define ALLFLAGS (LWPFLAGS|PROCFLAGS) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate int 777c478bd9Sstevel@tonic-gate main(int argc, char **argv) 787c478bd9Sstevel@tonic-gate { 797c478bd9Sstevel@tonic-gate int rc = 0; 807c478bd9Sstevel@tonic-gate int errflg = 0; 817c478bd9Sstevel@tonic-gate int opt; 827c478bd9Sstevel@tonic-gate struct rlimit rlim; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate if ((command = strrchr(argv[0], '/')) != NULL) 857c478bd9Sstevel@tonic-gate command++; 867c478bd9Sstevel@tonic-gate else 877c478bd9Sstevel@tonic-gate command = argv[0]; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* options */ 907c478bd9Sstevel@tonic-gate while ((opt = getopt(argc, argv, "r")) != EOF) { 917c478bd9Sstevel@tonic-gate switch (opt) { 927c478bd9Sstevel@tonic-gate case 'r': /* show registers */ 937c478bd9Sstevel@tonic-gate rflag = 1; 947c478bd9Sstevel@tonic-gate break; 957c478bd9Sstevel@tonic-gate default: 967c478bd9Sstevel@tonic-gate errflg = 1; 977c478bd9Sstevel@tonic-gate break; 987c478bd9Sstevel@tonic-gate } 997c478bd9Sstevel@tonic-gate } 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate argc -= optind; 1027c478bd9Sstevel@tonic-gate argv += optind; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate if (errflg || argc <= 0) { 1057c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 1067c478bd9Sstevel@tonic-gate "usage:\t%s [-r] { pid | core }[/lwps] ...\n", command); 1077c478bd9Sstevel@tonic-gate (void) fprintf(stderr, " (report process status flags)\n"); 1087c478bd9Sstevel@tonic-gate (void) fprintf(stderr, " -r : report registers\n"); 1097c478bd9Sstevel@tonic-gate return (2); 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate /* 1137c478bd9Sstevel@tonic-gate * Make sure we'll have enough file descriptors to handle a target 1147c478bd9Sstevel@tonic-gate * that has many many mappings. 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) { 1177c478bd9Sstevel@tonic-gate rlim.rlim_cur = rlim.rlim_max; 1187c478bd9Sstevel@tonic-gate (void) setrlimit(RLIMIT_NOFILE, &rlim); 119004388ebScasper (void) enable_extended_FILE_stdio(-1, -1); 1207c478bd9Sstevel@tonic-gate } 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate while (argc-- > 0) 1237c478bd9Sstevel@tonic-gate rc += look(*argv++); 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate return (rc); 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate static int 1297c478bd9Sstevel@tonic-gate look(char *arg) 1307c478bd9Sstevel@tonic-gate { 1317c478bd9Sstevel@tonic-gate int gcode; 1327c478bd9Sstevel@tonic-gate int gcode2; 1337c478bd9Sstevel@tonic-gate pstatus_t pstatus; 1347c478bd9Sstevel@tonic-gate psinfo_t psinfo; 1357c478bd9Sstevel@tonic-gate int flags; 1367c478bd9Sstevel@tonic-gate sigset_t sigmask; 1377c478bd9Sstevel@tonic-gate fltset_t fltmask; 1387c478bd9Sstevel@tonic-gate sysset_t entryset; 1397c478bd9Sstevel@tonic-gate sysset_t exitset; 140bc5ed3ddSRoger A. Faulkner uint32_t sigtrace, sigtrace1, sigtrace2, fltbits; 141bc5ed3ddSRoger A. Faulkner uint32_t sigpend, sigpend1, sigpend2; 1427c478bd9Sstevel@tonic-gate uint32_t *bits; 1437c478bd9Sstevel@tonic-gate char buf[PRSIGBUFSZ]; 1447c478bd9Sstevel@tonic-gate look_arg_t lookarg; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate if ((Pr = proc_arg_xgrab(arg, NULL, PR_ARG_ANY, 1477c478bd9Sstevel@tonic-gate PGRAB_RETAIN | PGRAB_FORCE | PGRAB_RDONLY | PGRAB_NOSTOP, &gcode, 1487c478bd9Sstevel@tonic-gate &lookarg.lwps)) == NULL) { 1497c478bd9Sstevel@tonic-gate if (gcode == G_NOPROC && 1507c478bd9Sstevel@tonic-gate proc_arg_psinfo(arg, PR_ARG_PIDS, &psinfo, &gcode2) > 0 && 1517c478bd9Sstevel@tonic-gate psinfo.pr_nlwp == 0) { 1527c478bd9Sstevel@tonic-gate (void) printf("%d:\t<defunct>\n\n", (int)psinfo.pr_pid); 1537c478bd9Sstevel@tonic-gate return (0); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: cannot examine %s: %s\n", 1567c478bd9Sstevel@tonic-gate command, arg, Pgrab_error(gcode)); 1577c478bd9Sstevel@tonic-gate return (1); 1587c478bd9Sstevel@tonic-gate } 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate (void) memcpy(&pstatus, Pstatus(Pr), sizeof (pstatus_t)); 1617c478bd9Sstevel@tonic-gate (void) memcpy(&psinfo, Ppsinfo(Pr), sizeof (psinfo_t)); 1627c478bd9Sstevel@tonic-gate proc_unctrl_psinfo(&psinfo); 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate if (psinfo.pr_nlwp == 0) { 1657c478bd9Sstevel@tonic-gate (void) printf("%d:\t<defunct>\n\n", (int)psinfo.pr_pid); 1667c478bd9Sstevel@tonic-gate Prelease(Pr, PRELEASE_RETAIN); 1677c478bd9Sstevel@tonic-gate return (0); 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate is64 = (pstatus.pr_dmodel == PR_MODEL_LP64); 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate sigmask = pstatus.pr_sigtrace; 1737c478bd9Sstevel@tonic-gate fltmask = pstatus.pr_flttrace; 1747c478bd9Sstevel@tonic-gate entryset = pstatus.pr_sysentry; 1757c478bd9Sstevel@tonic-gate exitset = pstatus.pr_sysexit; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate if (Pstate(Pr) == PS_DEAD) { 1787c478bd9Sstevel@tonic-gate (void) printf("core '%s' of %d:\t%.70s\n", 1797c478bd9Sstevel@tonic-gate arg, (int)psinfo.pr_pid, psinfo.pr_psargs); 1807c478bd9Sstevel@tonic-gate } else { 1817c478bd9Sstevel@tonic-gate (void) printf("%d:\t%.70s\n", 1827c478bd9Sstevel@tonic-gate (int)psinfo.pr_pid, psinfo.pr_psargs); 1837c478bd9Sstevel@tonic-gate } 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate (void) printf("\tdata model = %s", is64? "_LP64" : "_ILP32"); 1867c478bd9Sstevel@tonic-gate if ((flags = (pstatus.pr_flags & PROCFLAGS)) != 0) 1877c478bd9Sstevel@tonic-gate (void) printf(" flags = %s", prflags(flags)); 1887c478bd9Sstevel@tonic-gate (void) printf("\n"); 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate fltbits = *((uint32_t *)&fltmask); 1917c478bd9Sstevel@tonic-gate if (fltbits) 1927c478bd9Sstevel@tonic-gate (void) printf("\tflttrace = 0x%.8x\n", fltbits); 1937c478bd9Sstevel@tonic-gate 194bc5ed3ddSRoger A. Faulkner #if (MAXSIG > 2 * 32) && (MAXSIG <= 3 * 32) /* assumption */ 1957c478bd9Sstevel@tonic-gate sigtrace = *((uint32_t *)&sigmask); 196bc5ed3ddSRoger A. Faulkner sigtrace1 = *((uint32_t *)&sigmask + 1); 197bc5ed3ddSRoger A. Faulkner sigtrace2 = *((uint32_t *)&sigmask + 2); 198bc5ed3ddSRoger A. Faulkner #else 199bc5ed3ddSRoger A. Faulkner #error "fix me: MAXSIG out of bounds" 200bc5ed3ddSRoger A. Faulkner #endif 201bc5ed3ddSRoger A. Faulkner if (sigtrace | sigtrace1 | sigtrace2) 202bc5ed3ddSRoger A. Faulkner (void) printf("\tsigtrace = 0x%.8x 0x%.8x 0x%.8x\n\t %s\n", 203bc5ed3ddSRoger A. Faulkner sigtrace, sigtrace1, sigtrace2, 2047c478bd9Sstevel@tonic-gate proc_sigset2str(&sigmask, "|", 1, buf, sizeof (buf))); 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate bits = ((uint32_t *)&entryset); 2077c478bd9Sstevel@tonic-gate if (bits[0] | bits[1] | bits[2] | bits[3] | 2087c478bd9Sstevel@tonic-gate bits[4] | bits[5] | bits[6] | bits[7]) 2097c478bd9Sstevel@tonic-gate (void) printf( 2107c478bd9Sstevel@tonic-gate "\tentryset = " 2117c478bd9Sstevel@tonic-gate "0x%.8x 0x%.8x 0x%.8x 0x%.8x\n" 2127c478bd9Sstevel@tonic-gate "\t " 2137c478bd9Sstevel@tonic-gate "0x%.8x 0x%.8x 0x%.8x 0x%.8x\n", 2147c478bd9Sstevel@tonic-gate bits[0], bits[1], bits[2], bits[3], 2157c478bd9Sstevel@tonic-gate bits[4], bits[5], bits[6], bits[7]); 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate bits = ((uint32_t *)&exitset); 2187c478bd9Sstevel@tonic-gate if (bits[0] | bits[1] | bits[2] | bits[3] | 2197c478bd9Sstevel@tonic-gate bits[4] | bits[5] | bits[6] | bits[7]) 2207c478bd9Sstevel@tonic-gate (void) printf( 2217c478bd9Sstevel@tonic-gate "\texitset = " 2227c478bd9Sstevel@tonic-gate "0x%.8x 0x%.8x 0x%.8x 0x%.8x\n" 2237c478bd9Sstevel@tonic-gate "\t " 2247c478bd9Sstevel@tonic-gate "0x%.8x 0x%.8x 0x%.8x 0x%.8x\n", 2257c478bd9Sstevel@tonic-gate bits[0], bits[1], bits[2], bits[3], 2267c478bd9Sstevel@tonic-gate bits[4], bits[5], bits[6], bits[7]); 2277c478bd9Sstevel@tonic-gate 228bc5ed3ddSRoger A. Faulkner #if (MAXSIG > 2 * 32) && (MAXSIG <= 3 * 32) /* assumption */ 2297c478bd9Sstevel@tonic-gate sigpend = *((uint32_t *)&pstatus.pr_sigpend); 230bc5ed3ddSRoger A. Faulkner sigpend1 = *((uint32_t *)&pstatus.pr_sigpend + 1); 231bc5ed3ddSRoger A. Faulkner sigpend2 = *((uint32_t *)&pstatus.pr_sigpend + 2); 232bc5ed3ddSRoger A. Faulkner #else 233bc5ed3ddSRoger A. Faulkner #error "fix me: MAXSIG out of bounds" 234bc5ed3ddSRoger A. Faulkner #endif 235bc5ed3ddSRoger A. Faulkner if (sigpend | sigpend1 | sigpend2) 236bc5ed3ddSRoger A. Faulkner (void) printf("\tsigpend = 0x%.8x,0x%.8x,0x%.8x\n", 237bc5ed3ddSRoger A. Faulkner sigpend, sigpend1, sigpend2); 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate lookarg.pflags = pstatus.pr_flags; 2407c478bd9Sstevel@tonic-gate lookarg.count = 0; 2417c478bd9Sstevel@tonic-gate (void) Plwp_iter_all(Pr, (proc_lwp_all_f *)lwplook, &lookarg); 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate if (lookarg.count == 0) 2447c478bd9Sstevel@tonic-gate (void) printf("No matching lwps found"); 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate (void) printf("\n"); 2477c478bd9Sstevel@tonic-gate Prelease(Pr, PRELEASE_RETAIN); 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate return (0); 2507c478bd9Sstevel@tonic-gate } 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate static int 2537c478bd9Sstevel@tonic-gate lwplook_zombie(const lwpsinfo_t *pip) 2547c478bd9Sstevel@tonic-gate { 2557c478bd9Sstevel@tonic-gate (void) printf(" /%d:\t<defunct>\n", (int)pip->pr_lwpid); 2567c478bd9Sstevel@tonic-gate return (0); 2577c478bd9Sstevel@tonic-gate } 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate static int 2607c478bd9Sstevel@tonic-gate lwplook(look_arg_t *arg, const lwpstatus_t *psp, const lwpsinfo_t *pip) 2617c478bd9Sstevel@tonic-gate { 2627c478bd9Sstevel@tonic-gate int flags; 263bc5ed3ddSRoger A. Faulkner uint32_t sighold, sighold1, sighold2; 264bc5ed3ddSRoger A. Faulkner uint32_t sigpend, sigpend1, sigpend2; 265*f971a346SBryan Cantrill psinfo_t ps; 2667c478bd9Sstevel@tonic-gate int cursig; 2677c478bd9Sstevel@tonic-gate char buf[32]; 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate if (!proc_lwp_in_set(arg->lwps, pip->pr_lwpid)) 2707c478bd9Sstevel@tonic-gate return (0); 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate arg->count++; 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate if (psp == NULL) 2757c478bd9Sstevel@tonic-gate return (lwplook_zombie(pip)); 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate /* 2787c478bd9Sstevel@tonic-gate * PR_PCINVAL is just noise if the lwp is not stopped. 2797c478bd9Sstevel@tonic-gate * Don't bother reporting it unless the lwp is stopped. 2807c478bd9Sstevel@tonic-gate */ 2817c478bd9Sstevel@tonic-gate flags = psp->pr_flags & LWPFLAGS; 2827c478bd9Sstevel@tonic-gate if (!(flags & PR_STOPPED)) 2837c478bd9Sstevel@tonic-gate flags &= ~PR_PCINVAL; 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate (void) printf(" /%d:\tflags = %s", (int)psp->pr_lwpid, prflags(flags)); 2867c478bd9Sstevel@tonic-gate if ((flags & PR_ASLEEP) || (psp->pr_syscall && 2877c478bd9Sstevel@tonic-gate !(arg->pflags & PR_ISSYS))) { 2887c478bd9Sstevel@tonic-gate if (flags & PR_ASLEEP) { 2897c478bd9Sstevel@tonic-gate if ((flags & ~PR_ASLEEP) != 0) 2907c478bd9Sstevel@tonic-gate (void) printf("|"); 2917c478bd9Sstevel@tonic-gate (void) printf("ASLEEP"); 2927c478bd9Sstevel@tonic-gate } 2937c478bd9Sstevel@tonic-gate if (psp->pr_syscall && !(arg->pflags & PR_ISSYS)) { 2947c478bd9Sstevel@tonic-gate uint_t i; 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate (void) printf(" %s(", 2977c478bd9Sstevel@tonic-gate proc_sysname(psp->pr_syscall, buf, sizeof (buf))); 2987c478bd9Sstevel@tonic-gate for (i = 0; i < psp->pr_nsysarg; i++) { 2997c478bd9Sstevel@tonic-gate if (i != 0) 3007c478bd9Sstevel@tonic-gate (void) printf(","); 3017c478bd9Sstevel@tonic-gate (void) printf("0x%lx", psp->pr_sysarg[i]); 3027c478bd9Sstevel@tonic-gate } 3037c478bd9Sstevel@tonic-gate (void) printf(")"); 3047c478bd9Sstevel@tonic-gate } 3057c478bd9Sstevel@tonic-gate } 3067c478bd9Sstevel@tonic-gate (void) printf("\n"); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate if (flags & PR_STOPPED) { 3097c478bd9Sstevel@tonic-gate (void) printf("\twhy = %s", prwhy(psp->pr_why)); 3107c478bd9Sstevel@tonic-gate if (psp->pr_why != PR_REQUESTED && 3117c478bd9Sstevel@tonic-gate psp->pr_why != PR_SUSPENDED) 3127c478bd9Sstevel@tonic-gate (void) printf(" what = %s", 3137c478bd9Sstevel@tonic-gate prwhat(psp->pr_why, psp->pr_what)); 3147c478bd9Sstevel@tonic-gate (void) printf("\n"); 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate 317bc5ed3ddSRoger A. Faulkner #if (MAXSIG > 2 * 32) && (MAXSIG <= 3 * 32) /* assumption */ 3187c478bd9Sstevel@tonic-gate sighold = *((uint32_t *)&psp->pr_lwphold); 319bc5ed3ddSRoger A. Faulkner sighold1 = *((uint32_t *)&psp->pr_lwphold + 1); 320bc5ed3ddSRoger A. Faulkner sighold2 = *((uint32_t *)&psp->pr_lwphold + 2); 3217c478bd9Sstevel@tonic-gate sigpend = *((uint32_t *)&psp->pr_lwppend); 322bc5ed3ddSRoger A. Faulkner sigpend1 = *((uint32_t *)&psp->pr_lwppend + 1); 323bc5ed3ddSRoger A. Faulkner sigpend2 = *((uint32_t *)&psp->pr_lwppend + 2); 324bc5ed3ddSRoger A. Faulkner #else 325bc5ed3ddSRoger A. Faulkner #error "fix me: MAXSIG out of bounds" 326bc5ed3ddSRoger A. Faulkner #endif 3277c478bd9Sstevel@tonic-gate cursig = psp->pr_cursig; 3287c478bd9Sstevel@tonic-gate 329bc5ed3ddSRoger A. Faulkner if (sighold | sighold1 | sighold2) 330bc5ed3ddSRoger A. Faulkner (void) printf("\tsigmask = 0x%.8x,0x%.8x,0x%.8x\n", 331bc5ed3ddSRoger A. Faulkner sighold, sighold1, sighold2); 332bc5ed3ddSRoger A. Faulkner if (sigpend | sigpend1 | sigpend2) 333bc5ed3ddSRoger A. Faulkner (void) printf("\tlwppend = 0x%.8x,0x%.8x,0x%.8x\n", 334bc5ed3ddSRoger A. Faulkner sigpend, sigpend1, sigpend2); 3357c478bd9Sstevel@tonic-gate if (cursig) 336bc5ed3ddSRoger A. Faulkner (void) printf("\tcursig = %s\n", 3377c478bd9Sstevel@tonic-gate proc_signame(cursig, buf, sizeof (buf))); 3387c478bd9Sstevel@tonic-gate 339*f971a346SBryan Cantrill if ((flags & PR_AGENT) && 340*f971a346SBryan Cantrill Plwp_getspymaster(Pr, pip->pr_lwpid, &ps) == 0) { 341*f971a346SBryan Cantrill time_t time = ps.pr_time.tv_sec; 342*f971a346SBryan Cantrill char t[64]; 343*f971a346SBryan Cantrill 344*f971a346SBryan Cantrill (void) strftime(t, sizeof (t), "%F:%H.%M.%S", localtime(&time)); 345*f971a346SBryan Cantrill 346*f971a346SBryan Cantrill (void) printf("\tspymaster = pid %d, \"%s\" at %s\n", 347*f971a346SBryan Cantrill (int)ps.pr_pid, ps.pr_psargs, t); 348*f971a346SBryan Cantrill } 349*f971a346SBryan Cantrill 3507c478bd9Sstevel@tonic-gate if (rflag) { 3517c478bd9Sstevel@tonic-gate if (Pstate(Pr) == PS_DEAD || (arg->pflags & PR_STOPPED)) { 3527c478bd9Sstevel@tonic-gate #if defined(__sparc) && defined(_ILP32) 3537c478bd9Sstevel@tonic-gate /* 3547c478bd9Sstevel@tonic-gate * If we're SPARC/32-bit, see if we can get extra 3557c478bd9Sstevel@tonic-gate * register state for this lwp. If it's a v8plus 3567c478bd9Sstevel@tonic-gate * program, print the 64-bit register values. 3577c478bd9Sstevel@tonic-gate */ 3587c478bd9Sstevel@tonic-gate prxregset_t prx; 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate if (Plwp_getxregs(Pr, psp->pr_lwpid, &prx) == 0 && 3617c478bd9Sstevel@tonic-gate prx.pr_type == XR_TYPE_V8P) 3627c478bd9Sstevel@tonic-gate dumpregs_v8p(psp->pr_reg, &prx, is64); 3637c478bd9Sstevel@tonic-gate else 3647c478bd9Sstevel@tonic-gate #endif /* __sparc && _ILP32 */ 3657c478bd9Sstevel@tonic-gate dumpregs(psp->pr_reg, is64); 3667c478bd9Sstevel@tonic-gate } else 3677c478bd9Sstevel@tonic-gate (void) printf("\tNot stopped, can't show registers\n"); 3687c478bd9Sstevel@tonic-gate } 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate return (0); 3717c478bd9Sstevel@tonic-gate } 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate static char * 3747c478bd9Sstevel@tonic-gate prflags(int arg) 3757c478bd9Sstevel@tonic-gate { 3767c478bd9Sstevel@tonic-gate static char code_buf[200]; 3777c478bd9Sstevel@tonic-gate char *str = code_buf; 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate if (arg == 0) 3807c478bd9Sstevel@tonic-gate return ("0"); 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate if (arg & ~ALLFLAGS) 3837c478bd9Sstevel@tonic-gate (void) sprintf(str, "0x%x", arg & ~ALLFLAGS); 3847c478bd9Sstevel@tonic-gate else 3857c478bd9Sstevel@tonic-gate *str = '\0'; 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate /* 3887c478bd9Sstevel@tonic-gate * Display the semi-permanent lwp flags first. 3897c478bd9Sstevel@tonic-gate */ 3907c478bd9Sstevel@tonic-gate if (arg & PR_DAEMON) /* daemons are always detached so */ 3917c478bd9Sstevel@tonic-gate (void) strcat(str, "|DAEMON"); 3927c478bd9Sstevel@tonic-gate else if (arg & PR_DETACH) /* report detach only if non-daemon */ 3937c478bd9Sstevel@tonic-gate (void) strcat(str, "|DETACH"); 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate if (arg & PR_STOPPED) 3967c478bd9Sstevel@tonic-gate (void) strcat(str, "|STOPPED"); 3977c478bd9Sstevel@tonic-gate if (arg & PR_ISTOP) 3987c478bd9Sstevel@tonic-gate (void) strcat(str, "|ISTOP"); 3997c478bd9Sstevel@tonic-gate if (arg & PR_DSTOP) 4007c478bd9Sstevel@tonic-gate (void) strcat(str, "|DSTOP"); 4017c478bd9Sstevel@tonic-gate #if 0 /* displayed elsewhere */ 4027c478bd9Sstevel@tonic-gate if (arg & PR_ASLEEP) 4037c478bd9Sstevel@tonic-gate (void) strcat(str, "|ASLEEP"); 4047c478bd9Sstevel@tonic-gate #endif 4057c478bd9Sstevel@tonic-gate if (arg & PR_PCINVAL) 4067c478bd9Sstevel@tonic-gate (void) strcat(str, "|PCINVAL"); 4077c478bd9Sstevel@tonic-gate if (arg & PR_STEP) 4087c478bd9Sstevel@tonic-gate (void) strcat(str, "|STEP"); 4097c478bd9Sstevel@tonic-gate if (arg & PR_AGENT) 4107c478bd9Sstevel@tonic-gate (void) strcat(str, "|AGENT"); 4117c478bd9Sstevel@tonic-gate if (arg & PR_ISSYS) 4127c478bd9Sstevel@tonic-gate (void) strcat(str, "|ISSYS"); 4137c478bd9Sstevel@tonic-gate if (arg & PR_VFORKP) 4147c478bd9Sstevel@tonic-gate (void) strcat(str, "|VFORKP"); 4157c478bd9Sstevel@tonic-gate if (arg & PR_ORPHAN) 4167c478bd9Sstevel@tonic-gate (void) strcat(str, "|ORPHAN"); 417657b1f3dSraf if (arg & PR_NOSIGCHLD) 418657b1f3dSraf (void) strcat(str, "|NOSIGCHLD"); 419657b1f3dSraf if (arg & PR_WAITPID) 420657b1f3dSraf (void) strcat(str, "|WAITPID"); 4217c478bd9Sstevel@tonic-gate if (arg & PR_FORK) 4227c478bd9Sstevel@tonic-gate (void) strcat(str, "|FORK"); 4237c478bd9Sstevel@tonic-gate if (arg & PR_RLC) 4247c478bd9Sstevel@tonic-gate (void) strcat(str, "|RLC"); 4257c478bd9Sstevel@tonic-gate if (arg & PR_KLC) 4267c478bd9Sstevel@tonic-gate (void) strcat(str, "|KLC"); 4277c478bd9Sstevel@tonic-gate if (arg & PR_ASYNC) 4287c478bd9Sstevel@tonic-gate (void) strcat(str, "|ASYNC"); 4297c478bd9Sstevel@tonic-gate if (arg & PR_BPTADJ) 4307c478bd9Sstevel@tonic-gate (void) strcat(str, "|BPTADJ"); 4317c478bd9Sstevel@tonic-gate if (arg & PR_MSACCT) 4327c478bd9Sstevel@tonic-gate (void) strcat(str, "|MSACCT"); 4337c478bd9Sstevel@tonic-gate if (arg & PR_MSFORK) 4347c478bd9Sstevel@tonic-gate (void) strcat(str, "|MSFORK"); 4357c478bd9Sstevel@tonic-gate if (arg & PR_PTRACE) 4367c478bd9Sstevel@tonic-gate (void) strcat(str, "|PTRACE"); 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate if (*str == '|') 4397c478bd9Sstevel@tonic-gate str++; 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate return (str); 4427c478bd9Sstevel@tonic-gate } 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate static char * 4457c478bd9Sstevel@tonic-gate prwhy(int why) 4467c478bd9Sstevel@tonic-gate { 4477c478bd9Sstevel@tonic-gate static char buf[20]; 4487c478bd9Sstevel@tonic-gate char *str; 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate switch (why) { 4517c478bd9Sstevel@tonic-gate case PR_REQUESTED: 4527c478bd9Sstevel@tonic-gate str = "PR_REQUESTED"; 4537c478bd9Sstevel@tonic-gate break; 4547c478bd9Sstevel@tonic-gate case PR_SIGNALLED: 4557c478bd9Sstevel@tonic-gate str = "PR_SIGNALLED"; 4567c478bd9Sstevel@tonic-gate break; 4577c478bd9Sstevel@tonic-gate case PR_SYSENTRY: 4587c478bd9Sstevel@tonic-gate str = "PR_SYSENTRY"; 4597c478bd9Sstevel@tonic-gate break; 4607c478bd9Sstevel@tonic-gate case PR_SYSEXIT: 4617c478bd9Sstevel@tonic-gate str = "PR_SYSEXIT"; 4627c478bd9Sstevel@tonic-gate break; 4637c478bd9Sstevel@tonic-gate case PR_JOBCONTROL: 4647c478bd9Sstevel@tonic-gate str = "PR_JOBCONTROL"; 4657c478bd9Sstevel@tonic-gate break; 4667c478bd9Sstevel@tonic-gate case PR_FAULTED: 4677c478bd9Sstevel@tonic-gate str = "PR_FAULTED"; 4687c478bd9Sstevel@tonic-gate break; 4697c478bd9Sstevel@tonic-gate case PR_SUSPENDED: 4707c478bd9Sstevel@tonic-gate str = "PR_SUSPENDED"; 4717c478bd9Sstevel@tonic-gate break; 4727c478bd9Sstevel@tonic-gate default: 4737c478bd9Sstevel@tonic-gate str = buf; 4747c478bd9Sstevel@tonic-gate (void) sprintf(str, "%d", why); 4757c478bd9Sstevel@tonic-gate break; 4767c478bd9Sstevel@tonic-gate } 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate return (str); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate static char * 4827c478bd9Sstevel@tonic-gate prwhat(int why, int what) 4837c478bd9Sstevel@tonic-gate { 4847c478bd9Sstevel@tonic-gate static char buf[32]; 4857c478bd9Sstevel@tonic-gate char *str; 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate switch (why) { 4887c478bd9Sstevel@tonic-gate case PR_SIGNALLED: 4897c478bd9Sstevel@tonic-gate case PR_JOBCONTROL: 4907c478bd9Sstevel@tonic-gate str = proc_signame(what, buf, sizeof (buf)); 4917c478bd9Sstevel@tonic-gate break; 4927c478bd9Sstevel@tonic-gate case PR_SYSENTRY: 4937c478bd9Sstevel@tonic-gate case PR_SYSEXIT: 4947c478bd9Sstevel@tonic-gate str = proc_sysname(what, buf, sizeof (buf)); 4957c478bd9Sstevel@tonic-gate break; 4967c478bd9Sstevel@tonic-gate case PR_FAULTED: 4977c478bd9Sstevel@tonic-gate str = proc_fltname(what, buf, sizeof (buf)); 4987c478bd9Sstevel@tonic-gate break; 4997c478bd9Sstevel@tonic-gate default: 5007c478bd9Sstevel@tonic-gate (void) sprintf(str = buf, "%d", what); 5017c478bd9Sstevel@tonic-gate break; 5027c478bd9Sstevel@tonic-gate } 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate return (str); 5057c478bd9Sstevel@tonic-gate } 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate #if defined(__sparc) 5087c478bd9Sstevel@tonic-gate static const char * const regname[NPRGREG] = { 5097c478bd9Sstevel@tonic-gate " %g0", " %g1", " %g2", " %g3", " %g4", " %g5", " %g6", " %g7", 5107c478bd9Sstevel@tonic-gate " %o0", " %o1", " %o2", " %o3", " %o4", " %o5", " %sp", " %o7", 5117c478bd9Sstevel@tonic-gate " %l0", " %l1", " %l2", " %l3", " %l4", " %l5", " %l6", " %l7", 5127c478bd9Sstevel@tonic-gate " %i0", " %i1", " %i2", " %i3", " %i4", " %i5", " %fp", " %i7", 5137c478bd9Sstevel@tonic-gate #ifdef __sparcv9 5147c478bd9Sstevel@tonic-gate "%ccr", " %pc", "%npc", " %y", "%asi", "%fprs" 5157c478bd9Sstevel@tonic-gate #else 5167c478bd9Sstevel@tonic-gate "%psr", " %pc", "%npc", " %y", "%wim", "%tbr" 5177c478bd9Sstevel@tonic-gate #endif 5187c478bd9Sstevel@tonic-gate }; 5197c478bd9Sstevel@tonic-gate #endif /* __sparc */ 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate #if defined(__amd64) 5227c478bd9Sstevel@tonic-gate static const char * const regname[NPRGREG] = { 5237c478bd9Sstevel@tonic-gate "%r15", "%r14", "%r13", "%r12", "%r11", "%r10", " %r9", " %r8", 5247c478bd9Sstevel@tonic-gate "%rdi", "%rsi", "%rbp", "%rbx", "%rdx", "%rcx", "%rax", "%trapno", 5257c478bd9Sstevel@tonic-gate "%err", "%rip", " %cs", "%rfl", "%rsp", " %ss", " %fs", " %gs", 5267c478bd9Sstevel@tonic-gate " %es", " %ds", "%fsbase", "%gsbase" 5277c478bd9Sstevel@tonic-gate }; 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate static const char * const regname32[NPRGREG32] = { 5307c478bd9Sstevel@tonic-gate " %gs", " %fs", " %es", " %ds", "%edi", "%esi", "%ebp", "%esp", 5317c478bd9Sstevel@tonic-gate "%ebx", "%edx", "%ecx", "%eax", "%trapno", "%err", "%eip", " %cs", 5327c478bd9Sstevel@tonic-gate "%efl", "%uesp", " %ss" 5337c478bd9Sstevel@tonic-gate }; 5347c478bd9Sstevel@tonic-gate 5357c478bd9Sstevel@tonic-gate /* XX64 Do we want to expose this through libproc */ 5367c478bd9Sstevel@tonic-gate void 5377c478bd9Sstevel@tonic-gate prgregset_n_to_32(const prgreg_t *src, prgreg32_t *dst) 5387c478bd9Sstevel@tonic-gate { 5397c478bd9Sstevel@tonic-gate bzero(dst, NPRGREG32 * sizeof (prgreg32_t)); 5407c478bd9Sstevel@tonic-gate dst[GS] = src[REG_GS]; 5417c478bd9Sstevel@tonic-gate dst[FS] = src[REG_FS]; 5427c478bd9Sstevel@tonic-gate dst[DS] = src[REG_DS]; 5437c478bd9Sstevel@tonic-gate dst[ES] = src[REG_ES]; 5447c478bd9Sstevel@tonic-gate dst[EDI] = src[REG_RDI]; 5457c478bd9Sstevel@tonic-gate dst[ESI] = src[REG_RSI]; 5467c478bd9Sstevel@tonic-gate dst[EBP] = src[REG_RBP]; 5477c478bd9Sstevel@tonic-gate dst[EBX] = src[REG_RBX]; 5487c478bd9Sstevel@tonic-gate dst[EDX] = src[REG_RDX]; 5497c478bd9Sstevel@tonic-gate dst[ECX] = src[REG_RCX]; 5507c478bd9Sstevel@tonic-gate dst[EAX] = src[REG_RAX]; 5517c478bd9Sstevel@tonic-gate dst[TRAPNO] = src[REG_TRAPNO]; 5527c478bd9Sstevel@tonic-gate dst[ERR] = src[REG_ERR]; 5537c478bd9Sstevel@tonic-gate dst[EIP] = src[REG_RIP]; 5547c478bd9Sstevel@tonic-gate dst[CS] = src[REG_CS]; 5557c478bd9Sstevel@tonic-gate dst[EFL] = src[REG_RFL]; 5567c478bd9Sstevel@tonic-gate dst[UESP] = src[REG_RSP]; 5577c478bd9Sstevel@tonic-gate dst[SS] = src[REG_SS]; 5587c478bd9Sstevel@tonic-gate } 5597c478bd9Sstevel@tonic-gate 5607c478bd9Sstevel@tonic-gate #elif defined(__i386) 5617c478bd9Sstevel@tonic-gate static const char * const regname[NPRGREG] = { 5627c478bd9Sstevel@tonic-gate " %gs", " %fs", " %es", " %ds", "%edi", "%esi", "%ebp", "%esp", 5637c478bd9Sstevel@tonic-gate "%ebx", "%edx", "%ecx", "%eax", "%trapno", "%err", "%eip", " %cs", 5647c478bd9Sstevel@tonic-gate "%efl", "%uesp", " %ss" 5657c478bd9Sstevel@tonic-gate }; 5667c478bd9Sstevel@tonic-gate #endif /* __i386 */ 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate #if defined(__amd64) && defined(_LP64) 5697c478bd9Sstevel@tonic-gate static void 5707c478bd9Sstevel@tonic-gate dumpregs32(const prgregset_t reg) 5717c478bd9Sstevel@tonic-gate { 5727c478bd9Sstevel@tonic-gate prgregset32_t reg32; 5737c478bd9Sstevel@tonic-gate int i; 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate prgregset_n_to_32(reg, reg32); 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate for (i = 0; i < NPRGREG32; i++) { 5787c478bd9Sstevel@tonic-gate (void) printf(" %s = 0x%.8X", 5797c478bd9Sstevel@tonic-gate regname32[i], reg32[i]); 5807c478bd9Sstevel@tonic-gate if ((i+1) % 4 == 0) 5817c478bd9Sstevel@tonic-gate (void) putchar('\n'); 5827c478bd9Sstevel@tonic-gate } 5837c478bd9Sstevel@tonic-gate if (i % 4 != 0) 5847c478bd9Sstevel@tonic-gate (void) putchar('\n'); 5857c478bd9Sstevel@tonic-gate } 5867c478bd9Sstevel@tonic-gate #endif 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate static void 5897c478bd9Sstevel@tonic-gate dumpregs(const prgregset_t reg, int is64) 5907c478bd9Sstevel@tonic-gate { 5917c478bd9Sstevel@tonic-gate int width = is64? 16 : 8; 5927c478bd9Sstevel@tonic-gate int cols = is64? 2 : 4; 5937c478bd9Sstevel@tonic-gate int i; 5947c478bd9Sstevel@tonic-gate 5957c478bd9Sstevel@tonic-gate #if defined(__amd64) && defined(_LP64) 5967c478bd9Sstevel@tonic-gate if (!is64) { 5977c478bd9Sstevel@tonic-gate dumpregs32(reg); 5987c478bd9Sstevel@tonic-gate return; 5997c478bd9Sstevel@tonic-gate } 6007c478bd9Sstevel@tonic-gate #endif 6017c478bd9Sstevel@tonic-gate 6027c478bd9Sstevel@tonic-gate for (i = 0; i < NPRGREG; i++) { 6037c478bd9Sstevel@tonic-gate (void) printf(" %s = 0x%.*lX", 6047c478bd9Sstevel@tonic-gate regname[i], width, (long)reg[i]); 6057c478bd9Sstevel@tonic-gate if ((i+1) % cols == 0) 6067c478bd9Sstevel@tonic-gate (void) putchar('\n'); 6077c478bd9Sstevel@tonic-gate } 6087c478bd9Sstevel@tonic-gate if (i % cols != 0) 6097c478bd9Sstevel@tonic-gate (void) putchar('\n'); 6107c478bd9Sstevel@tonic-gate } 6117c478bd9Sstevel@tonic-gate 6127c478bd9Sstevel@tonic-gate #if defined(__sparc) && defined(_ILP32) 6137c478bd9Sstevel@tonic-gate static void 6147c478bd9Sstevel@tonic-gate dumpregs_v8p(const prgregset_t reg, const prxregset_t *xreg, int is64) 6157c478bd9Sstevel@tonic-gate { 6167c478bd9Sstevel@tonic-gate static const uint32_t zero[8] = { 0 }; 6177c478bd9Sstevel@tonic-gate int gr, xr, cols = 2; 6187c478bd9Sstevel@tonic-gate uint64_t xval; 6197c478bd9Sstevel@tonic-gate 6207c478bd9Sstevel@tonic-gate if (memcmp(xreg->pr_un.pr_v8p.pr_xg, zero, sizeof (zero)) == 0 && 6217c478bd9Sstevel@tonic-gate memcmp(xreg->pr_un.pr_v8p.pr_xo, zero, sizeof (zero)) == 0) { 6227c478bd9Sstevel@tonic-gate dumpregs(reg, is64); 6237c478bd9Sstevel@tonic-gate return; 6247c478bd9Sstevel@tonic-gate } 6257c478bd9Sstevel@tonic-gate 6267c478bd9Sstevel@tonic-gate for (gr = R_G0, xr = XR_G0; gr <= R_G7; gr++, xr++) { 6277c478bd9Sstevel@tonic-gate xval = (uint64_t)xreg->pr_un.pr_v8p.pr_xg[xr] << 32 | 6287c478bd9Sstevel@tonic-gate (uint64_t)(uint32_t)reg[gr]; 6297c478bd9Sstevel@tonic-gate (void) printf(" %s = 0x%.16" PRIX64, regname[gr], xval); 6307c478bd9Sstevel@tonic-gate if ((gr + 1) % cols == 0) 6317c478bd9Sstevel@tonic-gate (void) putchar('\n'); 6327c478bd9Sstevel@tonic-gate } 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gate for (gr = R_O0, xr = XR_O0; gr <= R_O7; gr++, xr++) { 6357c478bd9Sstevel@tonic-gate xval = (uint64_t)xreg->pr_un.pr_v8p.pr_xo[xr] << 32 | 6367c478bd9Sstevel@tonic-gate (uint64_t)(uint32_t)reg[gr]; 6377c478bd9Sstevel@tonic-gate (void) printf(" %s = 0x%.16" PRIX64, regname[gr], xval); 6387c478bd9Sstevel@tonic-gate if ((gr + 1) % cols == 0) 6397c478bd9Sstevel@tonic-gate (void) putchar('\n'); 6407c478bd9Sstevel@tonic-gate } 6417c478bd9Sstevel@tonic-gate 6427c478bd9Sstevel@tonic-gate for (gr = R_L0; gr < NPRGREG; gr++) { 6437c478bd9Sstevel@tonic-gate (void) printf(" %s = 0x%.8lX", 6447c478bd9Sstevel@tonic-gate regname[gr], (long)reg[gr]); 6457c478bd9Sstevel@tonic-gate if ((gr + 1) % cols == 0) 6467c478bd9Sstevel@tonic-gate (void) putchar('\n'); 6477c478bd9Sstevel@tonic-gate } 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate if (gr % cols != 0) 6507c478bd9Sstevel@tonic-gate (void) putchar('\n'); 6517c478bd9Sstevel@tonic-gate } 6527c478bd9Sstevel@tonic-gate #endif /* __sparc && _ILP32 */ 653