xref: /onnv-gate/usr/src/cmd/truss/expound.c (revision 10440)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51548Srshoaib  * Common Development and Distribution License (the "License").
61548Srshoaib  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211548Srshoaib 
220Sstevel@tonic-gate /*
23*10440SRoger.Faulkner@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved  	*/
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #define	_SYSCALL32
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <stdio.h>
330Sstevel@tonic-gate #include <stdlib.h>
340Sstevel@tonic-gate #include <unistd.h>
350Sstevel@tonic-gate #include <ctype.h>
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include <sys/mman.h>
380Sstevel@tonic-gate #include <libproc.h>
390Sstevel@tonic-gate #include <string.h>
400Sstevel@tonic-gate #include <limits.h>
410Sstevel@tonic-gate #include <sys/statfs.h>
420Sstevel@tonic-gate #include <sys/times.h>
430Sstevel@tonic-gate #include <sys/timex.h>
440Sstevel@tonic-gate #include <sys/utssys.h>
450Sstevel@tonic-gate #include <sys/utsname.h>
460Sstevel@tonic-gate #include <sys/ipc.h>
470Sstevel@tonic-gate #include <sys/ipc_impl.h>
480Sstevel@tonic-gate #include <sys/msg.h>
490Sstevel@tonic-gate #include <sys/msg_impl.h>
500Sstevel@tonic-gate #include <sys/sem.h>
510Sstevel@tonic-gate #include <sys/sem_impl.h>
520Sstevel@tonic-gate #include <sys/shm.h>
530Sstevel@tonic-gate #include <sys/shm_impl.h>
540Sstevel@tonic-gate #include <sys/dirent.h>
550Sstevel@tonic-gate #include <sys/utime.h>
560Sstevel@tonic-gate #include <ustat.h>
570Sstevel@tonic-gate #include <fcntl.h>
580Sstevel@tonic-gate #include <time.h>
590Sstevel@tonic-gate #include <sys/termios.h>
600Sstevel@tonic-gate #include <sys/termiox.h>
610Sstevel@tonic-gate #include <sys/termio.h>
620Sstevel@tonic-gate #include <sys/ttold.h>
630Sstevel@tonic-gate #include <sys/jioctl.h>
640Sstevel@tonic-gate #include <sys/filio.h>
650Sstevel@tonic-gate #include <stropts.h>
660Sstevel@tonic-gate #include <poll.h>
670Sstevel@tonic-gate #include <sys/uio.h>
680Sstevel@tonic-gate #include <sys/resource.h>
690Sstevel@tonic-gate #include <sys/statvfs.h>
700Sstevel@tonic-gate #include <sys/time.h>
710Sstevel@tonic-gate #include <sys/aio.h>
720Sstevel@tonic-gate #include <sys/socket.h>
730Sstevel@tonic-gate #include <netinet/in.h>
740Sstevel@tonic-gate #include <sys/un.h>
750Sstevel@tonic-gate #include <sys/byteorder.h>
760Sstevel@tonic-gate #include <arpa/inet.h>
770Sstevel@tonic-gate #include <sys/audioio.h>
780Sstevel@tonic-gate #include <sys/cladm.h>
790Sstevel@tonic-gate #include <sys/synch.h>
800Sstevel@tonic-gate #include <sys/synch32.h>
810Sstevel@tonic-gate #include <sys/sysmacros.h>
820Sstevel@tonic-gate #include <sys/sendfile.h>
830Sstevel@tonic-gate #include <priv.h>
840Sstevel@tonic-gate #include <ucred.h>
850Sstevel@tonic-gate #include <sys/ucred.h>
860Sstevel@tonic-gate #include <sys/port_impl.h>
87813Sdp #include <sys/zone.h>
88813Sdp #include <sys/priv_impl.h>
89813Sdp #include <sys/priv.h>
901676Sjpk #include <tsol/label.h>
912447Snf202958 #include <sys/nvpair.h>
922447Snf202958 #include <libnvpair.h>
933684Srd117015 #include <sys/rctl_impl.h>
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #include "ramdata.h"
960Sstevel@tonic-gate #include "systable.h"
970Sstevel@tonic-gate #include "proto.h"
980Sstevel@tonic-gate 
990Sstevel@tonic-gate void	show_sigset(private_t *, long, const char *);
1000Sstevel@tonic-gate void	show_ioctl(private_t *, int, long);
1010Sstevel@tonic-gate 
102*10440SRoger.Faulkner@Sun.COM static void
103*10440SRoger.Faulkner@Sun.COM mk_ctime(char *str, size_t maxsize, time_t value)
104*10440SRoger.Faulkner@Sun.COM {
105*10440SRoger.Faulkner@Sun.COM 	(void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
106*10440SRoger.Faulkner@Sun.COM 	    localtime(&value));
107*10440SRoger.Faulkner@Sun.COM }
108*10440SRoger.Faulkner@Sun.COM 
1090Sstevel@tonic-gate void
1100Sstevel@tonic-gate prtime(private_t *pri, const char *name, time_t value)
1110Sstevel@tonic-gate {
1120Sstevel@tonic-gate 	char str[80];
1130Sstevel@tonic-gate 
114*10440SRoger.Faulkner@Sun.COM 	mk_ctime(str, sizeof (str), value);
115*10440SRoger.Faulkner@Sun.COM 	(void) printf("%s\t%s%s  [ %lu ]\n",
1160Sstevel@tonic-gate 	    pri->pname,
1170Sstevel@tonic-gate 	    name,
1180Sstevel@tonic-gate 	    str,
119*10440SRoger.Faulkner@Sun.COM 	    value);
120*10440SRoger.Faulkner@Sun.COM }
121*10440SRoger.Faulkner@Sun.COM 
122*10440SRoger.Faulkner@Sun.COM void
123*10440SRoger.Faulkner@Sun.COM prtimeval(private_t *pri, const char *name, struct timeval *value)
124*10440SRoger.Faulkner@Sun.COM {
125*10440SRoger.Faulkner@Sun.COM 	char str[80];
126*10440SRoger.Faulkner@Sun.COM 
127*10440SRoger.Faulkner@Sun.COM 	mk_ctime(str, sizeof (str), value->tv_sec);
128*10440SRoger.Faulkner@Sun.COM 	(void) printf("%s\t%s%s  [ %lu.%6.6lu ]\n",
129*10440SRoger.Faulkner@Sun.COM 	    pri->pname,
130*10440SRoger.Faulkner@Sun.COM 	    name,
131*10440SRoger.Faulkner@Sun.COM 	    str,
132*10440SRoger.Faulkner@Sun.COM 	    value->tv_sec,
133*10440SRoger.Faulkner@Sun.COM 	    value->tv_usec);
1340Sstevel@tonic-gate }
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate void
1370Sstevel@tonic-gate prtimestruc(private_t *pri, const char *name, timestruc_t *value)
1380Sstevel@tonic-gate {
139*10440SRoger.Faulkner@Sun.COM 	char str[80];
140*10440SRoger.Faulkner@Sun.COM 
141*10440SRoger.Faulkner@Sun.COM 	mk_ctime(str, sizeof (str), value->tv_sec);
142*10440SRoger.Faulkner@Sun.COM 	(void) printf("%s\t%s%s  [ %lu.%9.9lu ]\n",
143*10440SRoger.Faulkner@Sun.COM 	    pri->pname,
144*10440SRoger.Faulkner@Sun.COM 	    name,
145*10440SRoger.Faulkner@Sun.COM 	    str,
146*10440SRoger.Faulkner@Sun.COM 	    value->tv_sec,
147*10440SRoger.Faulkner@Sun.COM 	    value->tv_nsec);
1480Sstevel@tonic-gate }
1490Sstevel@tonic-gate 
150*10440SRoger.Faulkner@Sun.COM static void
1510Sstevel@tonic-gate show_utime(private_t *pri)
1520Sstevel@tonic-gate {
1530Sstevel@tonic-gate 	long offset;
1540Sstevel@tonic-gate 	struct utimbuf utimbuf;
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL)
1570Sstevel@tonic-gate 		return;
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
1600Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
1610Sstevel@tonic-gate 		    != sizeof (utimbuf))
1620Sstevel@tonic-gate 			return;
1630Sstevel@tonic-gate 	} else {
1640Sstevel@tonic-gate 		struct utimbuf32 utimbuf32;
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
1670Sstevel@tonic-gate 		    != sizeof (utimbuf32))
1680Sstevel@tonic-gate 			return;
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate 		utimbuf.actime = (time_t)utimbuf32.actime;
1710Sstevel@tonic-gate 		utimbuf.modtime = (time_t)utimbuf32.modtime;
1720Sstevel@tonic-gate 	}
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate 	/* print access and modification times */
175*10440SRoger.Faulkner@Sun.COM 	prtime(pri, "at = ", utimbuf.actime);
176*10440SRoger.Faulkner@Sun.COM 	prtime(pri, "mt = ", utimbuf.modtime);
1770Sstevel@tonic-gate }
1780Sstevel@tonic-gate 
179*10440SRoger.Faulkner@Sun.COM static void
180*10440SRoger.Faulkner@Sun.COM show_utimes(private_t *pri, long offset)
1810Sstevel@tonic-gate {
1820Sstevel@tonic-gate 	struct {
1830Sstevel@tonic-gate 		struct timeval	atime;
1840Sstevel@tonic-gate 		struct timeval	mtime;
1850Sstevel@tonic-gate 	} utimbuf;
1860Sstevel@tonic-gate 
187*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
1880Sstevel@tonic-gate 		return;
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
1910Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
1920Sstevel@tonic-gate 		    != sizeof (utimbuf))
1930Sstevel@tonic-gate 			return;
1940Sstevel@tonic-gate 	} else {
1950Sstevel@tonic-gate 		struct {
1960Sstevel@tonic-gate 			struct timeval32 atime;
1970Sstevel@tonic-gate 			struct timeval32 mtime;
1980Sstevel@tonic-gate 		} utimbuf32;
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
2010Sstevel@tonic-gate 		    != sizeof (utimbuf32))
2020Sstevel@tonic-gate 			return;
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&utimbuf.atime, &utimbuf32.atime);
2050Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&utimbuf.mtime, &utimbuf32.mtime);
2060Sstevel@tonic-gate 	}
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate 	/* print access and modification times */
209*10440SRoger.Faulkner@Sun.COM 	prtimeval(pri, "at = ", &utimbuf.atime);
210*10440SRoger.Faulkner@Sun.COM 	prtimeval(pri, "mt = ", &utimbuf.mtime);
211*10440SRoger.Faulkner@Sun.COM }
212*10440SRoger.Faulkner@Sun.COM 
213*10440SRoger.Faulkner@Sun.COM static void
214*10440SRoger.Faulkner@Sun.COM show_utimens(private_t *pri, long offset)
215*10440SRoger.Faulkner@Sun.COM {
216*10440SRoger.Faulkner@Sun.COM 	struct {
217*10440SRoger.Faulkner@Sun.COM 		timespec_t atime;
218*10440SRoger.Faulkner@Sun.COM 		timespec_t mtime;
219*10440SRoger.Faulkner@Sun.COM 	} utimbuf;
220*10440SRoger.Faulkner@Sun.COM 
221*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
222*10440SRoger.Faulkner@Sun.COM 		return;
223*10440SRoger.Faulkner@Sun.COM 
224*10440SRoger.Faulkner@Sun.COM 	if (data_model == PR_MODEL_NATIVE) {
225*10440SRoger.Faulkner@Sun.COM 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
226*10440SRoger.Faulkner@Sun.COM 		    != sizeof (utimbuf))
227*10440SRoger.Faulkner@Sun.COM 			return;
228*10440SRoger.Faulkner@Sun.COM 	} else {
229*10440SRoger.Faulkner@Sun.COM 		struct {
230*10440SRoger.Faulkner@Sun.COM 			timespec32_t atime;
231*10440SRoger.Faulkner@Sun.COM 			timespec32_t mtime;
232*10440SRoger.Faulkner@Sun.COM 		} utimbuf32;
233*10440SRoger.Faulkner@Sun.COM 
234*10440SRoger.Faulkner@Sun.COM 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
235*10440SRoger.Faulkner@Sun.COM 		    != sizeof (utimbuf32))
236*10440SRoger.Faulkner@Sun.COM 			return;
237*10440SRoger.Faulkner@Sun.COM 
238*10440SRoger.Faulkner@Sun.COM 		TIMESPEC32_TO_TIMESPEC(&utimbuf.atime, &utimbuf32.atime);
239*10440SRoger.Faulkner@Sun.COM 		TIMESPEC32_TO_TIMESPEC(&utimbuf.mtime, &utimbuf32.mtime);
240*10440SRoger.Faulkner@Sun.COM 	}
241*10440SRoger.Faulkner@Sun.COM 
242*10440SRoger.Faulkner@Sun.COM 	/* print access and modification times */
243*10440SRoger.Faulkner@Sun.COM 	if (utimbuf.atime.tv_nsec == UTIME_OMIT)
244*10440SRoger.Faulkner@Sun.COM 		(void) printf("%s\tat = UTIME_OMIT\n", pri->pname);
245*10440SRoger.Faulkner@Sun.COM 	else if (utimbuf.atime.tv_nsec == UTIME_NOW)
246*10440SRoger.Faulkner@Sun.COM 		(void) printf("%s\tat = UTIME_NOW\n", pri->pname);
247*10440SRoger.Faulkner@Sun.COM 	else
248*10440SRoger.Faulkner@Sun.COM 		prtimestruc(pri, "at = ", &utimbuf.atime);
249*10440SRoger.Faulkner@Sun.COM 	if (utimbuf.mtime.tv_nsec == UTIME_OMIT)
250*10440SRoger.Faulkner@Sun.COM 		(void) printf("%s\tmt = UTIME_OMIT\n", pri->pname);
251*10440SRoger.Faulkner@Sun.COM 	else if (utimbuf.mtime.tv_nsec == UTIME_NOW)
252*10440SRoger.Faulkner@Sun.COM 		(void) printf("%s\tmt = UTIME_NOW\n", pri->pname);
253*10440SRoger.Faulkner@Sun.COM 	else
254*10440SRoger.Faulkner@Sun.COM 		prtimestruc(pri, "mt = ", &utimbuf.atime);
2550Sstevel@tonic-gate }
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate void
2580Sstevel@tonic-gate show_timeofday(private_t *pri)
2590Sstevel@tonic-gate {
2600Sstevel@tonic-gate 	struct timeval tod;
2610Sstevel@tonic-gate 	long offset;
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
2640Sstevel@tonic-gate 		return;
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
2670Sstevel@tonic-gate 		if (Pread(Proc, &tod, sizeof (tod), offset)
2680Sstevel@tonic-gate 		    != sizeof (tod))
2690Sstevel@tonic-gate 			return;
2700Sstevel@tonic-gate 	} else {
2710Sstevel@tonic-gate 		struct timeval32 tod32;
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate 		if (Pread(Proc, &tod32, sizeof (tod32), offset)
2740Sstevel@tonic-gate 		    != sizeof (tod32))
2750Sstevel@tonic-gate 			return;
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
2780Sstevel@tonic-gate 	}
2790Sstevel@tonic-gate 
280*10440SRoger.Faulkner@Sun.COM 	prtimeval(pri, "time: ", &tod);
2810Sstevel@tonic-gate }
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate void
2840Sstevel@tonic-gate show_itimerval(private_t *pri, long offset, const char *name)
2850Sstevel@tonic-gate {
2860Sstevel@tonic-gate 	struct itimerval itimerval;
2870Sstevel@tonic-gate 
288*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
2890Sstevel@tonic-gate 		return;
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
2920Sstevel@tonic-gate 		if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
2930Sstevel@tonic-gate 		    != sizeof (itimerval))
2940Sstevel@tonic-gate 			return;
2950Sstevel@tonic-gate 	} else {
2960Sstevel@tonic-gate 		struct itimerval32 itimerval32;
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate 		if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
2990Sstevel@tonic-gate 		    != sizeof (itimerval32))
3000Sstevel@tonic-gate 			return;
3010Sstevel@tonic-gate 
3020Sstevel@tonic-gate 		ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
3030Sstevel@tonic-gate 	}
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate 	(void) printf(
3060Sstevel@tonic-gate 	    "%s\t%s:  interval: %4ld.%6.6ld sec  value: %4ld.%6.6ld sec\n",
3070Sstevel@tonic-gate 	    pri->pname,
3080Sstevel@tonic-gate 	    name,
3090Sstevel@tonic-gate 	    itimerval.it_interval.tv_sec,
3100Sstevel@tonic-gate 	    itimerval.it_interval.tv_usec,
3110Sstevel@tonic-gate 	    itimerval.it_value.tv_sec,
3120Sstevel@tonic-gate 	    itimerval.it_value.tv_usec);
3130Sstevel@tonic-gate }
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate void
3160Sstevel@tonic-gate show_timeval(private_t *pri, long offset, const char *name)
3170Sstevel@tonic-gate {
3180Sstevel@tonic-gate 	struct timeval timeval;
3190Sstevel@tonic-gate 
320*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
3210Sstevel@tonic-gate 		return;
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
3240Sstevel@tonic-gate 		if (Pread(Proc, &timeval, sizeof (timeval), offset)
3250Sstevel@tonic-gate 		    != sizeof (timeval))
3260Sstevel@tonic-gate 			return;
3270Sstevel@tonic-gate 	} else {
3280Sstevel@tonic-gate 		struct timeval32 timeval32;
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate 		if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
3310Sstevel@tonic-gate 		    != sizeof (timeval32))
3320Sstevel@tonic-gate 			return;
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
3350Sstevel@tonic-gate 	}
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate 	(void) printf(
3380Sstevel@tonic-gate 	    "%s\t%s: %ld.%6.6ld sec\n",
3390Sstevel@tonic-gate 	    pri->pname,
3400Sstevel@tonic-gate 	    name,
3410Sstevel@tonic-gate 	    timeval.tv_sec,
3420Sstevel@tonic-gate 	    timeval.tv_usec);
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate void
3460Sstevel@tonic-gate show_timestruc(private_t *pri, long offset, const char *name)
3470Sstevel@tonic-gate {
3480Sstevel@tonic-gate 	timestruc_t timestruc;
3490Sstevel@tonic-gate 
350*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
3510Sstevel@tonic-gate 		return;
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
3540Sstevel@tonic-gate 		if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
3550Sstevel@tonic-gate 		    != sizeof (timestruc))
3560Sstevel@tonic-gate 			return;
3570Sstevel@tonic-gate 	} else {
3580Sstevel@tonic-gate 		timestruc32_t timestruc32;
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate 		if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
3610Sstevel@tonic-gate 		    != sizeof (timestruc32))
3620Sstevel@tonic-gate 			return;
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 		TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
3650Sstevel@tonic-gate 	}
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 	(void) printf(
3680Sstevel@tonic-gate 	    "%s\t%s: %ld.%9.9ld sec\n",
3690Sstevel@tonic-gate 	    pri->pname,
3700Sstevel@tonic-gate 	    name,
3710Sstevel@tonic-gate 	    timestruc.tv_sec,
3720Sstevel@tonic-gate 	    timestruc.tv_nsec);
3730Sstevel@tonic-gate }
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate void
3760Sstevel@tonic-gate show_stime(private_t *pri)
3770Sstevel@tonic-gate {
3780Sstevel@tonic-gate 	if (pri->sys_nargs >= 1) {
3790Sstevel@tonic-gate 		/* print new system time */
3800Sstevel@tonic-gate 		prtime(pri, "systime = ", (time_t)pri->sys_args[0]);
3810Sstevel@tonic-gate 	}
3820Sstevel@tonic-gate }
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate void
3850Sstevel@tonic-gate show_times(private_t *pri)
3860Sstevel@tonic-gate {
3870Sstevel@tonic-gate 	long hz = sysconf(_SC_CLK_TCK);
3880Sstevel@tonic-gate 	long offset;
3890Sstevel@tonic-gate 	struct tms tms;
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
3920Sstevel@tonic-gate 		return;
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
3950Sstevel@tonic-gate 		if (Pread(Proc, &tms, sizeof (tms), offset)
3960Sstevel@tonic-gate 		    != sizeof (tms))
3970Sstevel@tonic-gate 			return;
3980Sstevel@tonic-gate 	} else {
3990Sstevel@tonic-gate 		struct tms32 tms32;
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate 		if (Pread(Proc, &tms32, sizeof (tms32), offset)
4020Sstevel@tonic-gate 		    != sizeof (tms32))
4030Sstevel@tonic-gate 			return;
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate 		/*
4060Sstevel@tonic-gate 		 * This looks a bit odd (since the values are actually
4070Sstevel@tonic-gate 		 * signed), but we need to suppress sign extension to
4080Sstevel@tonic-gate 		 * preserve compatibility (we've always printed these
4090Sstevel@tonic-gate 		 * numbers as unsigned quantities).
4100Sstevel@tonic-gate 		 */
4110Sstevel@tonic-gate 		tms.tms_utime = (unsigned)tms32.tms_utime;
4120Sstevel@tonic-gate 		tms.tms_stime = (unsigned)tms32.tms_stime;
4130Sstevel@tonic-gate 		tms.tms_cutime = (unsigned)tms32.tms_cutime;
4140Sstevel@tonic-gate 		tms.tms_cstime = (unsigned)tms32.tms_cstime;
4150Sstevel@tonic-gate 	}
4160Sstevel@tonic-gate 
4170Sstevel@tonic-gate 	(void) printf(
4180Sstevel@tonic-gate 	    "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
4190Sstevel@tonic-gate 	    pri->pname,
4200Sstevel@tonic-gate 	    tms.tms_utime,
4210Sstevel@tonic-gate 	    tms.tms_stime,
4220Sstevel@tonic-gate 	    tms.tms_cutime,
4230Sstevel@tonic-gate 	    tms.tms_cstime,
4240Sstevel@tonic-gate 	    hz);
4250Sstevel@tonic-gate }
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate void
4280Sstevel@tonic-gate show_uname(private_t *pri, long offset)
4290Sstevel@tonic-gate {
4300Sstevel@tonic-gate 	/*
4310Sstevel@tonic-gate 	 * Old utsname buffer (no longer accessible in <sys/utsname.h>).
4320Sstevel@tonic-gate 	 */
4330Sstevel@tonic-gate 	struct {
4340Sstevel@tonic-gate 		char	sysname[9];
4350Sstevel@tonic-gate 		char	nodename[9];
4360Sstevel@tonic-gate 		char	release[9];
4370Sstevel@tonic-gate 		char	version[9];
4380Sstevel@tonic-gate 		char	machine[9];
4390Sstevel@tonic-gate 	} ubuf;
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate 	if (offset != NULL &&
4420Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
4430Sstevel@tonic-gate 		(void) printf(
4447088Sraf 		    "%s\tsys=%-9.9snod=%-9.9srel=%-9.9sver=%-9.9smch=%.9s\n",
4457088Sraf 		    pri->pname,
4467088Sraf 		    ubuf.sysname,
4477088Sraf 		    ubuf.nodename,
4487088Sraf 		    ubuf.release,
4497088Sraf 		    ubuf.version,
4507088Sraf 		    ubuf.machine);
4510Sstevel@tonic-gate 	}
4520Sstevel@tonic-gate }
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
4550Sstevel@tonic-gate void
4560Sstevel@tonic-gate show_ustat(private_t *pri, long offset)
4570Sstevel@tonic-gate {
4580Sstevel@tonic-gate 	struct ustat ubuf;
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate 	if (offset != NULL &&
4610Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
4620Sstevel@tonic-gate 		(void) printf(
4637088Sraf 		    "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
4647088Sraf 		    pri->pname,
4657088Sraf 		    ubuf.f_tfree,
4667088Sraf 		    ubuf.f_tinode,
4677088Sraf 		    ubuf.f_fname,
4687088Sraf 		    ubuf.f_fpack);
4690Sstevel@tonic-gate 	}
4700Sstevel@tonic-gate }
4710Sstevel@tonic-gate 
4720Sstevel@tonic-gate #ifdef _LP64
4730Sstevel@tonic-gate void
4740Sstevel@tonic-gate show_ustat32(private_t *pri, long offset)
4750Sstevel@tonic-gate {
4760Sstevel@tonic-gate 	struct ustat32 ubuf;
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate 	if (offset != NULL &&
4790Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
4800Sstevel@tonic-gate 		(void) printf(
4817088Sraf 		    "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
4827088Sraf 		    pri->pname,
4837088Sraf 		    ubuf.f_tfree,
4847088Sraf 		    ubuf.f_tinode,
4857088Sraf 		    ubuf.f_fname,
4867088Sraf 		    ubuf.f_fpack);
4870Sstevel@tonic-gate 	}
4880Sstevel@tonic-gate }
4890Sstevel@tonic-gate #endif	/* _LP64 */
4900Sstevel@tonic-gate 
4910Sstevel@tonic-gate void
4920Sstevel@tonic-gate show_fusers(private_t *pri, long offset, long nproc)
4930Sstevel@tonic-gate {
4940Sstevel@tonic-gate 	f_user_t fubuf;
4950Sstevel@tonic-gate 	int serial = (nproc > 4);
4960Sstevel@tonic-gate 
497*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
4980Sstevel@tonic-gate 		return;
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate 	/* enter region of lengthy output */
5010Sstevel@tonic-gate 	if (serial)
5020Sstevel@tonic-gate 		Eserialize();
5030Sstevel@tonic-gate 
5040Sstevel@tonic-gate 	while (nproc > 0 &&
5050Sstevel@tonic-gate 	    Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
5064321Scasper 		(void) printf("%s\tpid=%-5d uid=%-5u flags=%s\n",
5070Sstevel@tonic-gate 		    pri->pname,
5080Sstevel@tonic-gate 		    (int)fubuf.fu_pid,
5094321Scasper 		    fubuf.fu_uid,
5100Sstevel@tonic-gate 		    fuflags(pri, fubuf.fu_flags));
5110Sstevel@tonic-gate 		nproc--;
5120Sstevel@tonic-gate 		offset += sizeof (fubuf);
5130Sstevel@tonic-gate 	}
5140Sstevel@tonic-gate 
5150Sstevel@tonic-gate 	/* exit region of lengthy output */
5160Sstevel@tonic-gate 	if (serial)
5170Sstevel@tonic-gate 		Xserialize();
5180Sstevel@tonic-gate }
5190Sstevel@tonic-gate 
5200Sstevel@tonic-gate void
5210Sstevel@tonic-gate show_utssys(private_t *pri, long r0)
5220Sstevel@tonic-gate {
5230Sstevel@tonic-gate 	if (pri->sys_nargs >= 3) {
5240Sstevel@tonic-gate 		switch (pri->sys_args[2]) {
5250Sstevel@tonic-gate 		case UTS_UNAME:
5260Sstevel@tonic-gate 			show_uname(pri, (long)pri->sys_args[0]);
5270Sstevel@tonic-gate 			break;
5280Sstevel@tonic-gate 		case UTS_USTAT:
5290Sstevel@tonic-gate 			show_ustat(pri, (long)pri->sys_args[0]);
5300Sstevel@tonic-gate 			break;
5310Sstevel@tonic-gate 		case UTS_FUSERS:
5320Sstevel@tonic-gate 			show_fusers(pri, (long)pri->sys_args[3], r0);
5330Sstevel@tonic-gate 			break;
5340Sstevel@tonic-gate 		}
5350Sstevel@tonic-gate 	}
5360Sstevel@tonic-gate }
5370Sstevel@tonic-gate 
5380Sstevel@tonic-gate #ifdef _LP64
5390Sstevel@tonic-gate void
5400Sstevel@tonic-gate show_utssys32(private_t *pri, long r0)
5410Sstevel@tonic-gate {
5420Sstevel@tonic-gate 	if (pri->sys_nargs >= 3) {
5430Sstevel@tonic-gate 		switch (pri->sys_args[2]) {
5440Sstevel@tonic-gate 		case UTS_UNAME:
5450Sstevel@tonic-gate 			show_uname(pri, (long)pri->sys_args[0]);
5460Sstevel@tonic-gate 			break;
5470Sstevel@tonic-gate 		case UTS_USTAT:
5480Sstevel@tonic-gate 			show_ustat32(pri, (long)pri->sys_args[0]);
5490Sstevel@tonic-gate 			break;
5500Sstevel@tonic-gate 		case UTS_FUSERS:
5510Sstevel@tonic-gate 			show_fusers(pri, (long)pri->sys_args[3], r0);
5520Sstevel@tonic-gate 			break;
5530Sstevel@tonic-gate 		}
5540Sstevel@tonic-gate 	}
5550Sstevel@tonic-gate }
5560Sstevel@tonic-gate #endif	/* _LP64 */
5570Sstevel@tonic-gate 
5580Sstevel@tonic-gate void
5590Sstevel@tonic-gate show_cladm(private_t *pri, int code, int function, long offset)
5600Sstevel@tonic-gate {
5610Sstevel@tonic-gate 	int	arg;
5620Sstevel@tonic-gate 
5630Sstevel@tonic-gate 	switch (code) {
5640Sstevel@tonic-gate 	case CL_INITIALIZE:
5650Sstevel@tonic-gate 		switch (function) {
5660Sstevel@tonic-gate 		case CL_GET_BOOTFLAG:
5670Sstevel@tonic-gate 			if (Pread(Proc, &arg, sizeof (arg), offset)
5680Sstevel@tonic-gate 			    == sizeof (arg)) {
5690Sstevel@tonic-gate 				if (arg & CLUSTER_CONFIGURED)
5700Sstevel@tonic-gate 					(void) printf("%s\tbootflags="
5710Sstevel@tonic-gate 					    "CLUSTER_CONFIGURED", pri->pname);
5720Sstevel@tonic-gate 				if (arg & CLUSTER_BOOTED)
5730Sstevel@tonic-gate 					(void) printf("|CLUSTER_BOOTED\n");
5740Sstevel@tonic-gate 			}
5750Sstevel@tonic-gate 			break;
5760Sstevel@tonic-gate 		}
5770Sstevel@tonic-gate 		break;
5780Sstevel@tonic-gate 	case CL_CONFIG:
5790Sstevel@tonic-gate 		switch (function) {
5800Sstevel@tonic-gate 		case CL_NODEID:
5810Sstevel@tonic-gate 		case CL_HIGHEST_NODEID:
5820Sstevel@tonic-gate 			if (Pread(Proc, &arg, sizeof (arg), offset)
5830Sstevel@tonic-gate 			    == sizeof (arg))
5840Sstevel@tonic-gate 				(void) printf("%s\tnodeid=%d\n",
5857088Sraf 				    pri->pname, arg);
5860Sstevel@tonic-gate 		}
5870Sstevel@tonic-gate 		break;
5880Sstevel@tonic-gate 	}
5890Sstevel@tonic-gate }
5900Sstevel@tonic-gate 
5914574Sraf #define	ALL_LOCK_TYPES						\
5924574Sraf 	(USYNC_PROCESS | LOCK_ERRORCHECK | LOCK_RECURSIVE | 	\
5934574Sraf 	LOCK_PRIO_INHERIT | LOCK_PRIO_PROTECT | LOCK_ROBUST | 	\
5944574Sraf 	USYNC_PROCESS_ROBUST)
5950Sstevel@tonic-gate 
5960Sstevel@tonic-gate /* return cv and mutex types */
5970Sstevel@tonic-gate const char *
5980Sstevel@tonic-gate synch_type(private_t *pri, uint_t type)
5990Sstevel@tonic-gate {
6000Sstevel@tonic-gate 	char *str = pri->code_buf;
6010Sstevel@tonic-gate 
6020Sstevel@tonic-gate 	if (type & USYNC_PROCESS)
6030Sstevel@tonic-gate 		(void) strcpy(str, "USYNC_PROCESS");
6040Sstevel@tonic-gate 	else
6050Sstevel@tonic-gate 		(void) strcpy(str, "USYNC_THREAD");
6060Sstevel@tonic-gate 
6070Sstevel@tonic-gate 	if (type & LOCK_ERRORCHECK)
6080Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_ERRORCHECK");
6090Sstevel@tonic-gate 	if (type & LOCK_RECURSIVE)
6100Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_RECURSIVE");
6110Sstevel@tonic-gate 	if (type & LOCK_PRIO_INHERIT)
6120Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_PRIO_INHERIT");
6130Sstevel@tonic-gate 	if (type & LOCK_PRIO_PROTECT)
6140Sstevel@tonic-gate 		(void) strcat(str, "|LOCK_PRIO_PROTECT");
6154574Sraf 	if (type & LOCK_ROBUST)
6164574Sraf 		(void) strcat(str, "|LOCK_ROBUST");
6174574Sraf 	if (type & USYNC_PROCESS_ROBUST)
6184574Sraf 		(void) strcat(str, "|USYNC_PROCESS_ROBUST");
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate 	if ((type &= ~ALL_LOCK_TYPES) != 0)
6210Sstevel@tonic-gate 		(void) sprintf(str + strlen(str), "|0x%.4X", type);
6220Sstevel@tonic-gate 
6230Sstevel@tonic-gate 	return ((const char *)str);
6240Sstevel@tonic-gate }
6250Sstevel@tonic-gate 
6260Sstevel@tonic-gate void
6270Sstevel@tonic-gate show_mutex(private_t *pri, long offset)
6280Sstevel@tonic-gate {
6290Sstevel@tonic-gate 	lwp_mutex_t mutex;
6300Sstevel@tonic-gate 
6310Sstevel@tonic-gate 	if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
6320Sstevel@tonic-gate 		(void) printf("%s\tmutex type: %s\n",
6337088Sraf 		    pri->pname,
6347088Sraf 		    synch_type(pri, mutex.mutex_type));
6350Sstevel@tonic-gate 	}
6360Sstevel@tonic-gate }
6370Sstevel@tonic-gate 
6380Sstevel@tonic-gate void
6390Sstevel@tonic-gate show_condvar(private_t *pri, long offset)
6400Sstevel@tonic-gate {
6410Sstevel@tonic-gate 	lwp_cond_t condvar;
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate 	if (Pread(Proc, &condvar, sizeof (condvar), offset)
6440Sstevel@tonic-gate 	    == sizeof (condvar)) {
6450Sstevel@tonic-gate 		(void) printf("%s\tcondvar type: %s\n",
6467088Sraf 		    pri->pname,
6477088Sraf 		    synch_type(pri, condvar.cond_type));
6480Sstevel@tonic-gate 	}
6490Sstevel@tonic-gate }
6500Sstevel@tonic-gate 
6510Sstevel@tonic-gate void
6520Sstevel@tonic-gate show_sema(private_t *pri, long offset)
6530Sstevel@tonic-gate {
6540Sstevel@tonic-gate 	lwp_sema_t sema;
6550Sstevel@tonic-gate 
6560Sstevel@tonic-gate 	if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
6570Sstevel@tonic-gate 		(void) printf("%s\tsema type: %s  count = %u\n",
6587088Sraf 		    pri->pname,
6597088Sraf 		    synch_type(pri, sema.sema_type),
6607088Sraf 		    sema.sema_count);
6610Sstevel@tonic-gate 	}
6620Sstevel@tonic-gate }
6630Sstevel@tonic-gate 
6640Sstevel@tonic-gate void
6650Sstevel@tonic-gate show_rwlock(private_t *pri, long offset)
6660Sstevel@tonic-gate {
6670Sstevel@tonic-gate 	lwp_rwlock_t rwlock;
6680Sstevel@tonic-gate 
6690Sstevel@tonic-gate 	if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
6700Sstevel@tonic-gate 		(void) printf("%s\trwlock type: %s  readers = %d\n",
6717088Sraf 		    pri->pname,
6727088Sraf 		    synch_type(pri, rwlock.rwlock_type),
6737088Sraf 		    rwlock.rwlock_readers);
6740Sstevel@tonic-gate 	}
6750Sstevel@tonic-gate }
6760Sstevel@tonic-gate 
6770Sstevel@tonic-gate /* represent character as itself ('c') or octal (012) */
6780Sstevel@tonic-gate char *
6790Sstevel@tonic-gate show_char(char *buf, int c)
6800Sstevel@tonic-gate {
6810Sstevel@tonic-gate 	const char *fmt;
6820Sstevel@tonic-gate 
6830Sstevel@tonic-gate 	if (c >= ' ' && c < 0177)
6840Sstevel@tonic-gate 		fmt = "'%c'";
6850Sstevel@tonic-gate 	else
6860Sstevel@tonic-gate 		fmt = "%.3o";
6870Sstevel@tonic-gate 
6880Sstevel@tonic-gate 	(void) sprintf(buf, fmt, c&0xff);
6890Sstevel@tonic-gate 	return (buf);
6900Sstevel@tonic-gate }
6910Sstevel@tonic-gate 
6920Sstevel@tonic-gate void
6930Sstevel@tonic-gate show_termio(private_t *pri, long offset)
6940Sstevel@tonic-gate {
6950Sstevel@tonic-gate 	struct termio termio;
6960Sstevel@tonic-gate 	char cbuf[8];
6970Sstevel@tonic-gate 	int i;
6980Sstevel@tonic-gate 
6990Sstevel@tonic-gate 	if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
7000Sstevel@tonic-gate 		(void) printf(
7010Sstevel@tonic-gate 		"%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
7027088Sraf 		    pri->pname,
7037088Sraf 		    termio.c_iflag,
7047088Sraf 		    termio.c_oflag,
7057088Sraf 		    termio.c_cflag,
7067088Sraf 		    termio.c_lflag,
7077088Sraf 		    termio.c_line);
7080Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
7090Sstevel@tonic-gate 		for (i = 0; i < NCC; i++)
7100Sstevel@tonic-gate 			(void) printf(" %s",
7117088Sraf 			    show_char(cbuf, (int)termio.c_cc[i]));
7120Sstevel@tonic-gate 		(void) fputc('\n', stdout);
7130Sstevel@tonic-gate 	}
7140Sstevel@tonic-gate }
7150Sstevel@tonic-gate 
7160Sstevel@tonic-gate void
7170Sstevel@tonic-gate show_termios(private_t *pri, long offset)
7180Sstevel@tonic-gate {
7190Sstevel@tonic-gate 	struct termios termios;
7200Sstevel@tonic-gate 	char cbuf[8];
7210Sstevel@tonic-gate 	int i;
7220Sstevel@tonic-gate 
7230Sstevel@tonic-gate 	if (Pread(Proc, &termios, sizeof (termios), offset)
7240Sstevel@tonic-gate 	    == sizeof (termios)) {
7250Sstevel@tonic-gate 		(void) printf(
7267088Sraf 		    "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
7277088Sraf 		    pri->pname,
7287088Sraf 		    termios.c_iflag,
7297088Sraf 		    termios.c_oflag,
7307088Sraf 		    termios.c_cflag,
7317088Sraf 		    termios.c_lflag);
7320Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
7330Sstevel@tonic-gate 		for (i = 0; i < NCCS; i++) {
7340Sstevel@tonic-gate 			if (i == NCC)	/* show new chars on new line */
7350Sstevel@tonic-gate 				(void) printf("\n%s\t\t", pri->pname);
7360Sstevel@tonic-gate 			(void) printf(" %s",
7377088Sraf 			    show_char(cbuf, (int)termios.c_cc[i]));
7380Sstevel@tonic-gate 		}
7390Sstevel@tonic-gate 		(void) fputc('\n', stdout);
7400Sstevel@tonic-gate 	}
7410Sstevel@tonic-gate }
7420Sstevel@tonic-gate 
7430Sstevel@tonic-gate void
7440Sstevel@tonic-gate show_termiox(private_t *pri, long offset)
7450Sstevel@tonic-gate {
7460Sstevel@tonic-gate 	struct termiox termiox;
7470Sstevel@tonic-gate 	int i;
7480Sstevel@tonic-gate 
7490Sstevel@tonic-gate 	if (Pread(Proc, &termiox, sizeof (termiox), offset)
7500Sstevel@tonic-gate 	    == sizeof (termiox)) {
7510Sstevel@tonic-gate 		(void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
7527088Sraf 		    pri->pname,
7537088Sraf 		    termiox.x_hflag,
7547088Sraf 		    termiox.x_cflag,
7557088Sraf 		    termiox.x_rflag[0]);
7560Sstevel@tonic-gate 		for (i = 1; i < NFF; i++)
7570Sstevel@tonic-gate 			(void) printf(",0%.3o", termiox.x_rflag[i]);
7580Sstevel@tonic-gate 		(void) printf(" sflag=0%.3o\n",
7597088Sraf 		    termiox.x_sflag);
7600Sstevel@tonic-gate 	}
7610Sstevel@tonic-gate }
7620Sstevel@tonic-gate 
7630Sstevel@tonic-gate void
7640Sstevel@tonic-gate show_sgttyb(private_t *pri, long offset)
7650Sstevel@tonic-gate {
7660Sstevel@tonic-gate 	struct sgttyb sgttyb;
7670Sstevel@tonic-gate 
7680Sstevel@tonic-gate 	if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
7690Sstevel@tonic-gate 		char erase[8];
7700Sstevel@tonic-gate 		char kill[8];
7710Sstevel@tonic-gate 
7720Sstevel@tonic-gate 		(void) printf(
7730Sstevel@tonic-gate 		"%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
7747088Sraf 		    pri->pname,
7757088Sraf 		    sgttyb.sg_ispeed&0xff,
7767088Sraf 		    sgttyb.sg_ospeed&0xff,
7777088Sraf 		    show_char(erase, sgttyb.sg_erase),
7787088Sraf 		    show_char(kill, sgttyb.sg_kill),
7797088Sraf 		    sgttyb.sg_flags);
7800Sstevel@tonic-gate 	}
7810Sstevel@tonic-gate }
7820Sstevel@tonic-gate 
7830Sstevel@tonic-gate void
7840Sstevel@tonic-gate show_ltchars(private_t *pri, long offset)
7850Sstevel@tonic-gate {
7860Sstevel@tonic-gate 	struct ltchars ltchars;
7870Sstevel@tonic-gate 	char *p;
7880Sstevel@tonic-gate 	char cbuf[8];
7890Sstevel@tonic-gate 	int i;
7900Sstevel@tonic-gate 
7910Sstevel@tonic-gate 	if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
7920Sstevel@tonic-gate 	    == sizeof (ltchars)) {
7930Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
7940Sstevel@tonic-gate 		for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
7950Sstevel@tonic-gate 			(void) printf(" %s", show_char(cbuf, (int)*p++));
7960Sstevel@tonic-gate 		(void) fputc('\n', stdout);
7970Sstevel@tonic-gate 	}
7980Sstevel@tonic-gate }
7990Sstevel@tonic-gate 
8000Sstevel@tonic-gate void
8010Sstevel@tonic-gate show_tchars(private_t *pri, long offset)
8020Sstevel@tonic-gate {
8030Sstevel@tonic-gate 	struct tchars tchars;
8040Sstevel@tonic-gate 	char *p;
8050Sstevel@tonic-gate 	char cbuf[8];
8060Sstevel@tonic-gate 	int i;
8070Sstevel@tonic-gate 
8080Sstevel@tonic-gate 	if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) {
8090Sstevel@tonic-gate 		(void) printf("%s\t    cc: ", pri->pname);
8100Sstevel@tonic-gate 		for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++)
8110Sstevel@tonic-gate 			(void) printf(" %s", show_char(cbuf, (int)*p++));
8120Sstevel@tonic-gate 		(void) fputc('\n', stdout);
8130Sstevel@tonic-gate 	}
8140Sstevel@tonic-gate }
8150Sstevel@tonic-gate 
8160Sstevel@tonic-gate void
8170Sstevel@tonic-gate show_termcb(private_t *pri, long offset)
8180Sstevel@tonic-gate {
8190Sstevel@tonic-gate 	struct termcb termcb;
8200Sstevel@tonic-gate 
8210Sstevel@tonic-gate 	if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
8220Sstevel@tonic-gate 		(void) printf(
8237088Sraf 		    "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
8247088Sraf 		    pri->pname,
8257088Sraf 		    termcb.st_flgs&0xff,
8267088Sraf 		    termcb.st_termt&0xff,
8277088Sraf 		    termcb.st_crow&0xff,
8287088Sraf 		    termcb.st_ccol&0xff,
8297088Sraf 		    termcb.st_vrow&0xff,
8307088Sraf 		    termcb.st_lrow&0xff);
8310Sstevel@tonic-gate 	}
8320Sstevel@tonic-gate }
8330Sstevel@tonic-gate 
8340Sstevel@tonic-gate /* integer value pointed to by ioctl() arg */
8350Sstevel@tonic-gate void
8360Sstevel@tonic-gate show_strint(private_t *pri, int code, long offset)
8370Sstevel@tonic-gate {
8380Sstevel@tonic-gate 	int val;
8390Sstevel@tonic-gate 
8400Sstevel@tonic-gate 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
8410Sstevel@tonic-gate 		const char *s = NULL;
8420Sstevel@tonic-gate 
8430Sstevel@tonic-gate 		switch (code) {		/* interpret these symbolically */
8440Sstevel@tonic-gate 		case I_GRDOPT:
8450Sstevel@tonic-gate 			s = strrdopt(val);
8460Sstevel@tonic-gate 			break;
8470Sstevel@tonic-gate 		case I_GETSIG:
8480Sstevel@tonic-gate 			s = strevents(pri, val);
8490Sstevel@tonic-gate 			break;
8500Sstevel@tonic-gate 		case TIOCFLUSH:
8510Sstevel@tonic-gate 			s = tiocflush(pri, val);
8520Sstevel@tonic-gate 			break;
8530Sstevel@tonic-gate 		}
8540Sstevel@tonic-gate 
8550Sstevel@tonic-gate 		if (s == NULL)
8560Sstevel@tonic-gate 			(void) printf("%s\t0x%.8lX: %d\n",
8577088Sraf 			    pri->pname, offset, val);
8580Sstevel@tonic-gate 		else
8590Sstevel@tonic-gate 			(void) printf("%s\t0x%.8lX: %s\n",
8607088Sraf 			    pri->pname, offset, s);
8610Sstevel@tonic-gate 	}
8620Sstevel@tonic-gate }
8630Sstevel@tonic-gate 
8640Sstevel@tonic-gate void
8650Sstevel@tonic-gate show_strioctl(private_t *pri, long offset)
8660Sstevel@tonic-gate {
8670Sstevel@tonic-gate 	struct strioctl strioctl;
8680Sstevel@tonic-gate 
8690Sstevel@tonic-gate 	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
8700Sstevel@tonic-gate 	    sizeof (strioctl)) {
8710Sstevel@tonic-gate 		(void) printf(
8727088Sraf 		    "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
8737088Sraf 		    pri->pname,
8747088Sraf 		    ioctlname(pri, strioctl.ic_cmd),
8757088Sraf 		    strioctl.ic_timout,
8767088Sraf 		    strioctl.ic_len,
8777088Sraf 		    (long)strioctl.ic_dp);
8780Sstevel@tonic-gate 
8790Sstevel@tonic-gate 		if (pri->recur++ == 0)	/* avoid indefinite recursion */
8800Sstevel@tonic-gate 			show_ioctl(pri, strioctl.ic_cmd,
8817088Sraf 			    (long)strioctl.ic_dp);
8820Sstevel@tonic-gate 		--pri->recur;
8830Sstevel@tonic-gate 	}
8840Sstevel@tonic-gate }
8850Sstevel@tonic-gate 
8860Sstevel@tonic-gate #ifdef _LP64
8870Sstevel@tonic-gate void
8880Sstevel@tonic-gate show_strioctl32(private_t *pri, long offset)
8890Sstevel@tonic-gate {
8900Sstevel@tonic-gate 	struct strioctl32 strioctl;
8910Sstevel@tonic-gate 
8920Sstevel@tonic-gate 	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
8930Sstevel@tonic-gate 	    sizeof (strioctl)) {
8940Sstevel@tonic-gate 		(void) printf(
8957088Sraf 		    "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
8967088Sraf 		    pri->pname,
8977088Sraf 		    ioctlname(pri, strioctl.ic_cmd),
8987088Sraf 		    strioctl.ic_timout,
8997088Sraf 		    strioctl.ic_len,
9007088Sraf 		    (long)strioctl.ic_dp);
9010Sstevel@tonic-gate 
9020Sstevel@tonic-gate 		if (pri->recur++ == 0)	/* avoid indefinite recursion */
9030Sstevel@tonic-gate 			show_ioctl(pri, strioctl.ic_cmd,
9047088Sraf 			    (long)strioctl.ic_dp);
9050Sstevel@tonic-gate 		--pri->recur;
9060Sstevel@tonic-gate 	}
9070Sstevel@tonic-gate }
9080Sstevel@tonic-gate #endif	/* _LP64 */
9090Sstevel@tonic-gate 
9100Sstevel@tonic-gate void
9110Sstevel@tonic-gate print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
9120Sstevel@tonic-gate {
9130Sstevel@tonic-gate 	(void) printf(
9147088Sraf 	    "%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
9157088Sraf 	    pri->pname,
9167088Sraf 	    name,
9177088Sraf 	    sp->maxlen,
9187088Sraf 	    sp->len,
9197088Sraf 	    (long)sp->buf);
9200Sstevel@tonic-gate 	/*
9210Sstevel@tonic-gate 	 * Should we show the buffer contents?
9220Sstevel@tonic-gate 	 * Keyed to the '-r fds' and '-w fds' options?
9230Sstevel@tonic-gate 	 */
9240Sstevel@tonic-gate 	if (sp->buf == NULL || sp->len <= 0)
9250Sstevel@tonic-gate 		(void) fputc('\n', stdout);
9260Sstevel@tonic-gate 	else {
9270Sstevel@tonic-gate 		int nb = (sp->len > 8)? 8 : sp->len;
9280Sstevel@tonic-gate 		char buffer[8];
9290Sstevel@tonic-gate 		char obuf[40];
9300Sstevel@tonic-gate 
9310Sstevel@tonic-gate 		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
9320Sstevel@tonic-gate 			(void) strcpy(obuf, ": \"");
9330Sstevel@tonic-gate 			showbytes(buffer, nb, obuf+3);
9340Sstevel@tonic-gate 			(void) strcat(obuf,
9357088Sraf 			    (nb == sp->len)?
9367088Sraf 			    (const char *)"\"" : (const char *)"\"..");
9370Sstevel@tonic-gate 			(void) fputs(obuf, stdout);
9380Sstevel@tonic-gate 		}
9390Sstevel@tonic-gate 		(void) fputc('\n', stdout);
9400Sstevel@tonic-gate 		if (dump && sp->len > 8)
9410Sstevel@tonic-gate 			showbuffer(pri, (long)sp->buf, (long)sp->len);
9420Sstevel@tonic-gate 	}
9430Sstevel@tonic-gate }
9440Sstevel@tonic-gate 
9450Sstevel@tonic-gate #ifdef _LP64
9460Sstevel@tonic-gate void
9470Sstevel@tonic-gate print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
9480Sstevel@tonic-gate {
9490Sstevel@tonic-gate 	(void) printf(
9507088Sraf 	    "%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
9517088Sraf 	    pri->pname,
9527088Sraf 	    name,
9537088Sraf 	    sp->maxlen,
9547088Sraf 	    sp->len,
9557088Sraf 	    (long)sp->buf);
9560Sstevel@tonic-gate 	/*
9570Sstevel@tonic-gate 	 * Should we show the buffer contents?
9580Sstevel@tonic-gate 	 * Keyed to the '-r fds' and '-w fds' options?
9590Sstevel@tonic-gate 	 */
9600Sstevel@tonic-gate 	if (sp->buf == NULL || sp->len <= 0)
9610Sstevel@tonic-gate 		(void) fputc('\n', stdout);
9620Sstevel@tonic-gate 	else {
9630Sstevel@tonic-gate 		int nb = (sp->len > 8)? 8 : sp->len;
9640Sstevel@tonic-gate 		char buffer[8];
9650Sstevel@tonic-gate 		char obuf[40];
9660Sstevel@tonic-gate 
9670Sstevel@tonic-gate 		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
9680Sstevel@tonic-gate 			(void) strcpy(obuf, ": \"");
9690Sstevel@tonic-gate 			showbytes(buffer, nb, obuf+3);
9700Sstevel@tonic-gate 			(void) strcat(obuf,
9717088Sraf 			    (nb == sp->len)?
9727088Sraf 			    (const char *)"\"" : (const char *)"\"..");
9730Sstevel@tonic-gate 			(void) fputs(obuf, stdout);
9740Sstevel@tonic-gate 		}
9750Sstevel@tonic-gate 		(void) fputc('\n', stdout);
9760Sstevel@tonic-gate 		if (dump && sp->len > 8)
9770Sstevel@tonic-gate 			showbuffer(pri, (long)sp->buf, (long)sp->len);
9780Sstevel@tonic-gate 	}
9790Sstevel@tonic-gate }
9800Sstevel@tonic-gate #endif	/* _LP64 */
9810Sstevel@tonic-gate 
9820Sstevel@tonic-gate /* strpeek and strfdinsert flags word */
9830Sstevel@tonic-gate const char *
9840Sstevel@tonic-gate strflags(private_t *pri, int flags)
9850Sstevel@tonic-gate {
9860Sstevel@tonic-gate 	const char *s;
9870Sstevel@tonic-gate 
9880Sstevel@tonic-gate 	switch (flags) {
9890Sstevel@tonic-gate 	case 0:
9900Sstevel@tonic-gate 		s = "0";
9910Sstevel@tonic-gate 		break;
9920Sstevel@tonic-gate 	case RS_HIPRI:
9930Sstevel@tonic-gate 		s = "RS_HIPRI";
9940Sstevel@tonic-gate 		break;
9950Sstevel@tonic-gate 	default:
9960Sstevel@tonic-gate 		(void) sprintf(pri->code_buf, "0x%.4X", flags);
9970Sstevel@tonic-gate 		s = pri->code_buf;
9980Sstevel@tonic-gate 	}
9990Sstevel@tonic-gate 
10000Sstevel@tonic-gate 	return (s);
10010Sstevel@tonic-gate }
10020Sstevel@tonic-gate 
10030Sstevel@tonic-gate void
10040Sstevel@tonic-gate show_strpeek(private_t *pri, long offset)
10050Sstevel@tonic-gate {
10060Sstevel@tonic-gate 	struct strpeek strpeek;
10070Sstevel@tonic-gate 
10080Sstevel@tonic-gate 	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
10090Sstevel@tonic-gate 	    == sizeof (strpeek)) {
10100Sstevel@tonic-gate 
10110Sstevel@tonic-gate 		print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
10120Sstevel@tonic-gate 		print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
10130Sstevel@tonic-gate 
10140Sstevel@tonic-gate 		(void) printf("%s\tflags=%s\n",
10157088Sraf 		    pri->pname,
10167088Sraf 		    strflags(pri, strpeek.flags));
10170Sstevel@tonic-gate 	}
10180Sstevel@tonic-gate }
10190Sstevel@tonic-gate 
10200Sstevel@tonic-gate #ifdef _LP64
10210Sstevel@tonic-gate void
10220Sstevel@tonic-gate show_strpeek32(private_t *pri, long offset)
10230Sstevel@tonic-gate {
10240Sstevel@tonic-gate 	struct strpeek32 strpeek;
10250Sstevel@tonic-gate 
10260Sstevel@tonic-gate 	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
10270Sstevel@tonic-gate 	    == sizeof (strpeek)) {
10280Sstevel@tonic-gate 
10290Sstevel@tonic-gate 		print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
10300Sstevel@tonic-gate 		print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
10310Sstevel@tonic-gate 
10320Sstevel@tonic-gate 		(void) printf("%s\tflags=%s\n",
10337088Sraf 		    pri->pname,
10347088Sraf 		    strflags(pri, strpeek.flags));
10350Sstevel@tonic-gate 	}
10360Sstevel@tonic-gate }
10370Sstevel@tonic-gate #endif	/* _LP64 */
10380Sstevel@tonic-gate 
10390Sstevel@tonic-gate void
10400Sstevel@tonic-gate show_strfdinsert(private_t *pri, long offset)
10410Sstevel@tonic-gate {
10420Sstevel@tonic-gate 	struct strfdinsert strfdinsert;
10430Sstevel@tonic-gate 
10440Sstevel@tonic-gate 	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
10450Sstevel@tonic-gate 	    sizeof (strfdinsert)) {
10460Sstevel@tonic-gate 
10470Sstevel@tonic-gate 		print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
10480Sstevel@tonic-gate 		print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
10490Sstevel@tonic-gate 
10500Sstevel@tonic-gate 		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
10517088Sraf 		    pri->pname,
10527088Sraf 		    strflags(pri, strfdinsert.flags),
10537088Sraf 		    strfdinsert.fildes,
10547088Sraf 		    strfdinsert.offset);
10550Sstevel@tonic-gate 	}
10560Sstevel@tonic-gate }
10570Sstevel@tonic-gate 
10580Sstevel@tonic-gate #ifdef _LP64
10590Sstevel@tonic-gate void
10600Sstevel@tonic-gate show_strfdinsert32(private_t *pri, long offset)
10610Sstevel@tonic-gate {
10620Sstevel@tonic-gate 	struct strfdinsert32 strfdinsert;
10630Sstevel@tonic-gate 
10640Sstevel@tonic-gate 	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
10650Sstevel@tonic-gate 	    sizeof (strfdinsert)) {
10660Sstevel@tonic-gate 
10670Sstevel@tonic-gate 		print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
10680Sstevel@tonic-gate 		print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
10690Sstevel@tonic-gate 
10700Sstevel@tonic-gate 		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
10717088Sraf 		    pri->pname,
10727088Sraf 		    strflags(pri, strfdinsert.flags),
10737088Sraf 		    strfdinsert.fildes,
10747088Sraf 		    strfdinsert.offset);
10750Sstevel@tonic-gate 	}
10760Sstevel@tonic-gate }
10770Sstevel@tonic-gate #endif	/* _LP64 */
10780Sstevel@tonic-gate 
10790Sstevel@tonic-gate void
10800Sstevel@tonic-gate show_strrecvfd(private_t *pri, long offset)
10810Sstevel@tonic-gate {
10820Sstevel@tonic-gate 	struct strrecvfd strrecvfd;
10830Sstevel@tonic-gate 
10840Sstevel@tonic-gate 	if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
10850Sstevel@tonic-gate 	    sizeof (strrecvfd)) {
10860Sstevel@tonic-gate 		(void) printf(
10877088Sraf 		    "%s\tfd=%-5d uid=%-5u gid=%u\n",
10887088Sraf 		    pri->pname,
10897088Sraf 		    strrecvfd.fd,
10907088Sraf 		    strrecvfd.uid,
10917088Sraf 		    strrecvfd.gid);
10920Sstevel@tonic-gate 	}
10930Sstevel@tonic-gate }
10940Sstevel@tonic-gate 
10950Sstevel@tonic-gate void
10960Sstevel@tonic-gate show_strlist(private_t *pri, long offset)
10970Sstevel@tonic-gate {
10980Sstevel@tonic-gate 	struct str_list strlist;
10990Sstevel@tonic-gate 	struct str_mlist list;
11000Sstevel@tonic-gate 	int count;
11010Sstevel@tonic-gate 
11020Sstevel@tonic-gate 	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
11030Sstevel@tonic-gate 	    sizeof (strlist)) {
11040Sstevel@tonic-gate 		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
11057088Sraf 		    pri->pname,
11067088Sraf 		    strlist.sl_nmods,
11077088Sraf 		    (long)strlist.sl_modlist);
11080Sstevel@tonic-gate 
11090Sstevel@tonic-gate 		count = strlist.sl_nmods;
11100Sstevel@tonic-gate 		offset = (long)strlist.sl_modlist;
11110Sstevel@tonic-gate 		while (!interrupt && --count >= 0) {
11120Sstevel@tonic-gate 			if (Pread(Proc, &list, sizeof (list), offset) !=
11130Sstevel@tonic-gate 			    sizeof (list))
11140Sstevel@tonic-gate 				break;
11150Sstevel@tonic-gate 			(void) printf("%s\t\t\"%.*s\"\n",
11167088Sraf 			    pri->pname,
11177088Sraf 			    (int)sizeof (list.l_name),
11187088Sraf 			    list.l_name);
11190Sstevel@tonic-gate 			offset += sizeof (struct str_mlist);
11200Sstevel@tonic-gate 		}
11210Sstevel@tonic-gate 	}
11220Sstevel@tonic-gate }
11230Sstevel@tonic-gate 
11240Sstevel@tonic-gate #ifdef _LP64
11250Sstevel@tonic-gate void
11260Sstevel@tonic-gate show_strlist32(private_t *pri, long offset)
11270Sstevel@tonic-gate {
11280Sstevel@tonic-gate 	struct str_list32 strlist;
11290Sstevel@tonic-gate 	struct str_mlist list;
11300Sstevel@tonic-gate 	int count;
11310Sstevel@tonic-gate 
11320Sstevel@tonic-gate 	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
11330Sstevel@tonic-gate 	    sizeof (strlist)) {
11340Sstevel@tonic-gate 		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
11357088Sraf 		    pri->pname,
11367088Sraf 		    strlist.sl_nmods,
11377088Sraf 		    (long)strlist.sl_modlist);
11380Sstevel@tonic-gate 
11390Sstevel@tonic-gate 		count = strlist.sl_nmods;
11400Sstevel@tonic-gate 		offset = (long)strlist.sl_modlist;
11410Sstevel@tonic-gate 		while (!interrupt && --count >= 0) {
11420Sstevel@tonic-gate 			if (Pread(Proc, &list, sizeof (list), offset) !=
11430Sstevel@tonic-gate 			    sizeof (list))
11440Sstevel@tonic-gate 				break;
11450Sstevel@tonic-gate 			(void) printf("%s\t\t\"%.*s\"\n",
11467088Sraf 			    pri->pname,
11477088Sraf 			    (int)sizeof (list.l_name),
11487088Sraf 			    list.l_name);
11490Sstevel@tonic-gate 			offset += sizeof (struct str_mlist);
11500Sstevel@tonic-gate 		}
11510Sstevel@tonic-gate 	}
11520Sstevel@tonic-gate }
11530Sstevel@tonic-gate #endif	/* _LP64 */
11540Sstevel@tonic-gate 
11550Sstevel@tonic-gate void
11560Sstevel@tonic-gate show_jwinsize(private_t *pri, long offset)
11570Sstevel@tonic-gate {
11580Sstevel@tonic-gate 	struct jwinsize jwinsize;
11590Sstevel@tonic-gate 
11600Sstevel@tonic-gate 	if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
11610Sstevel@tonic-gate 	    sizeof (jwinsize)) {
11620Sstevel@tonic-gate 		(void) printf(
11637088Sraf 		    "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
11647088Sraf 		    pri->pname,
11657088Sraf 		    (unsigned)jwinsize.bytesx,
11667088Sraf 		    (unsigned)jwinsize.bytesy,
11677088Sraf 		    (unsigned)jwinsize.bitsx,
11687088Sraf 		    (unsigned)jwinsize.bitsy);
11690Sstevel@tonic-gate 	}
11700Sstevel@tonic-gate }
11710Sstevel@tonic-gate 
11720Sstevel@tonic-gate void
11730Sstevel@tonic-gate show_winsize(private_t *pri, long offset)
11740Sstevel@tonic-gate {
11750Sstevel@tonic-gate 	struct winsize winsize;
11760Sstevel@tonic-gate 
11770Sstevel@tonic-gate 	if (Pread(Proc, &winsize, sizeof (winsize), offset)
11780Sstevel@tonic-gate 	    == sizeof (winsize)) {
11790Sstevel@tonic-gate 		(void) printf(
11807088Sraf 		    "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
11817088Sraf 		    pri->pname,
11827088Sraf 		    winsize.ws_row,
11837088Sraf 		    winsize.ws_col,
11847088Sraf 		    winsize.ws_xpixel,
11857088Sraf 		    winsize.ws_ypixel);
11860Sstevel@tonic-gate 	}
11870Sstevel@tonic-gate }
11880Sstevel@tonic-gate 
11890Sstevel@tonic-gate struct audio_stuff {
11900Sstevel@tonic-gate 	uint_t	bit;
11910Sstevel@tonic-gate 	const char *str;
11920Sstevel@tonic-gate };
11930Sstevel@tonic-gate 
11940Sstevel@tonic-gate const struct audio_stuff audio_output_ports[] = {
11950Sstevel@tonic-gate 	{ AUDIO_SPEAKER, "SPEAKER" },
11960Sstevel@tonic-gate 	{ AUDIO_HEADPHONE, "HEADPHONE" },
11970Sstevel@tonic-gate 	{ AUDIO_LINE_OUT, "LINE_OUT" },
11980Sstevel@tonic-gate 	{ AUDIO_SPDIF_OUT, "SPDIF_OUT" },
11990Sstevel@tonic-gate 	{ AUDIO_AUX1_OUT, "AUX1_OUT" },
12000Sstevel@tonic-gate 	{ AUDIO_AUX2_OUT, "AUX2_OUT" },
12010Sstevel@tonic-gate 	{ 0, NULL }
12020Sstevel@tonic-gate };
12030Sstevel@tonic-gate 
12040Sstevel@tonic-gate const struct audio_stuff audio_input_ports[] = {
12050Sstevel@tonic-gate 	{ AUDIO_MICROPHONE, "MICROPHONE" },
12060Sstevel@tonic-gate 	{ AUDIO_LINE_IN, "LINE_IN" },
12070Sstevel@tonic-gate 	{ AUDIO_CD, "CD" },
12080Sstevel@tonic-gate 	{ AUDIO_SPDIF_IN, "SPDIF_IN" },
12090Sstevel@tonic-gate 	{ AUDIO_AUX1_IN, "AUX1_IN" },
12100Sstevel@tonic-gate 	{ AUDIO_AUX2_IN, "AUX2_IN" },
12110Sstevel@tonic-gate 	{ AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
12120Sstevel@tonic-gate 	{ AUDIO_SUNVTS, "SUNVTS" },
12130Sstevel@tonic-gate 	{ 0, NULL }
12140Sstevel@tonic-gate };
12150Sstevel@tonic-gate 
12160Sstevel@tonic-gate static const struct audio_stuff audio_hw_features[] = {
12170Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
12180Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
12190Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
12200Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_PLAY, "PLAY" },
12210Sstevel@tonic-gate 	{ AUDIO_HWFEATURE_RECORD, "RECORD" },
12220Sstevel@tonic-gate 	{ 0, NULL }
12230Sstevel@tonic-gate };
12240Sstevel@tonic-gate 
12250Sstevel@tonic-gate static const struct audio_stuff audio_sw_features[] = {
12260Sstevel@tonic-gate 	{ AUDIO_SWFEATURE_MIXER, "MIXER" },
12270Sstevel@tonic-gate 	{ 0, NULL }
12280Sstevel@tonic-gate };
12290Sstevel@tonic-gate 
12300Sstevel@tonic-gate void
12310Sstevel@tonic-gate show_audio_features(const private_t *pri,
12320Sstevel@tonic-gate 	const struct audio_stuff *audio_porttab, uint_t features,
12330Sstevel@tonic-gate 	const char *name)
12340Sstevel@tonic-gate {
12350Sstevel@tonic-gate 	(void) printf("%s\t%s=", pri->pname, name);
12360Sstevel@tonic-gate 	if (features == 0) {
12370Sstevel@tonic-gate 		(void) printf("0\n");
12380Sstevel@tonic-gate 		return;
12390Sstevel@tonic-gate 	}
12400Sstevel@tonic-gate 
12410Sstevel@tonic-gate 	for (; audio_porttab->bit != 0; ++audio_porttab) {
12420Sstevel@tonic-gate 		if (features & audio_porttab->bit) {
12430Sstevel@tonic-gate 			(void) printf(audio_porttab->str);
12440Sstevel@tonic-gate 			features &= ~audio_porttab->bit;
12450Sstevel@tonic-gate 			if (features)
12460Sstevel@tonic-gate 				(void) putchar('|');
12470Sstevel@tonic-gate 		}
12480Sstevel@tonic-gate 	}
12490Sstevel@tonic-gate 	if (features)
12500Sstevel@tonic-gate 		(void) printf("0x%x", features);
12510Sstevel@tonic-gate 	(void) putchar('\n');
12520Sstevel@tonic-gate }
12530Sstevel@tonic-gate 
12540Sstevel@tonic-gate void
12550Sstevel@tonic-gate show_audio_ports(private_t *pri, const char *mode,
12560Sstevel@tonic-gate 	const char *field, uint_t ports)
12570Sstevel@tonic-gate {
12580Sstevel@tonic-gate 	const struct audio_stuff *audio_porttab;
12590Sstevel@tonic-gate 
12600Sstevel@tonic-gate 	(void) printf("%s\t%s\t%s=", pri->pname, mode, field);
12610Sstevel@tonic-gate 	if (ports == 0) {
12620Sstevel@tonic-gate 		(void) printf("0\n");
12630Sstevel@tonic-gate 		return;
12640Sstevel@tonic-gate 	}
12650Sstevel@tonic-gate 	if (*mode == 'p')
12660Sstevel@tonic-gate 		audio_porttab = audio_output_ports;
12670Sstevel@tonic-gate 	else
12680Sstevel@tonic-gate 		audio_porttab = audio_input_ports;
12690Sstevel@tonic-gate 	for (; audio_porttab->bit != 0; ++audio_porttab) {
12700Sstevel@tonic-gate 		if (ports & audio_porttab->bit) {
12710Sstevel@tonic-gate 			(void) printf(audio_porttab->str);
12720Sstevel@tonic-gate 			ports &= ~audio_porttab->bit;
12730Sstevel@tonic-gate 			if (ports)
12740Sstevel@tonic-gate 				(void) putchar('|');
12750Sstevel@tonic-gate 		}
12760Sstevel@tonic-gate 	}
12770Sstevel@tonic-gate 	if (ports)
12780Sstevel@tonic-gate 		(void) printf("0x%x", ports);
12790Sstevel@tonic-gate 	(void) putchar('\n');
12800Sstevel@tonic-gate }
12810Sstevel@tonic-gate 
12820Sstevel@tonic-gate void
12830Sstevel@tonic-gate show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
12840Sstevel@tonic-gate {
12850Sstevel@tonic-gate 	const char *s;
12860Sstevel@tonic-gate 
12870Sstevel@tonic-gate 	/*
12880Sstevel@tonic-gate 	 * The following values describe the audio data encoding.
12890Sstevel@tonic-gate 	 */
12900Sstevel@tonic-gate 
12910Sstevel@tonic-gate 	(void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
12927088Sraf 	    pri->pname, mode,
12937088Sraf 	    au_pr->sample_rate,
12947088Sraf 	    au_pr->channels,
12957088Sraf 	    au_pr->precision);
12960Sstevel@tonic-gate 
12970Sstevel@tonic-gate 	s = NULL;
12980Sstevel@tonic-gate 	switch (au_pr->encoding) {
12990Sstevel@tonic-gate 	case AUDIO_ENCODING_NONE:	s = "NONE";	break;
13000Sstevel@tonic-gate 	case AUDIO_ENCODING_ULAW:	s = "ULAW";	break;
13010Sstevel@tonic-gate 	case AUDIO_ENCODING_ALAW:	s = "ALAW";	break;
13020Sstevel@tonic-gate 	case AUDIO_ENCODING_LINEAR:	s = "LINEAR";	break;
13030Sstevel@tonic-gate 	case AUDIO_ENCODING_DVI:	s = "DVI";	break;
13040Sstevel@tonic-gate 	case AUDIO_ENCODING_LINEAR8:	s = "LINEAR8";	break;
13050Sstevel@tonic-gate 	}
13060Sstevel@tonic-gate 	if (s)
13070Sstevel@tonic-gate 		(void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
13080Sstevel@tonic-gate 	else {
13090Sstevel@tonic-gate 		(void) printf("%s\t%s\tencoding=%u\n",
13107088Sraf 		    pri->pname, mode, au_pr->encoding);
13110Sstevel@tonic-gate 	}
13120Sstevel@tonic-gate 
13130Sstevel@tonic-gate 	/*
13140Sstevel@tonic-gate 	 * The following values control audio device configuration
13150Sstevel@tonic-gate 	 */
13160Sstevel@tonic-gate 
13170Sstevel@tonic-gate 	(void) printf(
13187088Sraf 	    "%s\t%s\tgain=%u buffer_size=%u\n",
13197088Sraf 	    pri->pname, mode,
13207088Sraf 	    au_pr->gain,
13217088Sraf 	    au_pr->buffer_size);
13220Sstevel@tonic-gate 	show_audio_ports(pri, mode, "port", au_pr->port);
13230Sstevel@tonic-gate 	show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
13240Sstevel@tonic-gate 	show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
13250Sstevel@tonic-gate 
13260Sstevel@tonic-gate 	/*
13270Sstevel@tonic-gate 	 * The following values describe driver state
13280Sstevel@tonic-gate 	 */
13290Sstevel@tonic-gate 
13300Sstevel@tonic-gate 	(void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
13317088Sraf 	    pri->pname, mode,
13327088Sraf 	    au_pr->samples,
13337088Sraf 	    au_pr->eof,
13347088Sraf 	    au_pr->pause,
13357088Sraf 	    au_pr->error);
13360Sstevel@tonic-gate 	(void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
13377088Sraf 	    pri->pname, mode,
13387088Sraf 	    au_pr->waiting,
13397088Sraf 	    au_pr->balance,
13407088Sraf 	    au_pr->minordev);
13410Sstevel@tonic-gate 
13420Sstevel@tonic-gate 	/*
13430Sstevel@tonic-gate 	 * The following values are read-only state flags
13440Sstevel@tonic-gate 	 */
13450Sstevel@tonic-gate 	(void) printf("%s\t%s\topen=%u active=%u\n",
13467088Sraf 	    pri->pname, mode,
13477088Sraf 	    au_pr->open,
13487088Sraf 	    au_pr->active);
13490Sstevel@tonic-gate }
13500Sstevel@tonic-gate 
13510Sstevel@tonic-gate void
13520Sstevel@tonic-gate show_audio_info(private_t *pri, long offset)
13530Sstevel@tonic-gate {
13540Sstevel@tonic-gate 	struct audio_info au;
13550Sstevel@tonic-gate 
13560Sstevel@tonic-gate 	if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
13570Sstevel@tonic-gate 		show_audio_prinfo(pri, "play", &au.play);
13580Sstevel@tonic-gate 		show_audio_prinfo(pri, "record", &au.record);
13590Sstevel@tonic-gate 		(void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
13607088Sraf 		    pri->pname, au.monitor_gain, au.output_muted);
13610Sstevel@tonic-gate 		show_audio_features(pri, audio_hw_features, au.hw_features,
13620Sstevel@tonic-gate 		    "hw_features");
13630Sstevel@tonic-gate 		show_audio_features(pri, audio_sw_features, au.sw_features,
13640Sstevel@tonic-gate 		    "sw_features");
13650Sstevel@tonic-gate 		show_audio_features(pri, audio_sw_features,
13660Sstevel@tonic-gate 		    au.sw_features_enabled, "sw_features_enabled");
13670Sstevel@tonic-gate 	}
13680Sstevel@tonic-gate }
13690Sstevel@tonic-gate 
13700Sstevel@tonic-gate void
13710Sstevel@tonic-gate show_ioctl(private_t *pri, int code, long offset)
13720Sstevel@tonic-gate {
13730Sstevel@tonic-gate 	int lp64 = (data_model == PR_MODEL_LP64);
13740Sstevel@tonic-gate 	int err = pri->Errno;	/* don't display output parameters */
13750Sstevel@tonic-gate 				/* for a failed system call */
13760Sstevel@tonic-gate #ifndef _LP64
13770Sstevel@tonic-gate 	if (lp64)
13780Sstevel@tonic-gate 		return;
13790Sstevel@tonic-gate #endif
1380*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
13810Sstevel@tonic-gate 		return;
13820Sstevel@tonic-gate 
13830Sstevel@tonic-gate 	switch (code) {
13840Sstevel@tonic-gate 	case TCGETA:
13850Sstevel@tonic-gate 		if (err)
13860Sstevel@tonic-gate 			break;
13870Sstevel@tonic-gate 		/*FALLTHROUGH*/
13880Sstevel@tonic-gate 	case TCSETA:
13890Sstevel@tonic-gate 	case TCSETAW:
13900Sstevel@tonic-gate 	case TCSETAF:
13910Sstevel@tonic-gate 		show_termio(pri, offset);
13920Sstevel@tonic-gate 		break;
13930Sstevel@tonic-gate 	case TCGETS:
13940Sstevel@tonic-gate 		if (err)
13950Sstevel@tonic-gate 			break;
13960Sstevel@tonic-gate 		/*FALLTHROUGH*/
13970Sstevel@tonic-gate 	case TCSETS:
13980Sstevel@tonic-gate 	case TCSETSW:
13990Sstevel@tonic-gate 	case TCSETSF:
14000Sstevel@tonic-gate 		show_termios(pri, offset);
14010Sstevel@tonic-gate 		break;
14020Sstevel@tonic-gate 	case TCGETX:
14030Sstevel@tonic-gate 		if (err)
14040Sstevel@tonic-gate 			break;
14050Sstevel@tonic-gate 		/*FALLTHROUGH*/
14060Sstevel@tonic-gate 	case TCSETX:
14070Sstevel@tonic-gate 	case TCSETXW:
14080Sstevel@tonic-gate 	case TCSETXF:
14090Sstevel@tonic-gate 		show_termiox(pri, offset);
14100Sstevel@tonic-gate 		break;
14110Sstevel@tonic-gate 	case TIOCGETP:
14120Sstevel@tonic-gate 		if (err)
14130Sstevel@tonic-gate 			break;
14140Sstevel@tonic-gate 		/*FALLTHROUGH*/
14150Sstevel@tonic-gate 	case TIOCSETN:
14160Sstevel@tonic-gate 	case TIOCSETP:
14170Sstevel@tonic-gate 		show_sgttyb(pri, offset);
14180Sstevel@tonic-gate 		break;
14190Sstevel@tonic-gate 	case TIOCGLTC:
14200Sstevel@tonic-gate 		if (err)
14210Sstevel@tonic-gate 			break;
14220Sstevel@tonic-gate 		/*FALLTHROUGH*/
14230Sstevel@tonic-gate 	case TIOCSLTC:
14240Sstevel@tonic-gate 		show_ltchars(pri, offset);
14250Sstevel@tonic-gate 		break;
14260Sstevel@tonic-gate 	case TIOCGETC:
14270Sstevel@tonic-gate 		if (err)
14280Sstevel@tonic-gate 			break;
14290Sstevel@tonic-gate 		/*FALLTHROUGH*/
14300Sstevel@tonic-gate 	case TIOCSETC:
14310Sstevel@tonic-gate 		show_tchars(pri, offset);
14320Sstevel@tonic-gate 		break;
14330Sstevel@tonic-gate 	case LDGETT:
14340Sstevel@tonic-gate 		if (err)
14350Sstevel@tonic-gate 			break;
14360Sstevel@tonic-gate 		/*FALLTHROUGH*/
14370Sstevel@tonic-gate 	case LDSETT:
14380Sstevel@tonic-gate 		show_termcb(pri, offset);
14390Sstevel@tonic-gate 		break;
14400Sstevel@tonic-gate 	/* streams ioctl()s */
14410Sstevel@tonic-gate #if 0
14420Sstevel@tonic-gate 		/* these are displayed as strings in the arg list */
14430Sstevel@tonic-gate 		/* by prt_ioa().  don't display them again here */
14440Sstevel@tonic-gate 	case I_PUSH:
14450Sstevel@tonic-gate 	case I_LOOK:
14460Sstevel@tonic-gate 	case I_FIND:
14470Sstevel@tonic-gate 		/* these are displayed as decimal in the arg list */
14480Sstevel@tonic-gate 		/* by prt_ioa().  don't display them again here */
14490Sstevel@tonic-gate 	case I_LINK:
14500Sstevel@tonic-gate 	case I_UNLINK:
14510Sstevel@tonic-gate 	case I_SENDFD:
14520Sstevel@tonic-gate 		/* these are displayed symbolically in the arg list */
14530Sstevel@tonic-gate 		/* by prt_ioa().  don't display them again here */
14540Sstevel@tonic-gate 	case I_SRDOPT:
14550Sstevel@tonic-gate 	case I_SETSIG:
14560Sstevel@tonic-gate 	case I_FLUSH:
14570Sstevel@tonic-gate 		break;
14580Sstevel@tonic-gate 		/* this one just ignores the argument */
14590Sstevel@tonic-gate 	case I_POP:
14600Sstevel@tonic-gate 		break;
14610Sstevel@tonic-gate #endif
14620Sstevel@tonic-gate 		/* these return something in an int pointed to by arg */
14630Sstevel@tonic-gate 	case I_NREAD:
14640Sstevel@tonic-gate 	case I_GRDOPT:
14650Sstevel@tonic-gate 	case I_GETSIG:
14660Sstevel@tonic-gate 	case TIOCGSID:
14670Sstevel@tonic-gate 	case TIOCGPGRP:
14680Sstevel@tonic-gate 	case TIOCLGET:
14690Sstevel@tonic-gate 	case FIONREAD:
14700Sstevel@tonic-gate 	case FIORDCHK:
14710Sstevel@tonic-gate 		if (err)
14720Sstevel@tonic-gate 			break;
14730Sstevel@tonic-gate 		/*FALLTHROUGH*/
14740Sstevel@tonic-gate 		/* these pass something in an int pointed to by arg */
14750Sstevel@tonic-gate 	case TIOCSPGRP:
14760Sstevel@tonic-gate 	case TIOCFLUSH:
14770Sstevel@tonic-gate 	case TIOCLBIS:
14780Sstevel@tonic-gate 	case TIOCLBIC:
14790Sstevel@tonic-gate 	case TIOCLSET:
14800Sstevel@tonic-gate 		show_strint(pri, code, offset);
14810Sstevel@tonic-gate 		break;
14820Sstevel@tonic-gate 		/* these all point to structures */
14830Sstevel@tonic-gate 	case I_STR:
14840Sstevel@tonic-gate #ifdef _LP64
14850Sstevel@tonic-gate 		if (lp64)
14860Sstevel@tonic-gate 			show_strioctl(pri, offset);
14870Sstevel@tonic-gate 		else
14880Sstevel@tonic-gate 			show_strioctl32(pri, offset);
14890Sstevel@tonic-gate #else
14900Sstevel@tonic-gate 		show_strioctl(pri, offset);
14910Sstevel@tonic-gate #endif
14920Sstevel@tonic-gate 		break;
14930Sstevel@tonic-gate 	case I_PEEK:
14940Sstevel@tonic-gate #ifdef _LP64
14950Sstevel@tonic-gate 		if (lp64)
14960Sstevel@tonic-gate 			show_strpeek(pri, offset);
14970Sstevel@tonic-gate 		else
14980Sstevel@tonic-gate 			show_strpeek32(pri, offset);
14990Sstevel@tonic-gate #else
15000Sstevel@tonic-gate 		show_strpeek(pri, offset);
15010Sstevel@tonic-gate #endif
15020Sstevel@tonic-gate 		break;
15030Sstevel@tonic-gate 	case I_FDINSERT:
15040Sstevel@tonic-gate #ifdef _LP64
15050Sstevel@tonic-gate 		if (lp64)
15060Sstevel@tonic-gate 			show_strfdinsert(pri, offset);
15070Sstevel@tonic-gate 		else
15080Sstevel@tonic-gate 			show_strfdinsert32(pri, offset);
15090Sstevel@tonic-gate #else
15100Sstevel@tonic-gate 		show_strfdinsert(pri, offset);
15110Sstevel@tonic-gate #endif
15120Sstevel@tonic-gate 		break;
15130Sstevel@tonic-gate 	case I_RECVFD:
15140Sstevel@tonic-gate 		if (err)
15150Sstevel@tonic-gate 			break;
15160Sstevel@tonic-gate 		show_strrecvfd(pri, offset);
15170Sstevel@tonic-gate 		break;
15180Sstevel@tonic-gate 	case I_LIST:
15190Sstevel@tonic-gate 		if (err)
15200Sstevel@tonic-gate 			break;
15210Sstevel@tonic-gate #ifdef _LP64
15220Sstevel@tonic-gate 		if (lp64)
15230Sstevel@tonic-gate 			show_strlist(pri, offset);
15240Sstevel@tonic-gate 		else
15250Sstevel@tonic-gate 			show_strlist32(pri, offset);
15260Sstevel@tonic-gate #else
15270Sstevel@tonic-gate 		show_strlist(pri, offset);
15280Sstevel@tonic-gate #endif
15290Sstevel@tonic-gate 		break;
15300Sstevel@tonic-gate 	case JWINSIZE:
15310Sstevel@tonic-gate 		if (err)
15320Sstevel@tonic-gate 			break;
15330Sstevel@tonic-gate 		show_jwinsize(pri, offset);
15340Sstevel@tonic-gate 		break;
15350Sstevel@tonic-gate 	case TIOCGWINSZ:
15360Sstevel@tonic-gate 		if (err)
15370Sstevel@tonic-gate 			break;
15380Sstevel@tonic-gate 		/*FALLTHROUGH*/
15390Sstevel@tonic-gate 	case TIOCSWINSZ:
15400Sstevel@tonic-gate 		show_winsize(pri, offset);
15410Sstevel@tonic-gate 		break;
15420Sstevel@tonic-gate 	case AUDIO_GETINFO:
15430Sstevel@tonic-gate 	case (int)AUDIO_SETINFO:
15440Sstevel@tonic-gate 		show_audio_info(pri, offset);
15450Sstevel@tonic-gate 		break;
15460Sstevel@tonic-gate 
15470Sstevel@tonic-gate 	default:
15480Sstevel@tonic-gate 		if (code & IOC_INOUT) {
15490Sstevel@tonic-gate 			const char *str = ioctldatastruct(code);
15500Sstevel@tonic-gate 
15510Sstevel@tonic-gate 			(void) printf("\t\t%s",
15520Sstevel@tonic-gate 			    (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
15530Sstevel@tonic-gate 			    code & IOC_IN ? "write" : "read");
15540Sstevel@tonic-gate 			if (str != NULL) {
15550Sstevel@tonic-gate 				(void) printf(" (struct %s)\n", str);
15560Sstevel@tonic-gate 			} else {
15570Sstevel@tonic-gate 				(void) printf(" %d bytes\n",
15580Sstevel@tonic-gate 				    (code >> 16) & IOCPARM_MASK);
15590Sstevel@tonic-gate 			}
15600Sstevel@tonic-gate 		}
15610Sstevel@tonic-gate 	}
15620Sstevel@tonic-gate }
15630Sstevel@tonic-gate 
15640Sstevel@tonic-gate void
15650Sstevel@tonic-gate show_statvfs(private_t *pri)
15660Sstevel@tonic-gate {
15670Sstevel@tonic-gate 	long offset;
15680Sstevel@tonic-gate 	struct statvfs statvfs;
15690Sstevel@tonic-gate 	char *cp;
15700Sstevel@tonic-gate 
15710Sstevel@tonic-gate 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
15720Sstevel@tonic-gate 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
15730Sstevel@tonic-gate 	    == sizeof (statvfs)) {
15740Sstevel@tonic-gate 		(void) printf(
15750Sstevel@tonic-gate 		"%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
15767088Sraf 		    pri->pname,
15777088Sraf 		    statvfs.f_bsize,
15787088Sraf 		    statvfs.f_frsize,
15797088Sraf 		    (u_longlong_t)statvfs.f_blocks,
15807088Sraf 		    (u_longlong_t)statvfs.f_bfree);
15810Sstevel@tonic-gate 		(void) printf(
15820Sstevel@tonic-gate 		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
15837088Sraf 		    pri->pname,
15847088Sraf 		    (u_longlong_t)statvfs.f_bavail,
15857088Sraf 		    (u_longlong_t)statvfs.f_files,
15867088Sraf 		    (u_longlong_t)statvfs.f_ffree,
15877088Sraf 		    (u_longlong_t)statvfs.f_favail);
15880Sstevel@tonic-gate 		(void) printf(
15897088Sraf 		    "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
15907088Sraf 		    pri->pname,
15917088Sraf 		    statvfs.f_fsid,
15927088Sraf 		    statvfs.f_basetype,
15937088Sraf 		    (long)statvfs.f_namemax);
15940Sstevel@tonic-gate 		(void) printf(
15957088Sraf 		    "%s\tflag=%s\n",
15967088Sraf 		    pri->pname,
15977088Sraf 		    svfsflags(pri, (ulong_t)statvfs.f_flag));
15980Sstevel@tonic-gate 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
15990Sstevel@tonic-gate 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
16000Sstevel@tonic-gate 		    *(cp+1) != '\0')
16010Sstevel@tonic-gate 			*cp = ' ';
16020Sstevel@tonic-gate 		(void) printf("%s\tfstr=\"%.*s\"\n",
16037088Sraf 		    pri->pname,
16047088Sraf 		    (int)sizeof (statvfs.f_fstr),
16057088Sraf 		    statvfs.f_fstr);
16060Sstevel@tonic-gate 	}
16070Sstevel@tonic-gate }
16080Sstevel@tonic-gate 
16090Sstevel@tonic-gate #ifdef _LP64
16100Sstevel@tonic-gate void
16110Sstevel@tonic-gate show_statvfs32(private_t *pri)
16120Sstevel@tonic-gate {
16130Sstevel@tonic-gate 	long offset;
16140Sstevel@tonic-gate 	struct statvfs32 statvfs;
16150Sstevel@tonic-gate 	char *cp;
16160Sstevel@tonic-gate 
16170Sstevel@tonic-gate 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
16180Sstevel@tonic-gate 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
16190Sstevel@tonic-gate 	    == sizeof (statvfs)) {
16200Sstevel@tonic-gate 		(void) printf(
16217088Sraf 		    "%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
16227088Sraf 		    pri->pname,
16237088Sraf 		    statvfs.f_bsize,
16247088Sraf 		    statvfs.f_frsize,
16257088Sraf 		    statvfs.f_blocks,
16267088Sraf 		    statvfs.f_bfree);
16270Sstevel@tonic-gate 		(void) printf(
16287088Sraf 		    "%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
16297088Sraf 		    pri->pname,
16307088Sraf 		    statvfs.f_bavail,
16317088Sraf 		    statvfs.f_files,
16327088Sraf 		    statvfs.f_ffree,
16337088Sraf 		    statvfs.f_favail);
16340Sstevel@tonic-gate 		(void) printf(
16357088Sraf 		    "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
16367088Sraf 		    pri->pname,
16377088Sraf 		    statvfs.f_fsid,
16387088Sraf 		    statvfs.f_basetype,
16397088Sraf 		    (int)statvfs.f_namemax);
16400Sstevel@tonic-gate 		(void) printf(
16417088Sraf 		    "%s\tflag=%s\n",
16427088Sraf 		    pri->pname,
16437088Sraf 		    svfsflags(pri, (ulong_t)statvfs.f_flag));
16440Sstevel@tonic-gate 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
16450Sstevel@tonic-gate 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
16460Sstevel@tonic-gate 		    *(cp+1) != '\0')
16470Sstevel@tonic-gate 			*cp = ' ';
16480Sstevel@tonic-gate 		(void) printf("%s\tfstr=\"%.*s\"\n",
16497088Sraf 		    pri->pname,
16507088Sraf 		    (int)sizeof (statvfs.f_fstr),
16517088Sraf 		    statvfs.f_fstr);
16520Sstevel@tonic-gate 	}
16530Sstevel@tonic-gate }
16540Sstevel@tonic-gate #endif	/* _LP64 */
16550Sstevel@tonic-gate 
16560Sstevel@tonic-gate void
16570Sstevel@tonic-gate show_statvfs64(private_t *pri)
16580Sstevel@tonic-gate {
16590Sstevel@tonic-gate 	long offset;
16600Sstevel@tonic-gate 	struct statvfs64_32 statvfs;
16610Sstevel@tonic-gate 	char *cp;
16620Sstevel@tonic-gate 
16630Sstevel@tonic-gate 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
16640Sstevel@tonic-gate 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
16650Sstevel@tonic-gate 	    == sizeof (statvfs)) {
16660Sstevel@tonic-gate 		(void) printf(
16677088Sraf 		    "%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
16687088Sraf 		    pri->pname,
16697088Sraf 		    statvfs.f_bsize,
16707088Sraf 		    statvfs.f_frsize,
16717088Sraf 		    (u_longlong_t)statvfs.f_blocks,
16727088Sraf 		    (u_longlong_t)statvfs.f_bfree);
16730Sstevel@tonic-gate 		(void) printf(
16740Sstevel@tonic-gate 		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
16757088Sraf 		    pri->pname,
16767088Sraf 		    (u_longlong_t)statvfs.f_bavail,
16777088Sraf 		    (u_longlong_t)statvfs.f_files,
16787088Sraf 		    (u_longlong_t)statvfs.f_ffree,
16797088Sraf 		    (u_longlong_t)statvfs.f_favail);
16800Sstevel@tonic-gate 		(void) printf(
16817088Sraf 		    "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
16827088Sraf 		    pri->pname,
16837088Sraf 		    statvfs.f_fsid,
16847088Sraf 		    statvfs.f_basetype,
16857088Sraf 		    (int)statvfs.f_namemax);
16860Sstevel@tonic-gate 		(void) printf(
16877088Sraf 		    "%s\tflag=%s\n",
16887088Sraf 		    pri->pname,
16897088Sraf 		    svfsflags(pri, (ulong_t)statvfs.f_flag));
16900Sstevel@tonic-gate 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
16910Sstevel@tonic-gate 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
16920Sstevel@tonic-gate 		    *(cp+1) != '\0')
16930Sstevel@tonic-gate 			*cp = ' ';
16940Sstevel@tonic-gate 		(void) printf("%s\tfstr=\"%.*s\"\n",
16957088Sraf 		    pri->pname,
16967088Sraf 		    (int)sizeof (statvfs.f_fstr),
16977088Sraf 		    statvfs.f_fstr);
16980Sstevel@tonic-gate 	}
16990Sstevel@tonic-gate }
17000Sstevel@tonic-gate 
17010Sstevel@tonic-gate void
17020Sstevel@tonic-gate show_statfs(private_t *pri)
17030Sstevel@tonic-gate {
17040Sstevel@tonic-gate 	long offset;
17050Sstevel@tonic-gate 	struct statfs statfs;
17060Sstevel@tonic-gate 
17070Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
17080Sstevel@tonic-gate 	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
17090Sstevel@tonic-gate 		(void) printf(
17100Sstevel@tonic-gate 		"%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
17117088Sraf 		    pri->pname,
17127088Sraf 		    statfs.f_fstyp,
17137088Sraf 		    statfs.f_bsize,
17147088Sraf 		    statfs.f_frsize,
17157088Sraf 		    statfs.f_blocks,
17167088Sraf 		    statfs.f_bfree,
17177088Sraf 		    statfs.f_files,
17187088Sraf 		    statfs.f_ffree);
17190Sstevel@tonic-gate 		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
17207088Sraf 		    pri->pname,
17217088Sraf 		    statfs.f_fname,
17227088Sraf 		    statfs.f_fpack);
17230Sstevel@tonic-gate 	}
17240Sstevel@tonic-gate }
17250Sstevel@tonic-gate 
17260Sstevel@tonic-gate #ifdef _LP64
17270Sstevel@tonic-gate void
17280Sstevel@tonic-gate show_statfs32(private_t *pri)
17290Sstevel@tonic-gate {
17300Sstevel@tonic-gate 	long offset;
17310Sstevel@tonic-gate 	struct statfs32 statfs;
17320Sstevel@tonic-gate 
17330Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
17340Sstevel@tonic-gate 	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
17350Sstevel@tonic-gate 		(void) printf(
17367088Sraf 		    "%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
17377088Sraf 		    pri->pname,
17387088Sraf 		    statfs.f_fstyp,
17397088Sraf 		    statfs.f_bsize,
17407088Sraf 		    statfs.f_frsize,
17417088Sraf 		    statfs.f_blocks,
17427088Sraf 		    statfs.f_bfree,
17437088Sraf 		    statfs.f_files,
17447088Sraf 		    statfs.f_ffree);
17450Sstevel@tonic-gate 		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
17467088Sraf 		    pri->pname,
17477088Sraf 		    statfs.f_fname,
17487088Sraf 		    statfs.f_fpack);
17490Sstevel@tonic-gate 	}
17500Sstevel@tonic-gate }
17510Sstevel@tonic-gate #endif	/* _LP64 */
17520Sstevel@tonic-gate 
17530Sstevel@tonic-gate void
17540Sstevel@tonic-gate show_flock32(private_t *pri, long offset)
17550Sstevel@tonic-gate {
17560Sstevel@tonic-gate 	struct flock32 flock;
17570Sstevel@tonic-gate 
17580Sstevel@tonic-gate 	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
17590Sstevel@tonic-gate 		const char *str = NULL;
17600Sstevel@tonic-gate 
17610Sstevel@tonic-gate 		(void) printf("%s\ttyp=", pri->pname);
17620Sstevel@tonic-gate 
17630Sstevel@tonic-gate 		switch (flock.l_type) {
17640Sstevel@tonic-gate 		case F_RDLCK:
17650Sstevel@tonic-gate 			str = "F_RDLCK";
17660Sstevel@tonic-gate 			break;
17670Sstevel@tonic-gate 		case F_WRLCK:
17680Sstevel@tonic-gate 			str = "F_WRLCK";
17690Sstevel@tonic-gate 			break;
17700Sstevel@tonic-gate 		case F_UNLCK:
17710Sstevel@tonic-gate 			str = "F_UNLCK";
17720Sstevel@tonic-gate 			break;
17730Sstevel@tonic-gate 		}
17740Sstevel@tonic-gate 		if (str != NULL)
17750Sstevel@tonic-gate 			(void) printf("%s", str);
17760Sstevel@tonic-gate 		else
17770Sstevel@tonic-gate 			(void) printf("%-7d", flock.l_type);
17780Sstevel@tonic-gate 
17790Sstevel@tonic-gate 		str = whencearg(flock.l_whence);
17800Sstevel@tonic-gate 		if (str != NULL)
17810Sstevel@tonic-gate 			(void) printf("  whence=%s", str);
17820Sstevel@tonic-gate 		else
17830Sstevel@tonic-gate 			(void) printf("  whence=%-8u", flock.l_whence);
17840Sstevel@tonic-gate 
17850Sstevel@tonic-gate 		(void) printf(
17867088Sraf 		    " start=%-5d len=%-5d sys=%-2u pid=%d\n",
17877088Sraf 		    flock.l_start,
17887088Sraf 		    flock.l_len,
17897088Sraf 		    flock.l_sysid,
17907088Sraf 		    flock.l_pid);
17910Sstevel@tonic-gate 	}
17920Sstevel@tonic-gate }
17930Sstevel@tonic-gate 
17940Sstevel@tonic-gate void
17950Sstevel@tonic-gate show_flock64(private_t *pri, long offset)
17960Sstevel@tonic-gate {
17970Sstevel@tonic-gate 	struct flock64 flock;
17980Sstevel@tonic-gate 
17990Sstevel@tonic-gate 	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
18000Sstevel@tonic-gate 		const char *str = NULL;
18010Sstevel@tonic-gate 
18020Sstevel@tonic-gate 		(void) printf("%s\ttyp=", pri->pname);
18030Sstevel@tonic-gate 
18040Sstevel@tonic-gate 		switch (flock.l_type) {
18050Sstevel@tonic-gate 		case F_RDLCK:
18060Sstevel@tonic-gate 			str = "F_RDLCK";
18070Sstevel@tonic-gate 			break;
18080Sstevel@tonic-gate 		case F_WRLCK:
18090Sstevel@tonic-gate 			str = "F_WRLCK";
18100Sstevel@tonic-gate 			break;
18110Sstevel@tonic-gate 		case F_UNLCK:
18120Sstevel@tonic-gate 			str = "F_UNLCK";
18130Sstevel@tonic-gate 			break;
18140Sstevel@tonic-gate 		}
18150Sstevel@tonic-gate 		if (str != NULL)
18160Sstevel@tonic-gate 			(void) printf("%s", str);
18170Sstevel@tonic-gate 		else
18180Sstevel@tonic-gate 			(void) printf("%-7d", flock.l_type);
18190Sstevel@tonic-gate 
18200Sstevel@tonic-gate 		str = whencearg(flock.l_whence);
18210Sstevel@tonic-gate 		if (str != NULL)
18220Sstevel@tonic-gate 			(void) printf("  whence=%s", str);
18230Sstevel@tonic-gate 		else
18240Sstevel@tonic-gate 			(void) printf("  whence=%-8u", flock.l_whence);
18250Sstevel@tonic-gate 
18260Sstevel@tonic-gate 		(void) printf(
18277088Sraf 		    " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
18287088Sraf 		    (long long)flock.l_start,
18297088Sraf 		    (long long)flock.l_len,
18307088Sraf 		    flock.l_sysid,
18317088Sraf 		    (int)flock.l_pid);
18320Sstevel@tonic-gate 	}
18330Sstevel@tonic-gate }
18340Sstevel@tonic-gate 
18350Sstevel@tonic-gate void
18360Sstevel@tonic-gate show_share(private_t *pri, long offset)
18370Sstevel@tonic-gate {
18380Sstevel@tonic-gate 	struct fshare fshare;
18390Sstevel@tonic-gate 
18400Sstevel@tonic-gate 	if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
18410Sstevel@tonic-gate 		const char *str = NULL;
18420Sstevel@tonic-gate 		int manddny = 0;
18430Sstevel@tonic-gate 
18440Sstevel@tonic-gate 		(void) printf("%s\taccess=", pri->pname);
18450Sstevel@tonic-gate 
18460Sstevel@tonic-gate 		switch (fshare.f_access) {
18470Sstevel@tonic-gate 		case F_RDACC:
18480Sstevel@tonic-gate 			str = "F_RDACC";
18490Sstevel@tonic-gate 			break;
18500Sstevel@tonic-gate 		case F_WRACC:
18510Sstevel@tonic-gate 			str = "F_WRACC";
18520Sstevel@tonic-gate 			break;
18530Sstevel@tonic-gate 		case F_RWACC:
18540Sstevel@tonic-gate 			str = "F_RWACC";
18550Sstevel@tonic-gate 			break;
18560Sstevel@tonic-gate 		}
18570Sstevel@tonic-gate 		if (str != NULL)
18580Sstevel@tonic-gate 			(void) printf("%s", str);
18590Sstevel@tonic-gate 		else
18600Sstevel@tonic-gate 			(void) printf("%-7d", fshare.f_access);
18610Sstevel@tonic-gate 
18620Sstevel@tonic-gate 		str = NULL;
18630Sstevel@tonic-gate 		if (fshare.f_deny & F_MANDDNY) {
18640Sstevel@tonic-gate 			fshare.f_deny &= ~F_MANDDNY;
18650Sstevel@tonic-gate 			manddny = 1;
18660Sstevel@tonic-gate 		}
18670Sstevel@tonic-gate 		switch (fshare.f_deny) {
18680Sstevel@tonic-gate 		case F_NODNY:
18690Sstevel@tonic-gate 			str = "F_NODNY";
18700Sstevel@tonic-gate 			break;
18710Sstevel@tonic-gate 		case F_RDDNY:
18720Sstevel@tonic-gate 			str = "F_RDDNY";
18730Sstevel@tonic-gate 			break;
18740Sstevel@tonic-gate 		case F_WRDNY:
18750Sstevel@tonic-gate 			str = "F_WRDNY";
18760Sstevel@tonic-gate 			break;
18770Sstevel@tonic-gate 		case F_RWDNY:
18780Sstevel@tonic-gate 			str = "F_RWDNY";
18790Sstevel@tonic-gate 			break;
18800Sstevel@tonic-gate 		case F_COMPAT:
18810Sstevel@tonic-gate 			str = "F_COMPAT";
18820Sstevel@tonic-gate 			break;
18830Sstevel@tonic-gate 		}
18840Sstevel@tonic-gate 		if (str != NULL) {
18850Sstevel@tonic-gate 			if (manddny)
18860Sstevel@tonic-gate 				(void) printf("  deny=F_MANDDNY|%s", str);
18870Sstevel@tonic-gate 			else
18880Sstevel@tonic-gate 				(void) printf("  deny=%s", str);
18890Sstevel@tonic-gate 		} else {
18900Sstevel@tonic-gate 			(void) printf("  deny=0x%x", manddny?
18917088Sraf 			    fshare.f_deny | F_MANDDNY : fshare.f_deny);
18920Sstevel@tonic-gate 		}
18930Sstevel@tonic-gate 
18940Sstevel@tonic-gate 		(void) printf("  id=%x\n", fshare.f_id);
18950Sstevel@tonic-gate 	}
18960Sstevel@tonic-gate }
18970Sstevel@tonic-gate 
18980Sstevel@tonic-gate void
18990Sstevel@tonic-gate show_ffg(private_t *pri)
19000Sstevel@tonic-gate {
19010Sstevel@tonic-gate 	(void) putchar('\t');
19020Sstevel@tonic-gate 	(void) putchar('\t');
19030Sstevel@tonic-gate 	prt_ffg(pri, 0, pri->Rval1);
19040Sstevel@tonic-gate 	(void) puts(pri->sys_string);
19050Sstevel@tonic-gate }
19060Sstevel@tonic-gate 
19070Sstevel@tonic-gate /* print values in fcntl() pointed-to structure */
19080Sstevel@tonic-gate void
19090Sstevel@tonic-gate show_fcntl(private_t *pri)
19100Sstevel@tonic-gate {
19110Sstevel@tonic-gate 	long offset;
19120Sstevel@tonic-gate 
19130Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
19140Sstevel@tonic-gate 		show_ffg(pri);
19150Sstevel@tonic-gate 		return;
19160Sstevel@tonic-gate 	}
19170Sstevel@tonic-gate 
19180Sstevel@tonic-gate 	if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == NULL)
19190Sstevel@tonic-gate 		return;
19200Sstevel@tonic-gate 
19210Sstevel@tonic-gate 	switch (pri->sys_args[1]) {
19220Sstevel@tonic-gate #ifdef _LP64
19230Sstevel@tonic-gate 	case F_GETLK:
19240Sstevel@tonic-gate 	case F_SETLK:
19250Sstevel@tonic-gate 	case F_SETLKW:
19260Sstevel@tonic-gate 	case F_FREESP:
19270Sstevel@tonic-gate 	case F_ALLOCSP:
19280Sstevel@tonic-gate 	case F_SETLK_NBMAND:
19290Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
19300Sstevel@tonic-gate 			show_flock64(pri, offset);
19310Sstevel@tonic-gate 		else
19320Sstevel@tonic-gate 			show_flock32(pri, offset);
19330Sstevel@tonic-gate 		break;
19340Sstevel@tonic-gate 	case 33:	/* F_GETLK64 */
19350Sstevel@tonic-gate 	case 34:	/* F_SETLK64 */
19360Sstevel@tonic-gate 	case 35:	/* F_SETLKW64 */
19370Sstevel@tonic-gate 	case 27:	/* F_FREESP64 */
19387088Sraf 	case 28:	/* F_ALLOCSP64 */
19390Sstevel@tonic-gate 	case 44:	/* F_SETLK64_NBMAND */
19400Sstevel@tonic-gate 		show_flock64(pri, offset);
19410Sstevel@tonic-gate 		break;
19420Sstevel@tonic-gate #else	/* _LP64 */
19430Sstevel@tonic-gate 	case F_GETLK:
19440Sstevel@tonic-gate 	case F_SETLK:
19450Sstevel@tonic-gate 	case F_SETLKW:
19460Sstevel@tonic-gate 	case F_FREESP:
19470Sstevel@tonic-gate 	case F_ALLOCSP:
19480Sstevel@tonic-gate 	case F_SETLK_NBMAND:
19490Sstevel@tonic-gate 		show_flock32(pri, offset);
19500Sstevel@tonic-gate 		break;
19510Sstevel@tonic-gate 	case F_GETLK64:
19520Sstevel@tonic-gate 	case F_SETLK64:
19530Sstevel@tonic-gate 	case F_SETLKW64:
19540Sstevel@tonic-gate 	case F_FREESP64:
19557088Sraf 	case F_ALLOCSP64:
19560Sstevel@tonic-gate 	case F_SETLK64_NBMAND:
19570Sstevel@tonic-gate 		show_flock64(pri, offset);
19580Sstevel@tonic-gate 		break;
19590Sstevel@tonic-gate #endif	/* _LP64 */
19600Sstevel@tonic-gate 	case F_SHARE:
19610Sstevel@tonic-gate 	case F_UNSHARE:
19620Sstevel@tonic-gate 		show_share(pri, offset);
19630Sstevel@tonic-gate 		break;
19640Sstevel@tonic-gate 	}
19650Sstevel@tonic-gate }
19660Sstevel@tonic-gate 
19670Sstevel@tonic-gate void
19680Sstevel@tonic-gate show_strbuf(private_t *pri, long offset, const char *name, int dump)
19690Sstevel@tonic-gate {
19700Sstevel@tonic-gate 	struct strbuf strbuf;
19710Sstevel@tonic-gate 
19720Sstevel@tonic-gate 	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
19730Sstevel@tonic-gate 		print_strbuf(pri, &strbuf, name, dump);
19740Sstevel@tonic-gate }
19750Sstevel@tonic-gate 
19760Sstevel@tonic-gate #ifdef _LP64
19770Sstevel@tonic-gate void
19780Sstevel@tonic-gate show_strbuf32(private_t *pri, long offset, const char *name, int dump)
19790Sstevel@tonic-gate {
19800Sstevel@tonic-gate 	struct strbuf32 strbuf;
19810Sstevel@tonic-gate 
19820Sstevel@tonic-gate 	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
19830Sstevel@tonic-gate 		print_strbuf32(pri, &strbuf, name, dump);
19840Sstevel@tonic-gate }
19850Sstevel@tonic-gate #endif	/* _LP64 */
19860Sstevel@tonic-gate 
19870Sstevel@tonic-gate void
19880Sstevel@tonic-gate show_gp_msg(private_t *pri, int what)
19890Sstevel@tonic-gate {
19900Sstevel@tonic-gate 	long offset;
19910Sstevel@tonic-gate 	int dump = FALSE;
19920Sstevel@tonic-gate 	int fdp1 = pri->sys_args[0] + 1;
19930Sstevel@tonic-gate 
19940Sstevel@tonic-gate 	switch (what) {
19950Sstevel@tonic-gate 	case SYS_getmsg:
19960Sstevel@tonic-gate 	case SYS_getpmsg:
19970Sstevel@tonic-gate 		if (pri->Errno == 0 && prismember(&readfd, fdp1))
19980Sstevel@tonic-gate 			dump = TRUE;
19990Sstevel@tonic-gate 		break;
20000Sstevel@tonic-gate 	case SYS_putmsg:
20010Sstevel@tonic-gate 	case SYS_putpmsg:
20020Sstevel@tonic-gate 		if (prismember(&writefd, fdp1))
20030Sstevel@tonic-gate 			dump = TRUE;
20040Sstevel@tonic-gate 		break;
20050Sstevel@tonic-gate 	}
20060Sstevel@tonic-gate 
20070Sstevel@tonic-gate 	/* enter region of lengthy output */
20080Sstevel@tonic-gate 	if (dump)
20090Sstevel@tonic-gate 		Eserialize();
20100Sstevel@tonic-gate 
20110Sstevel@tonic-gate #ifdef _LP64
20120Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL) {
20130Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
20140Sstevel@tonic-gate 			show_strbuf(pri, offset, "ctl", dump);
20150Sstevel@tonic-gate 		else
20160Sstevel@tonic-gate 			show_strbuf32(pri, offset, "ctl", dump);
20170Sstevel@tonic-gate 	}
20180Sstevel@tonic-gate 	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL) {
20190Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
20200Sstevel@tonic-gate 			show_strbuf(pri, offset, "dat", dump);
20210Sstevel@tonic-gate 		else
20220Sstevel@tonic-gate 			show_strbuf32(pri, offset, "dat", dump);
20230Sstevel@tonic-gate 	}
20240Sstevel@tonic-gate #else	/* _LP64 */
20250Sstevel@tonic-gate 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL)
20260Sstevel@tonic-gate 		show_strbuf(pri, offset, "ctl", dump);
20270Sstevel@tonic-gate 	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL)
20280Sstevel@tonic-gate 		show_strbuf(pri, offset, "dat", dump);
20290Sstevel@tonic-gate #endif	/* _LP64 */
20300Sstevel@tonic-gate 
20310Sstevel@tonic-gate 	/* exit region of lengthy output */
20320Sstevel@tonic-gate 	if (dump)
20330Sstevel@tonic-gate 		Xserialize();
20340Sstevel@tonic-gate }
20350Sstevel@tonic-gate 
20360Sstevel@tonic-gate void
20370Sstevel@tonic-gate show_int(private_t *pri, long offset, const char *name)
20380Sstevel@tonic-gate {
20390Sstevel@tonic-gate 	int value;
20400Sstevel@tonic-gate 
20410Sstevel@tonic-gate 	if (offset != 0 &&
20420Sstevel@tonic-gate 	    Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
20430Sstevel@tonic-gate 		(void) printf("%s\t%s:\t%d\n",
20447088Sraf 		    pri->pname,
20457088Sraf 		    name,
20467088Sraf 		    value);
20470Sstevel@tonic-gate }
20480Sstevel@tonic-gate 
20490Sstevel@tonic-gate void
20500Sstevel@tonic-gate show_hhex_int(private_t *pri, long offset, const char *name)
20510Sstevel@tonic-gate {
20520Sstevel@tonic-gate 	int value;
20530Sstevel@tonic-gate 
20540Sstevel@tonic-gate 	if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
20550Sstevel@tonic-gate 		(void) printf("%s\t%s:\t0x%.4X\n",
20567088Sraf 		    pri->pname,
20577088Sraf 		    name,
20587088Sraf 		    value);
20590Sstevel@tonic-gate }
20600Sstevel@tonic-gate 
20610Sstevel@tonic-gate #define	ALL_POLL_FLAGS	(POLLIN|POLLPRI|POLLOUT| \
20620Sstevel@tonic-gate 	POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
20630Sstevel@tonic-gate 
20640Sstevel@tonic-gate const char *
20650Sstevel@tonic-gate pollevent(private_t *pri, int arg)
20660Sstevel@tonic-gate {
20670Sstevel@tonic-gate 	char *str = pri->code_buf;
20680Sstevel@tonic-gate 
20690Sstevel@tonic-gate 	if (arg == 0)
20700Sstevel@tonic-gate 		return ("0");
20710Sstevel@tonic-gate 	if (arg & ~ALL_POLL_FLAGS) {
20720Sstevel@tonic-gate 		(void) sprintf(str, "0x%-5X", arg);
20730Sstevel@tonic-gate 		return ((const char *)str);
20740Sstevel@tonic-gate 	}
20750Sstevel@tonic-gate 
20760Sstevel@tonic-gate 	*str = '\0';
20770Sstevel@tonic-gate 	if (arg & POLLIN)
20780Sstevel@tonic-gate 		(void) strcat(str, "|POLLIN");
20790Sstevel@tonic-gate 	if (arg & POLLPRI)
20800Sstevel@tonic-gate 		(void) strcat(str, "|POLLPRI");
20810Sstevel@tonic-gate 	if (arg & POLLOUT)
20820Sstevel@tonic-gate 		(void) strcat(str, "|POLLOUT");
20830Sstevel@tonic-gate 	if (arg & POLLRDNORM)
20840Sstevel@tonic-gate 		(void) strcat(str, "|POLLRDNORM");
20850Sstevel@tonic-gate 	if (arg & POLLRDBAND)
20860Sstevel@tonic-gate 		(void) strcat(str, "|POLLRDBAND");
20870Sstevel@tonic-gate 	if (arg & POLLWRBAND)
20880Sstevel@tonic-gate 		(void) strcat(str, "|POLLWRBAND");
20890Sstevel@tonic-gate 	if (arg & POLLERR)
20900Sstevel@tonic-gate 		(void) strcat(str, "|POLLERR");
20910Sstevel@tonic-gate 	if (arg & POLLHUP)
20920Sstevel@tonic-gate 		(void) strcat(str, "|POLLHUP");
20930Sstevel@tonic-gate 	if (arg & POLLNVAL)
20940Sstevel@tonic-gate 		(void) strcat(str, "|POLLNVAL");
20950Sstevel@tonic-gate 
20960Sstevel@tonic-gate 	return ((const char *)(str+1));
20970Sstevel@tonic-gate }
20980Sstevel@tonic-gate 
20990Sstevel@tonic-gate static void
21000Sstevel@tonic-gate show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
21010Sstevel@tonic-gate {
21020Sstevel@tonic-gate 	/*
21030Sstevel@tonic-gate 	 * can't print both events and revents in same printf.
21040Sstevel@tonic-gate 	 * pollevent() returns a pointer to a TSD location.
21050Sstevel@tonic-gate 	 */
21060Sstevel@tonic-gate 	(void) printf("%s\tfd=%-2d ev=%s",
21070Sstevel@tonic-gate 	    pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
21080Sstevel@tonic-gate 	(void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
21090Sstevel@tonic-gate }
21100Sstevel@tonic-gate 
21110Sstevel@tonic-gate static void
21120Sstevel@tonic-gate show_all_pollfds(private_t *pri, long offset, int nfds)
21130Sstevel@tonic-gate {
21140Sstevel@tonic-gate 	struct pollfd pollfd[2];
21150Sstevel@tonic-gate 	int skip = -1;
21160Sstevel@tonic-gate 
21170Sstevel@tonic-gate 	for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
21180Sstevel@tonic-gate 		if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
21190Sstevel@tonic-gate 		    sizeof (struct pollfd))
21200Sstevel@tonic-gate 			continue;
21210Sstevel@tonic-gate 
21220Sstevel@tonic-gate 		if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
21230Sstevel@tonic-gate 		    pollfd[0].events == pollfd[1].events &&
21240Sstevel@tonic-gate 		    pollfd[0].revents == pollfd[1].revents) {
21250Sstevel@tonic-gate 			skip++;
21260Sstevel@tonic-gate 			continue;
21270Sstevel@tonic-gate 		}
21280Sstevel@tonic-gate 
21290Sstevel@tonic-gate 		if (skip > 0)
21300Sstevel@tonic-gate 			(void) printf("%s\t...last pollfd structure"
21310Sstevel@tonic-gate 			    " repeated %d time%s...\n",
21320Sstevel@tonic-gate 			    pri->pname, skip, (skip == 1 ? "" : "s"));
21330Sstevel@tonic-gate 
21340Sstevel@tonic-gate 		skip = 0;
21350Sstevel@tonic-gate 		show_one_pollfd(pri, &pollfd[0]);
21360Sstevel@tonic-gate 		pollfd[1] = pollfd[0];
21370Sstevel@tonic-gate 	}
21380Sstevel@tonic-gate 
21390Sstevel@tonic-gate 	if (skip > 0)
21400Sstevel@tonic-gate 		(void) printf(
21410Sstevel@tonic-gate 		    "%s\t...last pollfd structure repeated %d time%s...\n",
21420Sstevel@tonic-gate 		    pri->pname, skip, (skip == 1 ? "" : "s"));
21430Sstevel@tonic-gate }
21440Sstevel@tonic-gate 
21450Sstevel@tonic-gate void
21460Sstevel@tonic-gate show_poll(private_t *pri)
21470Sstevel@tonic-gate {
21480Sstevel@tonic-gate 	long offset;
21490Sstevel@tonic-gate 	int nfds;
21500Sstevel@tonic-gate 	int serial = 0;
21510Sstevel@tonic-gate 
21520Sstevel@tonic-gate 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[0]) == NULL ||
21530Sstevel@tonic-gate 	    (nfds = pri->sys_args[1]) <= 0)
21540Sstevel@tonic-gate 		return;
21550Sstevel@tonic-gate 
21560Sstevel@tonic-gate 	/* enter region of lengthy output */
21570Sstevel@tonic-gate 	if (nfds > 32) {
21580Sstevel@tonic-gate 		Eserialize();
21590Sstevel@tonic-gate 		serial = 1;
21600Sstevel@tonic-gate 	}
21610Sstevel@tonic-gate 
21620Sstevel@tonic-gate 	show_all_pollfds(pri, offset, nfds);
21630Sstevel@tonic-gate 
21640Sstevel@tonic-gate 	/* exit region of lengthy output */
21650Sstevel@tonic-gate 	if (serial)
21660Sstevel@tonic-gate 		Xserialize();
21670Sstevel@tonic-gate }
21680Sstevel@tonic-gate 
21690Sstevel@tonic-gate void
21700Sstevel@tonic-gate show_pollsys(private_t *pri)
21710Sstevel@tonic-gate {
21720Sstevel@tonic-gate 	long offset;
21730Sstevel@tonic-gate 	int nfds;
21740Sstevel@tonic-gate 	int serial = 0;
21750Sstevel@tonic-gate 
21760Sstevel@tonic-gate 	if (pri->sys_nargs < 2)
21770Sstevel@tonic-gate 		return;
21780Sstevel@tonic-gate 
21790Sstevel@tonic-gate 	offset = pri->sys_args[0];
21800Sstevel@tonic-gate 	nfds = pri->sys_args[1];
21810Sstevel@tonic-gate 
21820Sstevel@tonic-gate 	/* enter region of lengthy output */
21830Sstevel@tonic-gate 	if (offset != NULL && nfds > 32) {
21840Sstevel@tonic-gate 		Eserialize();
21850Sstevel@tonic-gate 		serial = 1;
21860Sstevel@tonic-gate 	}
21870Sstevel@tonic-gate 
21880Sstevel@tonic-gate 	if (offset != NULL && nfds > 0)
21890Sstevel@tonic-gate 		show_all_pollfds(pri, offset, nfds);
21900Sstevel@tonic-gate 
21910Sstevel@tonic-gate 	if (pri->sys_nargs > 2)
21920Sstevel@tonic-gate 		show_timestruc(pri, (long)pri->sys_args[2], "timeout");
21930Sstevel@tonic-gate 
21940Sstevel@tonic-gate 	if (pri->sys_nargs > 3)
21950Sstevel@tonic-gate 		show_sigset(pri, (long)pri->sys_args[3], "sigmask");
21960Sstevel@tonic-gate 
21970Sstevel@tonic-gate 	/* exit region of lengthy output */
21980Sstevel@tonic-gate 	if (serial)
21990Sstevel@tonic-gate 		Xserialize();
22000Sstevel@tonic-gate }
22010Sstevel@tonic-gate 
22020Sstevel@tonic-gate static void
22030Sstevel@tonic-gate show_perm64(private_t *pri, struct ipc_perm64 *ip)
22040Sstevel@tonic-gate {
22054321Scasper 	(void) printf("%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u z=%-5d "
22060Sstevel@tonic-gate 	    "m=0%.6o key=%d projid=%-5d\n",
22070Sstevel@tonic-gate 	    pri->pname,
22084321Scasper 	    ip->ipcx_uid,
22094321Scasper 	    ip->ipcx_gid,
22104321Scasper 	    ip->ipcx_cuid,
22114321Scasper 	    ip->ipcx_cgid,
22120Sstevel@tonic-gate 	    (int)ip->ipcx_zoneid,
22130Sstevel@tonic-gate 	    (unsigned int)ip->ipcx_mode,
22140Sstevel@tonic-gate 	    ip->ipcx_key,
22150Sstevel@tonic-gate 	    (int)ip->ipcx_projid);
22160Sstevel@tonic-gate }
22170Sstevel@tonic-gate 
22180Sstevel@tonic-gate void
22190Sstevel@tonic-gate show_perm(private_t *pri, struct ipc_perm *ip)
22200Sstevel@tonic-gate {
22210Sstevel@tonic-gate 	(void) printf(
22227088Sraf 	    "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
22237088Sraf 	    pri->pname,
22247088Sraf 	    ip->uid,
22257088Sraf 	    ip->gid,
22267088Sraf 	    ip->cuid,
22277088Sraf 	    ip->cgid,
22287088Sraf 	    (int)ip->mode,
22297088Sraf 	    ip->seq,
22307088Sraf 	    ip->key);
22310Sstevel@tonic-gate }
22320Sstevel@tonic-gate 
22330Sstevel@tonic-gate #ifdef _LP64
22340Sstevel@tonic-gate void
22350Sstevel@tonic-gate show_perm32(private_t *pri, struct ipc_perm32 *ip)
22360Sstevel@tonic-gate {
22370Sstevel@tonic-gate 	(void) printf(
22387088Sraf 	    "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
22397088Sraf 	    pri->pname,
22407088Sraf 	    ip->uid,
22417088Sraf 	    ip->gid,
22427088Sraf 	    ip->cuid,
22437088Sraf 	    ip->cgid,
22447088Sraf 	    ip->mode,
22457088Sraf 	    ip->seq,
22467088Sraf 	    ip->key);
22470Sstevel@tonic-gate }
22480Sstevel@tonic-gate #endif	/* _LP64 */
22490Sstevel@tonic-gate 
22500Sstevel@tonic-gate static void
22510Sstevel@tonic-gate show_msgctl64(private_t *pri, long offset)
22520Sstevel@tonic-gate {
22530Sstevel@tonic-gate 	struct msqid_ds64 msgq;
22540Sstevel@tonic-gate 
22550Sstevel@tonic-gate 	if (offset != NULL &&
22560Sstevel@tonic-gate 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
22570Sstevel@tonic-gate 		show_perm64(pri, &msgq.msgx_perm);
22580Sstevel@tonic-gate 
22590Sstevel@tonic-gate 		(void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
22600Sstevel@tonic-gate 		    "lspid=%-5d lrpid=%-5d\n", pri->pname,
22610Sstevel@tonic-gate 		    (unsigned long long)msgq.msgx_cbytes,
22620Sstevel@tonic-gate 		    (unsigned long long)msgq.msgx_qnum,
22630Sstevel@tonic-gate 		    (unsigned long long)msgq.msgx_qbytes,
22640Sstevel@tonic-gate 		    (int)msgq.msgx_lspid,
22650Sstevel@tonic-gate 		    (int)msgq.msgx_lrpid);
22660Sstevel@tonic-gate 
22670Sstevel@tonic-gate 		prtime(pri, "    st = ", (time_t)msgq.msgx_stime);
22680Sstevel@tonic-gate 		prtime(pri, "    rt = ", (time_t)msgq.msgx_rtime);
22690Sstevel@tonic-gate 		prtime(pri, "    ct = ", (time_t)msgq.msgx_ctime);
22700Sstevel@tonic-gate 	}
22710Sstevel@tonic-gate }
22720Sstevel@tonic-gate 
22730Sstevel@tonic-gate void
22740Sstevel@tonic-gate show_msgctl(private_t *pri, long offset)
22750Sstevel@tonic-gate {
22760Sstevel@tonic-gate 	struct msqid_ds msgq;
22770Sstevel@tonic-gate 
22780Sstevel@tonic-gate 	if (offset != NULL &&
22790Sstevel@tonic-gate 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
22800Sstevel@tonic-gate 		show_perm(pri, &msgq.msg_perm);
22810Sstevel@tonic-gate 
22820Sstevel@tonic-gate 		(void) printf(
22830Sstevel@tonic-gate 	"%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
22847088Sraf 		    pri->pname,
22857088Sraf 		    msgq.msg_cbytes,
22867088Sraf 		    msgq.msg_qnum,
22877088Sraf 		    msgq.msg_qbytes,
22887088Sraf 		    (int)msgq.msg_lspid,
22897088Sraf 		    (int)msgq.msg_lrpid);
22900Sstevel@tonic-gate 
22910Sstevel@tonic-gate 		prtime(pri, "    st = ", msgq.msg_stime);
22920Sstevel@tonic-gate 		prtime(pri, "    rt = ", msgq.msg_rtime);
22930Sstevel@tonic-gate 		prtime(pri, "    ct = ", msgq.msg_ctime);
22940Sstevel@tonic-gate 	}
22950Sstevel@tonic-gate }
22960Sstevel@tonic-gate 
22970Sstevel@tonic-gate #ifdef _LP64
22980Sstevel@tonic-gate void
22990Sstevel@tonic-gate show_msgctl32(private_t *pri, long offset)
23000Sstevel@tonic-gate {
23010Sstevel@tonic-gate 	struct msqid_ds32 msgq;
23020Sstevel@tonic-gate 
23030Sstevel@tonic-gate 	if (offset != NULL &&
23040Sstevel@tonic-gate 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
23050Sstevel@tonic-gate 		show_perm32(pri, &msgq.msg_perm);
23060Sstevel@tonic-gate 
23070Sstevel@tonic-gate 		(void) printf(
23080Sstevel@tonic-gate 	"%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
23097088Sraf 		    pri->pname,
23107088Sraf 		    msgq.msg_cbytes,
23117088Sraf 		    msgq.msg_qnum,
23127088Sraf 		    msgq.msg_qbytes,
23137088Sraf 		    msgq.msg_lspid,
23147088Sraf 		    msgq.msg_lrpid);
23150Sstevel@tonic-gate 
23160Sstevel@tonic-gate 		prtime(pri, "    st = ", msgq.msg_stime);
23170Sstevel@tonic-gate 		prtime(pri, "    rt = ", msgq.msg_rtime);
23180Sstevel@tonic-gate 		prtime(pri, "    ct = ", msgq.msg_ctime);
23190Sstevel@tonic-gate 	}
23200Sstevel@tonic-gate }
23210Sstevel@tonic-gate #endif	/* _LP64 */
23220Sstevel@tonic-gate 
23230Sstevel@tonic-gate void
23240Sstevel@tonic-gate show_msgbuf(private_t *pri, long offset, long msgsz)
23250Sstevel@tonic-gate {
23260Sstevel@tonic-gate 	struct msgbuf msgb;
23270Sstevel@tonic-gate 
23280Sstevel@tonic-gate 	if (offset != NULL &&
23290Sstevel@tonic-gate 	    Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
23300Sstevel@tonic-gate 	    sizeof (msgb.mtype)) {
23310Sstevel@tonic-gate 		/* enter region of lengthy output */
23320Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
23330Sstevel@tonic-gate 			Eserialize();
23340Sstevel@tonic-gate 
23350Sstevel@tonic-gate 		(void) printf("%s\tmtype=%lu  mtext[]=\n",
23367088Sraf 		    pri->pname,
23377088Sraf 		    msgb.mtype);
23380Sstevel@tonic-gate 		showbuffer(pri,
23397088Sraf 		    (long)(offset + sizeof (msgb.mtype)), msgsz);
23400Sstevel@tonic-gate 
23410Sstevel@tonic-gate 		/* exit region of lengthy output */
23420Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
23430Sstevel@tonic-gate 			Xserialize();
23440Sstevel@tonic-gate 	}
23450Sstevel@tonic-gate }
23460Sstevel@tonic-gate 
23470Sstevel@tonic-gate #ifdef _LP64
23480Sstevel@tonic-gate void
23490Sstevel@tonic-gate show_msgbuf32(private_t *pri, long offset, long msgsz)
23500Sstevel@tonic-gate {
23510Sstevel@tonic-gate 	struct ipcmsgbuf32 msgb;
23520Sstevel@tonic-gate 
23530Sstevel@tonic-gate 	if (offset != NULL &&
23540Sstevel@tonic-gate 	    Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
23550Sstevel@tonic-gate 	    sizeof (msgb.mtype)) {
23560Sstevel@tonic-gate 		/* enter region of lengthy output */
23570Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
23580Sstevel@tonic-gate 			Eserialize();
23590Sstevel@tonic-gate 
23600Sstevel@tonic-gate 		(void) printf("%s\tmtype=%u  mtext[]=\n",
23617088Sraf 		    pri->pname,
23627088Sraf 		    msgb.mtype);
23630Sstevel@tonic-gate 		showbuffer(pri,
23647088Sraf 		    (long)(offset + sizeof (msgb.mtype)), msgsz);
23650Sstevel@tonic-gate 
23660Sstevel@tonic-gate 		/* exit region of lengthy output */
23670Sstevel@tonic-gate 		if (msgsz > MYBUFSIZ / 4)
23680Sstevel@tonic-gate 			Xserialize();
23690Sstevel@tonic-gate 	}
23700Sstevel@tonic-gate }
23710Sstevel@tonic-gate #endif	/* _LP64 */
23720Sstevel@tonic-gate 
23730Sstevel@tonic-gate #ifdef _LP64
23740Sstevel@tonic-gate void
23750Sstevel@tonic-gate show_msgsys(private_t *pri, long msgsz)
23760Sstevel@tonic-gate {
23770Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
23780Sstevel@tonic-gate 	case 0:			/* msgget() */
23790Sstevel@tonic-gate 		break;
23800Sstevel@tonic-gate 	case 1:			/* msgctl() */
23810Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
23820Sstevel@tonic-gate 			switch (pri->sys_args[2]) {
23830Sstevel@tonic-gate 			case IPC_STAT:
23840Sstevel@tonic-gate 				if (pri->Errno)
23850Sstevel@tonic-gate 					break;
23860Sstevel@tonic-gate 				/*FALLTHROUGH*/
23870Sstevel@tonic-gate 			case IPC_SET:
23880Sstevel@tonic-gate 				if (data_model == PR_MODEL_LP64)
23890Sstevel@tonic-gate 					show_msgctl(pri,
23907088Sraf 					    (long)pri->sys_args[3]);
23910Sstevel@tonic-gate 				else
23920Sstevel@tonic-gate 					show_msgctl32(pri,
23937088Sraf 					    (long)pri->sys_args[3]);
23940Sstevel@tonic-gate 				break;
23950Sstevel@tonic-gate 			case IPC_STAT64:
23960Sstevel@tonic-gate 				if (pri->Errno)
23970Sstevel@tonic-gate 					break;
23980Sstevel@tonic-gate 				/*FALLTHROUGH*/
23990Sstevel@tonic-gate 			case IPC_SET64:
24000Sstevel@tonic-gate 				show_msgctl64(pri, (long)pri->sys_args[3]);
24010Sstevel@tonic-gate 				break;
24020Sstevel@tonic-gate 			}
24030Sstevel@tonic-gate 		}
24040Sstevel@tonic-gate 		break;
24050Sstevel@tonic-gate 	case 2:			/* msgrcv() */
24060Sstevel@tonic-gate 		if (!pri->Errno && pri->sys_nargs > 2) {
24070Sstevel@tonic-gate 			if (data_model == PR_MODEL_LP64)
24080Sstevel@tonic-gate 				show_msgbuf(pri, pri->sys_args[2], msgsz);
24090Sstevel@tonic-gate 			else
24100Sstevel@tonic-gate 				show_msgbuf32(pri, pri->sys_args[2], msgsz);
24110Sstevel@tonic-gate 		}
24120Sstevel@tonic-gate 		break;
24130Sstevel@tonic-gate 	case 3:			/* msgsnd() */
24140Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
24150Sstevel@tonic-gate 			if (data_model == PR_MODEL_LP64)
24160Sstevel@tonic-gate 				show_msgbuf(pri, pri->sys_args[2],
24177088Sraf 				    pri->sys_args[3]);
24180Sstevel@tonic-gate 			else
24190Sstevel@tonic-gate 				show_msgbuf32(pri, pri->sys_args[2],
24207088Sraf 				    pri->sys_args[3]);
24210Sstevel@tonic-gate 		}
24220Sstevel@tonic-gate 		break;
24230Sstevel@tonic-gate 	case 4:			/* msgids() */
24240Sstevel@tonic-gate 	case 5:			/* msgsnap() */
24250Sstevel@tonic-gate 	default:		/* unexpected subcode */
24260Sstevel@tonic-gate 		break;
24270Sstevel@tonic-gate 	}
24280Sstevel@tonic-gate }
24290Sstevel@tonic-gate #else	/* _LP64 */
24300Sstevel@tonic-gate void
24310Sstevel@tonic-gate show_msgsys(private_t *pri, long msgsz)
24320Sstevel@tonic-gate {
24330Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
24340Sstevel@tonic-gate 	case 0:			/* msgget() */
24350Sstevel@tonic-gate 		break;
24360Sstevel@tonic-gate 	case 1:			/* msgctl() */
24370Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
24380Sstevel@tonic-gate 			switch (pri->sys_args[2]) {
24390Sstevel@tonic-gate 			case IPC_STAT:
24400Sstevel@tonic-gate 				if (pri->Errno)
24410Sstevel@tonic-gate 					break;
24420Sstevel@tonic-gate 				/*FALLTHROUGH*/
24430Sstevel@tonic-gate 			case IPC_SET:
24440Sstevel@tonic-gate 				show_msgctl(pri, (long)pri->sys_args[3]);
24450Sstevel@tonic-gate 				break;
24460Sstevel@tonic-gate 			case IPC_STAT64:
24470Sstevel@tonic-gate 				if (pri->Errno)
24480Sstevel@tonic-gate 					break;
24490Sstevel@tonic-gate 				/*FALLTHROUGH*/
24500Sstevel@tonic-gate 			case IPC_SET64:
24510Sstevel@tonic-gate 				show_msgctl64(pri, (long)pri->sys_args[3]);
24520Sstevel@tonic-gate 				break;
24530Sstevel@tonic-gate 			}
24540Sstevel@tonic-gate 		}
24550Sstevel@tonic-gate 		break;
24560Sstevel@tonic-gate 	case 2:			/* msgrcv() */
24570Sstevel@tonic-gate 		if (!pri->Errno && pri->sys_nargs > 2)
24580Sstevel@tonic-gate 			show_msgbuf(pri, pri->sys_args[2], msgsz);
24590Sstevel@tonic-gate 		break;
24600Sstevel@tonic-gate 	case 3:			/* msgsnd() */
24610Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
24620Sstevel@tonic-gate 			show_msgbuf(pri, pri->sys_args[2],
24637088Sraf 			    pri->sys_args[3]);
24640Sstevel@tonic-gate 		break;
24650Sstevel@tonic-gate 	case 4:			/* msgids() */
24660Sstevel@tonic-gate 	case 5:			/* msgsnap() */
24670Sstevel@tonic-gate 	default:		/* unexpected subcode */
24680Sstevel@tonic-gate 		break;
24690Sstevel@tonic-gate 	}
24700Sstevel@tonic-gate }
24710Sstevel@tonic-gate #endif	/* _LP64 */
24720Sstevel@tonic-gate 
24730Sstevel@tonic-gate static void
24740Sstevel@tonic-gate show_semctl64(private_t *pri, long offset)
24750Sstevel@tonic-gate {
24760Sstevel@tonic-gate 	struct semid_ds64 semds;
24770Sstevel@tonic-gate 
24780Sstevel@tonic-gate 	if (offset != NULL &&
24790Sstevel@tonic-gate 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
24800Sstevel@tonic-gate 		show_perm64(pri, &semds.semx_perm);
24810Sstevel@tonic-gate 
24820Sstevel@tonic-gate 		(void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
24830Sstevel@tonic-gate 
24840Sstevel@tonic-gate 		prtime(pri, "    ot = ", (time_t)semds.semx_otime);
24850Sstevel@tonic-gate 		prtime(pri, "    ct = ", (time_t)semds.semx_ctime);
24860Sstevel@tonic-gate 	}
24870Sstevel@tonic-gate }
24880Sstevel@tonic-gate 
24890Sstevel@tonic-gate void
24900Sstevel@tonic-gate show_semctl(private_t *pri, long offset)
24910Sstevel@tonic-gate {
24920Sstevel@tonic-gate 	struct semid_ds semds;
24930Sstevel@tonic-gate 
24940Sstevel@tonic-gate 	if (offset != NULL &&
24950Sstevel@tonic-gate 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
24960Sstevel@tonic-gate 		show_perm(pri, &semds.sem_perm);
24970Sstevel@tonic-gate 
24980Sstevel@tonic-gate 		(void) printf("%s\tnsems=%u\n",
24997088Sraf 		    pri->pname,
25007088Sraf 		    semds.sem_nsems);
25010Sstevel@tonic-gate 
25020Sstevel@tonic-gate 		prtime(pri, "    ot = ", semds.sem_otime);
25030Sstevel@tonic-gate 		prtime(pri, "    ct = ", semds.sem_ctime);
25040Sstevel@tonic-gate 	}
25050Sstevel@tonic-gate }
25060Sstevel@tonic-gate 
25070Sstevel@tonic-gate #ifdef _LP64
25080Sstevel@tonic-gate void
25090Sstevel@tonic-gate show_semctl32(private_t *pri, long offset)
25100Sstevel@tonic-gate {
25110Sstevel@tonic-gate 	struct semid_ds32 semds;
25120Sstevel@tonic-gate 
25130Sstevel@tonic-gate 	if (offset != NULL &&
25140Sstevel@tonic-gate 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
25150Sstevel@tonic-gate 		show_perm32(pri, &semds.sem_perm);
25160Sstevel@tonic-gate 
25170Sstevel@tonic-gate 		(void) printf("%s\tnsems=%u\n",
25187088Sraf 		    pri->pname,
25197088Sraf 		    semds.sem_nsems);
25200Sstevel@tonic-gate 
25210Sstevel@tonic-gate 		prtime(pri, "    ot = ", semds.sem_otime);
25220Sstevel@tonic-gate 		prtime(pri, "    ct = ", semds.sem_ctime);
25230Sstevel@tonic-gate 	}
25240Sstevel@tonic-gate }
25250Sstevel@tonic-gate #endif	/* _LP64 */
25260Sstevel@tonic-gate 
25270Sstevel@tonic-gate void
25280Sstevel@tonic-gate show_semop(private_t *pri, long offset, long nsops, long timeout)
25290Sstevel@tonic-gate {
25300Sstevel@tonic-gate 	struct sembuf sembuf;
25310Sstevel@tonic-gate 	const char *str;
25320Sstevel@tonic-gate 
2533*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
25340Sstevel@tonic-gate 		return;
25350Sstevel@tonic-gate 
25360Sstevel@tonic-gate 	if (nsops > 40)		/* let's not be ridiculous */
25370Sstevel@tonic-gate 		nsops = 40;
25380Sstevel@tonic-gate 
25390Sstevel@tonic-gate 	for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
25400Sstevel@tonic-gate 		if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
25410Sstevel@tonic-gate 		    sizeof (sembuf))
25420Sstevel@tonic-gate 			break;
25430Sstevel@tonic-gate 
25440Sstevel@tonic-gate 		(void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
25457088Sraf 		    pri->pname,
25467088Sraf 		    sembuf.sem_num,
25477088Sraf 		    sembuf.sem_op);
25480Sstevel@tonic-gate 
25490Sstevel@tonic-gate 		if (sembuf.sem_flg == 0)
25500Sstevel@tonic-gate 			(void) printf("0\n");
25510Sstevel@tonic-gate 		else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
25520Sstevel@tonic-gate 			(void) printf("%s\n", str);
25530Sstevel@tonic-gate 		else
25540Sstevel@tonic-gate 			(void) printf("0%.6o\n", sembuf.sem_flg);
25550Sstevel@tonic-gate 	}
25560Sstevel@tonic-gate 	if (timeout)
25570Sstevel@tonic-gate 		show_timestruc(pri, timeout, "timeout");
25580Sstevel@tonic-gate }
25590Sstevel@tonic-gate 
25600Sstevel@tonic-gate void
25610Sstevel@tonic-gate show_semsys(private_t *pri)
25620Sstevel@tonic-gate {
25630Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
25640Sstevel@tonic-gate 	case 0:			/* semctl() */
25650Sstevel@tonic-gate 		if (pri->sys_nargs > 4) {
25660Sstevel@tonic-gate 			switch (pri->sys_args[3]) {
25670Sstevel@tonic-gate 			case IPC_STAT:
25680Sstevel@tonic-gate 				if (pri->Errno)
25690Sstevel@tonic-gate 					break;
25700Sstevel@tonic-gate 				/*FALLTHROUGH*/
25710Sstevel@tonic-gate 			case IPC_SET:
25720Sstevel@tonic-gate #ifdef _LP64
25730Sstevel@tonic-gate 				if (data_model == PR_MODEL_LP64)
25740Sstevel@tonic-gate 					show_semctl(pri,
25757088Sraf 					    (long)pri->sys_args[4]);
25760Sstevel@tonic-gate 				else
25770Sstevel@tonic-gate 					show_semctl32(pri,
25787088Sraf 					    (long)pri->sys_args[4]);
25790Sstevel@tonic-gate #else
25800Sstevel@tonic-gate 				show_semctl(pri, (long)pri->sys_args[4]);
25810Sstevel@tonic-gate #endif
25820Sstevel@tonic-gate 				break;
25830Sstevel@tonic-gate 			case IPC_STAT64:
25840Sstevel@tonic-gate 				if (pri->Errno)
25850Sstevel@tonic-gate 					break;
25860Sstevel@tonic-gate 				/*FALLTHROUGH*/
25870Sstevel@tonic-gate 			case IPC_SET64:
25880Sstevel@tonic-gate 				show_semctl64(pri, (long)pri->sys_args[4]);
25890Sstevel@tonic-gate 				break;
25900Sstevel@tonic-gate 			}
25910Sstevel@tonic-gate 		}
25920Sstevel@tonic-gate 		break;
25930Sstevel@tonic-gate 	case 1:			/* semget() */
25940Sstevel@tonic-gate 		break;
25950Sstevel@tonic-gate 	case 2:			/* semop() */
25960Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
25970Sstevel@tonic-gate 			show_semop(pri, (long)pri->sys_args[2],
25987088Sraf 			    pri->sys_args[3], 0);
25990Sstevel@tonic-gate 		break;
26000Sstevel@tonic-gate 	case 3:			/* semids() */
26010Sstevel@tonic-gate 		break;
26020Sstevel@tonic-gate 	case 4:			/* semtimedop() */
26030Sstevel@tonic-gate 		if (pri->sys_nargs > 4)
26040Sstevel@tonic-gate 			show_semop(pri, (long)pri->sys_args[2],
26057088Sraf 			    pri->sys_args[3], pri->sys_args[4]);
26060Sstevel@tonic-gate 		break;
26070Sstevel@tonic-gate 	default:		/* unexpected subcode */
26080Sstevel@tonic-gate 		break;
26090Sstevel@tonic-gate 	}
26100Sstevel@tonic-gate }
26110Sstevel@tonic-gate 
26120Sstevel@tonic-gate static void
26130Sstevel@tonic-gate show_shmctl64(private_t *pri, long offset)
26140Sstevel@tonic-gate {
26150Sstevel@tonic-gate 	struct shmid_ds64 shmds;
26160Sstevel@tonic-gate 
26170Sstevel@tonic-gate 	if (offset != NULL &&
26180Sstevel@tonic-gate 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
26190Sstevel@tonic-gate 		show_perm64(pri, &shmds.shmx_perm);
26200Sstevel@tonic-gate 
26210Sstevel@tonic-gate 		(void) printf(
26220Sstevel@tonic-gate 		    "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
26230Sstevel@tonic-gate 		    pri->pname,
26240Sstevel@tonic-gate 		    (unsigned long long)shmds.shmx_segsz,
26250Sstevel@tonic-gate 		    (int)shmds.shmx_lpid,
26260Sstevel@tonic-gate 		    (int)shmds.shmx_cpid,
26270Sstevel@tonic-gate 		    (unsigned long long)shmds.shmx_nattch,
26280Sstevel@tonic-gate 		    (unsigned long long)shmds.shmx_cnattch);
26290Sstevel@tonic-gate 
26300Sstevel@tonic-gate 		prtime(pri, "    at = ", (time_t)shmds.shmx_atime);
26310Sstevel@tonic-gate 		prtime(pri, "    dt = ", (time_t)shmds.shmx_dtime);
26320Sstevel@tonic-gate 		prtime(pri, "    ct = ", (time_t)shmds.shmx_ctime);
26330Sstevel@tonic-gate 	}
26340Sstevel@tonic-gate }
26350Sstevel@tonic-gate 
26360Sstevel@tonic-gate void
26370Sstevel@tonic-gate show_shmctl(private_t *pri, long offset)
26380Sstevel@tonic-gate {
26390Sstevel@tonic-gate 	struct shmid_ds shmds;
26400Sstevel@tonic-gate 
26410Sstevel@tonic-gate 	if (offset != NULL &&
26420Sstevel@tonic-gate 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
26430Sstevel@tonic-gate 		show_perm(pri, &shmds.shm_perm);
26440Sstevel@tonic-gate 
26450Sstevel@tonic-gate 		(void) printf(
26467088Sraf 		    "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
26477088Sraf 		    pri->pname,
26487088Sraf 		    (ulong_t)shmds.shm_segsz,
26497088Sraf 		    (int)shmds.shm_lpid,
26507088Sraf 		    (int)shmds.shm_cpid,
26517088Sraf 		    shmds.shm_nattch,
26527088Sraf 		    shmds.shm_cnattch);
26530Sstevel@tonic-gate 
26540Sstevel@tonic-gate 		prtime(pri, "    at = ", shmds.shm_atime);
26550Sstevel@tonic-gate 		prtime(pri, "    dt = ", shmds.shm_dtime);
26560Sstevel@tonic-gate 		prtime(pri, "    ct = ", shmds.shm_ctime);
26570Sstevel@tonic-gate 	}
26580Sstevel@tonic-gate }
26590Sstevel@tonic-gate 
26600Sstevel@tonic-gate #ifdef _LP64
26610Sstevel@tonic-gate void
26620Sstevel@tonic-gate show_shmctl32(private_t *pri, long offset)
26630Sstevel@tonic-gate {
26640Sstevel@tonic-gate 	struct shmid_ds32 shmds;
26650Sstevel@tonic-gate 
26660Sstevel@tonic-gate 	if (offset != NULL &&
26670Sstevel@tonic-gate 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
26680Sstevel@tonic-gate 		show_perm32(pri, &shmds.shm_perm);
26690Sstevel@tonic-gate 
26700Sstevel@tonic-gate 		(void) printf(
26717088Sraf 		    "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
26727088Sraf 		    pri->pname,
26737088Sraf 		    shmds.shm_segsz,
26747088Sraf 		    shmds.shm_lpid,
26757088Sraf 		    shmds.shm_cpid,
26767088Sraf 		    shmds.shm_nattch,
26777088Sraf 		    shmds.shm_cnattch);
26780Sstevel@tonic-gate 
26790Sstevel@tonic-gate 		prtime(pri, "    at = ", shmds.shm_atime);
26800Sstevel@tonic-gate 		prtime(pri, "    dt = ", shmds.shm_dtime);
26810Sstevel@tonic-gate 		prtime(pri, "    ct = ", shmds.shm_ctime);
26820Sstevel@tonic-gate 	}
26830Sstevel@tonic-gate }
26840Sstevel@tonic-gate #endif	/* _LP64 */
26850Sstevel@tonic-gate 
26860Sstevel@tonic-gate void
26870Sstevel@tonic-gate show_shmsys(private_t *pri)
26880Sstevel@tonic-gate {
26890Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
26900Sstevel@tonic-gate 	case 0:			/* shmat() */
26910Sstevel@tonic-gate 		break;
26920Sstevel@tonic-gate 	case 1:			/* shmctl() */
26930Sstevel@tonic-gate 		if (pri->sys_nargs > 3) {
26940Sstevel@tonic-gate 			switch (pri->sys_args[2]) {
26950Sstevel@tonic-gate 			case IPC_STAT:
26960Sstevel@tonic-gate 				if (pri->Errno)
26970Sstevel@tonic-gate 					break;
26980Sstevel@tonic-gate 				/*FALLTHROUGH*/
26990Sstevel@tonic-gate 			case IPC_SET:
27000Sstevel@tonic-gate #ifdef _LP64
27010Sstevel@tonic-gate 				if (data_model == PR_MODEL_LP64)
27020Sstevel@tonic-gate 					show_shmctl(pri,
27037088Sraf 					    (long)pri->sys_args[3]);
27040Sstevel@tonic-gate 				else
27050Sstevel@tonic-gate 					show_shmctl32(pri,
27067088Sraf 					    (long)pri->sys_args[3]);
27070Sstevel@tonic-gate #else
27080Sstevel@tonic-gate 				show_shmctl(pri, (long)pri->sys_args[3]);
27090Sstevel@tonic-gate #endif
27100Sstevel@tonic-gate 				break;
27110Sstevel@tonic-gate 			case IPC_STAT64:
27120Sstevel@tonic-gate 				if (pri->Errno)
27130Sstevel@tonic-gate 					break;
27140Sstevel@tonic-gate 				/*FALLTHROUGH*/
27150Sstevel@tonic-gate 			case IPC_SET64:
27160Sstevel@tonic-gate 				show_shmctl64(pri, (long)pri->sys_args[3]);
27170Sstevel@tonic-gate 				break;
27180Sstevel@tonic-gate 			}
27190Sstevel@tonic-gate 		}
27200Sstevel@tonic-gate 		break;
27210Sstevel@tonic-gate 	case 2:			/* shmdt() */
27220Sstevel@tonic-gate 	case 3:			/* shmget() */
27230Sstevel@tonic-gate 	case 4:			/* shmids() */
27240Sstevel@tonic-gate 	default:		/* unexpected subcode */
27250Sstevel@tonic-gate 		break;
27260Sstevel@tonic-gate 	}
27270Sstevel@tonic-gate }
27280Sstevel@tonic-gate 
27290Sstevel@tonic-gate void
27300Sstevel@tonic-gate show_groups(private_t *pri, long offset, long count)
27310Sstevel@tonic-gate {
27320Sstevel@tonic-gate 	int groups[100];
27330Sstevel@tonic-gate 
27340Sstevel@tonic-gate 	if (count > 100)
27350Sstevel@tonic-gate 		count = 100;
27360Sstevel@tonic-gate 
27370Sstevel@tonic-gate 	if (count > 0 && offset != NULL &&
27380Sstevel@tonic-gate 	    Pread(Proc, &groups[0], count*sizeof (int), offset) ==
27390Sstevel@tonic-gate 	    count*sizeof (int)) {
27400Sstevel@tonic-gate 		int n;
27410Sstevel@tonic-gate 
27420Sstevel@tonic-gate 		(void) printf("%s\t", pri->pname);
27430Sstevel@tonic-gate 		for (n = 0; !interrupt && n < count; n++) {
27440Sstevel@tonic-gate 			if (n != 0 && n%10 == 0)
27450Sstevel@tonic-gate 				(void) printf("\n%s\t", pri->pname);
27460Sstevel@tonic-gate 			(void) printf(" %5d", groups[n]);
27470Sstevel@tonic-gate 		}
27480Sstevel@tonic-gate 		(void) fputc('\n', stdout);
27490Sstevel@tonic-gate 	}
27500Sstevel@tonic-gate }
27510Sstevel@tonic-gate 
27520Sstevel@tonic-gate /*
27530Sstevel@tonic-gate  * This assumes that a sigset_t is simply an array of ints.
27540Sstevel@tonic-gate  */
27550Sstevel@tonic-gate char *
27560Sstevel@tonic-gate sigset_string(private_t *pri, sigset_t *sp)
27570Sstevel@tonic-gate {
27580Sstevel@tonic-gate 	char *s = pri->code_buf;
27590Sstevel@tonic-gate 	int n = sizeof (*sp) / sizeof (int32_t);
27600Sstevel@tonic-gate 	int32_t *lp = (int32_t *)sp;
27610Sstevel@tonic-gate 
27620Sstevel@tonic-gate 	while (--n >= 0) {
27630Sstevel@tonic-gate 		int32_t val = *lp++;
27640Sstevel@tonic-gate 
27650Sstevel@tonic-gate 		if (val == 0)
27660Sstevel@tonic-gate 			s += sprintf(s, " 0");
27670Sstevel@tonic-gate 		else
27680Sstevel@tonic-gate 			s += sprintf(s, " 0x%.8X", val);
27690Sstevel@tonic-gate 	}
27700Sstevel@tonic-gate 
27710Sstevel@tonic-gate 	return (pri->code_buf);
27720Sstevel@tonic-gate }
27730Sstevel@tonic-gate 
27740Sstevel@tonic-gate void
27750Sstevel@tonic-gate show_sigset(private_t *pri, long offset, const char *name)
27760Sstevel@tonic-gate {
27770Sstevel@tonic-gate 	sigset_t sigset;
27780Sstevel@tonic-gate 
27790Sstevel@tonic-gate 	if (offset != NULL &&
27800Sstevel@tonic-gate 	    Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
27810Sstevel@tonic-gate 		(void) printf("%s\t%s =%s\n",
27827088Sraf 		    pri->pname, name, sigset_string(pri, &sigset));
27830Sstevel@tonic-gate 	}
27840Sstevel@tonic-gate }
27850Sstevel@tonic-gate 
27860Sstevel@tonic-gate #ifdef _LP64
27870Sstevel@tonic-gate void
27880Sstevel@tonic-gate show_sigaltstack32(private_t *pri, long offset, const char *name)
27890Sstevel@tonic-gate {
27900Sstevel@tonic-gate 	struct sigaltstack32 altstack;
27910Sstevel@tonic-gate 
27920Sstevel@tonic-gate 	if (offset != NULL &&
27930Sstevel@tonic-gate 	    Pread(Proc, &altstack, sizeof (altstack), offset) ==
27940Sstevel@tonic-gate 	    sizeof (altstack)) {
27950Sstevel@tonic-gate 		(void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
27967088Sraf 		    pri->pname,
27977088Sraf 		    name,
27987088Sraf 		    altstack.ss_sp,
27997088Sraf 		    altstack.ss_size,
28007088Sraf 		    altstack.ss_flags);
28010Sstevel@tonic-gate 	}
28020Sstevel@tonic-gate }
28030Sstevel@tonic-gate #endif	/* _LP64 */
28040Sstevel@tonic-gate 
28050Sstevel@tonic-gate void
28060Sstevel@tonic-gate show_sigaltstack(private_t *pri, long offset, const char *name)
28070Sstevel@tonic-gate {
28080Sstevel@tonic-gate 	struct sigaltstack altstack;
28090Sstevel@tonic-gate 
28100Sstevel@tonic-gate #ifdef _LP64
28110Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
28120Sstevel@tonic-gate 		show_sigaltstack32(pri, offset, name);
28130Sstevel@tonic-gate 		return;
28140Sstevel@tonic-gate 	}
28150Sstevel@tonic-gate #endif
28160Sstevel@tonic-gate 	if (offset != NULL &&
28170Sstevel@tonic-gate 	    Pread(Proc, &altstack, sizeof (altstack), offset) ==
28180Sstevel@tonic-gate 	    sizeof (altstack)) {
28190Sstevel@tonic-gate 		(void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
28207088Sraf 		    pri->pname,
28217088Sraf 		    name,
28227088Sraf 		    (ulong_t)altstack.ss_sp,
28237088Sraf 		    (ulong_t)altstack.ss_size,
28247088Sraf 		    altstack.ss_flags);
28250Sstevel@tonic-gate 	}
28260Sstevel@tonic-gate }
28270Sstevel@tonic-gate 
28280Sstevel@tonic-gate #ifdef _LP64
28290Sstevel@tonic-gate void
28300Sstevel@tonic-gate show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
28310Sstevel@tonic-gate {
28320Sstevel@tonic-gate 	struct sigaction32 sigaction;
28330Sstevel@tonic-gate 
28340Sstevel@tonic-gate 	if (offset != NULL &&
28350Sstevel@tonic-gate 	    Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
28360Sstevel@tonic-gate 	    sizeof (sigaction)) {
28370Sstevel@tonic-gate 		/* This is stupid, we shouldn't have to do this */
28380Sstevel@tonic-gate 		if (odisp != NULL)
28390Sstevel@tonic-gate 			sigaction.sa_handler = (caddr32_t)odisp;
28400Sstevel@tonic-gate 		(void) printf(
28417088Sraf 		    "%s    %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
28427088Sraf 		    pri->pname,
28437088Sraf 		    name,
28447088Sraf 		    sigaction.sa_handler,
28457088Sraf 		    sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
28467088Sraf 		    sigaction.sa_flags);
28470Sstevel@tonic-gate 	}
28480Sstevel@tonic-gate }
28490Sstevel@tonic-gate #endif	/* _LP64 */
28500Sstevel@tonic-gate 
28510Sstevel@tonic-gate void
28520Sstevel@tonic-gate show_sigaction(private_t *pri, long offset, const char *name, long odisp)
28530Sstevel@tonic-gate {
28540Sstevel@tonic-gate 	struct sigaction sigaction;
28550Sstevel@tonic-gate 
28560Sstevel@tonic-gate #ifdef _LP64
28570Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
28580Sstevel@tonic-gate 		show_sigaction32(pri, offset, name, odisp);
28590Sstevel@tonic-gate 		return;
28600Sstevel@tonic-gate 	}
28610Sstevel@tonic-gate #endif
28620Sstevel@tonic-gate 	if (offset != NULL &&
28630Sstevel@tonic-gate 	    Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
28640Sstevel@tonic-gate 	    sizeof (sigaction)) {
28650Sstevel@tonic-gate 		/* This is stupid, we shouldn't have to do this */
28660Sstevel@tonic-gate 		if (odisp != NULL)
28670Sstevel@tonic-gate 			sigaction.sa_handler = (void (*)())odisp;
28680Sstevel@tonic-gate 		(void) printf(
28697088Sraf 		    "%s    %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
28707088Sraf 		    pri->pname,
28717088Sraf 		    name,
28727088Sraf 		    (long)sigaction.sa_handler,
28737088Sraf 		    sigset_string(pri, &sigaction.sa_mask),
28747088Sraf 		    sigaction.sa_flags);
28750Sstevel@tonic-gate 	}
28760Sstevel@tonic-gate }
28770Sstevel@tonic-gate 
28780Sstevel@tonic-gate #ifdef _LP64
28790Sstevel@tonic-gate void
28800Sstevel@tonic-gate print_siginfo32(private_t *pri, const siginfo32_t *sip)
28810Sstevel@tonic-gate {
28820Sstevel@tonic-gate 	const char *code = NULL;
28830Sstevel@tonic-gate 
28840Sstevel@tonic-gate 	(void) printf("%s      siginfo: %s", pri->pname,
28857088Sraf 	    signame(pri, sip->si_signo));
28860Sstevel@tonic-gate 
28870Sstevel@tonic-gate 	if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
28880Sstevel@tonic-gate 		(void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
28890Sstevel@tonic-gate 		if (sip->si_code != 0)
28900Sstevel@tonic-gate 			(void) printf(" code=%d", sip->si_code);
28910Sstevel@tonic-gate 		(void) fputc('\n', stdout);
28920Sstevel@tonic-gate 		return;
28930Sstevel@tonic-gate 	}
28940Sstevel@tonic-gate 
28950Sstevel@tonic-gate 	switch (sip->si_signo) {
28960Sstevel@tonic-gate 	default:
28970Sstevel@tonic-gate 		(void) fputc('\n', stdout);
28980Sstevel@tonic-gate 		return;
28990Sstevel@tonic-gate 	case SIGILL:
29000Sstevel@tonic-gate 	case SIGTRAP:
29010Sstevel@tonic-gate 	case SIGFPE:
29020Sstevel@tonic-gate 	case SIGSEGV:
29030Sstevel@tonic-gate 	case SIGBUS:
29040Sstevel@tonic-gate 	case SIGEMT:
29050Sstevel@tonic-gate 	case SIGCLD:
29060Sstevel@tonic-gate 	case SIGPOLL:
29070Sstevel@tonic-gate 	case SIGXFSZ:
29080Sstevel@tonic-gate 		break;
29090Sstevel@tonic-gate 	}
29100Sstevel@tonic-gate 
29110Sstevel@tonic-gate 	switch (sip->si_signo) {
29120Sstevel@tonic-gate 	case SIGILL:
29130Sstevel@tonic-gate 		switch (sip->si_code) {
29140Sstevel@tonic-gate 		case ILL_ILLOPC:	code = "ILL_ILLOPC";	break;
29150Sstevel@tonic-gate 		case ILL_ILLOPN:	code = "ILL_ILLOPN";	break;
29160Sstevel@tonic-gate 		case ILL_ILLADR:	code = "ILL_ILLADR";	break;
29170Sstevel@tonic-gate 		case ILL_ILLTRP:	code = "ILL_ILLTRP";	break;
29180Sstevel@tonic-gate 		case ILL_PRVOPC:	code = "ILL_PRVOPC";	break;
29190Sstevel@tonic-gate 		case ILL_PRVREG:	code = "ILL_PRVREG";	break;
29200Sstevel@tonic-gate 		case ILL_COPROC:	code = "ILL_COPROC";	break;
29210Sstevel@tonic-gate 		case ILL_BADSTK:	code = "ILL_BADSTK";	break;
29220Sstevel@tonic-gate 		}
29230Sstevel@tonic-gate 		break;
29240Sstevel@tonic-gate 	case SIGTRAP:
29250Sstevel@tonic-gate 		switch (sip->si_code) {
29260Sstevel@tonic-gate 		case TRAP_BRKPT:	code = "TRAP_BRKPT";	break;
29270Sstevel@tonic-gate 		case TRAP_TRACE:	code = "TRAP_TRACE";	break;
29280Sstevel@tonic-gate 		case TRAP_RWATCH:	code = "TRAP_RWATCH";	break;
29290Sstevel@tonic-gate 		case TRAP_WWATCH:	code = "TRAP_WWATCH";	break;
29300Sstevel@tonic-gate 		case TRAP_XWATCH:	code = "TRAP_XWATCH";	break;
29310Sstevel@tonic-gate 		case TRAP_DTRACE:	code = "TRAP_DTRACE";	break;
29320Sstevel@tonic-gate 		}
29330Sstevel@tonic-gate 		break;
29340Sstevel@tonic-gate 	case SIGFPE:
29350Sstevel@tonic-gate 		switch (sip->si_code) {
29360Sstevel@tonic-gate 		case FPE_INTDIV:	code = "FPE_INTDIV";	break;
29370Sstevel@tonic-gate 		case FPE_INTOVF:	code = "FPE_INTOVF";	break;
29380Sstevel@tonic-gate 		case FPE_FLTDIV:	code = "FPE_FLTDIV";	break;
29390Sstevel@tonic-gate 		case FPE_FLTOVF:	code = "FPE_FLTOVF";	break;
29400Sstevel@tonic-gate 		case FPE_FLTUND:	code = "FPE_FLTUND";	break;
29410Sstevel@tonic-gate 		case FPE_FLTRES:	code = "FPE_FLTRES";	break;
29420Sstevel@tonic-gate 		case FPE_FLTINV:	code = "FPE_FLTINV";	break;
29430Sstevel@tonic-gate 		case FPE_FLTSUB:	code = "FPE_FLTSUB";	break;
29440Sstevel@tonic-gate #if defined(FPE_FLTDEN)
29450Sstevel@tonic-gate 		case FPE_FLTDEN:	code = "FPE_FLTDEN";	break;
29460Sstevel@tonic-gate #endif
29470Sstevel@tonic-gate 		}
29480Sstevel@tonic-gate 		break;
29490Sstevel@tonic-gate 	case SIGSEGV:
29500Sstevel@tonic-gate 		switch (sip->si_code) {
29510Sstevel@tonic-gate 		case SEGV_MAPERR:	code = "SEGV_MAPERR";	break;
29520Sstevel@tonic-gate 		case SEGV_ACCERR:	code = "SEGV_ACCERR";	break;
29530Sstevel@tonic-gate 		}
29540Sstevel@tonic-gate 		break;
29550Sstevel@tonic-gate 	case SIGEMT:
29560Sstevel@tonic-gate 		switch (sip->si_code) {
29570Sstevel@tonic-gate #ifdef EMT_TAGOVF
29580Sstevel@tonic-gate 		case EMT_TAGOVF:	code = "EMT_TAGOVF";	break;
29590Sstevel@tonic-gate #endif
29600Sstevel@tonic-gate 		case EMT_CPCOVF:	code = "EMT_CPCOVF";	break;
29610Sstevel@tonic-gate 		}
29620Sstevel@tonic-gate 		break;
29630Sstevel@tonic-gate 	case SIGBUS:
29640Sstevel@tonic-gate 		switch (sip->si_code) {
29650Sstevel@tonic-gate 		case BUS_ADRALN:	code = "BUS_ADRALN";	break;
29660Sstevel@tonic-gate 		case BUS_ADRERR:	code = "BUS_ADRERR";	break;
29670Sstevel@tonic-gate 		case BUS_OBJERR:	code = "BUS_OBJERR";	break;
29680Sstevel@tonic-gate 		}
29690Sstevel@tonic-gate 		break;
29700Sstevel@tonic-gate 	case SIGCLD:
29710Sstevel@tonic-gate 		switch (sip->si_code) {
29720Sstevel@tonic-gate 		case CLD_EXITED:	code = "CLD_EXITED";	break;
29730Sstevel@tonic-gate 		case CLD_KILLED:	code = "CLD_KILLED";	break;
29740Sstevel@tonic-gate 		case CLD_DUMPED:	code = "CLD_DUMPED";	break;
29750Sstevel@tonic-gate 		case CLD_TRAPPED:	code = "CLD_TRAPPED";	break;
29760Sstevel@tonic-gate 		case CLD_STOPPED:	code = "CLD_STOPPED";	break;
29770Sstevel@tonic-gate 		case CLD_CONTINUED:	code = "CLD_CONTINUED";	break;
29780Sstevel@tonic-gate 		}
29790Sstevel@tonic-gate 		break;
29800Sstevel@tonic-gate 	case SIGPOLL:
29810Sstevel@tonic-gate 		switch (sip->si_code) {
29820Sstevel@tonic-gate 		case POLL_IN:		code = "POLL_IN";	break;
29830Sstevel@tonic-gate 		case POLL_OUT:		code = "POLL_OUT";	break;
29840Sstevel@tonic-gate 		case POLL_MSG:		code = "POLL_MSG";	break;
29850Sstevel@tonic-gate 		case POLL_ERR:		code = "POLL_ERR";	break;
29860Sstevel@tonic-gate 		case POLL_PRI:		code = "POLL_PRI";	break;
29870Sstevel@tonic-gate 		case POLL_HUP:		code = "POLL_HUP";	break;
29880Sstevel@tonic-gate 		}
29890Sstevel@tonic-gate 		break;
29900Sstevel@tonic-gate 	}
29910Sstevel@tonic-gate 
29920Sstevel@tonic-gate 	if (code == NULL) {
29930Sstevel@tonic-gate 		(void) sprintf(pri->code_buf, "code=%d", sip->si_code);
29940Sstevel@tonic-gate 		code = (const char *)pri->code_buf;
29950Sstevel@tonic-gate 	}
29960Sstevel@tonic-gate 
29970Sstevel@tonic-gate 	switch (sip->si_signo) {
29980Sstevel@tonic-gate 	case SIGILL:
29990Sstevel@tonic-gate 	case SIGTRAP:
30000Sstevel@tonic-gate 	case SIGFPE:
30010Sstevel@tonic-gate 	case SIGSEGV:
30020Sstevel@tonic-gate 	case SIGBUS:
30030Sstevel@tonic-gate 	case SIGEMT:
30040Sstevel@tonic-gate 		(void) printf(" %s addr=0x%.8X",
30057088Sraf 		    code,
30067088Sraf 		    sip->si_addr);
30070Sstevel@tonic-gate 		break;
30080Sstevel@tonic-gate 	case SIGCLD:
30090Sstevel@tonic-gate 		(void) printf(" %s pid=%d status=0x%.4X",
30107088Sraf 		    code,
30117088Sraf 		    sip->si_pid,
30127088Sraf 		    sip->si_status);
30130Sstevel@tonic-gate 		break;
30140Sstevel@tonic-gate 	case SIGPOLL:
30150Sstevel@tonic-gate 	case SIGXFSZ:
30160Sstevel@tonic-gate 		(void) printf(" %s fd=%d band=%d",
30177088Sraf 		    code,
30187088Sraf 		    sip->si_fd,
30197088Sraf 		    sip->si_band);
30200Sstevel@tonic-gate 		break;
30210Sstevel@tonic-gate 	}
30220Sstevel@tonic-gate 
30230Sstevel@tonic-gate 	if (sip->si_errno != 0) {
30240Sstevel@tonic-gate 		const char *ename = errname(sip->si_errno);
30250Sstevel@tonic-gate 
30260Sstevel@tonic-gate 		(void) printf(" errno=%d", sip->si_errno);
30270Sstevel@tonic-gate 		if (ename != NULL)
30280Sstevel@tonic-gate 			(void) printf("(%s)", ename);
30290Sstevel@tonic-gate 	}
30300Sstevel@tonic-gate 
30310Sstevel@tonic-gate 	(void) fputc('\n', stdout);
30320Sstevel@tonic-gate }
30330Sstevel@tonic-gate #endif	/* _LP64 */
30340Sstevel@tonic-gate 
30350Sstevel@tonic-gate void
30360Sstevel@tonic-gate print_siginfo(private_t *pri, const siginfo_t *sip)
30370Sstevel@tonic-gate {
30380Sstevel@tonic-gate 	const char *code = NULL;
30390Sstevel@tonic-gate 
30400Sstevel@tonic-gate 	(void) printf("%s      siginfo: %s", pri->pname,
30417088Sraf 	    signame(pri, sip->si_signo));
30420Sstevel@tonic-gate 
30430Sstevel@tonic-gate 	if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
30444321Scasper 		(void) printf(" pid=%d uid=%u",
30450Sstevel@tonic-gate 		    (int)sip->si_pid,
30464321Scasper 		    sip->si_uid);
30470Sstevel@tonic-gate 		if (sip->si_code != 0)
30480Sstevel@tonic-gate 			(void) printf(" code=%d", sip->si_code);
30490Sstevel@tonic-gate 		(void) fputc('\n', stdout);
30500Sstevel@tonic-gate 		return;
30510Sstevel@tonic-gate 	}
30520Sstevel@tonic-gate 
30530Sstevel@tonic-gate 	switch (sip->si_signo) {
30540Sstevel@tonic-gate 	default:
30550Sstevel@tonic-gate 		(void) fputc('\n', stdout);
30560Sstevel@tonic-gate 		return;
30570Sstevel@tonic-gate 	case SIGILL:
30580Sstevel@tonic-gate 	case SIGTRAP:
30590Sstevel@tonic-gate 	case SIGFPE:
30600Sstevel@tonic-gate 	case SIGSEGV:
30610Sstevel@tonic-gate 	case SIGBUS:
30620Sstevel@tonic-gate 	case SIGEMT:
30630Sstevel@tonic-gate 	case SIGCLD:
30640Sstevel@tonic-gate 	case SIGPOLL:
30650Sstevel@tonic-gate 	case SIGXFSZ:
30660Sstevel@tonic-gate 		break;
30670Sstevel@tonic-gate 	}
30680Sstevel@tonic-gate 
30690Sstevel@tonic-gate 	switch (sip->si_signo) {
30700Sstevel@tonic-gate 	case SIGILL:
30710Sstevel@tonic-gate 		switch (sip->si_code) {
30720Sstevel@tonic-gate 		case ILL_ILLOPC:	code = "ILL_ILLOPC";	break;
30730Sstevel@tonic-gate 		case ILL_ILLOPN:	code = "ILL_ILLOPN";	break;
30740Sstevel@tonic-gate 		case ILL_ILLADR:	code = "ILL_ILLADR";	break;
30750Sstevel@tonic-gate 		case ILL_ILLTRP:	code = "ILL_ILLTRP";	break;
30760Sstevel@tonic-gate 		case ILL_PRVOPC:	code = "ILL_PRVOPC";	break;
30770Sstevel@tonic-gate 		case ILL_PRVREG:	code = "ILL_PRVREG";	break;
30780Sstevel@tonic-gate 		case ILL_COPROC:	code = "ILL_COPROC";	break;
30790Sstevel@tonic-gate 		case ILL_BADSTK:	code = "ILL_BADSTK";	break;
30800Sstevel@tonic-gate 		}
30810Sstevel@tonic-gate 		break;
30820Sstevel@tonic-gate 	case SIGTRAP:
30830Sstevel@tonic-gate 		switch (sip->si_code) {
30840Sstevel@tonic-gate 		case TRAP_BRKPT:	code = "TRAP_BRKPT";	break;
30850Sstevel@tonic-gate 		case TRAP_TRACE:	code = "TRAP_TRACE";	break;
30860Sstevel@tonic-gate 		case TRAP_RWATCH:	code = "TRAP_RWATCH";	break;
30870Sstevel@tonic-gate 		case TRAP_WWATCH:	code = "TRAP_WWATCH";	break;
30880Sstevel@tonic-gate 		case TRAP_XWATCH:	code = "TRAP_XWATCH";	break;
30890Sstevel@tonic-gate 		case TRAP_DTRACE:	code = "TRAP_DTRACE";	break;
30900Sstevel@tonic-gate 		}
30910Sstevel@tonic-gate 		break;
30920Sstevel@tonic-gate 	case SIGFPE:
30930Sstevel@tonic-gate 		switch (sip->si_code) {
30940Sstevel@tonic-gate 		case FPE_INTDIV:	code = "FPE_INTDIV";	break;
30950Sstevel@tonic-gate 		case FPE_INTOVF:	code = "FPE_INTOVF";	break;
30960Sstevel@tonic-gate 		case FPE_FLTDIV:	code = "FPE_FLTDIV";	break;
30970Sstevel@tonic-gate 		case FPE_FLTOVF:	code = "FPE_FLTOVF";	break;
30980Sstevel@tonic-gate 		case FPE_FLTUND:	code = "FPE_FLTUND";	break;
30990Sstevel@tonic-gate 		case FPE_FLTRES:	code = "FPE_FLTRES";	break;
31000Sstevel@tonic-gate 		case FPE_FLTINV:	code = "FPE_FLTINV";	break;
31010Sstevel@tonic-gate 		case FPE_FLTSUB:	code = "FPE_FLTSUB";	break;
31020Sstevel@tonic-gate #if defined(FPE_FLTDEN)
31030Sstevel@tonic-gate 		case FPE_FLTDEN:	code = "FPE_FLTDEN";	break;
31040Sstevel@tonic-gate #endif
31050Sstevel@tonic-gate 		}
31060Sstevel@tonic-gate 		break;
31070Sstevel@tonic-gate 	case SIGSEGV:
31080Sstevel@tonic-gate 		switch (sip->si_code) {
31090Sstevel@tonic-gate 		case SEGV_MAPERR:	code = "SEGV_MAPERR";	break;
31100Sstevel@tonic-gate 		case SEGV_ACCERR:	code = "SEGV_ACCERR";	break;
31110Sstevel@tonic-gate 		}
31120Sstevel@tonic-gate 		break;
31130Sstevel@tonic-gate 	case SIGEMT:
31140Sstevel@tonic-gate 		switch (sip->si_code) {
31150Sstevel@tonic-gate #ifdef EMT_TAGOVF
31160Sstevel@tonic-gate 		case EMT_TAGOVF:	code = "EMT_TAGOVF";	break;
31170Sstevel@tonic-gate #endif
31180Sstevel@tonic-gate 		case EMT_CPCOVF:	code = "EMT_CPCOVF";	break;
31190Sstevel@tonic-gate 		}
31200Sstevel@tonic-gate 		break;
31210Sstevel@tonic-gate 	case SIGBUS:
31220Sstevel@tonic-gate 		switch (sip->si_code) {
31230Sstevel@tonic-gate 		case BUS_ADRALN:	code = "BUS_ADRALN";	break;
31240Sstevel@tonic-gate 		case BUS_ADRERR:	code = "BUS_ADRERR";	break;
31250Sstevel@tonic-gate 		case BUS_OBJERR:	code = "BUS_OBJERR";	break;
31260Sstevel@tonic-gate 		}
31270Sstevel@tonic-gate 		break;
31280Sstevel@tonic-gate 	case SIGCLD:
31290Sstevel@tonic-gate 		switch (sip->si_code) {
31300Sstevel@tonic-gate 		case CLD_EXITED:	code = "CLD_EXITED";	break;
31310Sstevel@tonic-gate 		case CLD_KILLED:	code = "CLD_KILLED";	break;
31320Sstevel@tonic-gate 		case CLD_DUMPED:	code = "CLD_DUMPED";	break;
31330Sstevel@tonic-gate 		case CLD_TRAPPED:	code = "CLD_TRAPPED";	break;
31340Sstevel@tonic-gate 		case CLD_STOPPED:	code = "CLD_STOPPED";	break;
31350Sstevel@tonic-gate 		case CLD_CONTINUED:	code = "CLD_CONTINUED";	break;
31360Sstevel@tonic-gate 		}
31370Sstevel@tonic-gate 		break;
31380Sstevel@tonic-gate 	case SIGPOLL:
31390Sstevel@tonic-gate 		switch (sip->si_code) {
31400Sstevel@tonic-gate 		case POLL_IN:		code = "POLL_IN";	break;
31410Sstevel@tonic-gate 		case POLL_OUT:		code = "POLL_OUT";	break;
31420Sstevel@tonic-gate 		case POLL_MSG:		code = "POLL_MSG";	break;
31430Sstevel@tonic-gate 		case POLL_ERR:		code = "POLL_ERR";	break;
31440Sstevel@tonic-gate 		case POLL_PRI:		code = "POLL_PRI";	break;
31450Sstevel@tonic-gate 		case POLL_HUP:		code = "POLL_HUP";	break;
31460Sstevel@tonic-gate 		}
31470Sstevel@tonic-gate 		break;
31480Sstevel@tonic-gate 	}
31490Sstevel@tonic-gate 
31500Sstevel@tonic-gate 	if (code == NULL) {
31510Sstevel@tonic-gate 		(void) sprintf(pri->code_buf, "code=%d", sip->si_code);
31520Sstevel@tonic-gate 		code = (const char *)pri->code_buf;
31530Sstevel@tonic-gate 	}
31540Sstevel@tonic-gate 
31550Sstevel@tonic-gate 	switch (sip->si_signo) {
31560Sstevel@tonic-gate 	case SIGILL:
31570Sstevel@tonic-gate 	case SIGTRAP:
31580Sstevel@tonic-gate 	case SIGFPE:
31590Sstevel@tonic-gate 	case SIGSEGV:
31600Sstevel@tonic-gate 	case SIGBUS:
31610Sstevel@tonic-gate 	case SIGEMT:
31620Sstevel@tonic-gate 		(void) printf(" %s addr=0x%.8lX",
31637088Sraf 		    code,
31647088Sraf 		    (long)sip->si_addr);
31650Sstevel@tonic-gate 		break;
31660Sstevel@tonic-gate 	case SIGCLD:
31670Sstevel@tonic-gate 		(void) printf(" %s pid=%d status=0x%.4X",
31687088Sraf 		    code,
31697088Sraf 		    (int)sip->si_pid,
31707088Sraf 		    sip->si_status);
31710Sstevel@tonic-gate 		break;
31720Sstevel@tonic-gate 	case SIGPOLL:
31730Sstevel@tonic-gate 	case SIGXFSZ:
31740Sstevel@tonic-gate 		(void) printf(" %s fd=%d band=%ld",
31757088Sraf 		    code,
31767088Sraf 		    sip->si_fd,
31777088Sraf 		    sip->si_band);
31780Sstevel@tonic-gate 		break;
31790Sstevel@tonic-gate 	}
31800Sstevel@tonic-gate 
31810Sstevel@tonic-gate 	if (sip->si_errno != 0) {
31820Sstevel@tonic-gate 		const char *ename = errname(sip->si_errno);
31830Sstevel@tonic-gate 
31840Sstevel@tonic-gate 		(void) printf(" errno=%d", sip->si_errno);
31850Sstevel@tonic-gate 		if (ename != NULL)
31860Sstevel@tonic-gate 			(void) printf("(%s)", ename);
31870Sstevel@tonic-gate 	}
31880Sstevel@tonic-gate 
31890Sstevel@tonic-gate 	(void) fputc('\n', stdout);
31900Sstevel@tonic-gate }
31910Sstevel@tonic-gate 
31920Sstevel@tonic-gate #ifdef _LP64
31930Sstevel@tonic-gate void
31940Sstevel@tonic-gate show_siginfo32(private_t *pri, long offset)
31950Sstevel@tonic-gate {
31960Sstevel@tonic-gate 	struct siginfo32 siginfo;
31970Sstevel@tonic-gate 
31980Sstevel@tonic-gate 	if (offset != NULL &&
31990Sstevel@tonic-gate 	    Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
32000Sstevel@tonic-gate 		print_siginfo32(pri, &siginfo);
32010Sstevel@tonic-gate }
32020Sstevel@tonic-gate #endif	/* _LP64 */
32030Sstevel@tonic-gate 
32040Sstevel@tonic-gate void
32050Sstevel@tonic-gate show_siginfo(private_t *pri, long offset)
32060Sstevel@tonic-gate {
32070Sstevel@tonic-gate 	struct siginfo siginfo;
32080Sstevel@tonic-gate 
32090Sstevel@tonic-gate #ifdef _LP64
32100Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
32110Sstevel@tonic-gate 		show_siginfo32(pri, offset);
32120Sstevel@tonic-gate 		return;
32130Sstevel@tonic-gate 	}
32140Sstevel@tonic-gate #endif
32150Sstevel@tonic-gate 	if (offset != NULL &&
32160Sstevel@tonic-gate 	    Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
32170Sstevel@tonic-gate 		print_siginfo(pri, &siginfo);
32180Sstevel@tonic-gate }
32190Sstevel@tonic-gate 
32200Sstevel@tonic-gate void
32210Sstevel@tonic-gate show_bool(private_t *pri, long offset, int count)
32220Sstevel@tonic-gate {
32230Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 4);
32240Sstevel@tonic-gate 
32250Sstevel@tonic-gate 	/* enter region of lengthy output */
32260Sstevel@tonic-gate 	if (serial)
32270Sstevel@tonic-gate 		Eserialize();
32280Sstevel@tonic-gate 
32290Sstevel@tonic-gate 	while (count > 0) {
32300Sstevel@tonic-gate 		char buf[32];
32310Sstevel@tonic-gate 		int nb = (count < 32)? count : 32;
32320Sstevel@tonic-gate 		int i;
32330Sstevel@tonic-gate 
32340Sstevel@tonic-gate 		if (Pread(Proc, buf, (size_t)nb, offset) != nb)
32350Sstevel@tonic-gate 			break;
32360Sstevel@tonic-gate 
32370Sstevel@tonic-gate 		(void) printf("%s   ", pri->pname);
32380Sstevel@tonic-gate 		for (i = 0; i < nb; i++)
32390Sstevel@tonic-gate 			(void) printf(" %d", buf[i]);
32400Sstevel@tonic-gate 		(void) fputc('\n', stdout);
32410Sstevel@tonic-gate 
32420Sstevel@tonic-gate 		count -= nb;
32430Sstevel@tonic-gate 		offset += nb;
32440Sstevel@tonic-gate 	}
32450Sstevel@tonic-gate 
32460Sstevel@tonic-gate 	/* exit region of lengthy output */
32470Sstevel@tonic-gate 	if (serial)
32480Sstevel@tonic-gate 		Xserialize();
32490Sstevel@tonic-gate }
32500Sstevel@tonic-gate 
32510Sstevel@tonic-gate #ifdef _LP64
32520Sstevel@tonic-gate void
32530Sstevel@tonic-gate show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
32540Sstevel@tonic-gate {
32550Sstevel@tonic-gate 	iovec32_t iovec[16];
32560Sstevel@tonic-gate 	iovec32_t *ip;
32570Sstevel@tonic-gate 	long nb;
32580Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 4 && showbuf);
32590Sstevel@tonic-gate 
32600Sstevel@tonic-gate 	if (niov > 16)		/* is this the real limit? */
32610Sstevel@tonic-gate 		niov = 16;
32620Sstevel@tonic-gate 
32630Sstevel@tonic-gate 	if (offset != NULL && niov > 0 &&
32640Sstevel@tonic-gate 	    Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
32650Sstevel@tonic-gate 	    == niov*sizeof (iovec32_t)) {
32660Sstevel@tonic-gate 		/* enter region of lengthy output */
32670Sstevel@tonic-gate 		if (serial)
32680Sstevel@tonic-gate 			Eserialize();
32690Sstevel@tonic-gate 
32700Sstevel@tonic-gate 		for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
32710Sstevel@tonic-gate 			(void) printf("%s\tiov_base = 0x%.8X  iov_len = %d\n",
32727088Sraf 			    pri->pname,
32737088Sraf 			    ip->iov_base,
32747088Sraf 			    ip->iov_len);
32750Sstevel@tonic-gate 			if ((nb = count) > 0) {
32760Sstevel@tonic-gate 				if (nb > ip->iov_len)
32770Sstevel@tonic-gate 					nb = ip->iov_len;
32780Sstevel@tonic-gate 				if (nb > 0)
32790Sstevel@tonic-gate 					count -= nb;
32800Sstevel@tonic-gate 			}
32810Sstevel@tonic-gate 			if (showbuf && nb > 0)
32820Sstevel@tonic-gate 				showbuffer(pri, (long)ip->iov_base, nb);
32830Sstevel@tonic-gate 		}
32840Sstevel@tonic-gate 
32850Sstevel@tonic-gate 		/* exit region of lengthy output */
32860Sstevel@tonic-gate 		if (serial)
32870Sstevel@tonic-gate 			Xserialize();
32880Sstevel@tonic-gate 	}
32890Sstevel@tonic-gate }
32900Sstevel@tonic-gate #endif	/* _LP64 */
32910Sstevel@tonic-gate 
32920Sstevel@tonic-gate void
32930Sstevel@tonic-gate show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
32940Sstevel@tonic-gate {
32950Sstevel@tonic-gate 	iovec_t iovec[16];
32960Sstevel@tonic-gate 	iovec_t *ip;
32970Sstevel@tonic-gate 	long nb;
32980Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 4 && showbuf);
32990Sstevel@tonic-gate 
33000Sstevel@tonic-gate #ifdef _LP64
33010Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
33020Sstevel@tonic-gate 		show_iovec32(pri, offset, niov, showbuf, count);
33030Sstevel@tonic-gate 		return;
33040Sstevel@tonic-gate 	}
33050Sstevel@tonic-gate #endif
33060Sstevel@tonic-gate 	if (niov > 16)		/* is this the real limit? */
33070Sstevel@tonic-gate 		niov = 16;
33080Sstevel@tonic-gate 
33090Sstevel@tonic-gate 	if (offset != NULL && niov > 0 &&
33100Sstevel@tonic-gate 	    Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
33110Sstevel@tonic-gate 	    == niov*sizeof (iovec_t)) {
33120Sstevel@tonic-gate 		/* enter region of lengthy output */
33130Sstevel@tonic-gate 		if (serial)
33140Sstevel@tonic-gate 			Eserialize();
33150Sstevel@tonic-gate 
33160Sstevel@tonic-gate 		for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
33170Sstevel@tonic-gate 			(void) printf("%s\tiov_base = 0x%.8lX  iov_len = %lu\n",
33187088Sraf 			    pri->pname,
33197088Sraf 			    (long)ip->iov_base,
33207088Sraf 			    ip->iov_len);
33210Sstevel@tonic-gate 			if ((nb = count) > 0) {
33220Sstevel@tonic-gate 				if (nb > ip->iov_len)
33230Sstevel@tonic-gate 					nb = ip->iov_len;
33240Sstevel@tonic-gate 				if (nb > 0)
33250Sstevel@tonic-gate 					count -= nb;
33260Sstevel@tonic-gate 			}
33270Sstevel@tonic-gate 			if (showbuf && nb > 0)
33280Sstevel@tonic-gate 				showbuffer(pri, (long)ip->iov_base, nb);
33290Sstevel@tonic-gate 		}
33300Sstevel@tonic-gate 
33310Sstevel@tonic-gate 		/* exit region of lengthy output */
33320Sstevel@tonic-gate 		if (serial)
33330Sstevel@tonic-gate 			Xserialize();
33340Sstevel@tonic-gate 	}
33350Sstevel@tonic-gate }
33360Sstevel@tonic-gate 
33370Sstevel@tonic-gate void
33380Sstevel@tonic-gate show_dents32(private_t *pri, long offset, long count)
33390Sstevel@tonic-gate {
33400Sstevel@tonic-gate 	long buf[MYBUFSIZ / sizeof (long)];
33410Sstevel@tonic-gate 	struct dirent32 *dp;
33420Sstevel@tonic-gate 	int serial = (count > 100);
33430Sstevel@tonic-gate 
3344*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
33450Sstevel@tonic-gate 		return;
33460Sstevel@tonic-gate 
33470Sstevel@tonic-gate 	/* enter region of lengthy output */
33480Sstevel@tonic-gate 	if (serial)
33490Sstevel@tonic-gate 		Eserialize();
33500Sstevel@tonic-gate 
33510Sstevel@tonic-gate 	while (count > 0 && !interrupt) {
33520Sstevel@tonic-gate 		int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
33530Sstevel@tonic-gate 
33540Sstevel@tonic-gate 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
33550Sstevel@tonic-gate 			break;
33560Sstevel@tonic-gate 
33570Sstevel@tonic-gate 		dp = (struct dirent32 *)&buf[0];
33580Sstevel@tonic-gate 		if (nb < (int)(dp->d_name - (char *)dp))
33590Sstevel@tonic-gate 			break;
33600Sstevel@tonic-gate 		if ((unsigned)nb < dp->d_reclen) {
33610Sstevel@tonic-gate 			/* getdents() error? */
33620Sstevel@tonic-gate 			(void) printf(
33637088Sraf 			    "%s    ino=%-5u off=%-4d rlen=%-3d\n",
33647088Sraf 			    pri->pname,
33657088Sraf 			    dp->d_ino,
33667088Sraf 			    dp->d_off,
33677088Sraf 			    dp->d_reclen);
33680Sstevel@tonic-gate 			break;
33690Sstevel@tonic-gate 		}
33700Sstevel@tonic-gate 
33710Sstevel@tonic-gate 		while (!interrupt &&
33720Sstevel@tonic-gate 		    nb >= (int)(dp->d_name - (char *)dp) &&
33730Sstevel@tonic-gate 		    (unsigned)nb >= dp->d_reclen) {
33740Sstevel@tonic-gate 			(void) printf(
33757088Sraf 			    "%s    ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n",
33767088Sraf 			    pri->pname,
33777088Sraf 			    dp->d_ino,
33787088Sraf 			    dp->d_off,
33797088Sraf 			    dp->d_reclen,
33807088Sraf 			    dp->d_reclen - (int)(dp->d_name - (char *)dp),
33817088Sraf 			    dp->d_name);
33820Sstevel@tonic-gate 			nb -= dp->d_reclen;
33830Sstevel@tonic-gate 			count -= dp->d_reclen;
33840Sstevel@tonic-gate 			offset += dp->d_reclen;
33850Sstevel@tonic-gate 			/* LINTED improper alignment */
33860Sstevel@tonic-gate 			dp = (struct dirent32 *)((char *)dp + dp->d_reclen);
33870Sstevel@tonic-gate 		}
33880Sstevel@tonic-gate 	}
33890Sstevel@tonic-gate 
33900Sstevel@tonic-gate 	/* exit region of lengthy output */
33910Sstevel@tonic-gate 	if (serial)
33920Sstevel@tonic-gate 		Xserialize();
33930Sstevel@tonic-gate }
33940Sstevel@tonic-gate 
33950Sstevel@tonic-gate void
33960Sstevel@tonic-gate show_dents64(private_t *pri, long offset, long count)
33970Sstevel@tonic-gate {
33980Sstevel@tonic-gate 	long long buf[MYBUFSIZ / sizeof (long long)];
33990Sstevel@tonic-gate 	struct dirent64 *dp;
34000Sstevel@tonic-gate 	int serial = (count > 100);
34010Sstevel@tonic-gate 
3402*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
34030Sstevel@tonic-gate 		return;
34040Sstevel@tonic-gate 
34050Sstevel@tonic-gate 	/* enter region of lengthy output */
34060Sstevel@tonic-gate 	if (serial)
34070Sstevel@tonic-gate 		Eserialize();
34080Sstevel@tonic-gate 
34090Sstevel@tonic-gate 	while (count > 0 && !interrupt) {
34100Sstevel@tonic-gate 		int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
34110Sstevel@tonic-gate 
34120Sstevel@tonic-gate 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
34130Sstevel@tonic-gate 			break;
34140Sstevel@tonic-gate 
34150Sstevel@tonic-gate 		dp = (struct dirent64 *)&buf[0];
34160Sstevel@tonic-gate 		if (nb < (int)(dp->d_name - (char *)dp))
34170Sstevel@tonic-gate 			break;
34180Sstevel@tonic-gate 		if ((unsigned)nb < dp->d_reclen) {
34190Sstevel@tonic-gate 			/* getdents() error? */
34200Sstevel@tonic-gate 			(void) printf(
34217088Sraf 			    "%s    ino=%-5llu off=%-4lld rlen=%-3d\n",
34227088Sraf 			    pri->pname,
34237088Sraf 			    (long long)dp->d_ino,
34247088Sraf 			    (long long)dp->d_off,
34257088Sraf 			    dp->d_reclen);
34260Sstevel@tonic-gate 			break;
34270Sstevel@tonic-gate 		}
34280Sstevel@tonic-gate 
34290Sstevel@tonic-gate 		while (!interrupt &&
34300Sstevel@tonic-gate 		    nb >= (int)(dp->d_name - (char *)dp) &&
34310Sstevel@tonic-gate 		    (unsigned)nb >= dp->d_reclen) {
34320Sstevel@tonic-gate 			(void) printf(
34337088Sraf 			    "%s    ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
34347088Sraf 			    pri->pname,
34357088Sraf 			    (long long)dp->d_ino,
34367088Sraf 			    (long long)dp->d_off,
34377088Sraf 			    dp->d_reclen,
34387088Sraf 			    dp->d_reclen - (int)(dp->d_name - (char *)dp),
34397088Sraf 			    dp->d_name);
34400Sstevel@tonic-gate 			nb -= dp->d_reclen;
34410Sstevel@tonic-gate 			count -= dp->d_reclen;
34420Sstevel@tonic-gate 			offset += dp->d_reclen;
34430Sstevel@tonic-gate 			/* LINTED improper alignment */
34440Sstevel@tonic-gate 			dp = (struct dirent64 *)((char *)dp + dp->d_reclen);
34450Sstevel@tonic-gate 		}
34460Sstevel@tonic-gate 	}
34470Sstevel@tonic-gate 
34480Sstevel@tonic-gate 	/* exit region of lengthy output */
34490Sstevel@tonic-gate 	if (serial)
34500Sstevel@tonic-gate 		Xserialize();
34510Sstevel@tonic-gate }
34520Sstevel@tonic-gate 
34530Sstevel@tonic-gate void
34540Sstevel@tonic-gate show_rlimit32(private_t *pri, long offset)
34550Sstevel@tonic-gate {
34560Sstevel@tonic-gate 	struct rlimit32 rlimit;
34570Sstevel@tonic-gate 
34580Sstevel@tonic-gate 	if (offset != NULL &&
34590Sstevel@tonic-gate 	    Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
34600Sstevel@tonic-gate 		(void) printf("%s\t", pri->pname);
34610Sstevel@tonic-gate 		switch (rlimit.rlim_cur) {
34620Sstevel@tonic-gate 		case RLIM32_INFINITY:
34630Sstevel@tonic-gate 			(void) fputs("cur = RLIM_INFINITY", stdout);
34640Sstevel@tonic-gate 			break;
34650Sstevel@tonic-gate 		case RLIM32_SAVED_MAX:
34660Sstevel@tonic-gate 			(void) fputs("cur = RLIM_SAVED_MAX", stdout);
34670Sstevel@tonic-gate 			break;
34680Sstevel@tonic-gate 		case RLIM32_SAVED_CUR:
34690Sstevel@tonic-gate 			(void) fputs("cur = RLIM_SAVED_CUR", stdout);
34700Sstevel@tonic-gate 			break;
34710Sstevel@tonic-gate 		default:
34720Sstevel@tonic-gate 			(void) printf("cur = %lu", (long)rlimit.rlim_cur);
34730Sstevel@tonic-gate 			break;
34740Sstevel@tonic-gate 		}
34750Sstevel@tonic-gate 		switch (rlimit.rlim_max) {
34760Sstevel@tonic-gate 		case RLIM32_INFINITY:
34770Sstevel@tonic-gate 			(void) fputs("  max = RLIM_INFINITY\n", stdout);
34780Sstevel@tonic-gate 			break;
34790Sstevel@tonic-gate 		case RLIM32_SAVED_MAX:
34800Sstevel@tonic-gate 			(void) fputs("  max = RLIM_SAVED_MAX\n", stdout);
34810Sstevel@tonic-gate 			break;
34820Sstevel@tonic-gate 		case RLIM32_SAVED_CUR:
34830Sstevel@tonic-gate 			(void) fputs("  max = RLIM_SAVED_CUR\n", stdout);
34840Sstevel@tonic-gate 			break;
34850Sstevel@tonic-gate 		default:
34860Sstevel@tonic-gate 			(void) printf("  max = %lu\n", (long)rlimit.rlim_max);
34870Sstevel@tonic-gate 			break;
34880Sstevel@tonic-gate 		}
34890Sstevel@tonic-gate 	}
34900Sstevel@tonic-gate }
34910Sstevel@tonic-gate 
34920Sstevel@tonic-gate void
34930Sstevel@tonic-gate show_rlimit64(private_t *pri, long offset)
34940Sstevel@tonic-gate {
34950Sstevel@tonic-gate 	struct rlimit64 rlimit;
34960Sstevel@tonic-gate 
34970Sstevel@tonic-gate 	if (offset != NULL &&
34980Sstevel@tonic-gate 	    Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
34990Sstevel@tonic-gate 		(void) printf("%s\t", pri->pname);
35000Sstevel@tonic-gate 		switch (rlimit.rlim_cur) {
35010Sstevel@tonic-gate 		case RLIM64_INFINITY:
35020Sstevel@tonic-gate 			(void) fputs("cur = RLIM64_INFINITY", stdout);
35030Sstevel@tonic-gate 			break;
35040Sstevel@tonic-gate 		case RLIM64_SAVED_MAX:
35050Sstevel@tonic-gate 			(void) fputs("cur = RLIM64_SAVED_MAX", stdout);
35060Sstevel@tonic-gate 			break;
35070Sstevel@tonic-gate 		case RLIM64_SAVED_CUR:
35080Sstevel@tonic-gate 			(void) fputs("cur = RLIM64_SAVED_CUR", stdout);
35090Sstevel@tonic-gate 			break;
35100Sstevel@tonic-gate 		default:
35110Sstevel@tonic-gate 			(void) printf("cur = %llu",
35120Sstevel@tonic-gate 			    (unsigned long long)rlimit.rlim_cur);
35130Sstevel@tonic-gate 			break;
35140Sstevel@tonic-gate 		}
35150Sstevel@tonic-gate 		switch (rlimit.rlim_max) {
35160Sstevel@tonic-gate 		case RLIM64_INFINITY:
35170Sstevel@tonic-gate 			(void) fputs("  max = RLIM64_INFINITY\n", stdout);
35180Sstevel@tonic-gate 			break;
35190Sstevel@tonic-gate 		case RLIM64_SAVED_MAX:
35200Sstevel@tonic-gate 			(void) fputs("  max = RLIM64_SAVED_MAX\n", stdout);
35210Sstevel@tonic-gate 			break;
35220Sstevel@tonic-gate 		case RLIM64_SAVED_CUR:
35230Sstevel@tonic-gate 			(void) fputs("  max = RLIM64_SAVED_CUR\n", stdout);
35240Sstevel@tonic-gate 			break;
35250Sstevel@tonic-gate 		default:
35260Sstevel@tonic-gate 			(void) printf("  max = %llu\n",
35270Sstevel@tonic-gate 			    (unsigned long long)rlimit.rlim_max);
35280Sstevel@tonic-gate 			break;
35290Sstevel@tonic-gate 		}
35300Sstevel@tonic-gate 	}
35310Sstevel@tonic-gate }
35320Sstevel@tonic-gate 
35330Sstevel@tonic-gate void
35340Sstevel@tonic-gate show_nuname(private_t *pri, long offset)
35350Sstevel@tonic-gate {
35360Sstevel@tonic-gate 	struct utsname ubuf;
35370Sstevel@tonic-gate 
35380Sstevel@tonic-gate 	if (offset != NULL &&
35390Sstevel@tonic-gate 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
35400Sstevel@tonic-gate 		(void) printf(
35417088Sraf 		    "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
35427088Sraf 		    pri->pname,
35437088Sraf 		    ubuf.sysname,
35447088Sraf 		    ubuf.nodename,
35457088Sraf 		    ubuf.release,
35467088Sraf 		    ubuf.version,
35477088Sraf 		    ubuf.machine);
35480Sstevel@tonic-gate 	}
35490Sstevel@tonic-gate }
35500Sstevel@tonic-gate 
35510Sstevel@tonic-gate void
35520Sstevel@tonic-gate show_adjtime(private_t *pri, long off1, long off2)
35530Sstevel@tonic-gate {
35540Sstevel@tonic-gate 	show_timeval(pri, off1, "   delta");
35550Sstevel@tonic-gate 	show_timeval(pri, off2, "olddelta");
35560Sstevel@tonic-gate }
35570Sstevel@tonic-gate 
35580Sstevel@tonic-gate void
35590Sstevel@tonic-gate show_sockaddr(private_t *pri,
35600Sstevel@tonic-gate 	const char *str, long addroff, long lenoff, long len)
35610Sstevel@tonic-gate {
35620Sstevel@tonic-gate 	/*
35630Sstevel@tonic-gate 	 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
35640Sstevel@tonic-gate 	 * also large enough to store a sockaddr_in or a sockaddr_in6.
35650Sstevel@tonic-gate 	 */
35660Sstevel@tonic-gate 	long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
35677088Sraf 	    / sizeof (long)];
35680Sstevel@tonic-gate 	struct sockaddr *sa = (struct sockaddr *)buf;
35690Sstevel@tonic-gate 	struct sockaddr_in *sin = (struct sockaddr_in *)buf;
35700Sstevel@tonic-gate 	struct sockaddr_un *soun = (struct sockaddr_un *)buf;
35710Sstevel@tonic-gate 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
35720Sstevel@tonic-gate 	char addrbuf[INET6_ADDRSTRLEN];
35730Sstevel@tonic-gate 
35740Sstevel@tonic-gate 	if (lenoff != 0) {
35750Sstevel@tonic-gate 		uint_t ilen;
35760Sstevel@tonic-gate 		if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
35770Sstevel@tonic-gate 			return;
35780Sstevel@tonic-gate 		len = ilen;
35790Sstevel@tonic-gate 	}
35800Sstevel@tonic-gate 
35810Sstevel@tonic-gate 	if (len >= sizeof (buf))	/* protect against ridiculous length */
35820Sstevel@tonic-gate 		len = sizeof (buf) - 1;
35830Sstevel@tonic-gate 	if (Pread(Proc, buf, len, addroff) != len)
35840Sstevel@tonic-gate 		return;
35850Sstevel@tonic-gate 
35860Sstevel@tonic-gate 	switch (sa->sa_family) {
35870Sstevel@tonic-gate 	case AF_INET6:
35880Sstevel@tonic-gate 		(void) printf("%s\tAF_INET6  %s = %s  port = %u\n",
35890Sstevel@tonic-gate 		    pri->pname, str,
35900Sstevel@tonic-gate 		    inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
35917088Sraf 		    sizeof (addrbuf)),
35920Sstevel@tonic-gate 		    ntohs(sin6->sin6_port));
35930Sstevel@tonic-gate 		(void) printf("%s\tscope id = %u  source id = 0x%x\n"
35940Sstevel@tonic-gate 		    "%s\tflow class = 0x%02x  flow label = 0x%05x\n",
35950Sstevel@tonic-gate 		    pri->pname, ntohl(sin6->sin6_scope_id),
35960Sstevel@tonic-gate 		    ntohl(sin6->__sin6_src_id),
35970Sstevel@tonic-gate 		    pri->pname,
35980Sstevel@tonic-gate 		    ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
35990Sstevel@tonic-gate 		    ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
36000Sstevel@tonic-gate 		break;
36010Sstevel@tonic-gate 	case AF_INET:
36020Sstevel@tonic-gate 		(void) printf("%s\tAF_%s  %s = %s  port = %u\n",
36031548Srshoaib 		    pri->pname, "INET",
36040Sstevel@tonic-gate 		    str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
36050Sstevel@tonic-gate 		    sizeof (addrbuf)), ntohs(sin->sin_port));
36060Sstevel@tonic-gate 		break;
36070Sstevel@tonic-gate 	case AF_UNIX:
36080Sstevel@tonic-gate 		len -= sizeof (soun->sun_family);
36090Sstevel@tonic-gate 		if (len >= 0) {
36100Sstevel@tonic-gate 			/* Null terminate */
36110Sstevel@tonic-gate 			soun->sun_path[len] = NULL;
36120Sstevel@tonic-gate 			(void) printf("%s\tAF_UNIX  %s = %s\n", pri->pname,
36137088Sraf 			    str, soun->sun_path);
36140Sstevel@tonic-gate 		}
36150Sstevel@tonic-gate 		break;
36160Sstevel@tonic-gate 	}
36170Sstevel@tonic-gate }
36180Sstevel@tonic-gate 
36190Sstevel@tonic-gate void
36200Sstevel@tonic-gate show_msghdr(private_t *pri, long offset)
36210Sstevel@tonic-gate {
3622328Sja97890 	const lwpstatus_t *Lsp = pri->lwpstat;
3623328Sja97890 	int what = Lsp->pr_what;
3624328Sja97890 	int err = pri->Errno;
36250Sstevel@tonic-gate 	struct msghdr msg;
3626328Sja97890 	int showbuf = FALSE;
3627328Sja97890 	int i = pri->sys_args[0]+1;
3628328Sja97890 	long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
36290Sstevel@tonic-gate 
36300Sstevel@tonic-gate 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
36310Sstevel@tonic-gate 		return;
3632328Sja97890 
36330Sstevel@tonic-gate 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
36340Sstevel@tonic-gate 		show_sockaddr(pri, "msg_name",
36357088Sraf 		    (long)msg.msg_name, 0, (long)msg.msg_namelen);
3636328Sja97890 
3637328Sja97890 	/*
3638328Sja97890 	 * Print the iovec if the syscall was successful and the fd is
3639328Sja97890 	 * part of the set being traced.
3640328Sja97890 	 */
3641328Sja97890 	if ((what == SYS_recvmsg && !err &&
3642328Sja97890 	    prismember(&readfd, i)) ||
3643328Sja97890 	    (what == SYS_sendmsg &&
3644328Sja97890 	    prismember(&writefd, i)))
3645328Sja97890 		showbuf = TRUE;
3646328Sja97890 
3647328Sja97890 	show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3648328Sja97890 
36490Sstevel@tonic-gate }
36500Sstevel@tonic-gate 
36510Sstevel@tonic-gate #ifdef _LP64
36520Sstevel@tonic-gate void
36530Sstevel@tonic-gate show_msghdr32(private_t *pri, long offset)
36540Sstevel@tonic-gate {
36550Sstevel@tonic-gate 	struct msghdr32 {
36560Sstevel@tonic-gate 		caddr32_t	msg_name;
3657328Sja97890 		uint32_t	msg_namelen;
3658328Sja97890 		caddr32_t 	msg_iov;
3659328Sja97890 		int32_t		msg_iovlen;
36600Sstevel@tonic-gate 	} msg;
3661328Sja97890 	const lwpstatus_t *Lsp = pri->lwpstat;
3662328Sja97890 	int what = Lsp->pr_what;
3663328Sja97890 	int err = pri->Errno;
3664328Sja97890 	int showbuf = FALSE;
3665328Sja97890 	int i = pri->sys_args[0]+1;
3666328Sja97890 	long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
36670Sstevel@tonic-gate 
36680Sstevel@tonic-gate 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
36690Sstevel@tonic-gate 		return;
3670328Sja97890 
36710Sstevel@tonic-gate 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
36720Sstevel@tonic-gate 		show_sockaddr(pri, "msg_name",
36737088Sraf 		    (long)msg.msg_name, 0, (long)msg.msg_namelen);
3674328Sja97890 	/*
3675328Sja97890 	 * Print the iovec if the syscall was successful and the fd is
3676328Sja97890 	 * part of the set being traced.
3677328Sja97890 	 */
3678328Sja97890 	if ((what == SYS_recvmsg && !err &&
3679328Sja97890 	    prismember(&readfd, i)) ||
3680328Sja97890 	    (what == SYS_sendmsg &&
3681328Sja97890 	    prismember(&writefd, i)))
3682328Sja97890 		showbuf = TRUE;
3683328Sja97890 
3684328Sja97890 	show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3685328Sja97890 
36860Sstevel@tonic-gate }
36870Sstevel@tonic-gate #endif	/* _LP64 */
36880Sstevel@tonic-gate 
36890Sstevel@tonic-gate static void
36900Sstevel@tonic-gate show_doorargs(private_t *pri, long offset)
36910Sstevel@tonic-gate {
36920Sstevel@tonic-gate 	door_arg_t args;
36930Sstevel@tonic-gate 
36940Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
36950Sstevel@tonic-gate 		(void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
36960Sstevel@tonic-gate 		    pri->pname,
36970Sstevel@tonic-gate 		    (ulong_t)args.data_ptr,
36980Sstevel@tonic-gate 		    (ulong_t)args.data_size);
36990Sstevel@tonic-gate 		(void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
37000Sstevel@tonic-gate 		    pri->pname,
37010Sstevel@tonic-gate 		    (ulong_t)args.desc_ptr,
37020Sstevel@tonic-gate 		    args.desc_num);
37030Sstevel@tonic-gate 		(void) printf("%s\trbuf=0x%lX rsize=%lu\n",
37040Sstevel@tonic-gate 		    pri->pname,
37050Sstevel@tonic-gate 		    (ulong_t)args.rbuf,
37060Sstevel@tonic-gate 		    (ulong_t)args.rsize);
37070Sstevel@tonic-gate 	}
37080Sstevel@tonic-gate }
37090Sstevel@tonic-gate 
37100Sstevel@tonic-gate static void
37110Sstevel@tonic-gate show_ucred_privsets(private_t *pri, ucred_t *uc)
37120Sstevel@tonic-gate {
37130Sstevel@tonic-gate 	int i = 0;
37140Sstevel@tonic-gate 	const priv_set_t *s;
37150Sstevel@tonic-gate 	priv_ptype_t sn;
37160Sstevel@tonic-gate 	char *str;
37170Sstevel@tonic-gate 
37180Sstevel@tonic-gate 	while ((sn = priv_getsetbynum(i++)) != NULL) {
37190Sstevel@tonic-gate 		s = ucred_getprivset(uc, sn);
37200Sstevel@tonic-gate 
37210Sstevel@tonic-gate 		if (s == NULL)
37220Sstevel@tonic-gate 			continue;
37230Sstevel@tonic-gate 
37240Sstevel@tonic-gate 		(void) printf("%s\t%c: %s\n",
37250Sstevel@tonic-gate 		    pri->pname,
37260Sstevel@tonic-gate 		    *sn,
37270Sstevel@tonic-gate 		    str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
37280Sstevel@tonic-gate 
37290Sstevel@tonic-gate 		free(str);
37300Sstevel@tonic-gate 	}
37310Sstevel@tonic-gate }
37320Sstevel@tonic-gate 
37330Sstevel@tonic-gate static void
37340Sstevel@tonic-gate show_ucred(private_t *pri, long offset)
37350Sstevel@tonic-gate {
37360Sstevel@tonic-gate 	ucred_t *uc = _ucred_alloc();
37370Sstevel@tonic-gate 	size_t sz;
37380Sstevel@tonic-gate 
37390Sstevel@tonic-gate 	if (uc == NULL)
37400Sstevel@tonic-gate 		return;
37410Sstevel@tonic-gate 
37420Sstevel@tonic-gate 	sz = Pread(Proc, uc, uc->uc_size, offset);
37430Sstevel@tonic-gate 
37440Sstevel@tonic-gate 	/*
37450Sstevel@tonic-gate 	 * A new uc_size is read, it could be smaller than the previously
37460Sstevel@tonic-gate 	 * value.  We accept short reads that fill the whole header.
37470Sstevel@tonic-gate 	 */
37480Sstevel@tonic-gate 	if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
37494321Scasper 		(void) printf("%s\teuid=%u egid=%u\n",
37500Sstevel@tonic-gate 		    pri->pname,
37514321Scasper 		    ucred_geteuid(uc),
37524321Scasper 		    ucred_getegid(uc));
37534321Scasper 		(void) printf("%s\truid=%u rgid=%u\n",
37540Sstevel@tonic-gate 		    pri->pname,
37554321Scasper 		    ucred_getruid(uc),
37564321Scasper 		    ucred_getrgid(uc));
37570Sstevel@tonic-gate 		(void) printf("%s\tpid=%d zoneid=%d\n",
37580Sstevel@tonic-gate 		    pri->pname,
37590Sstevel@tonic-gate 		    (int)ucred_getpid(uc),
37600Sstevel@tonic-gate 		    (int)ucred_getzoneid(uc));
37610Sstevel@tonic-gate 		show_ucred_privsets(pri, uc);
37620Sstevel@tonic-gate 	}
37630Sstevel@tonic-gate 	ucred_free(uc);
37640Sstevel@tonic-gate }
37650Sstevel@tonic-gate 
37660Sstevel@tonic-gate static void
3767813Sdp show_privset(private_t *pri, long offset, size_t size, char *label)
37680Sstevel@tonic-gate {
37690Sstevel@tonic-gate 	priv_set_t *tmp = priv_allocset();
37700Sstevel@tonic-gate 	size_t sz;
37710Sstevel@tonic-gate 
37720Sstevel@tonic-gate 	if (tmp == NULL)
37730Sstevel@tonic-gate 		return;
37740Sstevel@tonic-gate 
37750Sstevel@tonic-gate 	sz = Pread(Proc, tmp, size, offset);
37760Sstevel@tonic-gate 
37770Sstevel@tonic-gate 	if (sz == size) {
37780Sstevel@tonic-gate 		char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
37790Sstevel@tonic-gate 		if (str != NULL) {
3780813Sdp 			(void) printf("%s\t%s%s\n", pri->pname, label, str);
37810Sstevel@tonic-gate 			free(str);
37820Sstevel@tonic-gate 		}
37830Sstevel@tonic-gate 	}
37840Sstevel@tonic-gate 	priv_freeset(tmp);
37850Sstevel@tonic-gate }
37860Sstevel@tonic-gate 
37870Sstevel@tonic-gate static void
37880Sstevel@tonic-gate show_doorinfo(private_t *pri, long offset)
37890Sstevel@tonic-gate {
37900Sstevel@tonic-gate 	door_info_t info;
37910Sstevel@tonic-gate 	door_attr_t attr;
37920Sstevel@tonic-gate 
37930Sstevel@tonic-gate 	if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
37940Sstevel@tonic-gate 		return;
37950Sstevel@tonic-gate 	(void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
37960Sstevel@tonic-gate 	    pri->pname,
37970Sstevel@tonic-gate 	    (int)info.di_target,
37980Sstevel@tonic-gate 	    info.di_proc,
37990Sstevel@tonic-gate 	    info.di_data);
38000Sstevel@tonic-gate 	attr = info.di_attributes;
38010Sstevel@tonic-gate 	(void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
38020Sstevel@tonic-gate 	(void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
38030Sstevel@tonic-gate }
38040Sstevel@tonic-gate 
38050Sstevel@tonic-gate static void
38060Sstevel@tonic-gate show_doorparam(private_t *pri, long offset)
38070Sstevel@tonic-gate {
38080Sstevel@tonic-gate 	ulong_t val;
38090Sstevel@tonic-gate 
38100Sstevel@tonic-gate 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
38110Sstevel@tonic-gate 		(void) printf("%s\tvalue=%lu\n",
38120Sstevel@tonic-gate 		    pri->pname,
38130Sstevel@tonic-gate 		    val);
38140Sstevel@tonic-gate 	}
38150Sstevel@tonic-gate }
38160Sstevel@tonic-gate 
38170Sstevel@tonic-gate #ifdef _LP64
38180Sstevel@tonic-gate 
38190Sstevel@tonic-gate static void
38200Sstevel@tonic-gate show_doorargs32(private_t *pri, long offset)
38210Sstevel@tonic-gate {
38220Sstevel@tonic-gate 	struct door_arg32 args;
38230Sstevel@tonic-gate 
38240Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
38250Sstevel@tonic-gate 		(void) printf("%s\tdata_ptr=%X data_size=%u\n",
38260Sstevel@tonic-gate 		    pri->pname,
38270Sstevel@tonic-gate 		    args.data_ptr,
38280Sstevel@tonic-gate 		    args.data_size);
38290Sstevel@tonic-gate 		(void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
38300Sstevel@tonic-gate 		    pri->pname,
38310Sstevel@tonic-gate 		    args.desc_ptr,
38320Sstevel@tonic-gate 		    args.desc_num);
38330Sstevel@tonic-gate 		(void) printf("%s\trbuf=0x%X rsize=%u\n",
38340Sstevel@tonic-gate 		    pri->pname,
38350Sstevel@tonic-gate 		    args.rbuf,
38360Sstevel@tonic-gate 		    args.rsize);
38370Sstevel@tonic-gate 	}
38380Sstevel@tonic-gate }
38390Sstevel@tonic-gate 
38400Sstevel@tonic-gate static void
38410Sstevel@tonic-gate show_doorparam32(private_t *pri, long offset)
38420Sstevel@tonic-gate {
38430Sstevel@tonic-gate 	uint_t val;
38440Sstevel@tonic-gate 
38450Sstevel@tonic-gate 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
38460Sstevel@tonic-gate 		(void) printf("%s\tvalue=%u\n",
38470Sstevel@tonic-gate 		    pri->pname,
38480Sstevel@tonic-gate 		    val);
38490Sstevel@tonic-gate 	}
38500Sstevel@tonic-gate }
38510Sstevel@tonic-gate 
38520Sstevel@tonic-gate #endif	/* _LP64 */
38530Sstevel@tonic-gate 
38540Sstevel@tonic-gate static void
38550Sstevel@tonic-gate show_doors(private_t *pri)
38560Sstevel@tonic-gate {
38570Sstevel@tonic-gate 	switch (pri->sys_args[5]) {
38580Sstevel@tonic-gate 	case DOOR_CALL:
38590Sstevel@tonic-gate #ifdef _LP64
38600Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
38610Sstevel@tonic-gate 			show_doorargs(pri, (long)pri->sys_args[1]);
38620Sstevel@tonic-gate 		else
38630Sstevel@tonic-gate 			show_doorargs32(pri, (long)pri->sys_args[1]);
38640Sstevel@tonic-gate #else
38650Sstevel@tonic-gate 		show_doorargs(pri, (long)pri->sys_args[1]);
38660Sstevel@tonic-gate #endif
38670Sstevel@tonic-gate 		break;
38680Sstevel@tonic-gate 	case DOOR_UCRED:
38690Sstevel@tonic-gate 		if (!pri->Errno)
38700Sstevel@tonic-gate 			show_ucred(pri, (long)pri->sys_args[0]);
38710Sstevel@tonic-gate 		break;
38720Sstevel@tonic-gate 	case DOOR_INFO:
38730Sstevel@tonic-gate 		if (!pri->Errno)
38740Sstevel@tonic-gate 			show_doorinfo(pri, (long)pri->sys_args[1]);
38750Sstevel@tonic-gate 		break;
38760Sstevel@tonic-gate 	case DOOR_GETPARAM:
38770Sstevel@tonic-gate 		if (!pri->Errno) {
38780Sstevel@tonic-gate #ifdef _LP64
38790Sstevel@tonic-gate 			if (data_model == PR_MODEL_LP64)
38800Sstevel@tonic-gate 				show_doorparam(pri, (long)pri->sys_args[2]);
38810Sstevel@tonic-gate 			else
38820Sstevel@tonic-gate 				show_doorparam32(pri, (long)pri->sys_args[2]);
38830Sstevel@tonic-gate #else
38840Sstevel@tonic-gate 			show_doorparam(pri, (long)pri->sys_args[2]);
38850Sstevel@tonic-gate #endif
38860Sstevel@tonic-gate 		}
38870Sstevel@tonic-gate 		break;
38880Sstevel@tonic-gate 	}
38890Sstevel@tonic-gate }
38900Sstevel@tonic-gate 
38910Sstevel@tonic-gate static void
38920Sstevel@tonic-gate show_portargs(private_t *pri, long offset)
38930Sstevel@tonic-gate {
38940Sstevel@tonic-gate 	port_event_t args;
38950Sstevel@tonic-gate 
38960Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
38970Sstevel@tonic-gate 		(void) printf("%s\tevents=0x%x source=%u\n",
38980Sstevel@tonic-gate 		    pri->pname,
38990Sstevel@tonic-gate 		    args.portev_events,
39000Sstevel@tonic-gate 		    args.portev_source);
39010Sstevel@tonic-gate 		(void) printf("%s\tobject=0x%p user=0x%p\n",
39020Sstevel@tonic-gate 		    pri->pname,
39030Sstevel@tonic-gate 		    (void *)args.portev_object,
39040Sstevel@tonic-gate 		    (void *)args.portev_user);
39050Sstevel@tonic-gate 	}
39060Sstevel@tonic-gate }
39070Sstevel@tonic-gate 
39080Sstevel@tonic-gate 
39090Sstevel@tonic-gate #ifdef _LP64
39100Sstevel@tonic-gate 
39110Sstevel@tonic-gate static void
39120Sstevel@tonic-gate show_portargs32(private_t *pri, long offset)
39130Sstevel@tonic-gate {
39140Sstevel@tonic-gate 	port_event32_t args;
39150Sstevel@tonic-gate 
39160Sstevel@tonic-gate 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
39170Sstevel@tonic-gate 		(void) printf("%s\tevents=0x%x source=%u\n",
39180Sstevel@tonic-gate 		    pri->pname,
39190Sstevel@tonic-gate 		    args.portev_events,
39200Sstevel@tonic-gate 		    args.portev_source);
39210Sstevel@tonic-gate 		(void) printf("%s\tobject=0x%x user=0x%x\n",
39220Sstevel@tonic-gate 		    pri->pname,
39230Sstevel@tonic-gate 		    args.portev_object,
39240Sstevel@tonic-gate 		    args.portev_user);
39250Sstevel@tonic-gate 	}
39260Sstevel@tonic-gate }
39270Sstevel@tonic-gate 
39280Sstevel@tonic-gate #endif	/* _LP64 */
39290Sstevel@tonic-gate 
39300Sstevel@tonic-gate static void
39310Sstevel@tonic-gate show_ports(private_t *pri)
39320Sstevel@tonic-gate {
39330Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
39340Sstevel@tonic-gate 	case PORT_GET:
39350Sstevel@tonic-gate #ifdef _LP64
39360Sstevel@tonic-gate 		if (data_model == PR_MODEL_LP64)
39370Sstevel@tonic-gate 			show_portargs(pri, (long)pri->sys_args[2]);
39380Sstevel@tonic-gate 		else
39390Sstevel@tonic-gate 			show_portargs32(pri, (long)pri->sys_args[2]);
39400Sstevel@tonic-gate #else
39410Sstevel@tonic-gate 		show_portargs(pri, (long)pri->sys_args[2]);
39420Sstevel@tonic-gate #endif
39430Sstevel@tonic-gate 		break;
39440Sstevel@tonic-gate 	}
39450Sstevel@tonic-gate }
39460Sstevel@tonic-gate 
39470Sstevel@tonic-gate #define	MAX_SNDFL_PRD 16
39480Sstevel@tonic-gate 
39490Sstevel@tonic-gate #ifdef _LP64
39500Sstevel@tonic-gate 
39510Sstevel@tonic-gate static void
39520Sstevel@tonic-gate show_ksendfilevec32(private_t *pri, int fd,
39530Sstevel@tonic-gate     ksendfilevec32_t *sndvec, int sfvcnt)
39540Sstevel@tonic-gate {
39550Sstevel@tonic-gate 	ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
39560Sstevel@tonic-gate 	size_t cpy_rqst;
39570Sstevel@tonic-gate 
39580Sstevel@tonic-gate 	Eserialize();
39590Sstevel@tonic-gate 	while (sfvcnt > 0) {
39600Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
39610Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
39620Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
39630Sstevel@tonic-gate 
39640Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
39650Sstevel@tonic-gate 			break;
39660Sstevel@tonic-gate 
39670Sstevel@tonic-gate 		snd_ptr = &snd[0];
39680Sstevel@tonic-gate 
39690Sstevel@tonic-gate 		while (cpy_rqst) {
39700Sstevel@tonic-gate 			(void) printf(
39710Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
39720Sstevel@tonic-gate 			    "sfv_off=%d\tsfv_len=%u\n",
39730Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
39740Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
39750Sstevel@tonic-gate 			    snd_ptr->sfv_off,
39760Sstevel@tonic-gate 			    snd_ptr->sfv_len);
39770Sstevel@tonic-gate 
39780Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
39790Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
39800Sstevel@tonic-gate 				showbuffer(pri,
39810Sstevel@tonic-gate 				    (long)snd_ptr->sfv_off & 0xffffffff,
39820Sstevel@tonic-gate 				    (long)snd_ptr->sfv_len);
39830Sstevel@tonic-gate 			}
39840Sstevel@tonic-gate 
39850Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
39860Sstevel@tonic-gate 			snd_ptr++;
39870Sstevel@tonic-gate 		}
39880Sstevel@tonic-gate 
39890Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
39900Sstevel@tonic-gate 	}
39910Sstevel@tonic-gate 	Xserialize();
39920Sstevel@tonic-gate }
39930Sstevel@tonic-gate 
39940Sstevel@tonic-gate static void
39950Sstevel@tonic-gate show_ksendfilevec64(private_t *pri, int fd,
39960Sstevel@tonic-gate     ksendfilevec64_t *sndvec, int sfvcnt)
39970Sstevel@tonic-gate {
39980Sstevel@tonic-gate 	ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
39990Sstevel@tonic-gate 	size_t cpy_rqst;
40000Sstevel@tonic-gate 
40010Sstevel@tonic-gate 	Eserialize();
40020Sstevel@tonic-gate 	while (sfvcnt > 0) {
40030Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
40040Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
40050Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
40060Sstevel@tonic-gate 
40070Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
40080Sstevel@tonic-gate 			break;
40090Sstevel@tonic-gate 
40100Sstevel@tonic-gate 		snd_ptr = &snd[0];
40110Sstevel@tonic-gate 
40120Sstevel@tonic-gate 		while (cpy_rqst) {
40130Sstevel@tonic-gate 			(void) printf(
40140Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
40150Sstevel@tonic-gate 			    "sfv_off=%ld\tsfv_len=%u\n",
40160Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
40170Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
40180Sstevel@tonic-gate 			    snd_ptr->sfv_off,
40190Sstevel@tonic-gate 			    snd_ptr->sfv_len);
40200Sstevel@tonic-gate 
40210Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
40220Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
40230Sstevel@tonic-gate 				showbuffer(pri,
40240Sstevel@tonic-gate 				    (long)snd_ptr->sfv_off & 0xffffffff,
40250Sstevel@tonic-gate 				    (long)snd_ptr->sfv_len);
40260Sstevel@tonic-gate 			}
40270Sstevel@tonic-gate 
40280Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
40290Sstevel@tonic-gate 			snd_ptr++;
40300Sstevel@tonic-gate 		}
40310Sstevel@tonic-gate 
40320Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
40330Sstevel@tonic-gate 	}
40340Sstevel@tonic-gate 	Xserialize();
40350Sstevel@tonic-gate }
40360Sstevel@tonic-gate 
40370Sstevel@tonic-gate #endif /* _LP64 */
40380Sstevel@tonic-gate 
40390Sstevel@tonic-gate /*ARGSUSED*/
40400Sstevel@tonic-gate static void
40410Sstevel@tonic-gate show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
40420Sstevel@tonic-gate {
40430Sstevel@tonic-gate 	sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
40440Sstevel@tonic-gate 	size_t cpy_rqst;
40450Sstevel@tonic-gate 
40460Sstevel@tonic-gate #ifdef _LP64
40470Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
40480Sstevel@tonic-gate 		show_ksendfilevec32(pri, fd,
40490Sstevel@tonic-gate 		    (ksendfilevec32_t *)sndvec, sfvcnt);
40500Sstevel@tonic-gate 		return;
40510Sstevel@tonic-gate 	}
40520Sstevel@tonic-gate #endif
40530Sstevel@tonic-gate 	Eserialize();
40540Sstevel@tonic-gate 	while (sfvcnt > 0) {
40550Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
40560Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
40570Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
40580Sstevel@tonic-gate 
40590Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
40600Sstevel@tonic-gate 			break;
40610Sstevel@tonic-gate 
40620Sstevel@tonic-gate 		snd_ptr = &snd[0];
40630Sstevel@tonic-gate 
40640Sstevel@tonic-gate 		while (cpy_rqst) {
40650Sstevel@tonic-gate 			(void) printf(
40660Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
40670Sstevel@tonic-gate 			    "sfv_off=%ld\tsfv_len=%lu\n",
40680Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
40690Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
40700Sstevel@tonic-gate 			    snd_ptr->sfv_off,
40710Sstevel@tonic-gate 			    (ulong_t)snd_ptr->sfv_len);
40720Sstevel@tonic-gate 
40730Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
40740Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
40750Sstevel@tonic-gate 				showbuffer(pri, (long)snd_ptr->sfv_off,
40767088Sraf 				    (long)snd_ptr->sfv_len);
40770Sstevel@tonic-gate 			}
40780Sstevel@tonic-gate 
40790Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
40800Sstevel@tonic-gate 			snd_ptr++;
40810Sstevel@tonic-gate 		}
40820Sstevel@tonic-gate 
40830Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
40840Sstevel@tonic-gate 	}
40850Sstevel@tonic-gate 	Xserialize();
40860Sstevel@tonic-gate }
40870Sstevel@tonic-gate 
40880Sstevel@tonic-gate /*ARGSUSED*/
40890Sstevel@tonic-gate static void
40900Sstevel@tonic-gate show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
40910Sstevel@tonic-gate {
40920Sstevel@tonic-gate 	sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
40930Sstevel@tonic-gate 	size_t cpy_rqst;
40940Sstevel@tonic-gate 
40950Sstevel@tonic-gate #ifdef _LP64
40960Sstevel@tonic-gate 	if (data_model != PR_MODEL_LP64) {
40970Sstevel@tonic-gate 		show_ksendfilevec64(pri, fd,
40980Sstevel@tonic-gate 		    (ksendfilevec64_t *)sndvec, sfvcnt);
40990Sstevel@tonic-gate 		return;
41000Sstevel@tonic-gate 	}
41010Sstevel@tonic-gate #endif
41020Sstevel@tonic-gate 
41030Sstevel@tonic-gate 	Eserialize();
41040Sstevel@tonic-gate 	while (sfvcnt > 0) {
41050Sstevel@tonic-gate 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
41060Sstevel@tonic-gate 		sfvcnt -= cpy_rqst;
41070Sstevel@tonic-gate 		cpy_rqst *= sizeof (snd[0]);
41080Sstevel@tonic-gate 
41090Sstevel@tonic-gate 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
41100Sstevel@tonic-gate 			break;
41110Sstevel@tonic-gate 
41120Sstevel@tonic-gate 		snd_ptr = &snd[0];
41130Sstevel@tonic-gate 
41140Sstevel@tonic-gate 		while (cpy_rqst) {
41150Sstevel@tonic-gate 			(void) printf(
41160Sstevel@tonic-gate #ifdef _LP64
41170Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
41180Sstevel@tonic-gate 			    "sfv_off=%ld\tsfv_len=%lu\n",
41190Sstevel@tonic-gate #else
41200Sstevel@tonic-gate 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
41210Sstevel@tonic-gate 			    "sfv_off=%lld\tsfv_len=%lu\n",
41220Sstevel@tonic-gate #endif
41230Sstevel@tonic-gate 			    snd_ptr->sfv_fd,
41240Sstevel@tonic-gate 			    snd_ptr->sfv_flag,
41250Sstevel@tonic-gate 			    snd_ptr->sfv_off,
41260Sstevel@tonic-gate 			    (ulong_t)snd_ptr->sfv_len);
41270Sstevel@tonic-gate 
41280Sstevel@tonic-gate 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
41290Sstevel@tonic-gate 			    prismember(&writefd, fd)) {
41300Sstevel@tonic-gate 				showbuffer(pri, (long)snd_ptr->sfv_off,
41317088Sraf 				    (long)snd_ptr->sfv_len);
41320Sstevel@tonic-gate 			}
41330Sstevel@tonic-gate 
41340Sstevel@tonic-gate 			cpy_rqst -= sizeof (snd[0]);
41350Sstevel@tonic-gate 			snd_ptr++;
41360Sstevel@tonic-gate 		}
41370Sstevel@tonic-gate 
41380Sstevel@tonic-gate 		sndvec += MAX_SNDFL_PRD;
41390Sstevel@tonic-gate 	}
41400Sstevel@tonic-gate 	Xserialize();
41410Sstevel@tonic-gate }
41420Sstevel@tonic-gate 
41430Sstevel@tonic-gate static void
41440Sstevel@tonic-gate show_memcntl_mha(private_t *pri, long offset)
41450Sstevel@tonic-gate {
41460Sstevel@tonic-gate 	struct memcntl_mha mha;
41470Sstevel@tonic-gate 	const char *s = NULL;
41480Sstevel@tonic-gate 
41490Sstevel@tonic-gate 	if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
41500Sstevel@tonic-gate 		switch (mha.mha_cmd) {
41510Sstevel@tonic-gate 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
41520Sstevel@tonic-gate 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
41530Sstevel@tonic-gate 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
41540Sstevel@tonic-gate 		}
41550Sstevel@tonic-gate 		if (s)
41560Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
41570Sstevel@tonic-gate 			    " mha_pagesize=%lu\n",
41580Sstevel@tonic-gate 			    pri->pname, s, mha.mha_flags,
41590Sstevel@tonic-gate 			    (ulong_t)mha.mha_pagesize);
41600Sstevel@tonic-gate 		else
41610Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
41620Sstevel@tonic-gate 			    " mha_pagesize=%lu\n",
41630Sstevel@tonic-gate 			    pri->pname, mha.mha_cmd, mha.mha_flags,
41640Sstevel@tonic-gate 			    (ulong_t)mha.mha_pagesize);
41650Sstevel@tonic-gate 	}
41660Sstevel@tonic-gate }
41670Sstevel@tonic-gate 
41680Sstevel@tonic-gate #ifdef _LP64
41690Sstevel@tonic-gate 
41700Sstevel@tonic-gate static void
41710Sstevel@tonic-gate show_memcntl_mha32(private_t *pri, long offset)
41720Sstevel@tonic-gate {
41730Sstevel@tonic-gate 	struct memcntl_mha32 mha32;
41740Sstevel@tonic-gate 	const char *s = NULL;
41750Sstevel@tonic-gate 
41760Sstevel@tonic-gate 	if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
41770Sstevel@tonic-gate 	    sizeof (mha32)) {
41780Sstevel@tonic-gate 		switch (mha32.mha_cmd) {
41790Sstevel@tonic-gate 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
41800Sstevel@tonic-gate 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
41810Sstevel@tonic-gate 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
41820Sstevel@tonic-gate 		}
41830Sstevel@tonic-gate 		if (s)
41840Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
41850Sstevel@tonic-gate 			    " mha_pagesize=%u\n",
41860Sstevel@tonic-gate 			    pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
41870Sstevel@tonic-gate 		else
41880Sstevel@tonic-gate 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
41890Sstevel@tonic-gate 			    " mha_pagesize=%u\n",
41900Sstevel@tonic-gate 			    pri->pname, mha32.mha_cmd, mha32.mha_flags,
41910Sstevel@tonic-gate 			    mha32.mha_pagesize);
41920Sstevel@tonic-gate 	}
41930Sstevel@tonic-gate }
41940Sstevel@tonic-gate 
41950Sstevel@tonic-gate #endif	/* _LP64 */
41960Sstevel@tonic-gate 
41970Sstevel@tonic-gate static void
41980Sstevel@tonic-gate show_memcntl(private_t *pri)
41990Sstevel@tonic-gate {
42000Sstevel@tonic-gate 
42010Sstevel@tonic-gate 	if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
42020Sstevel@tonic-gate 		return;
42030Sstevel@tonic-gate #ifdef _LP64
42040Sstevel@tonic-gate 	if (data_model == PR_MODEL_LP64)
42050Sstevel@tonic-gate 		show_memcntl_mha(pri, (long)pri->sys_args[3]);
42060Sstevel@tonic-gate 	else
42070Sstevel@tonic-gate 		show_memcntl_mha32(pri, (long)pri->sys_args[3]);
42080Sstevel@tonic-gate #else
42090Sstevel@tonic-gate 	show_memcntl_mha(pri, (long)pri->sys_args[3]);
42100Sstevel@tonic-gate #endif
42110Sstevel@tonic-gate }
42120Sstevel@tonic-gate 
42130Sstevel@tonic-gate void
42140Sstevel@tonic-gate show_ids(private_t *pri, long offset, int count)
42150Sstevel@tonic-gate {
42160Sstevel@tonic-gate 	id_t buf[MYBUFSIZ / sizeof (id_t)];
42170Sstevel@tonic-gate 	id_t *idp;
42180Sstevel@tonic-gate 	int serial = (count > MYBUFSIZ / 48);
42190Sstevel@tonic-gate 
4220*10440SRoger.Faulkner@Sun.COM 	if (offset == 0)
42210Sstevel@tonic-gate 		return;
42220Sstevel@tonic-gate 
42230Sstevel@tonic-gate 	/* enter region of lengthy output */
42240Sstevel@tonic-gate 	if (serial)
42250Sstevel@tonic-gate 		Eserialize();
42260Sstevel@tonic-gate 
42270Sstevel@tonic-gate 	while (count > 0 && !interrupt) {
42280Sstevel@tonic-gate 		ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
42297088Sraf 		    count * sizeof (id_t) : MYBUFSIZ;
42300Sstevel@tonic-gate 
42310Sstevel@tonic-gate 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
42320Sstevel@tonic-gate 		    nb < sizeof (id_t))
42330Sstevel@tonic-gate 			break;
42340Sstevel@tonic-gate 
42350Sstevel@tonic-gate 		idp = buf;
42360Sstevel@tonic-gate 		while (!interrupt && nb >= sizeof (id_t)) {
42370Sstevel@tonic-gate 			(void) printf("%s\t%8d\n", pri->pname, (int)*idp);
42380Sstevel@tonic-gate 			offset += sizeof (id_t);
42390Sstevel@tonic-gate 			nb -= sizeof (id_t);
42400Sstevel@tonic-gate 			idp++;
42410Sstevel@tonic-gate 			count--;
42420Sstevel@tonic-gate 		}
42430Sstevel@tonic-gate 	}
42440Sstevel@tonic-gate 
42450Sstevel@tonic-gate 	/* exit region of lengthy output */
42460Sstevel@tonic-gate 	if (serial)
42470Sstevel@tonic-gate 		Xserialize();
42480Sstevel@tonic-gate }
42490Sstevel@tonic-gate 
42500Sstevel@tonic-gate void
42510Sstevel@tonic-gate show_ntp_gettime(private_t *pri)
42520Sstevel@tonic-gate {
42530Sstevel@tonic-gate 	struct ntptimeval ntv;
42540Sstevel@tonic-gate 	long offset;
42550Sstevel@tonic-gate 
42560Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
42570Sstevel@tonic-gate 		return;
42580Sstevel@tonic-gate 
42590Sstevel@tonic-gate 	if (data_model == PR_MODEL_NATIVE) {
42600Sstevel@tonic-gate 		if (Pread(Proc, &ntv, sizeof (ntv), offset)
42610Sstevel@tonic-gate 		    != sizeof (ntv))
42620Sstevel@tonic-gate 			return;
42630Sstevel@tonic-gate 	} else {
42640Sstevel@tonic-gate 		struct ntptimeval32 ntv32;
42650Sstevel@tonic-gate 
42660Sstevel@tonic-gate 		if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
42670Sstevel@tonic-gate 		    != sizeof (ntv32))
42680Sstevel@tonic-gate 			return;
42690Sstevel@tonic-gate 
42700Sstevel@tonic-gate 		TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
42710Sstevel@tonic-gate 		ntv.maxerror = ntv32.maxerror;
42720Sstevel@tonic-gate 		ntv.esterror = ntv32.esterror;
42730Sstevel@tonic-gate 	}
42740Sstevel@tonic-gate 
42750Sstevel@tonic-gate 	(void) printf("\ttime:     %ld.%6.6ld sec\n",
42760Sstevel@tonic-gate 	    ntv.time.tv_sec, ntv.time.tv_usec);
42770Sstevel@tonic-gate 	(void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
42780Sstevel@tonic-gate 	(void) printf("\testerror: %11d usec\n", ntv.esterror);
42790Sstevel@tonic-gate }
42800Sstevel@tonic-gate 
42810Sstevel@tonic-gate static char *
42820Sstevel@tonic-gate get_timex_modes(private_t *pri, uint32_t val)
42830Sstevel@tonic-gate {
42840Sstevel@tonic-gate 	char *str = pri->code_buf;
42850Sstevel@tonic-gate 	size_t used = 0;
42860Sstevel@tonic-gate 
42870Sstevel@tonic-gate 	*str = '\0';
42880Sstevel@tonic-gate 	if (val & MOD_OFFSET)
42890Sstevel@tonic-gate 		used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
42900Sstevel@tonic-gate 	if (val & MOD_FREQUENCY)
42910Sstevel@tonic-gate 		used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
42920Sstevel@tonic-gate 	if (val & MOD_MAXERROR)
42930Sstevel@tonic-gate 		used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
42940Sstevel@tonic-gate 	if (val & MOD_ESTERROR)
42950Sstevel@tonic-gate 		used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
42960Sstevel@tonic-gate 	if (val & MOD_STATUS)
42970Sstevel@tonic-gate 		used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
42980Sstevel@tonic-gate 	if (val & MOD_TIMECONST)
42990Sstevel@tonic-gate 		used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
43000Sstevel@tonic-gate 	if (val & MOD_CLKB)
43010Sstevel@tonic-gate 		used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
43020Sstevel@tonic-gate 	if (val & MOD_CLKA)
43030Sstevel@tonic-gate 		used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
43040Sstevel@tonic-gate 
43050Sstevel@tonic-gate 	if (used == 0 || used >= sizeof (pri->code_buf))
43060Sstevel@tonic-gate 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
43070Sstevel@tonic-gate 
43080Sstevel@tonic-gate 	return (str + 1);
43090Sstevel@tonic-gate }
43100Sstevel@tonic-gate 
43110Sstevel@tonic-gate static char *
43120Sstevel@tonic-gate get_timex_status(private_t *pri, int32_t val)
43130Sstevel@tonic-gate {
43140Sstevel@tonic-gate 	char *str = pri->code_buf;
43150Sstevel@tonic-gate 	size_t used = 0;
43160Sstevel@tonic-gate 
43170Sstevel@tonic-gate 	*str = '\0';
43180Sstevel@tonic-gate 	if (val & STA_PLL)
43190Sstevel@tonic-gate 		used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
43200Sstevel@tonic-gate 	if (val & STA_PPSFREQ)
43210Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
43220Sstevel@tonic-gate 	if (val & STA_PPSTIME)
43230Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
43240Sstevel@tonic-gate 	if (val & STA_FLL)
43250Sstevel@tonic-gate 		used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
43260Sstevel@tonic-gate 
43270Sstevel@tonic-gate 	if (val & STA_INS)
43280Sstevel@tonic-gate 		used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
43290Sstevel@tonic-gate 	if (val & STA_DEL)
43300Sstevel@tonic-gate 		used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
43310Sstevel@tonic-gate 	if (val & STA_UNSYNC)
43320Sstevel@tonic-gate 		used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
43330Sstevel@tonic-gate 	if (val & STA_FREQHOLD)
43340Sstevel@tonic-gate 		used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
43350Sstevel@tonic-gate 
43360Sstevel@tonic-gate 	if (val & STA_PPSSIGNAL)
43370Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
43380Sstevel@tonic-gate 	if (val & STA_PPSJITTER)
43390Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
43400Sstevel@tonic-gate 	if (val & STA_PPSWANDER)
43410Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
43420Sstevel@tonic-gate 	if (val & STA_PPSERROR)
43430Sstevel@tonic-gate 		used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
43440Sstevel@tonic-gate 
43450Sstevel@tonic-gate 	if (val & STA_CLOCKERR)
43460Sstevel@tonic-gate 		used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
43470Sstevel@tonic-gate 
43480Sstevel@tonic-gate 	if (used == 0 || used >= sizeof (pri->code_buf))
43490Sstevel@tonic-gate 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
43500Sstevel@tonic-gate 
43510Sstevel@tonic-gate 	return (str + 1);
43520Sstevel@tonic-gate }
43530Sstevel@tonic-gate 
43540Sstevel@tonic-gate void
43550Sstevel@tonic-gate show_ntp_adjtime(private_t *pri)
43560Sstevel@tonic-gate {
43570Sstevel@tonic-gate 	struct timex timex;
43580Sstevel@tonic-gate 	long offset;
43590Sstevel@tonic-gate 
43600Sstevel@tonic-gate 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
43610Sstevel@tonic-gate 		return;
43620Sstevel@tonic-gate 
43630Sstevel@tonic-gate 	if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
43640Sstevel@tonic-gate 		return;
43650Sstevel@tonic-gate 
43660Sstevel@tonic-gate 	(void) printf("\tmodes:     %s\n", get_timex_modes(pri, timex.modes));
43670Sstevel@tonic-gate 	(void) printf("\toffset:    %11d usec\n", timex.offset);
43680Sstevel@tonic-gate 	(void) printf("\tfreq:      %11d scaled ppm\n", timex.freq);
43690Sstevel@tonic-gate 	(void) printf("\tmaxerror:  %11d usec\n", timex.maxerror);
43700Sstevel@tonic-gate 	(void) printf("\testerror:  %11d usec\n", timex.esterror);
43710Sstevel@tonic-gate 	(void) printf("\tstatus:    %s\n", get_timex_status(pri, timex.status));
43720Sstevel@tonic-gate 	(void) printf("\tconstant:  %11d\n", timex.constant);
43730Sstevel@tonic-gate 	(void) printf("\tprecision: %11d usec\n", timex.precision);
43740Sstevel@tonic-gate 	(void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
43750Sstevel@tonic-gate 	(void) printf("\tppsfreq:   %11d scaled ppm\n", timex.ppsfreq);
43760Sstevel@tonic-gate 	(void) printf("\tjitter:    %11d usec\n", timex.jitter);
43770Sstevel@tonic-gate 	(void) printf("\tshift:     %11d sec\n", timex.shift);
43780Sstevel@tonic-gate 	(void) printf("\tstabil:    %11d scaled ppm\n", timex.stabil);
43790Sstevel@tonic-gate 	(void) printf("\tjitcnt:    %11d\n", timex.jitcnt);
43800Sstevel@tonic-gate 	(void) printf("\tcalcnt:    %11d\n", timex.calcnt);
43810Sstevel@tonic-gate 	(void) printf("\terrcnt:    %11d\n", timex.errcnt);
43820Sstevel@tonic-gate 	(void) printf("\tstbcnt:    %11d\n", timex.stbcnt);
43830Sstevel@tonic-gate }
43840Sstevel@tonic-gate 
43850Sstevel@tonic-gate void
43860Sstevel@tonic-gate show_getrusage(long offset)
43870Sstevel@tonic-gate {
43880Sstevel@tonic-gate 	struct rusage r;
43890Sstevel@tonic-gate 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
43900Sstevel@tonic-gate 		return;
43910Sstevel@tonic-gate 	(void) printf("\t       user time: %ld.%6.6ld sec\n",
43920Sstevel@tonic-gate 	    r.ru_utime.tv_sec,
43930Sstevel@tonic-gate 	    r.ru_utime.tv_usec);
43940Sstevel@tonic-gate 	(void) printf("\t     system time: %ld.%6.6ld sec\n",
43950Sstevel@tonic-gate 	    r.ru_stime.tv_sec,
43960Sstevel@tonic-gate 	    r.ru_stime.tv_usec);
43970Sstevel@tonic-gate 	(void) printf("\t         max rss: <unimpl> %ld\n",
43980Sstevel@tonic-gate 	    r.ru_maxrss);
43990Sstevel@tonic-gate 	(void) printf("\t     shared data: <unimpl> %ld\n",
44000Sstevel@tonic-gate 	    r.ru_ixrss);
44010Sstevel@tonic-gate 	(void) printf("\t   unshared data: <unimpl> %ld\n",
44020Sstevel@tonic-gate 	    r.ru_idrss);
44030Sstevel@tonic-gate 	(void) printf("\t  unshared stack: <unimpl> %ld\n",
44040Sstevel@tonic-gate 	    r.ru_isrss);
44050Sstevel@tonic-gate 	(void) printf("\t    minor faults: %ld\n",
44060Sstevel@tonic-gate 	    r.ru_minflt);
44070Sstevel@tonic-gate 	(void) printf("\t    major faults: %ld\n",
44080Sstevel@tonic-gate 	    r.ru_majflt);
44090Sstevel@tonic-gate 	(void) printf("\t      # of swaps: %ld\n",
44100Sstevel@tonic-gate 	    r.ru_nswap);
44110Sstevel@tonic-gate 	(void) printf("\t  blocked inputs: %ld\n",
44120Sstevel@tonic-gate 	    r.ru_inblock);
44130Sstevel@tonic-gate 	(void) printf("\t blocked outputs: %ld\n",
44140Sstevel@tonic-gate 	    r.ru_oublock);
44150Sstevel@tonic-gate 	(void) printf("\t       msgs sent: %ld\n",
44160Sstevel@tonic-gate 	    r.ru_msgsnd);
44170Sstevel@tonic-gate 	(void) printf("\t      msgs rcv'd: %ld\n",
44180Sstevel@tonic-gate 	    r.ru_msgrcv);
44190Sstevel@tonic-gate 	(void) printf("\t   signals rcv'd: %ld\n",
44200Sstevel@tonic-gate 	    r.ru_nsignals);
44210Sstevel@tonic-gate 	(void) printf("\tvol cntxt swtchs: %ld\n",
44220Sstevel@tonic-gate 	    r.ru_nvcsw);
44230Sstevel@tonic-gate 	(void) printf("\tinv cntxt swtchs: %ld\n",
44240Sstevel@tonic-gate 	    r.ru_nivcsw);
44250Sstevel@tonic-gate }
44260Sstevel@tonic-gate 
44270Sstevel@tonic-gate #ifdef _LP64
44280Sstevel@tonic-gate void
44290Sstevel@tonic-gate show_getrusage32(long offset)
44300Sstevel@tonic-gate {
44310Sstevel@tonic-gate 	struct rusage32 r;
44320Sstevel@tonic-gate 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
44330Sstevel@tonic-gate 		return;
44340Sstevel@tonic-gate 	(void) printf("\t       user time: %d.%6.6d sec\n",
44350Sstevel@tonic-gate 	    r.ru_utime.tv_sec,
44360Sstevel@tonic-gate 	    r.ru_utime.tv_usec);
44370Sstevel@tonic-gate 	(void) printf("\t     system time: %d.%6.6d sec\n",
44380Sstevel@tonic-gate 	    r.ru_stime.tv_sec,
44390Sstevel@tonic-gate 	    r.ru_stime.tv_usec);
44400Sstevel@tonic-gate 	(void) printf("\t         max rss: <unimpl> %d\n",
44410Sstevel@tonic-gate 	    r.ru_maxrss);
44420Sstevel@tonic-gate 	(void) printf("\t     shared data: <unimpl> %d\n",
44430Sstevel@tonic-gate 	    r.ru_ixrss);
44440Sstevel@tonic-gate 	(void) printf("\t   unshared data: <unimpl> %d\n",
44450Sstevel@tonic-gate 	    r.ru_idrss);
44460Sstevel@tonic-gate 	(void) printf("\t  unshared stack: <unimpl> %d\n",
44470Sstevel@tonic-gate 	    r.ru_isrss);
44480Sstevel@tonic-gate 	(void) printf("\t    minor faults: %d\n",
44490Sstevel@tonic-gate 	    r.ru_minflt);
44500Sstevel@tonic-gate 	(void) printf("\t    major faults: %d\n",
44510Sstevel@tonic-gate 	    r.ru_majflt);
44520Sstevel@tonic-gate 	(void) printf("\t      # of swaps: %d\n",
44530Sstevel@tonic-gate 	    r.ru_nswap);
44540Sstevel@tonic-gate 	(void) printf("\t  blocked inputs: %d\n",
44550Sstevel@tonic-gate 	    r.ru_inblock);
44560Sstevel@tonic-gate 	(void) printf("\t blocked outputs: %d\n",
44570Sstevel@tonic-gate 	    r.ru_oublock);
44580Sstevel@tonic-gate 	(void) printf("\t       msgs sent: %d\n",
44590Sstevel@tonic-gate 	    r.ru_msgsnd);
44600Sstevel@tonic-gate 	(void) printf("\t      msgs rcv'd: %d\n",
44610Sstevel@tonic-gate 	    r.ru_msgrcv);
44620Sstevel@tonic-gate 	(void) printf("\t   signals rcv'd: %d\n",
44630Sstevel@tonic-gate 	    r.ru_nsignals);
44640Sstevel@tonic-gate 	(void) printf("\tvol cntxt swtchs: %d\n",
44650Sstevel@tonic-gate 	    r.ru_nvcsw);
44660Sstevel@tonic-gate 	(void) printf("\tinv cntxt swtchs: %d\n",
44670Sstevel@tonic-gate 	    r.ru_nivcsw);
44680Sstevel@tonic-gate }
44690Sstevel@tonic-gate #endif
44700Sstevel@tonic-gate 
44712447Snf202958 /*
44722447Snf202958  * Utility function to print a packed nvlist by unpacking
44732447Snf202958  * and calling the libnvpair pretty printer.  Frees all
44742447Snf202958  * allocated memory internally.
44752447Snf202958  */
44762447Snf202958 static void
44772447Snf202958 show_packed_nvlist(private_t *pri, uintptr_t offset, size_t size)
44782447Snf202958 {
44792447Snf202958 	nvlist_t *nvl = NULL;
44802447Snf202958 	size_t readsize;
44812447Snf202958 	char *buf;
44822447Snf202958 
44832447Snf202958 	if ((offset == 0) || (size == 0)) {
44842447Snf202958 		return;
44852447Snf202958 	}
44862447Snf202958 
44872447Snf202958 	buf = my_malloc(size, "nvlist decode buffer");
44882447Snf202958 	readsize = Pread(Proc, buf, size, offset);
44892447Snf202958 	if (readsize != size) {
44902447Snf202958 		(void) printf("%s\t<?>", pri->pname);
44912447Snf202958 	} else {
44922447Snf202958 		int result;
44932447Snf202958 
44942447Snf202958 		result = nvlist_unpack(buf, size, &nvl, 0);
44952447Snf202958 		if (result == 0) {
44962447Snf202958 			nvlist_print(stdout, nvl);
44972447Snf202958 			nvlist_free(nvl);
44982447Snf202958 		} else {
44992447Snf202958 			(void) printf("%s\tunpack of nvlist"
45002447Snf202958 			    " failed: %d\n", pri->pname, result);
45012447Snf202958 		}
45022447Snf202958 	}
45032447Snf202958 	free(buf);
45042447Snf202958 }
45052447Snf202958 
4506813Sdp static void
4507813Sdp show_zone_create_args(private_t *pri, long offset)
4508813Sdp {
4509813Sdp 	zone_def args;
4510813Sdp 	char zone_name[ZONENAME_MAX];
4511813Sdp 	char zone_root[MAXPATHLEN];
4512813Sdp 	char *zone_zfs = NULL;
4513813Sdp 
4514813Sdp 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4515813Sdp 
4516813Sdp 		if (Pread_string(Proc, zone_name, sizeof (zone_name),
4517813Sdp 		    (uintptr_t)args.zone_name) == -1)
4518813Sdp 			(void) strcpy(zone_name, "<?>");
4519813Sdp 
4520813Sdp 		if (Pread_string(Proc, zone_root, sizeof (zone_root),
4521813Sdp 		    (uintptr_t)args.zone_root) == -1)
4522813Sdp 			(void) strcpy(zone_root, "<?>");
4523813Sdp 
4524813Sdp 		if (args.zfsbufsz > 0) {
4525813Sdp 			zone_zfs = malloc(MIN(4, args.zfsbufsz));
4526813Sdp 			if (zone_zfs != NULL) {
4527813Sdp 				if (Pread(Proc, zone_zfs, args.zfsbufsz,
4528813Sdp 				    (uintptr_t)args.zfsbuf) == -1)
4529813Sdp 					(void) strcpy(zone_zfs, "<?>");
4530813Sdp 			}
4531813Sdp 		} else {
4532813Sdp 			zone_zfs = "";
4533813Sdp 		}
4534813Sdp 
4535813Sdp 		(void) printf("%s\t     zone_name: %s\n", pri->pname,
4536813Sdp 		    zone_name);
4537813Sdp 		(void) printf("%s\t     zone_root: %s\n", pri->pname,
4538813Sdp 		    zone_root);
4539813Sdp 
4540813Sdp 		show_privset(pri, (uintptr_t)args.zone_privs,
4541813Sdp 		    args.zone_privssz, "    zone_privs: ");
4542813Sdp 
4543813Sdp 		(void) printf("%s\t       rctlbuf: 0x%p\n", pri->pname,
4544813Sdp 		    (void *)args.rctlbuf);
4545813Sdp 		(void) printf("%s\t     rctlbufsz: %lu\n", pri->pname,
4546813Sdp 		    (ulong_t)args.rctlbufsz);
4547813Sdp 
45482447Snf202958 		show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
45492447Snf202958 		    args.rctlbufsz);
45502447Snf202958 
4551813Sdp 		(void) printf("%s\t           zfs: %s\n", pri->pname, zone_zfs);
4552813Sdp 
4553813Sdp 		(void) printf("%s\textended_error: 0x%p\n", pri->pname,
4554813Sdp 		    (void *)args.extended_error);
4555813Sdp 
45561676Sjpk 		if (is_system_labeled()) {
45571676Sjpk 			char		*label_str = NULL;
45581676Sjpk 			bslabel_t	zone_label;
45591676Sjpk 
45601676Sjpk 			(void) printf("%s\t         match: %d\n", pri->pname,
45611676Sjpk 			    args.match);
45621676Sjpk 			(void) printf("%s\t           doi: %d\n", pri->pname,
45631676Sjpk 			    args.doi);
45641676Sjpk 
45651676Sjpk 			if (Pread_string(Proc, (char *)&zone_label,
45661676Sjpk 			    sizeof (zone_label), (uintptr_t)args.label) != -1) {
45671676Sjpk 				/* show the label as string */
45681676Sjpk 				if (label_to_str(&zone_label, &label_str,
45691676Sjpk 				    M_LABEL, SHORT_NAMES) != 0) {
45701676Sjpk 					/* have to dump label as raw string */
45711676Sjpk 					(void) label_to_str(&zone_label,
45721676Sjpk 					    &label_str, M_INTERNAL,
45731676Sjpk 					    SHORT_NAMES);
45741676Sjpk 				}
45751676Sjpk 			}
45761676Sjpk 
45771676Sjpk 			(void) printf("%s\t         label: %s\n",
45781676Sjpk 			    pri->pname, label_str != NULL ? label_str : "<?>");
45791676Sjpk 			if (label_str)
45801676Sjpk 				free(label_str);
45811676Sjpk 		}
45821676Sjpk 
4583813Sdp 		if (args.zfsbufsz > 0)
4584813Sdp 			free(zone_zfs);
4585813Sdp 	}
4586813Sdp }
4587813Sdp 
4588813Sdp 
4589813Sdp #ifdef _LP64
4590813Sdp 
4591813Sdp static void
4592813Sdp show_zone_create_args32(private_t *pri, long offset)
4593813Sdp {
4594813Sdp 	zone_def32 args;
4595813Sdp 	char zone_name[ZONENAME_MAX];
4596813Sdp 	char zone_root[MAXPATHLEN];
4597813Sdp 	char *zone_zfs = NULL;
4598813Sdp 
4599813Sdp 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4600813Sdp 
4601813Sdp 		if (Pread_string(Proc, zone_name, sizeof (zone_name),
4602813Sdp 		    (uintptr_t)args.zone_name) == -1)
4603813Sdp 			(void) strcpy(zone_name, "<?>");
4604813Sdp 
4605813Sdp 		if (Pread_string(Proc, zone_root, sizeof (zone_root),
4606813Sdp 		    (uintptr_t)args.zone_root) == -1)
4607813Sdp 			(void) strcpy(zone_root, "<?>");
4608813Sdp 
4609813Sdp 		if (args.zfsbufsz > 0) {
4610813Sdp 			zone_zfs = malloc(MIN(4, args.zfsbufsz));
4611813Sdp 			if (zone_zfs != NULL) {
4612813Sdp 				if (Pread(Proc, zone_zfs, args.zfsbufsz,
4613813Sdp 				    (uintptr_t)args.zfsbuf) == -1)
4614813Sdp 					(void) strcpy(zone_zfs, "<?>");
4615813Sdp 			}
4616813Sdp 		} else {
4617813Sdp 			zone_zfs = "";
4618813Sdp 		}
4619813Sdp 
4620813Sdp 		(void) printf("%s\t     zone_name: %s\n", pri->pname,
4621813Sdp 		    zone_name);
4622813Sdp 		(void) printf("%s\t     zone_root: %s\n", pri->pname,
4623813Sdp 		    zone_root);
4624813Sdp 
4625813Sdp 		show_privset(pri, (uintptr_t)args.zone_privs,
4626813Sdp 		    args.zone_privssz, "    zone_privs: ");
4627813Sdp 
4628835Sdp 		(void) printf("%s\t       rctlbuf: 0x%x\n", pri->pname,
4629835Sdp 		    (caddr32_t)args.rctlbuf);
4630813Sdp 		(void) printf("%s\t     rctlbufsz: %lu\n", pri->pname,
4631813Sdp 		    (ulong_t)args.rctlbufsz);
4632813Sdp 
46332447Snf202958 		show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
46342447Snf202958 		    args.rctlbufsz);
46352447Snf202958 
4636813Sdp 		(void) printf("%s\t           zfs: %s\n", pri->pname, zone_zfs);
4637813Sdp 
4638835Sdp 		(void) printf("%s\textended_error: 0x%x\n", pri->pname,
4639835Sdp 		    (caddr32_t)args.extended_error);
4640813Sdp 
46411676Sjpk 		if (is_system_labeled()) {
46421676Sjpk 			char		*label_str = NULL;
46431676Sjpk 			bslabel_t	zone_label;
46441676Sjpk 
46451676Sjpk 			(void) printf("%s\t         match: %d\n", pri->pname,
46461676Sjpk 			    args.match);
46471676Sjpk 			(void) printf("%s\t           doi: %d\n", pri->pname,
46481676Sjpk 			    args.doi);
46491676Sjpk 
46501676Sjpk 			if (Pread_string(Proc, (char *)&zone_label,
46511676Sjpk 			    sizeof (zone_label), (caddr32_t)args.label) != -1) {
46521676Sjpk 				/* show the label as string */
46531676Sjpk 				if (label_to_str(&zone_label, &label_str,
46541676Sjpk 				    M_LABEL, SHORT_NAMES) != 0) {
46551676Sjpk 					/* have to dump label as raw string */
46561676Sjpk 					(void) label_to_str(&zone_label,
46571676Sjpk 					    &label_str, M_INTERNAL,
46581676Sjpk 					    SHORT_NAMES);
46591676Sjpk 				}
46601676Sjpk 			}
46611676Sjpk 			(void) printf("%s\t         label: %s\n",
46621676Sjpk 			    pri->pname, label_str != NULL ? label_str : "<?>");
46631676Sjpk 			if (label_str)
46641676Sjpk 				free(label_str);
46651676Sjpk 		}
46661676Sjpk 
4667813Sdp 		if (args.zfsbufsz > 0)
4668813Sdp 			free(zone_zfs);
4669813Sdp 	}
4670813Sdp }
4671813Sdp 
4672813Sdp #endif
4673813Sdp 
4674813Sdp static void
4675813Sdp show_zones(private_t *pri)
4676813Sdp {
4677813Sdp 	switch (pri->sys_args[0]) {
4678813Sdp 	case ZONE_CREATE:
4679813Sdp #ifdef _LP64
4680813Sdp 		if (data_model == PR_MODEL_LP64)
4681813Sdp 			show_zone_create_args(pri, (long)pri->sys_args[1]);
4682813Sdp 		else
4683813Sdp 			show_zone_create_args32(pri, (long)pri->sys_args[1]);
4684813Sdp #else
4685813Sdp 		show_zone_create_args(pri, (long)pri->sys_args[1]);
4686813Sdp #endif
4687813Sdp 		break;
4688813Sdp 	}
4689813Sdp }
4690813Sdp 
46912447Snf202958 static void
46922447Snf202958 show_rctlblk(private_t *pri, long _rctlblk)
46932447Snf202958 {
46942447Snf202958 	rctlblk_t *blk;
46952447Snf202958 	int size = rctlblk_size();
46962447Snf202958 	size_t readsize;
46972447Snf202958 	const char *s;
46982447Snf202958 
46992447Snf202958 	blk = my_malloc(size, "rctlblk decode buffer");
47002447Snf202958 	readsize = Pread(Proc, blk, size, _rctlblk);
47012447Snf202958 	if (readsize != size) {
47022447Snf202958 		(void) printf("%s\t\t<?>", pri->pname);
47032447Snf202958 	} else {
47042447Snf202958 		(void) printf("%s\t\t     Privilege: 0x%x\n",
47052447Snf202958 		    pri->pname,
47062447Snf202958 		    rctlblk_get_privilege(blk));
47072447Snf202958 		(void) printf("%s\t\t         Value: %lld\n",
47082447Snf202958 		    pri->pname,
47092447Snf202958 		    rctlblk_get_value(blk));
47102447Snf202958 		(void) printf("%s\t\tEnforced Value: %lld\n",
47112447Snf202958 		    pri->pname,
47122447Snf202958 		    rctlblk_get_enforced_value(blk));
47132447Snf202958 
47142447Snf202958 		{
47152447Snf202958 			int sig, act;
47162447Snf202958 			act = rctlblk_get_local_action(blk, &sig);
47172447Snf202958 
47182447Snf202958 			s = rctl_local_action(pri, act);
47192447Snf202958 			if (s == NULL) {
47202447Snf202958 				(void) printf("%s\t\t  Local action: 0x%x\n",
47212447Snf202958 				    pri->pname, act);
47222447Snf202958 			} else {
47232447Snf202958 				(void) printf("%s\t\t  Local action: %s\n",
47242447Snf202958 				    pri->pname, s);
47252447Snf202958 			}
47262447Snf202958 
47272447Snf202958 			if (act & RCTL_LOCAL_SIGNAL) {
47282447Snf202958 				(void) printf("%s\t\t                "
47292447Snf202958 				    "For signal %s\n",
47302447Snf202958 				    pri->pname, signame(pri, sig));
47312447Snf202958 			}
47322447Snf202958 		}
47332447Snf202958 
47342447Snf202958 		s = rctl_local_flags(pri, rctlblk_get_local_flags(blk));
47352447Snf202958 		if (s == NULL) {
47362447Snf202958 			(void) printf("%s\t\t   Local flags: 0x%x\n",
47372447Snf202958 			    pri->pname, rctlblk_get_local_flags(blk));
47382447Snf202958 		} else {
47392447Snf202958 			(void) printf("%s\t\t   Local flags: %s\n",
47402447Snf202958 			    pri->pname, s);
47412447Snf202958 		}
47422447Snf202958 
47432447Snf202958 #ifdef _LP64
47442447Snf202958 		(void) printf("%s\t\t Recipient PID: %d\n",
47452447Snf202958 		    pri->pname,
47462447Snf202958 		    rctlblk_get_recipient_pid(blk));
47472447Snf202958 #else
47482447Snf202958 		(void) printf("%s\t\t Recipient PID: %ld\n",
47492447Snf202958 		    pri->pname,
47502447Snf202958 		    rctlblk_get_recipient_pid(blk));
47512447Snf202958 #endif
47522447Snf202958 		(void) printf("%s\t\t   Firing Time: %lld\n",
47532447Snf202958 		    pri->pname,
47542447Snf202958 		    rctlblk_get_firing_time(blk));
47552447Snf202958 	}
47562447Snf202958 	free(blk);
47572447Snf202958 }
47582447Snf202958 
47592447Snf202958 static void
47602447Snf202958 show_rctls(private_t *pri)
47612447Snf202958 {
47623684Srd117015 	int entry;
47633684Srd117015 
47642447Snf202958 	switch (pri->sys_args[0]) {
47652447Snf202958 	case 0:	/* getrctl */
47662447Snf202958 	case 1: /* setrctl */
47672447Snf202958 		/*
47682447Snf202958 		 * If these offsets look a little odd, remember that they're
47692447Snf202958 		 * into the _raw_ system call
47702447Snf202958 		 */
47712447Snf202958 		(void) printf("%s\tOld rctlblk: 0x%lx\n", pri->pname,
47722447Snf202958 		    pri->sys_args[2]);
47732447Snf202958 		if (pri->sys_args[2] != NULL) {
47742447Snf202958 			show_rctlblk(pri, pri->sys_args[2]);
47752447Snf202958 		}
47762447Snf202958 		(void) printf("%s\tNew rctlblk: 0x%lx\n", pri->pname,
47772447Snf202958 		    pri->sys_args[3]);
47782447Snf202958 		if (pri->sys_args[3] != NULL) {
47792447Snf202958 			show_rctlblk(pri, pri->sys_args[3]);
47802447Snf202958 		}
47812447Snf202958 		break;
47823684Srd117015 	case 4: /* setprojrctl */
47833684Srd117015 		for (entry = 0; entry < pri->sys_args[4]; entry++) {
47843684Srd117015 			(void) printf("%s\tNew rctlblk[%d]: 0x%lx\n",
47853684Srd117015 			    pri->pname, entry,
47863684Srd117015 			    (long)RCTLBLK_INC(pri->sys_args[3], entry));
47873684Srd117015 			if (RCTLBLK_INC(pri->sys_args[3], entry) != NULL) {
47883684Srd117015 				show_rctlblk(pri,
47893684Srd117015 				    (long)RCTLBLK_INC(pri->sys_args[3], entry));
47903684Srd117015 			}
47913684Srd117015 		}
47922447Snf202958 	}
47932447Snf202958 }
4794813Sdp 
4795*10440SRoger.Faulkner@Sun.COM void
4796*10440SRoger.Faulkner@Sun.COM show_utimesys(private_t *pri)
4797*10440SRoger.Faulkner@Sun.COM {
4798*10440SRoger.Faulkner@Sun.COM 	switch (pri->sys_args[0]) {
4799*10440SRoger.Faulkner@Sun.COM 	case 0:			/* futimens() */
4800*10440SRoger.Faulkner@Sun.COM 		if (pri->sys_nargs > 2)
4801*10440SRoger.Faulkner@Sun.COM 			show_utimens(pri, (long)pri->sys_args[2]);
4802*10440SRoger.Faulkner@Sun.COM 		break;
4803*10440SRoger.Faulkner@Sun.COM 	case 1:			/* utimensat */
4804*10440SRoger.Faulkner@Sun.COM 		if (pri->sys_nargs > 3)
4805*10440SRoger.Faulkner@Sun.COM 			show_utimens(pri, (long)pri->sys_args[3]);
4806*10440SRoger.Faulkner@Sun.COM 		break;
4807*10440SRoger.Faulkner@Sun.COM 	default:		/* unexpected subcode */
4808*10440SRoger.Faulkner@Sun.COM 		break;
4809*10440SRoger.Faulkner@Sun.COM 	}
4810*10440SRoger.Faulkner@Sun.COM }
4811*10440SRoger.Faulkner@Sun.COM 
48120Sstevel@tonic-gate /* expound verbosely upon syscall arguments */
48130Sstevel@tonic-gate /*ARGSUSED*/
48140Sstevel@tonic-gate void
48150Sstevel@tonic-gate expound(private_t *pri, long r0, int raw)
48160Sstevel@tonic-gate {
48170Sstevel@tonic-gate 	const lwpstatus_t *Lsp = pri->lwpstat;
48180Sstevel@tonic-gate 	int lp64 = (data_model == PR_MODEL_LP64);
48190Sstevel@tonic-gate 	int what = Lsp->pr_what;
48200Sstevel@tonic-gate 	int err = pri->Errno;		/* don't display output parameters */
48210Sstevel@tonic-gate 					/* for a failed system call */
48220Sstevel@tonic-gate #ifndef _LP64
48230Sstevel@tonic-gate 	/* We are a 32-bit truss; we can't grok a 64-bit process */
48240Sstevel@tonic-gate 	if (lp64)
48250Sstevel@tonic-gate 		return;
48260Sstevel@tonic-gate #endif
48270Sstevel@tonic-gate 	/* for reporting sleeping system calls */
48280Sstevel@tonic-gate 	if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
48290Sstevel@tonic-gate 		what = Lsp->pr_syscall;
48300Sstevel@tonic-gate 
48310Sstevel@tonic-gate 	switch (what) {
48320Sstevel@tonic-gate 	case SYS_utime:
48330Sstevel@tonic-gate 		show_utime(pri);
48340Sstevel@tonic-gate 		break;
48350Sstevel@tonic-gate 	case SYS_utimes:
4836*10440SRoger.Faulkner@Sun.COM 		show_utimes(pri, (long)pri->sys_args[1]);
48370Sstevel@tonic-gate 		break;
48380Sstevel@tonic-gate 	case SYS_gettimeofday:
48390Sstevel@tonic-gate 		if (!err)
48400Sstevel@tonic-gate 			show_timeofday(pri);
48410Sstevel@tonic-gate 		break;
48420Sstevel@tonic-gate 	case SYS_getitimer:
48430Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
48440Sstevel@tonic-gate 			show_itimerval(pri, (long)pri->sys_args[1],
48457088Sraf 			    " value");
48460Sstevel@tonic-gate 		break;
48470Sstevel@tonic-gate 	case SYS_setitimer:
48480Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
48490Sstevel@tonic-gate 			show_itimerval(pri, (long)pri->sys_args[1],
48507088Sraf 			    " value");
48510Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
48520Sstevel@tonic-gate 			show_itimerval(pri, (long)pri->sys_args[2],
48537088Sraf 			    "ovalue");
48540Sstevel@tonic-gate 		break;
48550Sstevel@tonic-gate 	case SYS_stime:
48560Sstevel@tonic-gate 		show_stime(pri);
48570Sstevel@tonic-gate 		break;
48580Sstevel@tonic-gate 	case SYS_times:
48590Sstevel@tonic-gate 		if (!err)
48600Sstevel@tonic-gate 			show_times(pri);
48610Sstevel@tonic-gate 		break;
48620Sstevel@tonic-gate 	case SYS_utssys:
48630Sstevel@tonic-gate 		if (err)
48640Sstevel@tonic-gate 			break;
48650Sstevel@tonic-gate #ifdef _LP64
48660Sstevel@tonic-gate 		if (lp64)
48670Sstevel@tonic-gate 			show_utssys(pri, r0);
48680Sstevel@tonic-gate 		else
48690Sstevel@tonic-gate 			show_utssys32(pri, r0);
48700Sstevel@tonic-gate #else
48710Sstevel@tonic-gate 		show_utssys(pri, r0);
48720Sstevel@tonic-gate #endif
48730Sstevel@tonic-gate 		break;
48740Sstevel@tonic-gate 	case SYS_ioctl:
48750Sstevel@tonic-gate 		if (pri->sys_nargs >= 3) /* each case must decide for itself */
48760Sstevel@tonic-gate 			show_ioctl(pri, pri->sys_args[1],
48777088Sraf 			    (long)pri->sys_args[2]);
48780Sstevel@tonic-gate 		break;
48790Sstevel@tonic-gate 	case SYS_stat:
48800Sstevel@tonic-gate 	case SYS_fstat:
48810Sstevel@tonic-gate 	case SYS_lstat:
48820Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 2)
48830Sstevel@tonic-gate 			show_stat(pri, (long)pri->sys_args[1]);
48840Sstevel@tonic-gate 		break;
48850Sstevel@tonic-gate 	case SYS_stat64:
48860Sstevel@tonic-gate 	case SYS_fstat64:
48870Sstevel@tonic-gate 	case SYS_lstat64:
48880Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 2)
48890Sstevel@tonic-gate 			show_stat64_32(pri, (long)pri->sys_args[1]);
48900Sstevel@tonic-gate 		break;
48910Sstevel@tonic-gate 	case SYS_fsat:
48920Sstevel@tonic-gate 		/*
4893*10440SRoger.Faulkner@Sun.COM 		 * subcodes for fstatat(), fstatat64(), futimesat().
48940Sstevel@tonic-gate 		 */
48950Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 4) {
48960Sstevel@tonic-gate 			if (pri->sys_args[0] == 3)
48970Sstevel@tonic-gate 				show_statat(pri, (long)pri->sys_args[3]);
48980Sstevel@tonic-gate 			else if (pri->sys_args[0] == 2)
48990Sstevel@tonic-gate 				show_stat64_32(pri, (long)pri->sys_args[3]);
4900*10440SRoger.Faulkner@Sun.COM 			else if (pri->sys_args[0] == 6)
4901*10440SRoger.Faulkner@Sun.COM 				show_utimes(pri, (long)pri->sys_args[3]);
49020Sstevel@tonic-gate 		}
49030Sstevel@tonic-gate 		break;
49040Sstevel@tonic-gate 	case SYS_xstat:
49050Sstevel@tonic-gate 	case SYS_fxstat:
49060Sstevel@tonic-gate 	case SYS_lxstat:
49070Sstevel@tonic-gate 		if (!err && pri->sys_nargs >= 3)
49080Sstevel@tonic-gate 			show_xstat(pri, (int)pri->sys_args[0],
49097088Sraf 			    (long)pri->sys_args[2]);
49100Sstevel@tonic-gate 		break;
49110Sstevel@tonic-gate 	case SYS_statvfs:
49120Sstevel@tonic-gate 	case SYS_fstatvfs:
49130Sstevel@tonic-gate 		if (err)
49140Sstevel@tonic-gate 			break;
49150Sstevel@tonic-gate #ifdef _LP64
49160Sstevel@tonic-gate 		if (!lp64) {
49170Sstevel@tonic-gate 			show_statvfs32(pri);
49180Sstevel@tonic-gate 			break;
49190Sstevel@tonic-gate 		}
49200Sstevel@tonic-gate #endif
49210Sstevel@tonic-gate 		show_statvfs(pri);
49220Sstevel@tonic-gate 		break;
49230Sstevel@tonic-gate 	case SYS_statvfs64:
49240Sstevel@tonic-gate 	case SYS_fstatvfs64:
49250Sstevel@tonic-gate 		if (err)
49260Sstevel@tonic-gate 			break;
49270Sstevel@tonic-gate 		show_statvfs64(pri);
49280Sstevel@tonic-gate 		break;
49290Sstevel@tonic-gate 	case SYS_statfs:
49300Sstevel@tonic-gate 	case SYS_fstatfs:
49310Sstevel@tonic-gate 		if (err)
49320Sstevel@tonic-gate 			break;
49330Sstevel@tonic-gate #ifdef _LP64
49340Sstevel@tonic-gate 		if (lp64)
49350Sstevel@tonic-gate 			show_statfs(pri);
49360Sstevel@tonic-gate 		else
49370Sstevel@tonic-gate 			show_statfs32(pri);
49380Sstevel@tonic-gate #else
49390Sstevel@tonic-gate 		show_statfs(pri);
49400Sstevel@tonic-gate #endif
49410Sstevel@tonic-gate 		break;
49420Sstevel@tonic-gate 	case SYS_fcntl:
49430Sstevel@tonic-gate 		show_fcntl(pri);
49440Sstevel@tonic-gate 		break;
49450Sstevel@tonic-gate 	case SYS_msgsys:
49460Sstevel@tonic-gate 		show_msgsys(pri, r0); /* each case must decide for itself */
49470Sstevel@tonic-gate 		break;
49480Sstevel@tonic-gate 	case SYS_semsys:
49490Sstevel@tonic-gate 		show_semsys(pri);	/* each case must decide for itself */
49500Sstevel@tonic-gate 		break;
49510Sstevel@tonic-gate 	case SYS_shmsys:
49520Sstevel@tonic-gate 		show_shmsys(pri);	/* each case must decide for itself */
49530Sstevel@tonic-gate 		break;
49540Sstevel@tonic-gate 	case SYS_getdents:
49550Sstevel@tonic-gate 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
49560Sstevel@tonic-gate 			break;
49570Sstevel@tonic-gate #ifdef _LP64
49580Sstevel@tonic-gate 		if (!lp64) {
49590Sstevel@tonic-gate 			show_dents32(pri, (long)pri->sys_args[1], r0);
49600Sstevel@tonic-gate 			break;
49610Sstevel@tonic-gate 		}
49620Sstevel@tonic-gate 		/* FALLTHROUGH */
49630Sstevel@tonic-gate #else
49640Sstevel@tonic-gate 		show_dents32(pri, (long)pri->sys_args[1], r0);
49650Sstevel@tonic-gate 		break;
49660Sstevel@tonic-gate #endif
49670Sstevel@tonic-gate 	case SYS_getdents64:
49680Sstevel@tonic-gate 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
49690Sstevel@tonic-gate 			break;
49700Sstevel@tonic-gate 		show_dents64(pri, (long)pri->sys_args[1], r0);
49710Sstevel@tonic-gate 		break;
49720Sstevel@tonic-gate 	case SYS_getmsg:
49730Sstevel@tonic-gate 		show_gp_msg(pri, what);
49740Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
49750Sstevel@tonic-gate 			show_hhex_int(pri, (long)pri->sys_args[3], "flags");
49760Sstevel@tonic-gate 		break;
49770Sstevel@tonic-gate 	case SYS_getpmsg:
49780Sstevel@tonic-gate 		show_gp_msg(pri, what);
49790Sstevel@tonic-gate 		if (pri->sys_nargs > 3)
49800Sstevel@tonic-gate 			show_hhex_int(pri, (long)pri->sys_args[3], "band");
49810Sstevel@tonic-gate 		if (pri->sys_nargs > 4)
49820Sstevel@tonic-gate 			show_hhex_int(pri, (long)pri->sys_args[4], "flags");
49830Sstevel@tonic-gate 		break;
49840Sstevel@tonic-gate 	case SYS_putmsg:
49850Sstevel@tonic-gate 	case SYS_putpmsg:
49860Sstevel@tonic-gate 		show_gp_msg(pri, what);
49870Sstevel@tonic-gate 		break;
49880Sstevel@tonic-gate 	case SYS_poll:
49890Sstevel@tonic-gate 		show_poll(pri);
49900Sstevel@tonic-gate 		break;
49910Sstevel@tonic-gate 	case SYS_pollsys:
49920Sstevel@tonic-gate 		show_pollsys(pri);
49930Sstevel@tonic-gate 		break;
49940Sstevel@tonic-gate 	case SYS_setgroups:
49950Sstevel@tonic-gate 		if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
49960Sstevel@tonic-gate 			show_groups(pri, (long)pri->sys_args[1], r0);
49970Sstevel@tonic-gate 		break;
49980Sstevel@tonic-gate 	case SYS_getgroups:
49990Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
50000Sstevel@tonic-gate 			show_groups(pri, (long)pri->sys_args[1], r0);
50010Sstevel@tonic-gate 		break;
50020Sstevel@tonic-gate 	case SYS_sigprocmask:
50030Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
50040Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[1], " set");
50050Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
50060Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[2], "oset");
50070Sstevel@tonic-gate 		break;
50080Sstevel@tonic-gate 	case SYS_sigsuspend:
50090Sstevel@tonic-gate 	case SYS_sigtimedwait:
50100Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
50110Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[0], "sigmask");
50120Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
50130Sstevel@tonic-gate 			show_siginfo(pri, (long)pri->sys_args[1]);
50140Sstevel@tonic-gate 		if (pri->sys_nargs > 2)
50150Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
50160Sstevel@tonic-gate 		break;
50170Sstevel@tonic-gate 	case SYS_sigaltstack:
50180Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
50190Sstevel@tonic-gate 			show_sigaltstack(pri, (long)pri->sys_args[0],
50207088Sraf 			    "new");
50210Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
50220Sstevel@tonic-gate 			show_sigaltstack(pri, (long)pri->sys_args[1],
50237088Sraf 			    "old");
50240Sstevel@tonic-gate 		break;
50250Sstevel@tonic-gate 	case SYS_sigaction:
50260Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
50270Sstevel@tonic-gate 			show_sigaction(pri, (long)pri->sys_args[1],
50287088Sraf 			    "new", NULL);
50290Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
50300Sstevel@tonic-gate 			show_sigaction(pri, (long)pri->sys_args[2],
50317088Sraf 			    "old", r0);
50320Sstevel@tonic-gate 		break;
50334806Sraf 	case SYS_signotify:
50344806Sraf 		if (pri->sys_nargs > 1)
50354806Sraf 			show_siginfo(pri, (long)pri->sys_args[1]);
50364806Sraf 		break;
50374806Sraf 	case SYS_sigresend:
50384806Sraf 		if (pri->sys_nargs > 1)
50394806Sraf 			show_siginfo(pri, (long)pri->sys_args[1]);
50404806Sraf 		if (pri->sys_nargs > 2)
50414806Sraf 			show_sigset(pri, (long)pri->sys_args[2], "sigmask");
50424806Sraf 		break;
50430Sstevel@tonic-gate 	case SYS_sigpending:
50440Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
50450Sstevel@tonic-gate 			show_sigset(pri, (long)pri->sys_args[1], "sigmask");
50460Sstevel@tonic-gate 		break;
50475891Sraf 	case SYS_waitid:
50480Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
50490Sstevel@tonic-gate 			show_siginfo(pri, (long)pri->sys_args[2]);
50500Sstevel@tonic-gate 		break;
50510Sstevel@tonic-gate 	case SYS_sigsendsys:
50520Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
50530Sstevel@tonic-gate 			show_procset(pri, (long)pri->sys_args[0]);
50540Sstevel@tonic-gate 		break;
50550Sstevel@tonic-gate 	case SYS_priocntlsys:
50560Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
50570Sstevel@tonic-gate 			show_procset(pri, (long)pri->sys_args[1]);
50580Sstevel@tonic-gate 		break;
50590Sstevel@tonic-gate 	case SYS_mincore:
50600Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
50610Sstevel@tonic-gate 			show_bool(pri, (long)pri->sys_args[2],
50627088Sraf 			    (pri->sys_args[1] + pagesize - 1) / pagesize);
50630Sstevel@tonic-gate 		break;
50640Sstevel@tonic-gate 	case SYS_readv:
50650Sstevel@tonic-gate 	case SYS_writev:
50660Sstevel@tonic-gate 		if (pri->sys_nargs > 2) {
50670Sstevel@tonic-gate 			int i = pri->sys_args[0]+1;
50680Sstevel@tonic-gate 			int showbuf = FALSE;
50690Sstevel@tonic-gate 			long nb = (what == SYS_readv)? r0 : 32*1024;
50700Sstevel@tonic-gate 
50710Sstevel@tonic-gate 			if ((what == SYS_readv && !err &&
50720Sstevel@tonic-gate 			    prismember(&readfd, i)) ||
50730Sstevel@tonic-gate 			    (what == SYS_writev &&
50740Sstevel@tonic-gate 			    prismember(&writefd, i)))
50750Sstevel@tonic-gate 				showbuf = TRUE;
50760Sstevel@tonic-gate 			show_iovec(pri, (long)pri->sys_args[1],
50777088Sraf 			    pri->sys_args[2], showbuf, nb);
50780Sstevel@tonic-gate 		}
50790Sstevel@tonic-gate 		break;
50800Sstevel@tonic-gate 	case SYS_getrlimit:
50810Sstevel@tonic-gate 		if (err)
50820Sstevel@tonic-gate 			break;
50830Sstevel@tonic-gate 		/*FALLTHROUGH*/
50840Sstevel@tonic-gate 	case SYS_setrlimit:
50850Sstevel@tonic-gate 		if (pri->sys_nargs <= 1)
50860Sstevel@tonic-gate 			break;
50870Sstevel@tonic-gate #ifdef _LP64
50880Sstevel@tonic-gate 		if (lp64)
50890Sstevel@tonic-gate 			show_rlimit64(pri, (long)pri->sys_args[1]);
50900Sstevel@tonic-gate 		else
50910Sstevel@tonic-gate 			show_rlimit32(pri, (long)pri->sys_args[1]);
50920Sstevel@tonic-gate #else
50930Sstevel@tonic-gate 		show_rlimit32(pri, (long)pri->sys_args[1]);
50940Sstevel@tonic-gate #endif
50950Sstevel@tonic-gate 		break;
50960Sstevel@tonic-gate 	case SYS_getrlimit64:
50970Sstevel@tonic-gate 		if (err)
50980Sstevel@tonic-gate 			break;
50990Sstevel@tonic-gate 		/*FALLTHROUGH*/
51000Sstevel@tonic-gate 	case SYS_setrlimit64:
51010Sstevel@tonic-gate 		if (pri->sys_nargs <= 1)
51020Sstevel@tonic-gate 			break;
51030Sstevel@tonic-gate 		show_rlimit64(pri, (long)pri->sys_args[1]);
51040Sstevel@tonic-gate 		break;
51050Sstevel@tonic-gate 	case SYS_uname:
51060Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 0)
51070Sstevel@tonic-gate 			show_nuname(pri, (long)pri->sys_args[0]);
51080Sstevel@tonic-gate 		break;
51090Sstevel@tonic-gate 	case SYS_adjtime:
51100Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
51110Sstevel@tonic-gate 			show_adjtime(pri, (long)pri->sys_args[0],
51127088Sraf 			    (long)pri->sys_args[1]);
51130Sstevel@tonic-gate 		break;
51140Sstevel@tonic-gate 	case SYS_lwp_info:
51150Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 0)
51160Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
51170Sstevel@tonic-gate 		break;
51180Sstevel@tonic-gate 	case SYS_lwp_wait:
51190Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 1)
51200Sstevel@tonic-gate 			show_int(pri, (long)pri->sys_args[1], "lwpid");
51210Sstevel@tonic-gate 		break;
51220Sstevel@tonic-gate 	case SYS_lwp_mutex_wakeup:
51230Sstevel@tonic-gate 	case SYS_lwp_mutex_lock:
51240Sstevel@tonic-gate 	case SYS_lwp_mutex_unlock:
51250Sstevel@tonic-gate 	case SYS_lwp_mutex_trylock:
51264574Sraf 	case SYS_lwp_mutex_register:
51270Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51280Sstevel@tonic-gate 			show_mutex(pri, (long)pri->sys_args[0]);
51290Sstevel@tonic-gate 		break;
51300Sstevel@tonic-gate 	case SYS_lwp_mutex_timedlock:
51310Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51320Sstevel@tonic-gate 			show_mutex(pri, (long)pri->sys_args[0]);
51330Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
51340Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
51350Sstevel@tonic-gate 		break;
51360Sstevel@tonic-gate 	case SYS_lwp_cond_wait:
51370Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51380Sstevel@tonic-gate 			show_condvar(pri, (long)pri->sys_args[0]);
51390Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
51400Sstevel@tonic-gate 			show_mutex(pri, (long)pri->sys_args[1]);
51410Sstevel@tonic-gate 		if (pri->sys_nargs > 2)
51420Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
51430Sstevel@tonic-gate 		break;
51440Sstevel@tonic-gate 	case SYS_lwp_cond_signal:
51450Sstevel@tonic-gate 	case SYS_lwp_cond_broadcast:
51460Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51470Sstevel@tonic-gate 			show_condvar(pri, (long)pri->sys_args[0]);
51480Sstevel@tonic-gate 		break;
51490Sstevel@tonic-gate 	case SYS_lwp_sema_wait:
51500Sstevel@tonic-gate 	case SYS_lwp_sema_trywait:
51510Sstevel@tonic-gate 	case SYS_lwp_sema_post:
51520Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51530Sstevel@tonic-gate 			show_sema(pri, (long)pri->sys_args[0]);
51540Sstevel@tonic-gate 		break;
51550Sstevel@tonic-gate 	case SYS_lwp_sema_timedwait:
51560Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51570Sstevel@tonic-gate 			show_sema(pri, (long)pri->sys_args[0]);
51580Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
51590Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
51600Sstevel@tonic-gate 		break;
51610Sstevel@tonic-gate 	case SYS_lwp_rwlock_sys:
51620Sstevel@tonic-gate 		if (pri->sys_nargs > 1)
51630Sstevel@tonic-gate 			show_rwlock(pri, (long)pri->sys_args[1]);
51640Sstevel@tonic-gate 		if (pri->sys_nargs > 2 &&
51650Sstevel@tonic-gate 		    (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
51660Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
51670Sstevel@tonic-gate 		break;
51680Sstevel@tonic-gate 	case SYS_lwp_create:
51690Sstevel@tonic-gate 		/* XXX print some values in ucontext ??? */
51700Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
51710Sstevel@tonic-gate 			show_int(pri, (long)pri->sys_args[2], "lwpid");
51720Sstevel@tonic-gate 		break;
51730Sstevel@tonic-gate 	case SYS_kaio:
51740Sstevel@tonic-gate 		if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
51750Sstevel@tonic-gate 			show_timeval(pri, (long)pri->sys_args[1], "timeout");
51760Sstevel@tonic-gate 		break;
51770Sstevel@tonic-gate 	case SYS_nanosleep:
51780Sstevel@tonic-gate 		if (pri->sys_nargs > 0)
51790Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[0], "tmout");
51800Sstevel@tonic-gate 		if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
51810Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "resid");
51820Sstevel@tonic-gate 		break;
51830Sstevel@tonic-gate 	case SYS_privsys:
51840Sstevel@tonic-gate 		switch (pri->sys_args[0]) {
51850Sstevel@tonic-gate 		case PRIVSYS_SETPPRIV:
51860Sstevel@tonic-gate 		case PRIVSYS_GETPPRIV:
51870Sstevel@tonic-gate 			if (!err)
51880Sstevel@tonic-gate 				show_privset(pri, (long)pri->sys_args[3],
51897088Sraf 				    (size_t)pri->sys_args[4], "");
51900Sstevel@tonic-gate 		}
51910Sstevel@tonic-gate 		break;
51920Sstevel@tonic-gate 	case SYS_ucredsys:
51930Sstevel@tonic-gate 		switch (pri->sys_args[0]) {
51940Sstevel@tonic-gate 		case UCREDSYS_UCREDGET:
51950Sstevel@tonic-gate 		case UCREDSYS_GETPEERUCRED:
51960Sstevel@tonic-gate 			if (err == 0)
51970Sstevel@tonic-gate 				show_ucred(pri, (long)pri->sys_args[2]);
51980Sstevel@tonic-gate 			break;
51990Sstevel@tonic-gate 		}
52000Sstevel@tonic-gate 		break;
52010Sstevel@tonic-gate 	case SYS_bind:
52020Sstevel@tonic-gate 	case SYS_connect:
52030Sstevel@tonic-gate 		if (pri->sys_nargs > 2)
52040Sstevel@tonic-gate 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
52057088Sraf 			    0, (long)pri->sys_args[2]);
52060Sstevel@tonic-gate 		break;
52070Sstevel@tonic-gate 	case SYS_sendto:
52080Sstevel@tonic-gate 		if (pri->sys_nargs > 5)
52090Sstevel@tonic-gate 			show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
52107088Sraf 			    pri->sys_args[5]);
52110Sstevel@tonic-gate 		break;
52120Sstevel@tonic-gate 	case SYS_accept:
52130Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
52140Sstevel@tonic-gate 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
52157088Sraf 			    (long)pri->sys_args[2], 0);
52160Sstevel@tonic-gate 		break;
52170Sstevel@tonic-gate 	case SYS_getsockname:
52180Sstevel@tonic-gate 	case SYS_getpeername:
52190Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
52200Sstevel@tonic-gate 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
52217088Sraf 			    (long)pri->sys_args[2], 0);
52220Sstevel@tonic-gate 		break;
52230Sstevel@tonic-gate 	case SYS_cladm:
52240Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 2)
52250Sstevel@tonic-gate 			show_cladm(pri, pri->sys_args[0], pri->sys_args[1],
52260Sstevel@tonic-gate 			    (long)pri->sys_args[2]);
52270Sstevel@tonic-gate 		break;
52280Sstevel@tonic-gate 	case SYS_recvfrom:
52290Sstevel@tonic-gate 		if (!err && pri->sys_nargs > 5)
52300Sstevel@tonic-gate 			show_sockaddr(pri, "from", (long)pri->sys_args[4],
52317088Sraf 			    (long)pri->sys_args[5], 0);
52320Sstevel@tonic-gate 		break;
52330Sstevel@tonic-gate 	case SYS_recvmsg:
52340Sstevel@tonic-gate 		if (err)
52350Sstevel@tonic-gate 			break;
52360Sstevel@tonic-gate 		/* FALLTHROUGH */
52370Sstevel@tonic-gate 	case SYS_sendmsg:
5238328Sja97890 		if (pri->sys_nargs <= 2)
52390Sstevel@tonic-gate 			break;
52400Sstevel@tonic-gate #ifdef _LP64
52410Sstevel@tonic-gate 		if (lp64)
52420Sstevel@tonic-gate 			show_msghdr(pri, pri->sys_args[1]);
52430Sstevel@tonic-gate 		else
52440Sstevel@tonic-gate 			show_msghdr32(pri, pri->sys_args[1]);
52450Sstevel@tonic-gate #else
52460Sstevel@tonic-gate 		show_msghdr(pri, pri->sys_args[1]);
52470Sstevel@tonic-gate #endif
52480Sstevel@tonic-gate 		break;
52490Sstevel@tonic-gate 	case SYS_door:
52500Sstevel@tonic-gate 		show_doors(pri);
52510Sstevel@tonic-gate 		break;
52520Sstevel@tonic-gate 	case SYS_sendfilev:
52530Sstevel@tonic-gate 		if (pri->sys_nargs != 5)
52540Sstevel@tonic-gate 			break;
52550Sstevel@tonic-gate 
52560Sstevel@tonic-gate 		if (pri->sys_args[0] == SENDFILEV) {
52570Sstevel@tonic-gate 			show_sendfilevec(pri, (int)pri->sys_args[1],
52587088Sraf 			    (sendfilevec_t *)pri->sys_args[2],
52597088Sraf 			    (int)pri->sys_args[3]);
52600Sstevel@tonic-gate 		} else if (pri->sys_args[0] == SENDFILEV64) {
52610Sstevel@tonic-gate 			show_sendfilevec64(pri, (int)pri->sys_args[1],
52627088Sraf 			    (sendfilevec64_t *)pri->sys_args[2],
52637088Sraf 			    (int)pri->sys_args[3]);
52640Sstevel@tonic-gate 		}
52650Sstevel@tonic-gate 		break;
52660Sstevel@tonic-gate 	case SYS_memcntl:
52670Sstevel@tonic-gate 		show_memcntl(pri);
52680Sstevel@tonic-gate 		break;
52690Sstevel@tonic-gate 	case SYS_lwp_park:
52704389Ssl108498 		/*
52714389Ssl108498 		 * subcode 0: lwp_park(timespec_t *, id_t)
52724389Ssl108498 		 * subcode 4: lwp_set_park(timespec_t *, id_t)
52734389Ssl108498 		 */
52744389Ssl108498 		if (pri->sys_nargs > 1 &&
52754389Ssl108498 		    (pri->sys_args[0] == 0 || pri->sys_args[0] == 4))
52760Sstevel@tonic-gate 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
52770Sstevel@tonic-gate 		/* subcode 2: lwp_unpark_all(id_t *, int) */
52780Sstevel@tonic-gate 		if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
52790Sstevel@tonic-gate 			show_ids(pri, (long)pri->sys_args[1],
52804389Ssl108498 			    (int)pri->sys_args[2]);
52810Sstevel@tonic-gate 		break;
52820Sstevel@tonic-gate 	case SYS_ntp_gettime:
52830Sstevel@tonic-gate 		if (!err)
52840Sstevel@tonic-gate 			show_ntp_gettime(pri);
52850Sstevel@tonic-gate 		break;
52860Sstevel@tonic-gate 	case SYS_ntp_adjtime:
52870Sstevel@tonic-gate 		if (!err)
52880Sstevel@tonic-gate 			show_ntp_adjtime(pri);
52890Sstevel@tonic-gate 		break;
52900Sstevel@tonic-gate 	case SYS_rusagesys:
52910Sstevel@tonic-gate 		if (!err)
52920Sstevel@tonic-gate 			if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
52930Sstevel@tonic-gate #ifdef _LP64
52940Sstevel@tonic-gate 				if (!lp64)
52957088Sraf 					show_getrusage32(pri->sys_args[1]);
52960Sstevel@tonic-gate 				else
52970Sstevel@tonic-gate #endif
52987088Sraf 					show_getrusage(pri->sys_args[1]);
52990Sstevel@tonic-gate 			}
53000Sstevel@tonic-gate 		break;
53010Sstevel@tonic-gate 	case SYS_port:
53020Sstevel@tonic-gate 		show_ports(pri);
53030Sstevel@tonic-gate 		break;
5304813Sdp 	case SYS_zone:
5305813Sdp 		show_zones(pri);
5306813Sdp 		break;
53072447Snf202958 	case SYS_rctlsys:
53082447Snf202958 		show_rctls(pri);
53092447Snf202958 		break;
5310*10440SRoger.Faulkner@Sun.COM 	case SYS_utimesys:
5311*10440SRoger.Faulkner@Sun.COM 		show_utimesys(pri);
5312*10440SRoger.Faulkner@Sun.COM 		break;
53130Sstevel@tonic-gate 	}
53140Sstevel@tonic-gate }
5315