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