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