xref: /titanic_41/usr/src/cmd/truss/expound.c (revision 02e56f3f1bfc8d9977bafb8cb5202f576dcded27)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #define	_SYSCALL32
34 
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <ctype.h>
39 #include <sys/types.h>
40 #include <sys/mman.h>
41 #include <libproc.h>
42 #include <string.h>
43 #include <limits.h>
44 #include <sys/statfs.h>
45 #include <sys/times.h>
46 #include <sys/timex.h>
47 #include <sys/utssys.h>
48 #include <sys/utsname.h>
49 #include <sys/ipc.h>
50 #include <sys/ipc_impl.h>
51 #include <sys/msg.h>
52 #include <sys/msg_impl.h>
53 #include <sys/sem.h>
54 #include <sys/sem_impl.h>
55 #include <sys/shm.h>
56 #include <sys/shm_impl.h>
57 #include <sys/dirent.h>
58 #include <sys/utime.h>
59 #include <ustat.h>
60 #include <fcntl.h>
61 #include <time.h>
62 #include <sys/termios.h>
63 #include <sys/termiox.h>
64 #include <sys/termio.h>
65 #include <sys/ttold.h>
66 #include <sys/jioctl.h>
67 #include <sys/filio.h>
68 #include <stropts.h>
69 #include <poll.h>
70 #include <sys/uio.h>
71 #include <sys/resource.h>
72 #include <sys/statvfs.h>
73 #include <sys/time.h>
74 #include <sys/aio.h>
75 #include <sys/socket.h>
76 #include <netinet/in.h>
77 #include <sys/un.h>
78 #include <sys/byteorder.h>
79 #include <arpa/inet.h>
80 #include <sys/audioio.h>
81 #include <sys/cladm.h>
82 #include <sys/synch.h>
83 #include <sys/synch32.h>
84 #include <sys/sysmacros.h>
85 #include <sys/sendfile.h>
86 #include <priv.h>
87 #include <ucred.h>
88 #include <sys/ucred.h>
89 #include <sys/port_impl.h>
90 
91 #include "ramdata.h"
92 #include "systable.h"
93 #include "proto.h"
94 
95 void	show_sigset(private_t *, long, const char *);
96 void	show_ioctl(private_t *, int, long);
97 
98 void
99 prtime(private_t *pri, const char *name, time_t value)
100 {
101 	char str[80];
102 
103 	(void) strftime(str, sizeof (str), "%b %e %H:%M:%S %Z %Y",
104 		localtime(&value));
105 	(void) printf("%s\t%s%s  [ %llu ]\n",
106 	    pri->pname,
107 	    name,
108 	    str,
109 	    (longlong_t)value);
110 }
111 
112 void
113 prtimestruc(private_t *pri, const char *name, timestruc_t *value)
114 {
115 	prtime(pri, name, value->tv_sec);
116 }
117 
118 void
119 show_utime(private_t *pri)
120 {
121 	long offset;
122 	struct utimbuf utimbuf;
123 
124 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL)
125 		return;
126 
127 	if (data_model == PR_MODEL_NATIVE) {
128 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
129 		    != sizeof (utimbuf))
130 			return;
131 	} else {
132 		struct utimbuf32 utimbuf32;
133 
134 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
135 		    != sizeof (utimbuf32))
136 			return;
137 
138 		utimbuf.actime = (time_t)utimbuf32.actime;
139 		utimbuf.modtime = (time_t)utimbuf32.modtime;
140 	}
141 
142 	/* print access and modification times */
143 	prtime(pri, "atime: ", utimbuf.actime);
144 	prtime(pri, "mtime: ", utimbuf.modtime);
145 }
146 
147 void
148 show_utimes(private_t *pri)
149 {
150 	long offset;
151 	struct {
152 		struct timeval	atime;
153 		struct timeval	mtime;
154 	} utimbuf;
155 
156 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[1]) == NULL)
157 		return;
158 
159 	if (data_model == PR_MODEL_NATIVE) {
160 		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
161 		    != sizeof (utimbuf))
162 			return;
163 	} else {
164 		struct {
165 			struct timeval32 atime;
166 			struct timeval32 mtime;
167 		} utimbuf32;
168 
169 		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
170 		    != sizeof (utimbuf32))
171 			return;
172 
173 		TIMEVAL32_TO_TIMEVAL(&utimbuf.atime, &utimbuf32.atime);
174 		TIMEVAL32_TO_TIMEVAL(&utimbuf.mtime, &utimbuf32.mtime);
175 	}
176 
177 	/* print access and modification times */
178 	prtime(pri, "atime: ", utimbuf.atime.tv_sec);
179 	prtime(pri, "mtime: ", utimbuf.mtime.tv_sec);
180 }
181 
182 void
183 show_timeofday(private_t *pri)
184 {
185 	struct timeval tod;
186 	long offset;
187 
188 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
189 		return;
190 
191 	if (data_model == PR_MODEL_NATIVE) {
192 		if (Pread(Proc, &tod, sizeof (tod), offset)
193 		    != sizeof (tod))
194 			return;
195 	} else {
196 		struct timeval32 tod32;
197 
198 		if (Pread(Proc, &tod32, sizeof (tod32), offset)
199 		    != sizeof (tod32))
200 			return;
201 
202 		TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
203 	}
204 
205 	prtime(pri, "time: ", tod.tv_sec);
206 }
207 
208 void
209 show_itimerval(private_t *pri, long offset, const char *name)
210 {
211 	struct itimerval itimerval;
212 
213 	if (offset == NULL)
214 		return;
215 
216 	if (data_model == PR_MODEL_NATIVE) {
217 		if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
218 		    != sizeof (itimerval))
219 			return;
220 	} else {
221 		struct itimerval32 itimerval32;
222 
223 		if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
224 		    != sizeof (itimerval32))
225 			return;
226 
227 		ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
228 	}
229 
230 	(void) printf(
231 	    "%s\t%s:  interval: %4ld.%6.6ld sec  value: %4ld.%6.6ld sec\n",
232 	    pri->pname,
233 	    name,
234 	    itimerval.it_interval.tv_sec,
235 	    itimerval.it_interval.tv_usec,
236 	    itimerval.it_value.tv_sec,
237 	    itimerval.it_value.tv_usec);
238 }
239 
240 void
241 show_timeval(private_t *pri, long offset, const char *name)
242 {
243 	struct timeval timeval;
244 
245 	if (offset == NULL)
246 		return;
247 
248 	if (data_model == PR_MODEL_NATIVE) {
249 		if (Pread(Proc, &timeval, sizeof (timeval), offset)
250 		    != sizeof (timeval))
251 			return;
252 	} else {
253 		struct timeval32 timeval32;
254 
255 		if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
256 		    != sizeof (timeval32))
257 			return;
258 
259 		TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
260 	}
261 
262 	(void) printf(
263 	    "%s\t%s: %ld.%6.6ld sec\n",
264 	    pri->pname,
265 	    name,
266 	    timeval.tv_sec,
267 	    timeval.tv_usec);
268 }
269 
270 void
271 show_timestruc(private_t *pri, long offset, const char *name)
272 {
273 	timestruc_t timestruc;
274 
275 	if (offset == NULL)
276 		return;
277 
278 	if (data_model == PR_MODEL_NATIVE) {
279 		if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
280 		    != sizeof (timestruc))
281 			return;
282 	} else {
283 		timestruc32_t timestruc32;
284 
285 		if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
286 		    != sizeof (timestruc32))
287 			return;
288 
289 		TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
290 	}
291 
292 	(void) printf(
293 	    "%s\t%s: %ld.%9.9ld sec\n",
294 	    pri->pname,
295 	    name,
296 	    timestruc.tv_sec,
297 	    timestruc.tv_nsec);
298 }
299 
300 void
301 show_stime(private_t *pri)
302 {
303 	if (pri->sys_nargs >= 1) {
304 		/* print new system time */
305 		prtime(pri, "systime = ", (time_t)pri->sys_args[0]);
306 	}
307 }
308 
309 void
310 show_times(private_t *pri)
311 {
312 	long hz = sysconf(_SC_CLK_TCK);
313 	long offset;
314 	struct tms tms;
315 
316 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
317 		return;
318 
319 	if (data_model == PR_MODEL_NATIVE) {
320 		if (Pread(Proc, &tms, sizeof (tms), offset)
321 		    != sizeof (tms))
322 			return;
323 	} else {
324 		struct tms32 tms32;
325 
326 		if (Pread(Proc, &tms32, sizeof (tms32), offset)
327 		    != sizeof (tms32))
328 			return;
329 
330 		/*
331 		 * This looks a bit odd (since the values are actually
332 		 * signed), but we need to suppress sign extension to
333 		 * preserve compatibility (we've always printed these
334 		 * numbers as unsigned quantities).
335 		 */
336 		tms.tms_utime = (unsigned)tms32.tms_utime;
337 		tms.tms_stime = (unsigned)tms32.tms_stime;
338 		tms.tms_cutime = (unsigned)tms32.tms_cutime;
339 		tms.tms_cstime = (unsigned)tms32.tms_cstime;
340 	}
341 
342 	(void) printf(
343 	    "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
344 	    pri->pname,
345 	    tms.tms_utime,
346 	    tms.tms_stime,
347 	    tms.tms_cutime,
348 	    tms.tms_cstime,
349 	    hz);
350 }
351 
352 void
353 show_uname(private_t *pri, long offset)
354 {
355 	/*
356 	 * Old utsname buffer (no longer accessible in <sys/utsname.h>).
357 	 */
358 	struct {
359 		char	sysname[9];
360 		char	nodename[9];
361 		char	release[9];
362 		char	version[9];
363 		char	machine[9];
364 	} ubuf;
365 
366 	if (offset != NULL &&
367 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
368 		(void) printf(
369 		"%s\tsys=%-9.9snod=%-9.9srel=%-9.9sver=%-9.9smch=%.9s\n",
370 			pri->pname,
371 			ubuf.sysname,
372 			ubuf.nodename,
373 			ubuf.release,
374 			ubuf.version,
375 			ubuf.machine);
376 	}
377 }
378 
379 /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
380 void
381 show_ustat(private_t *pri, long offset)
382 {
383 	struct ustat ubuf;
384 
385 	if (offset != NULL &&
386 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
387 		(void) printf(
388 		"%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
389 			pri->pname,
390 			ubuf.f_tfree,
391 			ubuf.f_tinode,
392 			ubuf.f_fname,
393 			ubuf.f_fpack);
394 	}
395 }
396 
397 #ifdef _LP64
398 void
399 show_ustat32(private_t *pri, long offset)
400 {
401 	struct ustat32 ubuf;
402 
403 	if (offset != NULL &&
404 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
405 		(void) printf(
406 		"%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
407 			pri->pname,
408 			ubuf.f_tfree,
409 			ubuf.f_tinode,
410 			ubuf.f_fname,
411 			ubuf.f_fpack);
412 	}
413 }
414 #endif	/* _LP64 */
415 
416 void
417 show_fusers(private_t *pri, long offset, long nproc)
418 {
419 	f_user_t fubuf;
420 	int serial = (nproc > 4);
421 
422 	if (offset == NULL)
423 		return;
424 
425 	/* enter region of lengthy output */
426 	if (serial)
427 		Eserialize();
428 
429 	while (nproc > 0 &&
430 	    Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
431 		(void) printf("%s\tpid=%-5d uid=%-5d flags=%s\n",
432 		    pri->pname,
433 		    (int)fubuf.fu_pid,
434 		    (int)fubuf.fu_uid,
435 		    fuflags(pri, fubuf.fu_flags));
436 		nproc--;
437 		offset += sizeof (fubuf);
438 	}
439 
440 	/* exit region of lengthy output */
441 	if (serial)
442 		Xserialize();
443 }
444 
445 void
446 show_utssys(private_t *pri, long r0)
447 {
448 	if (pri->sys_nargs >= 3) {
449 		switch (pri->sys_args[2]) {
450 		case UTS_UNAME:
451 			show_uname(pri, (long)pri->sys_args[0]);
452 			break;
453 		case UTS_USTAT:
454 			show_ustat(pri, (long)pri->sys_args[0]);
455 			break;
456 		case UTS_FUSERS:
457 			show_fusers(pri, (long)pri->sys_args[3], r0);
458 			break;
459 		}
460 	}
461 }
462 
463 #ifdef _LP64
464 void
465 show_utssys32(private_t *pri, long r0)
466 {
467 	if (pri->sys_nargs >= 3) {
468 		switch (pri->sys_args[2]) {
469 		case UTS_UNAME:
470 			show_uname(pri, (long)pri->sys_args[0]);
471 			break;
472 		case UTS_USTAT:
473 			show_ustat32(pri, (long)pri->sys_args[0]);
474 			break;
475 		case UTS_FUSERS:
476 			show_fusers(pri, (long)pri->sys_args[3], r0);
477 			break;
478 		}
479 	}
480 }
481 #endif	/* _LP64 */
482 
483 void
484 show_cladm(private_t *pri, int code, int function, long offset)
485 {
486 	int	arg;
487 
488 	switch (code) {
489 	case CL_INITIALIZE:
490 		switch (function) {
491 		case CL_GET_BOOTFLAG:
492 			if (Pread(Proc, &arg, sizeof (arg), offset)
493 			    == sizeof (arg)) {
494 				if (arg & CLUSTER_CONFIGURED)
495 					(void) printf("%s\tbootflags="
496 					    "CLUSTER_CONFIGURED", pri->pname);
497 				if (arg & CLUSTER_BOOTED)
498 					(void) printf("|CLUSTER_BOOTED\n");
499 			}
500 			break;
501 		}
502 		break;
503 	case CL_CONFIG:
504 		switch (function) {
505 		case CL_NODEID:
506 		case CL_HIGHEST_NODEID:
507 			if (Pread(Proc, &arg, sizeof (arg), offset)
508 			    == sizeof (arg))
509 				(void) printf("%s\tnodeid=%d\n",
510 					pri->pname, arg);
511 		}
512 		break;
513 	}
514 }
515 
516 #define	ALL_LOCK_TYPES	\
517 	(USYNC_PROCESS|LOCK_ERRORCHECK|LOCK_RECURSIVE|USYNC_PROCESS_ROBUST|\
518 	    LOCK_PRIO_INHERIT|LOCK_PRIO_PROTECT|LOCK_ROBUST_NP)
519 
520 /* return cv and mutex types */
521 const char *
522 synch_type(private_t *pri, uint_t type)
523 {
524 	char *str = pri->code_buf;
525 
526 	if (type & USYNC_PROCESS)
527 		(void) strcpy(str, "USYNC_PROCESS");
528 	else
529 		(void) strcpy(str, "USYNC_THREAD");
530 
531 	if (type & LOCK_ERRORCHECK)
532 		(void) strcat(str, "|LOCK_ERRORCHECK");
533 	if (type & LOCK_RECURSIVE)
534 		(void) strcat(str, "|LOCK_RECURSIVE");
535 	if (type & USYNC_PROCESS_ROBUST)
536 		(void) strcat(str, "|USYNC_PROCESS_ROBUST");
537 	if (type & LOCK_PRIO_INHERIT)
538 		(void) strcat(str, "|LOCK_PRIO_INHERIT");
539 	if (type & LOCK_PRIO_PROTECT)
540 		(void) strcat(str, "|LOCK_PRIO_PROTECT");
541 	if (type & LOCK_ROBUST_NP)
542 		(void) strcat(str, "|LOCK_ROBUST_NP");
543 
544 	if ((type &= ~ALL_LOCK_TYPES) != 0)
545 		(void) sprintf(str + strlen(str), "|0x%.4X", type);
546 
547 	return ((const char *)str);
548 }
549 
550 void
551 show_mutex(private_t *pri, long offset)
552 {
553 	lwp_mutex_t mutex;
554 
555 	if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
556 		(void) printf("%s\tmutex type: %s\n",
557 			pri->pname,
558 			synch_type(pri, mutex.mutex_type));
559 	}
560 }
561 
562 void
563 show_condvar(private_t *pri, long offset)
564 {
565 	lwp_cond_t condvar;
566 
567 	if (Pread(Proc, &condvar, sizeof (condvar), offset)
568 	    == sizeof (condvar)) {
569 		(void) printf("%s\tcondvar type: %s\n",
570 			pri->pname,
571 			synch_type(pri, condvar.cond_type));
572 	}
573 }
574 
575 void
576 show_sema(private_t *pri, long offset)
577 {
578 	lwp_sema_t sema;
579 
580 	if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
581 		(void) printf("%s\tsema type: %s  count = %u\n",
582 			pri->pname,
583 			synch_type(pri, sema.sema_type),
584 			sema.sema_count);
585 	}
586 }
587 
588 void
589 show_rwlock(private_t *pri, long offset)
590 {
591 	lwp_rwlock_t rwlock;
592 
593 	if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
594 		(void) printf("%s\trwlock type: %s  readers = %d\n",
595 			pri->pname,
596 			synch_type(pri, rwlock.rwlock_type),
597 			rwlock.rwlock_readers);
598 	}
599 }
600 
601 /* represent character as itself ('c') or octal (012) */
602 char *
603 show_char(char *buf, int c)
604 {
605 	const char *fmt;
606 
607 	if (c >= ' ' && c < 0177)
608 		fmt = "'%c'";
609 	else
610 		fmt = "%.3o";
611 
612 	(void) sprintf(buf, fmt, c&0xff);
613 	return (buf);
614 }
615 
616 void
617 show_termio(private_t *pri, long offset)
618 {
619 	struct termio termio;
620 	char cbuf[8];
621 	int i;
622 
623 	if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
624 		(void) printf(
625 		"%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
626 			pri->pname,
627 			termio.c_iflag,
628 			termio.c_oflag,
629 			termio.c_cflag,
630 			termio.c_lflag,
631 			termio.c_line);
632 		(void) printf("%s\t    cc: ", pri->pname);
633 		for (i = 0; i < NCC; i++)
634 			(void) printf(" %s",
635 				show_char(cbuf, (int)termio.c_cc[i]));
636 		(void) fputc('\n', stdout);
637 	}
638 }
639 
640 void
641 show_termios(private_t *pri, long offset)
642 {
643 	struct termios termios;
644 	char cbuf[8];
645 	int i;
646 
647 	if (Pread(Proc, &termios, sizeof (termios), offset)
648 	    == sizeof (termios)) {
649 		(void) printf(
650 		"%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
651 			pri->pname,
652 			termios.c_iflag,
653 			termios.c_oflag,
654 			termios.c_cflag,
655 			termios.c_lflag);
656 		(void) printf("%s\t    cc: ", pri->pname);
657 		for (i = 0; i < NCCS; i++) {
658 			if (i == NCC)	/* show new chars on new line */
659 				(void) printf("\n%s\t\t", pri->pname);
660 			(void) printf(" %s",
661 				show_char(cbuf, (int)termios.c_cc[i]));
662 		}
663 		(void) fputc('\n', stdout);
664 	}
665 }
666 
667 void
668 show_termiox(private_t *pri, long offset)
669 {
670 	struct termiox termiox;
671 	int i;
672 
673 	if (Pread(Proc, &termiox, sizeof (termiox), offset)
674 	    == sizeof (termiox)) {
675 		(void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
676 			pri->pname,
677 			termiox.x_hflag,
678 			termiox.x_cflag,
679 			termiox.x_rflag[0]);
680 		for (i = 1; i < NFF; i++)
681 			(void) printf(",0%.3o", termiox.x_rflag[i]);
682 		(void) printf(" sflag=0%.3o\n",
683 			termiox.x_sflag);
684 	}
685 }
686 
687 void
688 show_sgttyb(private_t *pri, long offset)
689 {
690 	struct sgttyb sgttyb;
691 
692 	if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
693 		char erase[8];
694 		char kill[8];
695 
696 		(void) printf(
697 		"%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
698 			pri->pname,
699 			sgttyb.sg_ispeed&0xff,
700 			sgttyb.sg_ospeed&0xff,
701 			show_char(erase, sgttyb.sg_erase),
702 			show_char(kill, sgttyb.sg_kill),
703 			sgttyb.sg_flags);
704 	}
705 }
706 
707 void
708 show_ltchars(private_t *pri, long offset)
709 {
710 	struct ltchars ltchars;
711 	char *p;
712 	char cbuf[8];
713 	int i;
714 
715 	if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
716 	    == sizeof (ltchars)) {
717 		(void) printf("%s\t    cc: ", pri->pname);
718 		for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
719 			(void) printf(" %s", show_char(cbuf, (int)*p++));
720 		(void) fputc('\n', stdout);
721 	}
722 }
723 
724 void
725 show_tchars(private_t *pri, long offset)
726 {
727 	struct tchars tchars;
728 	char *p;
729 	char cbuf[8];
730 	int i;
731 
732 	if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) {
733 		(void) printf("%s\t    cc: ", pri->pname);
734 		for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++)
735 			(void) printf(" %s", show_char(cbuf, (int)*p++));
736 		(void) fputc('\n', stdout);
737 	}
738 }
739 
740 void
741 show_termcb(private_t *pri, long offset)
742 {
743 	struct termcb termcb;
744 
745 	if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
746 		(void) printf(
747 		"%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
748 			pri->pname,
749 			termcb.st_flgs&0xff,
750 			termcb.st_termt&0xff,
751 			termcb.st_crow&0xff,
752 			termcb.st_ccol&0xff,
753 			termcb.st_vrow&0xff,
754 			termcb.st_lrow&0xff);
755 	}
756 }
757 
758 /* integer value pointed to by ioctl() arg */
759 void
760 show_strint(private_t *pri, int code, long offset)
761 {
762 	int val;
763 
764 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
765 		const char *s = NULL;
766 
767 		switch (code) {		/* interpret these symbolically */
768 		case I_GRDOPT:
769 			s = strrdopt(val);
770 			break;
771 		case I_GETSIG:
772 			s = strevents(pri, val);
773 			break;
774 		case TIOCFLUSH:
775 			s = tiocflush(pri, val);
776 			break;
777 		}
778 
779 		if (s == NULL)
780 			(void) printf("%s\t0x%.8lX: %d\n",
781 				pri->pname, offset, val);
782 		else
783 			(void) printf("%s\t0x%.8lX: %s\n",
784 				pri->pname, offset, s);
785 	}
786 }
787 
788 void
789 show_strioctl(private_t *pri, long offset)
790 {
791 	struct strioctl strioctl;
792 
793 	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
794 	    sizeof (strioctl)) {
795 		(void) printf(
796 			"%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
797 			pri->pname,
798 			ioctlname(pri, strioctl.ic_cmd),
799 			strioctl.ic_timout,
800 			strioctl.ic_len,
801 			(long)strioctl.ic_dp);
802 
803 		if (pri->recur++ == 0)	/* avoid indefinite recursion */
804 			show_ioctl(pri, strioctl.ic_cmd,
805 				(long)strioctl.ic_dp);
806 		--pri->recur;
807 	}
808 }
809 
810 #ifdef _LP64
811 void
812 show_strioctl32(private_t *pri, long offset)
813 {
814 	struct strioctl32 strioctl;
815 
816 	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
817 	    sizeof (strioctl)) {
818 		(void) printf(
819 			"%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
820 			pri->pname,
821 			ioctlname(pri, strioctl.ic_cmd),
822 			strioctl.ic_timout,
823 			strioctl.ic_len,
824 			(long)strioctl.ic_dp);
825 
826 		if (pri->recur++ == 0)	/* avoid indefinite recursion */
827 			show_ioctl(pri, strioctl.ic_cmd,
828 				(long)strioctl.ic_dp);
829 		--pri->recur;
830 	}
831 }
832 #endif	/* _LP64 */
833 
834 void
835 print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
836 {
837 	(void) printf(
838 		"%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
839 		pri->pname,
840 		name,
841 		sp->maxlen,
842 		sp->len,
843 		(long)sp->buf);
844 	/*
845 	 * Should we show the buffer contents?
846 	 * Keyed to the '-r fds' and '-w fds' options?
847 	 */
848 	if (sp->buf == NULL || sp->len <= 0)
849 		(void) fputc('\n', stdout);
850 	else {
851 		int nb = (sp->len > 8)? 8 : sp->len;
852 		char buffer[8];
853 		char obuf[40];
854 
855 		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
856 			(void) strcpy(obuf, ": \"");
857 			showbytes(buffer, nb, obuf+3);
858 			(void) strcat(obuf,
859 				(nb == sp->len)?
860 				    (const char *)"\"" : (const char *)"\"..");
861 			(void) fputs(obuf, stdout);
862 		}
863 		(void) fputc('\n', stdout);
864 		if (dump && sp->len > 8)
865 			showbuffer(pri, (long)sp->buf, (long)sp->len);
866 	}
867 }
868 
869 #ifdef _LP64
870 void
871 print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
872 {
873 	(void) printf(
874 		"%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
875 		pri->pname,
876 		name,
877 		sp->maxlen,
878 		sp->len,
879 		(long)sp->buf);
880 	/*
881 	 * Should we show the buffer contents?
882 	 * Keyed to the '-r fds' and '-w fds' options?
883 	 */
884 	if (sp->buf == NULL || sp->len <= 0)
885 		(void) fputc('\n', stdout);
886 	else {
887 		int nb = (sp->len > 8)? 8 : sp->len;
888 		char buffer[8];
889 		char obuf[40];
890 
891 		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
892 			(void) strcpy(obuf, ": \"");
893 			showbytes(buffer, nb, obuf+3);
894 			(void) strcat(obuf,
895 				(nb == sp->len)?
896 				    (const char *)"\"" : (const char *)"\"..");
897 			(void) fputs(obuf, stdout);
898 		}
899 		(void) fputc('\n', stdout);
900 		if (dump && sp->len > 8)
901 			showbuffer(pri, (long)sp->buf, (long)sp->len);
902 	}
903 }
904 #endif	/* _LP64 */
905 
906 /* strpeek and strfdinsert flags word */
907 const char *
908 strflags(private_t *pri, int flags)
909 {
910 	const char *s;
911 
912 	switch (flags) {
913 	case 0:
914 		s = "0";
915 		break;
916 	case RS_HIPRI:
917 		s = "RS_HIPRI";
918 		break;
919 	default:
920 		(void) sprintf(pri->code_buf, "0x%.4X", flags);
921 		s = pri->code_buf;
922 	}
923 
924 	return (s);
925 }
926 
927 void
928 show_strpeek(private_t *pri, long offset)
929 {
930 	struct strpeek strpeek;
931 
932 	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
933 	    == sizeof (strpeek)) {
934 
935 		print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
936 		print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
937 
938 		(void) printf("%s\tflags=%s\n",
939 			pri->pname,
940 			strflags(pri, strpeek.flags));
941 	}
942 }
943 
944 #ifdef _LP64
945 void
946 show_strpeek32(private_t *pri, long offset)
947 {
948 	struct strpeek32 strpeek;
949 
950 	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
951 	    == sizeof (strpeek)) {
952 
953 		print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
954 		print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
955 
956 		(void) printf("%s\tflags=%s\n",
957 			pri->pname,
958 			strflags(pri, strpeek.flags));
959 	}
960 }
961 #endif	/* _LP64 */
962 
963 void
964 show_strfdinsert(private_t *pri, long offset)
965 {
966 	struct strfdinsert strfdinsert;
967 
968 	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
969 	    sizeof (strfdinsert)) {
970 
971 		print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
972 		print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
973 
974 		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
975 			pri->pname,
976 			strflags(pri, strfdinsert.flags),
977 			strfdinsert.fildes,
978 			strfdinsert.offset);
979 	}
980 }
981 
982 #ifdef _LP64
983 void
984 show_strfdinsert32(private_t *pri, long offset)
985 {
986 	struct strfdinsert32 strfdinsert;
987 
988 	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
989 	    sizeof (strfdinsert)) {
990 
991 		print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
992 		print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
993 
994 		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
995 			pri->pname,
996 			strflags(pri, strfdinsert.flags),
997 			strfdinsert.fildes,
998 			strfdinsert.offset);
999 	}
1000 }
1001 #endif	/* _LP64 */
1002 
1003 void
1004 show_strrecvfd(private_t *pri, long offset)
1005 {
1006 	struct strrecvfd strrecvfd;
1007 
1008 	if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
1009 	    sizeof (strrecvfd)) {
1010 		(void) printf(
1011 			"%s\tfd=%-5d uid=%-5d gid=%d\n",
1012 			pri->pname,
1013 			strrecvfd.fd,
1014 			(int)strrecvfd.uid,
1015 			(int)strrecvfd.gid);
1016 	}
1017 }
1018 
1019 void
1020 show_strlist(private_t *pri, long offset)
1021 {
1022 	struct str_list strlist;
1023 	struct str_mlist list;
1024 	int count;
1025 
1026 	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1027 	    sizeof (strlist)) {
1028 		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
1029 			pri->pname,
1030 			strlist.sl_nmods,
1031 			(long)strlist.sl_modlist);
1032 
1033 		count = strlist.sl_nmods;
1034 		offset = (long)strlist.sl_modlist;
1035 		while (!interrupt && --count >= 0) {
1036 			if (Pread(Proc, &list, sizeof (list), offset) !=
1037 			    sizeof (list))
1038 				break;
1039 			(void) printf("%s\t\t\"%.*s\"\n",
1040 				pri->pname,
1041 				(int)sizeof (list.l_name),
1042 				list.l_name);
1043 			offset += sizeof (struct str_mlist);
1044 		}
1045 	}
1046 }
1047 
1048 #ifdef _LP64
1049 void
1050 show_strlist32(private_t *pri, long offset)
1051 {
1052 	struct str_list32 strlist;
1053 	struct str_mlist list;
1054 	int count;
1055 
1056 	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1057 	    sizeof (strlist)) {
1058 		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
1059 			pri->pname,
1060 			strlist.sl_nmods,
1061 			(long)strlist.sl_modlist);
1062 
1063 		count = strlist.sl_nmods;
1064 		offset = (long)strlist.sl_modlist;
1065 		while (!interrupt && --count >= 0) {
1066 			if (Pread(Proc, &list, sizeof (list), offset) !=
1067 			    sizeof (list))
1068 				break;
1069 			(void) printf("%s\t\t\"%.*s\"\n",
1070 				pri->pname,
1071 				(int)sizeof (list.l_name),
1072 				list.l_name);
1073 			offset += sizeof (struct str_mlist);
1074 		}
1075 	}
1076 }
1077 #endif	/* _LP64 */
1078 
1079 void
1080 show_jwinsize(private_t *pri, long offset)
1081 {
1082 	struct jwinsize jwinsize;
1083 
1084 	if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
1085 	    sizeof (jwinsize)) {
1086 		(void) printf(
1087 			"%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1088 			pri->pname,
1089 			(unsigned)jwinsize.bytesx,
1090 			(unsigned)jwinsize.bytesy,
1091 			(unsigned)jwinsize.bitsx,
1092 			(unsigned)jwinsize.bitsy);
1093 	}
1094 }
1095 
1096 void
1097 show_winsize(private_t *pri, long offset)
1098 {
1099 	struct winsize winsize;
1100 
1101 	if (Pread(Proc, &winsize, sizeof (winsize), offset)
1102 	    == sizeof (winsize)) {
1103 		(void) printf(
1104 			"%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1105 			pri->pname,
1106 			winsize.ws_row,
1107 			winsize.ws_col,
1108 			winsize.ws_xpixel,
1109 			winsize.ws_ypixel);
1110 	}
1111 }
1112 
1113 struct audio_stuff {
1114 	uint_t	bit;
1115 	const char *str;
1116 };
1117 
1118 const struct audio_stuff audio_output_ports[] = {
1119 	{ AUDIO_SPEAKER, "SPEAKER" },
1120 	{ AUDIO_HEADPHONE, "HEADPHONE" },
1121 	{ AUDIO_LINE_OUT, "LINE_OUT" },
1122 	{ AUDIO_SPDIF_OUT, "SPDIF_OUT" },
1123 	{ AUDIO_AUX1_OUT, "AUX1_OUT" },
1124 	{ AUDIO_AUX2_OUT, "AUX2_OUT" },
1125 	{ 0, NULL }
1126 };
1127 
1128 const struct audio_stuff audio_input_ports[] = {
1129 	{ AUDIO_MICROPHONE, "MICROPHONE" },
1130 	{ AUDIO_LINE_IN, "LINE_IN" },
1131 	{ AUDIO_CD, "CD" },
1132 	{ AUDIO_SPDIF_IN, "SPDIF_IN" },
1133 	{ AUDIO_AUX1_IN, "AUX1_IN" },
1134 	{ AUDIO_AUX2_IN, "AUX2_IN" },
1135 	{ AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
1136 	{ AUDIO_SUNVTS, "SUNVTS" },
1137 	{ 0, NULL }
1138 };
1139 
1140 static const struct audio_stuff audio_hw_features[] = {
1141 	{ AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
1142 	{ AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
1143 	{ AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
1144 	{ AUDIO_HWFEATURE_PLAY, "PLAY" },
1145 	{ AUDIO_HWFEATURE_RECORD, "RECORD" },
1146 	{ 0, NULL }
1147 };
1148 
1149 static const struct audio_stuff audio_sw_features[] = {
1150 	{ AUDIO_SWFEATURE_MIXER, "MIXER" },
1151 	{ 0, NULL }
1152 };
1153 
1154 void
1155 show_audio_features(const private_t *pri,
1156 	const struct audio_stuff *audio_porttab, uint_t features,
1157 	const char *name)
1158 {
1159 	(void) printf("%s\t%s=", pri->pname, name);
1160 	if (features == 0) {
1161 		(void) printf("0\n");
1162 		return;
1163 	}
1164 
1165 	for (; audio_porttab->bit != 0; ++audio_porttab) {
1166 		if (features & audio_porttab->bit) {
1167 			(void) printf(audio_porttab->str);
1168 			features &= ~audio_porttab->bit;
1169 			if (features)
1170 				(void) putchar('|');
1171 		}
1172 	}
1173 	if (features)
1174 		(void) printf("0x%x", features);
1175 	(void) putchar('\n');
1176 }
1177 
1178 void
1179 show_audio_ports(private_t *pri, const char *mode,
1180 	const char *field, uint_t ports)
1181 {
1182 	const struct audio_stuff *audio_porttab;
1183 
1184 	(void) printf("%s\t%s\t%s=", pri->pname, mode, field);
1185 	if (ports == 0) {
1186 		(void) printf("0\n");
1187 		return;
1188 	}
1189 	if (*mode == 'p')
1190 		audio_porttab = audio_output_ports;
1191 	else
1192 		audio_porttab = audio_input_ports;
1193 	for (; audio_porttab->bit != 0; ++audio_porttab) {
1194 		if (ports & audio_porttab->bit) {
1195 			(void) printf(audio_porttab->str);
1196 			ports &= ~audio_porttab->bit;
1197 			if (ports)
1198 				(void) putchar('|');
1199 		}
1200 	}
1201 	if (ports)
1202 		(void) printf("0x%x", ports);
1203 	(void) putchar('\n');
1204 }
1205 
1206 void
1207 show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
1208 {
1209 	const char *s;
1210 
1211 	/*
1212 	 * The following values describe the audio data encoding.
1213 	 */
1214 
1215 	(void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1216 		pri->pname, mode,
1217 		au_pr->sample_rate,
1218 		au_pr->channels,
1219 		au_pr->precision);
1220 
1221 	s = NULL;
1222 	switch (au_pr->encoding) {
1223 	case AUDIO_ENCODING_NONE:	s = "NONE";	break;
1224 	case AUDIO_ENCODING_ULAW:	s = "ULAW";	break;
1225 	case AUDIO_ENCODING_ALAW:	s = "ALAW";	break;
1226 	case AUDIO_ENCODING_LINEAR:	s = "LINEAR";	break;
1227 	case AUDIO_ENCODING_DVI:	s = "DVI";	break;
1228 	case AUDIO_ENCODING_LINEAR8:	s = "LINEAR8";	break;
1229 	}
1230 	if (s)
1231 		(void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
1232 	else {
1233 		(void) printf("%s\t%s\tencoding=%u\n",
1234 			pri->pname, mode, au_pr->encoding);
1235 	}
1236 
1237 	/*
1238 	 * The following values control audio device configuration
1239 	 */
1240 
1241 	(void) printf(
1242 	"%s\t%s\tgain=%u buffer_size=%u\n",
1243 		pri->pname, mode,
1244 		au_pr->gain,
1245 		au_pr->buffer_size);
1246 	show_audio_ports(pri, mode, "port", au_pr->port);
1247 	show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
1248 	show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
1249 
1250 	/*
1251 	 * The following values describe driver state
1252 	 */
1253 
1254 	(void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1255 		pri->pname, mode,
1256 		au_pr->samples,
1257 		au_pr->eof,
1258 		au_pr->pause,
1259 		au_pr->error);
1260 	(void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1261 		pri->pname, mode,
1262 		au_pr->waiting,
1263 		au_pr->balance,
1264 		au_pr->minordev);
1265 
1266 	/*
1267 	 * The following values are read-only state flags
1268 	 */
1269 	(void) printf("%s\t%s\topen=%u active=%u\n",
1270 		pri->pname, mode,
1271 		au_pr->open,
1272 		au_pr->active);
1273 }
1274 
1275 void
1276 show_audio_info(private_t *pri, long offset)
1277 {
1278 	struct audio_info au;
1279 
1280 	if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
1281 		show_audio_prinfo(pri, "play", &au.play);
1282 		show_audio_prinfo(pri, "record", &au.record);
1283 		(void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1284 			pri->pname, au.monitor_gain, au.output_muted);
1285 		show_audio_features(pri, audio_hw_features, au.hw_features,
1286 		    "hw_features");
1287 		show_audio_features(pri, audio_sw_features, au.sw_features,
1288 		    "sw_features");
1289 		show_audio_features(pri, audio_sw_features,
1290 		    au.sw_features_enabled, "sw_features_enabled");
1291 	}
1292 }
1293 
1294 void
1295 show_ioctl(private_t *pri, int code, long offset)
1296 {
1297 	int lp64 = (data_model == PR_MODEL_LP64);
1298 	int err = pri->Errno;	/* don't display output parameters */
1299 				/* for a failed system call */
1300 #ifndef _LP64
1301 	if (lp64)
1302 		return;
1303 #endif
1304 	if (offset == NULL)
1305 		return;
1306 
1307 	switch (code) {
1308 	case TCGETA:
1309 		if (err)
1310 			break;
1311 		/*FALLTHROUGH*/
1312 	case TCSETA:
1313 	case TCSETAW:
1314 	case TCSETAF:
1315 		show_termio(pri, offset);
1316 		break;
1317 	case TCGETS:
1318 		if (err)
1319 			break;
1320 		/*FALLTHROUGH*/
1321 	case TCSETS:
1322 	case TCSETSW:
1323 	case TCSETSF:
1324 		show_termios(pri, offset);
1325 		break;
1326 	case TCGETX:
1327 		if (err)
1328 			break;
1329 		/*FALLTHROUGH*/
1330 	case TCSETX:
1331 	case TCSETXW:
1332 	case TCSETXF:
1333 		show_termiox(pri, offset);
1334 		break;
1335 	case TIOCGETP:
1336 		if (err)
1337 			break;
1338 		/*FALLTHROUGH*/
1339 	case TIOCSETN:
1340 	case TIOCSETP:
1341 		show_sgttyb(pri, offset);
1342 		break;
1343 	case TIOCGLTC:
1344 		if (err)
1345 			break;
1346 		/*FALLTHROUGH*/
1347 	case TIOCSLTC:
1348 		show_ltchars(pri, offset);
1349 		break;
1350 	case TIOCGETC:
1351 		if (err)
1352 			break;
1353 		/*FALLTHROUGH*/
1354 	case TIOCSETC:
1355 		show_tchars(pri, offset);
1356 		break;
1357 	case LDGETT:
1358 		if (err)
1359 			break;
1360 		/*FALLTHROUGH*/
1361 	case LDSETT:
1362 		show_termcb(pri, offset);
1363 		break;
1364 	/* streams ioctl()s */
1365 #if 0
1366 		/* these are displayed as strings in the arg list */
1367 		/* by prt_ioa().  don't display them again here */
1368 	case I_PUSH:
1369 	case I_LOOK:
1370 	case I_FIND:
1371 		/* these are displayed as decimal in the arg list */
1372 		/* by prt_ioa().  don't display them again here */
1373 	case I_LINK:
1374 	case I_UNLINK:
1375 	case I_SENDFD:
1376 		/* these are displayed symbolically in the arg list */
1377 		/* by prt_ioa().  don't display them again here */
1378 	case I_SRDOPT:
1379 	case I_SETSIG:
1380 	case I_FLUSH:
1381 		break;
1382 		/* this one just ignores the argument */
1383 	case I_POP:
1384 		break;
1385 #endif
1386 		/* these return something in an int pointed to by arg */
1387 	case I_NREAD:
1388 	case I_GRDOPT:
1389 	case I_GETSIG:
1390 	case TIOCGSID:
1391 	case TIOCGPGRP:
1392 	case TIOCLGET:
1393 	case FIONREAD:
1394 	case FIORDCHK:
1395 		if (err)
1396 			break;
1397 		/*FALLTHROUGH*/
1398 		/* these pass something in an int pointed to by arg */
1399 	case TIOCSPGRP:
1400 	case TIOCFLUSH:
1401 	case TIOCLBIS:
1402 	case TIOCLBIC:
1403 	case TIOCLSET:
1404 		show_strint(pri, code, offset);
1405 		break;
1406 		/* these all point to structures */
1407 	case I_STR:
1408 #ifdef _LP64
1409 		if (lp64)
1410 			show_strioctl(pri, offset);
1411 		else
1412 			show_strioctl32(pri, offset);
1413 #else
1414 		show_strioctl(pri, offset);
1415 #endif
1416 		break;
1417 	case I_PEEK:
1418 #ifdef _LP64
1419 		if (lp64)
1420 			show_strpeek(pri, offset);
1421 		else
1422 			show_strpeek32(pri, offset);
1423 #else
1424 		show_strpeek(pri, offset);
1425 #endif
1426 		break;
1427 	case I_FDINSERT:
1428 #ifdef _LP64
1429 		if (lp64)
1430 			show_strfdinsert(pri, offset);
1431 		else
1432 			show_strfdinsert32(pri, offset);
1433 #else
1434 		show_strfdinsert(pri, offset);
1435 #endif
1436 		break;
1437 	case I_RECVFD:
1438 		if (err)
1439 			break;
1440 		show_strrecvfd(pri, offset);
1441 		break;
1442 	case I_LIST:
1443 		if (err)
1444 			break;
1445 #ifdef _LP64
1446 		if (lp64)
1447 			show_strlist(pri, offset);
1448 		else
1449 			show_strlist32(pri, offset);
1450 #else
1451 		show_strlist(pri, offset);
1452 #endif
1453 		break;
1454 	case JWINSIZE:
1455 		if (err)
1456 			break;
1457 		show_jwinsize(pri, offset);
1458 		break;
1459 	case TIOCGWINSZ:
1460 		if (err)
1461 			break;
1462 		/*FALLTHROUGH*/
1463 	case TIOCSWINSZ:
1464 		show_winsize(pri, offset);
1465 		break;
1466 	case AUDIO_GETINFO:
1467 	case (int)AUDIO_SETINFO:
1468 		show_audio_info(pri, offset);
1469 		break;
1470 
1471 	default:
1472 		if (code & IOC_INOUT) {
1473 			const char *str = ioctldatastruct(code);
1474 
1475 			(void) printf("\t\t%s",
1476 			    (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1477 			    code & IOC_IN ? "write" : "read");
1478 			if (str != NULL) {
1479 				(void) printf(" (struct %s)\n", str);
1480 			} else {
1481 				(void) printf(" %d bytes\n",
1482 				    (code >> 16) & IOCPARM_MASK);
1483 			}
1484 		}
1485 	}
1486 }
1487 
1488 void
1489 show_statvfs(private_t *pri)
1490 {
1491 	long offset;
1492 	struct statvfs statvfs;
1493 	char *cp;
1494 
1495 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1496 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
1497 	    == sizeof (statvfs)) {
1498 		(void) printf(
1499 		"%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1500 			pri->pname,
1501 			statvfs.f_bsize,
1502 			statvfs.f_frsize,
1503 			(u_longlong_t)statvfs.f_blocks,
1504 			(u_longlong_t)statvfs.f_bfree);
1505 		(void) printf(
1506 		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1507 			pri->pname,
1508 			(u_longlong_t)statvfs.f_bavail,
1509 			(u_longlong_t)statvfs.f_files,
1510 			(u_longlong_t)statvfs.f_ffree,
1511 			(u_longlong_t)statvfs.f_favail);
1512 		(void) printf(
1513 		"%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1514 			pri->pname,
1515 			statvfs.f_fsid,
1516 			statvfs.f_basetype,
1517 			(long)statvfs.f_namemax);
1518 		(void) printf(
1519 		"%s\tflag=%s\n",
1520 			pri->pname,
1521 			svfsflags(pri, (ulong_t)statvfs.f_flag));
1522 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1523 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1524 		    *(cp+1) != '\0')
1525 			*cp = ' ';
1526 		(void) printf("%s\tfstr=\"%.*s\"\n",
1527 			pri->pname,
1528 			(int)sizeof (statvfs.f_fstr),
1529 			statvfs.f_fstr);
1530 	}
1531 }
1532 
1533 #ifdef _LP64
1534 void
1535 show_statvfs32(private_t *pri)
1536 {
1537 	long offset;
1538 	struct statvfs32 statvfs;
1539 	char *cp;
1540 
1541 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1542 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
1543 	    == sizeof (statvfs)) {
1544 		(void) printf(
1545 		"%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
1546 			pri->pname,
1547 			statvfs.f_bsize,
1548 			statvfs.f_frsize,
1549 			statvfs.f_blocks,
1550 			statvfs.f_bfree);
1551 		(void) printf(
1552 		"%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
1553 			pri->pname,
1554 			statvfs.f_bavail,
1555 			statvfs.f_files,
1556 			statvfs.f_ffree,
1557 			statvfs.f_favail);
1558 		(void) printf(
1559 		"%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1560 			pri->pname,
1561 			statvfs.f_fsid,
1562 			statvfs.f_basetype,
1563 			(int)statvfs.f_namemax);
1564 		(void) printf(
1565 		"%s\tflag=%s\n",
1566 			pri->pname,
1567 			svfsflags(pri, (ulong_t)statvfs.f_flag));
1568 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1569 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1570 		    *(cp+1) != '\0')
1571 			*cp = ' ';
1572 		(void) printf("%s\tfstr=\"%.*s\"\n",
1573 			pri->pname,
1574 			(int)sizeof (statvfs.f_fstr),
1575 			statvfs.f_fstr);
1576 	}
1577 }
1578 #endif	/* _LP64 */
1579 
1580 void
1581 show_statvfs64(private_t *pri)
1582 {
1583 	long offset;
1584 	struct statvfs64_32 statvfs;
1585 	char *cp;
1586 
1587 	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1588 	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
1589 	    == sizeof (statvfs)) {
1590 		(void) printf(
1591 		"%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
1592 			pri->pname,
1593 			statvfs.f_bsize,
1594 			statvfs.f_frsize,
1595 			(u_longlong_t)statvfs.f_blocks,
1596 			(u_longlong_t)statvfs.f_bfree);
1597 		(void) printf(
1598 		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1599 			pri->pname,
1600 			(u_longlong_t)statvfs.f_bavail,
1601 			(u_longlong_t)statvfs.f_files,
1602 			(u_longlong_t)statvfs.f_ffree,
1603 			(u_longlong_t)statvfs.f_favail);
1604 		(void) printf(
1605 		"%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1606 			pri->pname,
1607 			statvfs.f_fsid,
1608 			statvfs.f_basetype,
1609 			(int)statvfs.f_namemax);
1610 		(void) printf(
1611 		"%s\tflag=%s\n",
1612 			pri->pname,
1613 			svfsflags(pri, (ulong_t)statvfs.f_flag));
1614 		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1615 		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1616 		    *(cp+1) != '\0')
1617 			*cp = ' ';
1618 		(void) printf("%s\tfstr=\"%.*s\"\n",
1619 			pri->pname,
1620 			(int)sizeof (statvfs.f_fstr),
1621 			statvfs.f_fstr);
1622 	}
1623 }
1624 
1625 void
1626 show_statfs(private_t *pri)
1627 {
1628 	long offset;
1629 	struct statfs statfs;
1630 
1631 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
1632 	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1633 		(void) printf(
1634 		"%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1635 			pri->pname,
1636 			statfs.f_fstyp,
1637 			statfs.f_bsize,
1638 			statfs.f_frsize,
1639 			statfs.f_blocks,
1640 			statfs.f_bfree,
1641 			statfs.f_files,
1642 			statfs.f_ffree);
1643 		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
1644 			pri->pname,
1645 			statfs.f_fname,
1646 			statfs.f_fpack);
1647 	}
1648 }
1649 
1650 #ifdef _LP64
1651 void
1652 show_statfs32(private_t *pri)
1653 {
1654 	long offset;
1655 	struct statfs32 statfs;
1656 
1657 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
1658 	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1659 		(void) printf(
1660 		"%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
1661 			pri->pname,
1662 			statfs.f_fstyp,
1663 			statfs.f_bsize,
1664 			statfs.f_frsize,
1665 			statfs.f_blocks,
1666 			statfs.f_bfree,
1667 			statfs.f_files,
1668 			statfs.f_ffree);
1669 		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
1670 			pri->pname,
1671 			statfs.f_fname,
1672 			statfs.f_fpack);
1673 	}
1674 }
1675 #endif	/* _LP64 */
1676 
1677 void
1678 show_flock32(private_t *pri, long offset)
1679 {
1680 	struct flock32 flock;
1681 
1682 	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1683 		const char *str = NULL;
1684 
1685 		(void) printf("%s\ttyp=", pri->pname);
1686 
1687 		switch (flock.l_type) {
1688 		case F_RDLCK:
1689 			str = "F_RDLCK";
1690 			break;
1691 		case F_WRLCK:
1692 			str = "F_WRLCK";
1693 			break;
1694 		case F_UNLCK:
1695 			str = "F_UNLCK";
1696 			break;
1697 		}
1698 		if (str != NULL)
1699 			(void) printf("%s", str);
1700 		else
1701 			(void) printf("%-7d", flock.l_type);
1702 
1703 		str = whencearg(flock.l_whence);
1704 		if (str != NULL)
1705 			(void) printf("  whence=%s", str);
1706 		else
1707 			(void) printf("  whence=%-8u", flock.l_whence);
1708 
1709 		(void) printf(
1710 			" start=%-5d len=%-5d sys=%-2u pid=%d\n",
1711 			flock.l_start,
1712 			flock.l_len,
1713 			flock.l_sysid,
1714 			flock.l_pid);
1715 	}
1716 }
1717 
1718 void
1719 show_flock64(private_t *pri, long offset)
1720 {
1721 	struct flock64 flock;
1722 
1723 	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1724 		const char *str = NULL;
1725 
1726 		(void) printf("%s\ttyp=", pri->pname);
1727 
1728 		switch (flock.l_type) {
1729 		case F_RDLCK:
1730 			str = "F_RDLCK";
1731 			break;
1732 		case F_WRLCK:
1733 			str = "F_WRLCK";
1734 			break;
1735 		case F_UNLCK:
1736 			str = "F_UNLCK";
1737 			break;
1738 		}
1739 		if (str != NULL)
1740 			(void) printf("%s", str);
1741 		else
1742 			(void) printf("%-7d", flock.l_type);
1743 
1744 		str = whencearg(flock.l_whence);
1745 		if (str != NULL)
1746 			(void) printf("  whence=%s", str);
1747 		else
1748 			(void) printf("  whence=%-8u", flock.l_whence);
1749 
1750 		(void) printf(
1751 			" start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1752 			(long long)flock.l_start,
1753 			(long long)flock.l_len,
1754 			flock.l_sysid,
1755 			(int)flock.l_pid);
1756 	}
1757 }
1758 
1759 void
1760 show_share(private_t *pri, long offset)
1761 {
1762 	struct fshare fshare;
1763 
1764 	if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
1765 		const char *str = NULL;
1766 		int manddny = 0;
1767 
1768 		(void) printf("%s\taccess=", pri->pname);
1769 
1770 		switch (fshare.f_access) {
1771 		case F_RDACC:
1772 			str = "F_RDACC";
1773 			break;
1774 		case F_WRACC:
1775 			str = "F_WRACC";
1776 			break;
1777 		case F_RWACC:
1778 			str = "F_RWACC";
1779 			break;
1780 		}
1781 		if (str != NULL)
1782 			(void) printf("%s", str);
1783 		else
1784 			(void) printf("%-7d", fshare.f_access);
1785 
1786 		str = NULL;
1787 		if (fshare.f_deny & F_MANDDNY) {
1788 			fshare.f_deny &= ~F_MANDDNY;
1789 			manddny = 1;
1790 		}
1791 		switch (fshare.f_deny) {
1792 		case F_NODNY:
1793 			str = "F_NODNY";
1794 			break;
1795 		case F_RDDNY:
1796 			str = "F_RDDNY";
1797 			break;
1798 		case F_WRDNY:
1799 			str = "F_WRDNY";
1800 			break;
1801 		case F_RWDNY:
1802 			str = "F_RWDNY";
1803 			break;
1804 		case F_COMPAT:
1805 			str = "F_COMPAT";
1806 			break;
1807 		}
1808 		if (str != NULL) {
1809 			if (manddny)
1810 				(void) printf("  deny=F_MANDDNY|%s", str);
1811 			else
1812 				(void) printf("  deny=%s", str);
1813 		} else {
1814 			(void) printf("  deny=0x%x", manddny?
1815 				fshare.f_deny | F_MANDDNY : fshare.f_deny);
1816 		}
1817 
1818 		(void) printf("  id=%x\n", fshare.f_id);
1819 	}
1820 }
1821 
1822 void
1823 show_ffg(private_t *pri)
1824 {
1825 	(void) putchar('\t');
1826 	(void) putchar('\t');
1827 	prt_ffg(pri, 0, pri->Rval1);
1828 	(void) puts(pri->sys_string);
1829 }
1830 
1831 /* print values in fcntl() pointed-to structure */
1832 void
1833 show_fcntl(private_t *pri)
1834 {
1835 	long offset;
1836 
1837 	if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
1838 		show_ffg(pri);
1839 		return;
1840 	}
1841 
1842 	if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == NULL)
1843 		return;
1844 
1845 	switch (pri->sys_args[1]) {
1846 #ifdef _LP64
1847 	case F_GETLK:
1848 	case F_SETLK:
1849 	case F_SETLKW:
1850 	case F_FREESP:
1851 	case F_ALLOCSP:
1852 	case F_SETLK_NBMAND:
1853 		if (data_model == PR_MODEL_LP64)
1854 			show_flock64(pri, offset);
1855 		else
1856 			show_flock32(pri, offset);
1857 		break;
1858 	case 33:	/* F_GETLK64 */
1859 	case 34:	/* F_SETLK64 */
1860 	case 35:	/* F_SETLKW64 */
1861 	case 27:	/* F_FREESP64 */
1862 	case 44:	/* F_SETLK64_NBMAND */
1863 		show_flock64(pri, offset);
1864 		break;
1865 #else	/* _LP64 */
1866 	case F_GETLK:
1867 	case F_SETLK:
1868 	case F_SETLKW:
1869 	case F_FREESP:
1870 	case F_ALLOCSP:
1871 	case F_SETLK_NBMAND:
1872 		show_flock32(pri, offset);
1873 		break;
1874 	case F_GETLK64:
1875 	case F_SETLK64:
1876 	case F_SETLKW64:
1877 	case F_FREESP64:
1878 	case F_SETLK64_NBMAND:
1879 		show_flock64(pri, offset);
1880 		break;
1881 #endif	/* _LP64 */
1882 	case F_SHARE:
1883 	case F_UNSHARE:
1884 		show_share(pri, offset);
1885 		break;
1886 	}
1887 }
1888 
1889 void
1890 show_strbuf(private_t *pri, long offset, const char *name, int dump)
1891 {
1892 	struct strbuf strbuf;
1893 
1894 	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1895 		print_strbuf(pri, &strbuf, name, dump);
1896 }
1897 
1898 #ifdef _LP64
1899 void
1900 show_strbuf32(private_t *pri, long offset, const char *name, int dump)
1901 {
1902 	struct strbuf32 strbuf;
1903 
1904 	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1905 		print_strbuf32(pri, &strbuf, name, dump);
1906 }
1907 #endif	/* _LP64 */
1908 
1909 void
1910 show_gp_msg(private_t *pri, int what)
1911 {
1912 	long offset;
1913 	int dump = FALSE;
1914 	int fdp1 = pri->sys_args[0] + 1;
1915 
1916 	switch (what) {
1917 	case SYS_getmsg:
1918 	case SYS_getpmsg:
1919 		if (pri->Errno == 0 && prismember(&readfd, fdp1))
1920 			dump = TRUE;
1921 		break;
1922 	case SYS_putmsg:
1923 	case SYS_putpmsg:
1924 		if (prismember(&writefd, fdp1))
1925 			dump = TRUE;
1926 		break;
1927 	}
1928 
1929 	/* enter region of lengthy output */
1930 	if (dump)
1931 		Eserialize();
1932 
1933 #ifdef _LP64
1934 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL) {
1935 		if (data_model == PR_MODEL_LP64)
1936 			show_strbuf(pri, offset, "ctl", dump);
1937 		else
1938 			show_strbuf32(pri, offset, "ctl", dump);
1939 	}
1940 	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL) {
1941 		if (data_model == PR_MODEL_LP64)
1942 			show_strbuf(pri, offset, "dat", dump);
1943 		else
1944 			show_strbuf32(pri, offset, "dat", dump);
1945 	}
1946 #else	/* _LP64 */
1947 	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL)
1948 		show_strbuf(pri, offset, "ctl", dump);
1949 	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL)
1950 		show_strbuf(pri, offset, "dat", dump);
1951 #endif	/* _LP64 */
1952 
1953 	/* exit region of lengthy output */
1954 	if (dump)
1955 		Xserialize();
1956 }
1957 
1958 void
1959 show_int(private_t *pri, long offset, const char *name)
1960 {
1961 	int value;
1962 
1963 	if (offset != 0 &&
1964 	    Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1965 		(void) printf("%s\t%s:\t%d\n",
1966 			pri->pname,
1967 			name,
1968 			value);
1969 }
1970 
1971 void
1972 show_hhex_int(private_t *pri, long offset, const char *name)
1973 {
1974 	int value;
1975 
1976 	if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1977 		(void) printf("%s\t%s:\t0x%.4X\n",
1978 			pri->pname,
1979 			name,
1980 			value);
1981 }
1982 
1983 #define	ALL_POLL_FLAGS	(POLLIN|POLLPRI|POLLOUT| \
1984 	POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
1985 
1986 const char *
1987 pollevent(private_t *pri, int arg)
1988 {
1989 	char *str = pri->code_buf;
1990 
1991 	if (arg == 0)
1992 		return ("0");
1993 	if (arg & ~ALL_POLL_FLAGS) {
1994 		(void) sprintf(str, "0x%-5X", arg);
1995 		return ((const char *)str);
1996 	}
1997 
1998 	*str = '\0';
1999 	if (arg & POLLIN)
2000 		(void) strcat(str, "|POLLIN");
2001 	if (arg & POLLPRI)
2002 		(void) strcat(str, "|POLLPRI");
2003 	if (arg & POLLOUT)
2004 		(void) strcat(str, "|POLLOUT");
2005 	if (arg & POLLRDNORM)
2006 		(void) strcat(str, "|POLLRDNORM");
2007 	if (arg & POLLRDBAND)
2008 		(void) strcat(str, "|POLLRDBAND");
2009 	if (arg & POLLWRBAND)
2010 		(void) strcat(str, "|POLLWRBAND");
2011 	if (arg & POLLERR)
2012 		(void) strcat(str, "|POLLERR");
2013 	if (arg & POLLHUP)
2014 		(void) strcat(str, "|POLLHUP");
2015 	if (arg & POLLNVAL)
2016 		(void) strcat(str, "|POLLNVAL");
2017 
2018 	return ((const char *)(str+1));
2019 }
2020 
2021 static void
2022 show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
2023 {
2024 	/*
2025 	 * can't print both events and revents in same printf.
2026 	 * pollevent() returns a pointer to a TSD location.
2027 	 */
2028 	(void) printf("%s\tfd=%-2d ev=%s",
2029 	    pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
2030 	(void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
2031 }
2032 
2033 static void
2034 show_all_pollfds(private_t *pri, long offset, int nfds)
2035 {
2036 	struct pollfd pollfd[2];
2037 	int skip = -1;
2038 
2039 	for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
2040 		if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
2041 		    sizeof (struct pollfd))
2042 			continue;
2043 
2044 		if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
2045 		    pollfd[0].events == pollfd[1].events &&
2046 		    pollfd[0].revents == pollfd[1].revents) {
2047 			skip++;
2048 			continue;
2049 		}
2050 
2051 		if (skip > 0)
2052 			(void) printf("%s\t...last pollfd structure"
2053 			    " repeated %d time%s...\n",
2054 			    pri->pname, skip, (skip == 1 ? "" : "s"));
2055 
2056 		skip = 0;
2057 		show_one_pollfd(pri, &pollfd[0]);
2058 		pollfd[1] = pollfd[0];
2059 	}
2060 
2061 	if (skip > 0)
2062 		(void) printf(
2063 		    "%s\t...last pollfd structure repeated %d time%s...\n",
2064 		    pri->pname, skip, (skip == 1 ? "" : "s"));
2065 }
2066 
2067 void
2068 show_poll(private_t *pri)
2069 {
2070 	long offset;
2071 	int nfds;
2072 	int serial = 0;
2073 
2074 	if (pri->sys_nargs < 2 || (offset = pri->sys_args[0]) == NULL ||
2075 	    (nfds = pri->sys_args[1]) <= 0)
2076 		return;
2077 
2078 	/* enter region of lengthy output */
2079 	if (nfds > 32) {
2080 		Eserialize();
2081 		serial = 1;
2082 	}
2083 
2084 	show_all_pollfds(pri, offset, nfds);
2085 
2086 	/* exit region of lengthy output */
2087 	if (serial)
2088 		Xserialize();
2089 }
2090 
2091 void
2092 show_pollsys(private_t *pri)
2093 {
2094 	long offset;
2095 	int nfds;
2096 	int serial = 0;
2097 
2098 	if (pri->sys_nargs < 2)
2099 		return;
2100 
2101 	offset = pri->sys_args[0];
2102 	nfds = pri->sys_args[1];
2103 
2104 	/* enter region of lengthy output */
2105 	if (offset != NULL && nfds > 32) {
2106 		Eserialize();
2107 		serial = 1;
2108 	}
2109 
2110 	if (offset != NULL && nfds > 0)
2111 		show_all_pollfds(pri, offset, nfds);
2112 
2113 	if (pri->sys_nargs > 2)
2114 		show_timestruc(pri, (long)pri->sys_args[2], "timeout");
2115 
2116 	if (pri->sys_nargs > 3)
2117 		show_sigset(pri, (long)pri->sys_args[3], "sigmask");
2118 
2119 	/* exit region of lengthy output */
2120 	if (serial)
2121 		Xserialize();
2122 }
2123 
2124 static void
2125 show_perm64(private_t *pri, struct ipc_perm64 *ip)
2126 {
2127 	(void) printf("%s\tu=%-5d g=%-5d cu=%-5d cg=%-5d z=%-5d "
2128 	    "m=0%.6o key=%d projid=%-5d\n",
2129 	    pri->pname,
2130 	    (int)ip->ipcx_uid,
2131 	    (int)ip->ipcx_gid,
2132 	    (int)ip->ipcx_cuid,
2133 	    (int)ip->ipcx_cgid,
2134 	    (int)ip->ipcx_zoneid,
2135 	    (unsigned int)ip->ipcx_mode,
2136 	    ip->ipcx_key,
2137 	    (int)ip->ipcx_projid);
2138 }
2139 
2140 void
2141 show_perm(private_t *pri, struct ipc_perm *ip)
2142 {
2143 	(void) printf(
2144 	"%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2145 		pri->pname,
2146 		(int)ip->uid,
2147 		(int)ip->gid,
2148 		(int)ip->cuid,
2149 		(int)ip->cgid,
2150 		(int)ip->mode,
2151 		ip->seq,
2152 		ip->key);
2153 }
2154 
2155 #ifdef _LP64
2156 void
2157 show_perm32(private_t *pri, struct ipc_perm32 *ip)
2158 {
2159 	(void) printf(
2160 	"%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2161 		pri->pname,
2162 		ip->uid,
2163 		ip->gid,
2164 		ip->cuid,
2165 		ip->cgid,
2166 		ip->mode,
2167 		ip->seq,
2168 		ip->key);
2169 }
2170 #endif	/* _LP64 */
2171 
2172 static void
2173 show_msgctl64(private_t *pri, long offset)
2174 {
2175 	struct msqid_ds64 msgq;
2176 
2177 	if (offset != NULL &&
2178 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2179 		show_perm64(pri, &msgq.msgx_perm);
2180 
2181 		(void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2182 		    "lspid=%-5d lrpid=%-5d\n", pri->pname,
2183 		    (unsigned long long)msgq.msgx_cbytes,
2184 		    (unsigned long long)msgq.msgx_qnum,
2185 		    (unsigned long long)msgq.msgx_qbytes,
2186 		    (int)msgq.msgx_lspid,
2187 		    (int)msgq.msgx_lrpid);
2188 
2189 		prtime(pri, "    st = ", (time_t)msgq.msgx_stime);
2190 		prtime(pri, "    rt = ", (time_t)msgq.msgx_rtime);
2191 		prtime(pri, "    ct = ", (time_t)msgq.msgx_ctime);
2192 	}
2193 }
2194 
2195 void
2196 show_msgctl(private_t *pri, long offset)
2197 {
2198 	struct msqid_ds msgq;
2199 
2200 	if (offset != NULL &&
2201 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2202 		show_perm(pri, &msgq.msg_perm);
2203 
2204 		(void) printf(
2205 	"%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2206 			pri->pname,
2207 			msgq.msg_cbytes,
2208 			msgq.msg_qnum,
2209 			msgq.msg_qbytes,
2210 			(int)msgq.msg_lspid,
2211 			(int)msgq.msg_lrpid);
2212 
2213 		prtime(pri, "    st = ", msgq.msg_stime);
2214 		prtime(pri, "    rt = ", msgq.msg_rtime);
2215 		prtime(pri, "    ct = ", msgq.msg_ctime);
2216 	}
2217 }
2218 
2219 #ifdef _LP64
2220 void
2221 show_msgctl32(private_t *pri, long offset)
2222 {
2223 	struct msqid_ds32 msgq;
2224 
2225 	if (offset != NULL &&
2226 	    Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2227 		show_perm32(pri, &msgq.msg_perm);
2228 
2229 		(void) printf(
2230 	"%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2231 			pri->pname,
2232 			msgq.msg_cbytes,
2233 			msgq.msg_qnum,
2234 			msgq.msg_qbytes,
2235 			msgq.msg_lspid,
2236 			msgq.msg_lrpid);
2237 
2238 		prtime(pri, "    st = ", msgq.msg_stime);
2239 		prtime(pri, "    rt = ", msgq.msg_rtime);
2240 		prtime(pri, "    ct = ", msgq.msg_ctime);
2241 	}
2242 }
2243 #endif	/* _LP64 */
2244 
2245 void
2246 show_msgbuf(private_t *pri, long offset, long msgsz)
2247 {
2248 	struct msgbuf msgb;
2249 
2250 	if (offset != NULL &&
2251 	    Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2252 	    sizeof (msgb.mtype)) {
2253 		/* enter region of lengthy output */
2254 		if (msgsz > MYBUFSIZ / 4)
2255 			Eserialize();
2256 
2257 		(void) printf("%s\tmtype=%lu  mtext[]=\n",
2258 			pri->pname,
2259 			msgb.mtype);
2260 		showbuffer(pri,
2261 			(long)(offset + sizeof (msgb.mtype)), msgsz);
2262 
2263 		/* exit region of lengthy output */
2264 		if (msgsz > MYBUFSIZ / 4)
2265 			Xserialize();
2266 	}
2267 }
2268 
2269 #ifdef _LP64
2270 void
2271 show_msgbuf32(private_t *pri, long offset, long msgsz)
2272 {
2273 	struct ipcmsgbuf32 msgb;
2274 
2275 	if (offset != NULL &&
2276 	    Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2277 	    sizeof (msgb.mtype)) {
2278 		/* enter region of lengthy output */
2279 		if (msgsz > MYBUFSIZ / 4)
2280 			Eserialize();
2281 
2282 		(void) printf("%s\tmtype=%u  mtext[]=\n",
2283 			pri->pname,
2284 			msgb.mtype);
2285 		showbuffer(pri,
2286 			(long)(offset + sizeof (msgb.mtype)), msgsz);
2287 
2288 		/* exit region of lengthy output */
2289 		if (msgsz > MYBUFSIZ / 4)
2290 			Xserialize();
2291 	}
2292 }
2293 #endif	/* _LP64 */
2294 
2295 #ifdef _LP64
2296 void
2297 show_msgsys(private_t *pri, long msgsz)
2298 {
2299 	switch (pri->sys_args[0]) {
2300 	case 0:			/* msgget() */
2301 		break;
2302 	case 1:			/* msgctl() */
2303 		if (pri->sys_nargs > 3) {
2304 			switch (pri->sys_args[2]) {
2305 			case IPC_STAT:
2306 				if (pri->Errno)
2307 					break;
2308 				/*FALLTHROUGH*/
2309 			case IPC_SET:
2310 				if (data_model == PR_MODEL_LP64)
2311 					show_msgctl(pri,
2312 						(long)pri->sys_args[3]);
2313 				else
2314 					show_msgctl32(pri,
2315 						(long)pri->sys_args[3]);
2316 				break;
2317 			case IPC_STAT64:
2318 				if (pri->Errno)
2319 					break;
2320 				/*FALLTHROUGH*/
2321 			case IPC_SET64:
2322 				show_msgctl64(pri, (long)pri->sys_args[3]);
2323 				break;
2324 			}
2325 		}
2326 		break;
2327 	case 2:			/* msgrcv() */
2328 		if (!pri->Errno && pri->sys_nargs > 2) {
2329 			if (data_model == PR_MODEL_LP64)
2330 				show_msgbuf(pri, pri->sys_args[2], msgsz);
2331 			else
2332 				show_msgbuf32(pri, pri->sys_args[2], msgsz);
2333 		}
2334 		break;
2335 	case 3:			/* msgsnd() */
2336 		if (pri->sys_nargs > 3) {
2337 			if (data_model == PR_MODEL_LP64)
2338 				show_msgbuf(pri, pri->sys_args[2],
2339 					pri->sys_args[3]);
2340 			else
2341 				show_msgbuf32(pri, pri->sys_args[2],
2342 					pri->sys_args[3]);
2343 		}
2344 		break;
2345 	case 4:			/* msgids() */
2346 	case 5:			/* msgsnap() */
2347 	default:		/* unexpected subcode */
2348 		break;
2349 	}
2350 }
2351 #else	/* _LP64 */
2352 void
2353 show_msgsys(private_t *pri, long msgsz)
2354 {
2355 	switch (pri->sys_args[0]) {
2356 	case 0:			/* msgget() */
2357 		break;
2358 	case 1:			/* msgctl() */
2359 		if (pri->sys_nargs > 3) {
2360 			switch (pri->sys_args[2]) {
2361 			case IPC_STAT:
2362 				if (pri->Errno)
2363 					break;
2364 				/*FALLTHROUGH*/
2365 			case IPC_SET:
2366 				show_msgctl(pri, (long)pri->sys_args[3]);
2367 				break;
2368 			case IPC_STAT64:
2369 				if (pri->Errno)
2370 					break;
2371 				/*FALLTHROUGH*/
2372 			case IPC_SET64:
2373 				show_msgctl64(pri, (long)pri->sys_args[3]);
2374 				break;
2375 			}
2376 		}
2377 		break;
2378 	case 2:			/* msgrcv() */
2379 		if (!pri->Errno && pri->sys_nargs > 2)
2380 			show_msgbuf(pri, pri->sys_args[2], msgsz);
2381 		break;
2382 	case 3:			/* msgsnd() */
2383 		if (pri->sys_nargs > 3)
2384 			show_msgbuf(pri, pri->sys_args[2],
2385 				pri->sys_args[3]);
2386 		break;
2387 	case 4:			/* msgids() */
2388 	case 5:			/* msgsnap() */
2389 	default:		/* unexpected subcode */
2390 		break;
2391 	}
2392 }
2393 #endif	/* _LP64 */
2394 
2395 static void
2396 show_semctl64(private_t *pri, long offset)
2397 {
2398 	struct semid_ds64 semds;
2399 
2400 	if (offset != NULL &&
2401 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2402 		show_perm64(pri, &semds.semx_perm);
2403 
2404 		(void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
2405 
2406 		prtime(pri, "    ot = ", (time_t)semds.semx_otime);
2407 		prtime(pri, "    ct = ", (time_t)semds.semx_ctime);
2408 	}
2409 }
2410 
2411 void
2412 show_semctl(private_t *pri, long offset)
2413 {
2414 	struct semid_ds semds;
2415 
2416 	if (offset != NULL &&
2417 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2418 		show_perm(pri, &semds.sem_perm);
2419 
2420 		(void) printf("%s\tnsems=%u\n",
2421 			pri->pname,
2422 			semds.sem_nsems);
2423 
2424 		prtime(pri, "    ot = ", semds.sem_otime);
2425 		prtime(pri, "    ct = ", semds.sem_ctime);
2426 	}
2427 }
2428 
2429 #ifdef _LP64
2430 void
2431 show_semctl32(private_t *pri, long offset)
2432 {
2433 	struct semid_ds32 semds;
2434 
2435 	if (offset != NULL &&
2436 	    Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2437 		show_perm32(pri, &semds.sem_perm);
2438 
2439 		(void) printf("%s\tnsems=%u\n",
2440 			pri->pname,
2441 			semds.sem_nsems);
2442 
2443 		prtime(pri, "    ot = ", semds.sem_otime);
2444 		prtime(pri, "    ct = ", semds.sem_ctime);
2445 	}
2446 }
2447 #endif	/* _LP64 */
2448 
2449 void
2450 show_semop(private_t *pri, long offset, long nsops, long timeout)
2451 {
2452 	struct sembuf sembuf;
2453 	const char *str;
2454 
2455 	if (offset == NULL)
2456 		return;
2457 
2458 	if (nsops > 40)		/* let's not be ridiculous */
2459 		nsops = 40;
2460 
2461 	for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
2462 		if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
2463 		    sizeof (sembuf))
2464 			break;
2465 
2466 		(void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2467 			pri->pname,
2468 			sembuf.sem_num,
2469 			sembuf.sem_op);
2470 
2471 		if (sembuf.sem_flg == 0)
2472 			(void) printf("0\n");
2473 		else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
2474 			(void) printf("%s\n", str);
2475 		else
2476 			(void) printf("0%.6o\n", sembuf.sem_flg);
2477 	}
2478 	if (timeout)
2479 		show_timestruc(pri, timeout, "timeout");
2480 }
2481 
2482 void
2483 show_semsys(private_t *pri)
2484 {
2485 	switch (pri->sys_args[0]) {
2486 	case 0:			/* semctl() */
2487 		if (pri->sys_nargs > 4) {
2488 			switch (pri->sys_args[3]) {
2489 			case IPC_STAT:
2490 				if (pri->Errno)
2491 					break;
2492 				/*FALLTHROUGH*/
2493 			case IPC_SET:
2494 #ifdef _LP64
2495 				if (data_model == PR_MODEL_LP64)
2496 					show_semctl(pri,
2497 						(long)pri->sys_args[4]);
2498 				else
2499 					show_semctl32(pri,
2500 						(long)pri->sys_args[4]);
2501 #else
2502 				show_semctl(pri, (long)pri->sys_args[4]);
2503 #endif
2504 				break;
2505 			case IPC_STAT64:
2506 				if (pri->Errno)
2507 					break;
2508 				/*FALLTHROUGH*/
2509 			case IPC_SET64:
2510 				show_semctl64(pri, (long)pri->sys_args[4]);
2511 				break;
2512 			}
2513 		}
2514 		break;
2515 	case 1:			/* semget() */
2516 		break;
2517 	case 2:			/* semop() */
2518 		if (pri->sys_nargs > 3)
2519 			show_semop(pri, (long)pri->sys_args[2],
2520 				pri->sys_args[3], 0);
2521 		break;
2522 	case 3:			/* semids() */
2523 		break;
2524 	case 4:			/* semtimedop() */
2525 		if (pri->sys_nargs > 4)
2526 			show_semop(pri, (long)pri->sys_args[2],
2527 				pri->sys_args[3], pri->sys_args[4]);
2528 		break;
2529 	default:		/* unexpected subcode */
2530 		break;
2531 	}
2532 }
2533 
2534 static void
2535 show_shmctl64(private_t *pri, long offset)
2536 {
2537 	struct shmid_ds64 shmds;
2538 
2539 	if (offset != NULL &&
2540 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2541 		show_perm64(pri, &shmds.shmx_perm);
2542 
2543 		(void) printf(
2544 		    "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2545 		    pri->pname,
2546 		    (unsigned long long)shmds.shmx_segsz,
2547 		    (int)shmds.shmx_lpid,
2548 		    (int)shmds.shmx_cpid,
2549 		    (unsigned long long)shmds.shmx_nattch,
2550 		    (unsigned long long)shmds.shmx_cnattch);
2551 
2552 		prtime(pri, "    at = ", (time_t)shmds.shmx_atime);
2553 		prtime(pri, "    dt = ", (time_t)shmds.shmx_dtime);
2554 		prtime(pri, "    ct = ", (time_t)shmds.shmx_ctime);
2555 	}
2556 }
2557 
2558 void
2559 show_shmctl(private_t *pri, long offset)
2560 {
2561 	struct shmid_ds shmds;
2562 
2563 	if (offset != NULL &&
2564 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2565 		show_perm(pri, &shmds.shm_perm);
2566 
2567 		(void) printf(
2568 		"%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2569 			pri->pname,
2570 			(ulong_t)shmds.shm_segsz,
2571 			(int)shmds.shm_lpid,
2572 			(int)shmds.shm_cpid,
2573 			shmds.shm_nattch,
2574 			shmds.shm_cnattch);
2575 
2576 		prtime(pri, "    at = ", shmds.shm_atime);
2577 		prtime(pri, "    dt = ", shmds.shm_dtime);
2578 		prtime(pri, "    ct = ", shmds.shm_ctime);
2579 	}
2580 }
2581 
2582 #ifdef _LP64
2583 void
2584 show_shmctl32(private_t *pri, long offset)
2585 {
2586 	struct shmid_ds32 shmds;
2587 
2588 	if (offset != NULL &&
2589 	    Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2590 		show_perm32(pri, &shmds.shm_perm);
2591 
2592 		(void) printf(
2593 		"%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2594 			pri->pname,
2595 			shmds.shm_segsz,
2596 			shmds.shm_lpid,
2597 			shmds.shm_cpid,
2598 			shmds.shm_nattch,
2599 			shmds.shm_cnattch);
2600 
2601 		prtime(pri, "    at = ", shmds.shm_atime);
2602 		prtime(pri, "    dt = ", shmds.shm_dtime);
2603 		prtime(pri, "    ct = ", shmds.shm_ctime);
2604 	}
2605 }
2606 #endif	/* _LP64 */
2607 
2608 void
2609 show_shmsys(private_t *pri)
2610 {
2611 	switch (pri->sys_args[0]) {
2612 	case 0:			/* shmat() */
2613 		break;
2614 	case 1:			/* shmctl() */
2615 		if (pri->sys_nargs > 3) {
2616 			switch (pri->sys_args[2]) {
2617 			case IPC_STAT:
2618 				if (pri->Errno)
2619 					break;
2620 				/*FALLTHROUGH*/
2621 			case IPC_SET:
2622 #ifdef _LP64
2623 				if (data_model == PR_MODEL_LP64)
2624 					show_shmctl(pri,
2625 						(long)pri->sys_args[3]);
2626 				else
2627 					show_shmctl32(pri,
2628 						(long)pri->sys_args[3]);
2629 #else
2630 				show_shmctl(pri, (long)pri->sys_args[3]);
2631 #endif
2632 				break;
2633 			case IPC_STAT64:
2634 				if (pri->Errno)
2635 					break;
2636 				/*FALLTHROUGH*/
2637 			case IPC_SET64:
2638 				show_shmctl64(pri, (long)pri->sys_args[3]);
2639 				break;
2640 			}
2641 		}
2642 		break;
2643 	case 2:			/* shmdt() */
2644 	case 3:			/* shmget() */
2645 	case 4:			/* shmids() */
2646 	default:		/* unexpected subcode */
2647 		break;
2648 	}
2649 }
2650 
2651 void
2652 show_groups(private_t *pri, long offset, long count)
2653 {
2654 	int groups[100];
2655 
2656 	if (count > 100)
2657 		count = 100;
2658 
2659 	if (count > 0 && offset != NULL &&
2660 	    Pread(Proc, &groups[0], count*sizeof (int), offset) ==
2661 	    count*sizeof (int)) {
2662 		int n;
2663 
2664 		(void) printf("%s\t", pri->pname);
2665 		for (n = 0; !interrupt && n < count; n++) {
2666 			if (n != 0 && n%10 == 0)
2667 				(void) printf("\n%s\t", pri->pname);
2668 			(void) printf(" %5d", groups[n]);
2669 		}
2670 		(void) fputc('\n', stdout);
2671 	}
2672 }
2673 
2674 /*
2675  * This assumes that a sigset_t is simply an array of ints.
2676  */
2677 char *
2678 sigset_string(private_t *pri, sigset_t *sp)
2679 {
2680 	char *s = pri->code_buf;
2681 	int n = sizeof (*sp) / sizeof (int32_t);
2682 	int32_t *lp = (int32_t *)sp;
2683 
2684 	while (--n >= 0) {
2685 		int32_t val = *lp++;
2686 
2687 		if (val == 0)
2688 			s += sprintf(s, " 0");
2689 		else
2690 			s += sprintf(s, " 0x%.8X", val);
2691 	}
2692 
2693 	return (pri->code_buf);
2694 }
2695 
2696 void
2697 show_sigset(private_t *pri, long offset, const char *name)
2698 {
2699 	sigset_t sigset;
2700 
2701 	if (offset != NULL &&
2702 	    Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
2703 		(void) printf("%s\t%s =%s\n",
2704 			pri->pname, name, sigset_string(pri, &sigset));
2705 	}
2706 }
2707 
2708 #ifdef _LP64
2709 void
2710 show_sigaltstack32(private_t *pri, long offset, const char *name)
2711 {
2712 	struct sigaltstack32 altstack;
2713 
2714 	if (offset != NULL &&
2715 	    Pread(Proc, &altstack, sizeof (altstack), offset) ==
2716 	    sizeof (altstack)) {
2717 		(void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2718 			pri->pname,
2719 			name,
2720 			altstack.ss_sp,
2721 			altstack.ss_size,
2722 			altstack.ss_flags);
2723 	}
2724 }
2725 #endif	/* _LP64 */
2726 
2727 void
2728 show_sigaltstack(private_t *pri, long offset, const char *name)
2729 {
2730 	struct sigaltstack altstack;
2731 
2732 #ifdef _LP64
2733 	if (data_model != PR_MODEL_LP64) {
2734 		show_sigaltstack32(pri, offset, name);
2735 		return;
2736 	}
2737 #endif
2738 	if (offset != NULL &&
2739 	    Pread(Proc, &altstack, sizeof (altstack), offset) ==
2740 	    sizeof (altstack)) {
2741 		(void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2742 			pri->pname,
2743 			name,
2744 			(ulong_t)altstack.ss_sp,
2745 			(ulong_t)altstack.ss_size,
2746 			altstack.ss_flags);
2747 	}
2748 }
2749 
2750 #ifdef _LP64
2751 void
2752 show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
2753 {
2754 	struct sigaction32 sigaction;
2755 
2756 	if (offset != NULL &&
2757 	    Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2758 	    sizeof (sigaction)) {
2759 		/* This is stupid, we shouldn't have to do this */
2760 		if (odisp != NULL)
2761 			sigaction.sa_handler = (caddr32_t)odisp;
2762 		(void) printf(
2763 			"%s    %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2764 			pri->pname,
2765 			name,
2766 			sigaction.sa_handler,
2767 			sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
2768 			sigaction.sa_flags);
2769 	}
2770 }
2771 #endif	/* _LP64 */
2772 
2773 void
2774 show_sigaction(private_t *pri, long offset, const char *name, long odisp)
2775 {
2776 	struct sigaction sigaction;
2777 
2778 #ifdef _LP64
2779 	if (data_model != PR_MODEL_LP64) {
2780 		show_sigaction32(pri, offset, name, odisp);
2781 		return;
2782 	}
2783 #endif
2784 	if (offset != NULL &&
2785 	    Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2786 	    sizeof (sigaction)) {
2787 		/* This is stupid, we shouldn't have to do this */
2788 		if (odisp != NULL)
2789 			sigaction.sa_handler = (void (*)())odisp;
2790 		(void) printf(
2791 			"%s    %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2792 			pri->pname,
2793 			name,
2794 			(long)sigaction.sa_handler,
2795 			sigset_string(pri, &sigaction.sa_mask),
2796 			sigaction.sa_flags);
2797 	}
2798 }
2799 
2800 #ifdef _LP64
2801 void
2802 print_siginfo32(private_t *pri, const siginfo32_t *sip)
2803 {
2804 	const char *code = NULL;
2805 
2806 	(void) printf("%s      siginfo: %s", pri->pname,
2807 		signame(pri, sip->si_signo));
2808 
2809 	if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2810 		(void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
2811 		if (sip->si_code != 0)
2812 			(void) printf(" code=%d", sip->si_code);
2813 		(void) fputc('\n', stdout);
2814 		return;
2815 	}
2816 
2817 	switch (sip->si_signo) {
2818 	default:
2819 		(void) fputc('\n', stdout);
2820 		return;
2821 	case SIGILL:
2822 	case SIGTRAP:
2823 	case SIGFPE:
2824 	case SIGSEGV:
2825 	case SIGBUS:
2826 	case SIGEMT:
2827 	case SIGCLD:
2828 	case SIGPOLL:
2829 	case SIGXFSZ:
2830 		break;
2831 	}
2832 
2833 	switch (sip->si_signo) {
2834 	case SIGILL:
2835 		switch (sip->si_code) {
2836 		case ILL_ILLOPC:	code = "ILL_ILLOPC";	break;
2837 		case ILL_ILLOPN:	code = "ILL_ILLOPN";	break;
2838 		case ILL_ILLADR:	code = "ILL_ILLADR";	break;
2839 		case ILL_ILLTRP:	code = "ILL_ILLTRP";	break;
2840 		case ILL_PRVOPC:	code = "ILL_PRVOPC";	break;
2841 		case ILL_PRVREG:	code = "ILL_PRVREG";	break;
2842 		case ILL_COPROC:	code = "ILL_COPROC";	break;
2843 		case ILL_BADSTK:	code = "ILL_BADSTK";	break;
2844 		}
2845 		break;
2846 	case SIGTRAP:
2847 		switch (sip->si_code) {
2848 		case TRAP_BRKPT:	code = "TRAP_BRKPT";	break;
2849 		case TRAP_TRACE:	code = "TRAP_TRACE";	break;
2850 		case TRAP_RWATCH:	code = "TRAP_RWATCH";	break;
2851 		case TRAP_WWATCH:	code = "TRAP_WWATCH";	break;
2852 		case TRAP_XWATCH:	code = "TRAP_XWATCH";	break;
2853 		case TRAP_DTRACE:	code = "TRAP_DTRACE";	break;
2854 		}
2855 		break;
2856 	case SIGFPE:
2857 		switch (sip->si_code) {
2858 		case FPE_INTDIV:	code = "FPE_INTDIV";	break;
2859 		case FPE_INTOVF:	code = "FPE_INTOVF";	break;
2860 		case FPE_FLTDIV:	code = "FPE_FLTDIV";	break;
2861 		case FPE_FLTOVF:	code = "FPE_FLTOVF";	break;
2862 		case FPE_FLTUND:	code = "FPE_FLTUND";	break;
2863 		case FPE_FLTRES:	code = "FPE_FLTRES";	break;
2864 		case FPE_FLTINV:	code = "FPE_FLTINV";	break;
2865 		case FPE_FLTSUB:	code = "FPE_FLTSUB";	break;
2866 #if defined(FPE_FLTDEN)
2867 		case FPE_FLTDEN:	code = "FPE_FLTDEN";	break;
2868 #endif
2869 		}
2870 		break;
2871 	case SIGSEGV:
2872 		switch (sip->si_code) {
2873 		case SEGV_MAPERR:	code = "SEGV_MAPERR";	break;
2874 		case SEGV_ACCERR:	code = "SEGV_ACCERR";	break;
2875 		}
2876 		break;
2877 	case SIGEMT:
2878 		switch (sip->si_code) {
2879 #ifdef EMT_TAGOVF
2880 		case EMT_TAGOVF:	code = "EMT_TAGOVF";	break;
2881 #endif
2882 		case EMT_CPCOVF:	code = "EMT_CPCOVF";	break;
2883 		}
2884 		break;
2885 	case SIGBUS:
2886 		switch (sip->si_code) {
2887 		case BUS_ADRALN:	code = "BUS_ADRALN";	break;
2888 		case BUS_ADRERR:	code = "BUS_ADRERR";	break;
2889 		case BUS_OBJERR:	code = "BUS_OBJERR";	break;
2890 		}
2891 		break;
2892 	case SIGCLD:
2893 		switch (sip->si_code) {
2894 		case CLD_EXITED:	code = "CLD_EXITED";	break;
2895 		case CLD_KILLED:	code = "CLD_KILLED";	break;
2896 		case CLD_DUMPED:	code = "CLD_DUMPED";	break;
2897 		case CLD_TRAPPED:	code = "CLD_TRAPPED";	break;
2898 		case CLD_STOPPED:	code = "CLD_STOPPED";	break;
2899 		case CLD_CONTINUED:	code = "CLD_CONTINUED";	break;
2900 		}
2901 		break;
2902 	case SIGPOLL:
2903 		switch (sip->si_code) {
2904 		case POLL_IN:		code = "POLL_IN";	break;
2905 		case POLL_OUT:		code = "POLL_OUT";	break;
2906 		case POLL_MSG:		code = "POLL_MSG";	break;
2907 		case POLL_ERR:		code = "POLL_ERR";	break;
2908 		case POLL_PRI:		code = "POLL_PRI";	break;
2909 		case POLL_HUP:		code = "POLL_HUP";	break;
2910 		}
2911 		break;
2912 	}
2913 
2914 	if (code == NULL) {
2915 		(void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2916 		code = (const char *)pri->code_buf;
2917 	}
2918 
2919 	switch (sip->si_signo) {
2920 	case SIGILL:
2921 	case SIGTRAP:
2922 	case SIGFPE:
2923 	case SIGSEGV:
2924 	case SIGBUS:
2925 	case SIGEMT:
2926 		(void) printf(" %s addr=0x%.8X",
2927 			code,
2928 			sip->si_addr);
2929 		break;
2930 	case SIGCLD:
2931 		(void) printf(" %s pid=%d status=0x%.4X",
2932 			code,
2933 			sip->si_pid,
2934 			sip->si_status);
2935 		break;
2936 	case SIGPOLL:
2937 	case SIGXFSZ:
2938 		(void) printf(" %s fd=%d band=%d",
2939 			code,
2940 			sip->si_fd,
2941 			sip->si_band);
2942 		break;
2943 	}
2944 
2945 	if (sip->si_errno != 0) {
2946 		const char *ename = errname(sip->si_errno);
2947 
2948 		(void) printf(" errno=%d", sip->si_errno);
2949 		if (ename != NULL)
2950 			(void) printf("(%s)", ename);
2951 	}
2952 
2953 	(void) fputc('\n', stdout);
2954 }
2955 #endif	/* _LP64 */
2956 
2957 void
2958 print_siginfo(private_t *pri, const siginfo_t *sip)
2959 {
2960 	const char *code = NULL;
2961 
2962 	(void) printf("%s      siginfo: %s", pri->pname,
2963 		signame(pri, sip->si_signo));
2964 
2965 	if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2966 		(void) printf(" pid=%d uid=%d",
2967 		    (int)sip->si_pid,
2968 		    (int)sip->si_uid);
2969 		if (sip->si_code != 0)
2970 			(void) printf(" code=%d", sip->si_code);
2971 		(void) fputc('\n', stdout);
2972 		return;
2973 	}
2974 
2975 	switch (sip->si_signo) {
2976 	default:
2977 		(void) fputc('\n', stdout);
2978 		return;
2979 	case SIGILL:
2980 	case SIGTRAP:
2981 	case SIGFPE:
2982 	case SIGSEGV:
2983 	case SIGBUS:
2984 	case SIGEMT:
2985 	case SIGCLD:
2986 	case SIGPOLL:
2987 	case SIGXFSZ:
2988 		break;
2989 	}
2990 
2991 	switch (sip->si_signo) {
2992 	case SIGILL:
2993 		switch (sip->si_code) {
2994 		case ILL_ILLOPC:	code = "ILL_ILLOPC";	break;
2995 		case ILL_ILLOPN:	code = "ILL_ILLOPN";	break;
2996 		case ILL_ILLADR:	code = "ILL_ILLADR";	break;
2997 		case ILL_ILLTRP:	code = "ILL_ILLTRP";	break;
2998 		case ILL_PRVOPC:	code = "ILL_PRVOPC";	break;
2999 		case ILL_PRVREG:	code = "ILL_PRVREG";	break;
3000 		case ILL_COPROC:	code = "ILL_COPROC";	break;
3001 		case ILL_BADSTK:	code = "ILL_BADSTK";	break;
3002 		}
3003 		break;
3004 	case SIGTRAP:
3005 		switch (sip->si_code) {
3006 		case TRAP_BRKPT:	code = "TRAP_BRKPT";	break;
3007 		case TRAP_TRACE:	code = "TRAP_TRACE";	break;
3008 		case TRAP_RWATCH:	code = "TRAP_RWATCH";	break;
3009 		case TRAP_WWATCH:	code = "TRAP_WWATCH";	break;
3010 		case TRAP_XWATCH:	code = "TRAP_XWATCH";	break;
3011 		case TRAP_DTRACE:	code = "TRAP_DTRACE";	break;
3012 		}
3013 		break;
3014 	case SIGFPE:
3015 		switch (sip->si_code) {
3016 		case FPE_INTDIV:	code = "FPE_INTDIV";	break;
3017 		case FPE_INTOVF:	code = "FPE_INTOVF";	break;
3018 		case FPE_FLTDIV:	code = "FPE_FLTDIV";	break;
3019 		case FPE_FLTOVF:	code = "FPE_FLTOVF";	break;
3020 		case FPE_FLTUND:	code = "FPE_FLTUND";	break;
3021 		case FPE_FLTRES:	code = "FPE_FLTRES";	break;
3022 		case FPE_FLTINV:	code = "FPE_FLTINV";	break;
3023 		case FPE_FLTSUB:	code = "FPE_FLTSUB";	break;
3024 #if defined(FPE_FLTDEN)
3025 		case FPE_FLTDEN:	code = "FPE_FLTDEN";	break;
3026 #endif
3027 		}
3028 		break;
3029 	case SIGSEGV:
3030 		switch (sip->si_code) {
3031 		case SEGV_MAPERR:	code = "SEGV_MAPERR";	break;
3032 		case SEGV_ACCERR:	code = "SEGV_ACCERR";	break;
3033 		}
3034 		break;
3035 	case SIGEMT:
3036 		switch (sip->si_code) {
3037 #ifdef EMT_TAGOVF
3038 		case EMT_TAGOVF:	code = "EMT_TAGOVF";	break;
3039 #endif
3040 		case EMT_CPCOVF:	code = "EMT_CPCOVF";	break;
3041 		}
3042 		break;
3043 	case SIGBUS:
3044 		switch (sip->si_code) {
3045 		case BUS_ADRALN:	code = "BUS_ADRALN";	break;
3046 		case BUS_ADRERR:	code = "BUS_ADRERR";	break;
3047 		case BUS_OBJERR:	code = "BUS_OBJERR";	break;
3048 		}
3049 		break;
3050 	case SIGCLD:
3051 		switch (sip->si_code) {
3052 		case CLD_EXITED:	code = "CLD_EXITED";	break;
3053 		case CLD_KILLED:	code = "CLD_KILLED";	break;
3054 		case CLD_DUMPED:	code = "CLD_DUMPED";	break;
3055 		case CLD_TRAPPED:	code = "CLD_TRAPPED";	break;
3056 		case CLD_STOPPED:	code = "CLD_STOPPED";	break;
3057 		case CLD_CONTINUED:	code = "CLD_CONTINUED";	break;
3058 		}
3059 		break;
3060 	case SIGPOLL:
3061 		switch (sip->si_code) {
3062 		case POLL_IN:		code = "POLL_IN";	break;
3063 		case POLL_OUT:		code = "POLL_OUT";	break;
3064 		case POLL_MSG:		code = "POLL_MSG";	break;
3065 		case POLL_ERR:		code = "POLL_ERR";	break;
3066 		case POLL_PRI:		code = "POLL_PRI";	break;
3067 		case POLL_HUP:		code = "POLL_HUP";	break;
3068 		}
3069 		break;
3070 	}
3071 
3072 	if (code == NULL) {
3073 		(void) sprintf(pri->code_buf, "code=%d", sip->si_code);
3074 		code = (const char *)pri->code_buf;
3075 	}
3076 
3077 	switch (sip->si_signo) {
3078 	case SIGILL:
3079 	case SIGTRAP:
3080 	case SIGFPE:
3081 	case SIGSEGV:
3082 	case SIGBUS:
3083 	case SIGEMT:
3084 		(void) printf(" %s addr=0x%.8lX",
3085 			code,
3086 			(long)sip->si_addr);
3087 		break;
3088 	case SIGCLD:
3089 		(void) printf(" %s pid=%d status=0x%.4X",
3090 			code,
3091 			(int)sip->si_pid,
3092 			sip->si_status);
3093 		break;
3094 	case SIGPOLL:
3095 	case SIGXFSZ:
3096 		(void) printf(" %s fd=%d band=%ld",
3097 			code,
3098 			sip->si_fd,
3099 			sip->si_band);
3100 		break;
3101 	}
3102 
3103 	if (sip->si_errno != 0) {
3104 		const char *ename = errname(sip->si_errno);
3105 
3106 		(void) printf(" errno=%d", sip->si_errno);
3107 		if (ename != NULL)
3108 			(void) printf("(%s)", ename);
3109 	}
3110 
3111 	(void) fputc('\n', stdout);
3112 }
3113 
3114 #ifdef _LP64
3115 void
3116 show_siginfo32(private_t *pri, long offset)
3117 {
3118 	struct siginfo32 siginfo;
3119 
3120 	if (offset != NULL &&
3121 	    Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3122 		print_siginfo32(pri, &siginfo);
3123 }
3124 #endif	/* _LP64 */
3125 
3126 void
3127 show_siginfo(private_t *pri, long offset)
3128 {
3129 	struct siginfo siginfo;
3130 
3131 #ifdef _LP64
3132 	if (data_model != PR_MODEL_LP64) {
3133 		show_siginfo32(pri, offset);
3134 		return;
3135 	}
3136 #endif
3137 	if (offset != NULL &&
3138 	    Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3139 		print_siginfo(pri, &siginfo);
3140 }
3141 
3142 void
3143 show_bool(private_t *pri, long offset, int count)
3144 {
3145 	int serial = (count > MYBUFSIZ / 4);
3146 
3147 	/* enter region of lengthy output */
3148 	if (serial)
3149 		Eserialize();
3150 
3151 	while (count > 0) {
3152 		char buf[32];
3153 		int nb = (count < 32)? count : 32;
3154 		int i;
3155 
3156 		if (Pread(Proc, buf, (size_t)nb, offset) != nb)
3157 			break;
3158 
3159 		(void) printf("%s   ", pri->pname);
3160 		for (i = 0; i < nb; i++)
3161 			(void) printf(" %d", buf[i]);
3162 		(void) fputc('\n', stdout);
3163 
3164 		count -= nb;
3165 		offset += nb;
3166 	}
3167 
3168 	/* exit region of lengthy output */
3169 	if (serial)
3170 		Xserialize();
3171 }
3172 
3173 #ifdef _LP64
3174 void
3175 show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
3176 {
3177 	iovec32_t iovec[16];
3178 	iovec32_t *ip;
3179 	long nb;
3180 	int serial = (count > MYBUFSIZ / 4 && showbuf);
3181 
3182 	if (niov > 16)		/* is this the real limit? */
3183 		niov = 16;
3184 
3185 	if (offset != NULL && niov > 0 &&
3186 	    Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
3187 	    == niov*sizeof (iovec32_t)) {
3188 		/* enter region of lengthy output */
3189 		if (serial)
3190 			Eserialize();
3191 
3192 		for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3193 			(void) printf("%s\tiov_base = 0x%.8X  iov_len = %d\n",
3194 				pri->pname,
3195 				ip->iov_base,
3196 				ip->iov_len);
3197 			if ((nb = count) > 0) {
3198 				if (nb > ip->iov_len)
3199 					nb = ip->iov_len;
3200 				if (nb > 0)
3201 					count -= nb;
3202 			}
3203 			if (showbuf && nb > 0)
3204 				showbuffer(pri, (long)ip->iov_base, nb);
3205 		}
3206 
3207 		/* exit region of lengthy output */
3208 		if (serial)
3209 			Xserialize();
3210 	}
3211 }
3212 #endif	/* _LP64 */
3213 
3214 void
3215 show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
3216 {
3217 	iovec_t iovec[16];
3218 	iovec_t *ip;
3219 	long nb;
3220 	int serial = (count > MYBUFSIZ / 4 && showbuf);
3221 
3222 #ifdef _LP64
3223 	if (data_model != PR_MODEL_LP64) {
3224 		show_iovec32(pri, offset, niov, showbuf, count);
3225 		return;
3226 	}
3227 #endif
3228 	if (niov > 16)		/* is this the real limit? */
3229 		niov = 16;
3230 
3231 	if (offset != NULL && niov > 0 &&
3232 	    Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
3233 	    == niov*sizeof (iovec_t)) {
3234 		/* enter region of lengthy output */
3235 		if (serial)
3236 			Eserialize();
3237 
3238 		for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3239 			(void) printf("%s\tiov_base = 0x%.8lX  iov_len = %lu\n",
3240 				pri->pname,
3241 				(long)ip->iov_base,
3242 				ip->iov_len);
3243 			if ((nb = count) > 0) {
3244 				if (nb > ip->iov_len)
3245 					nb = ip->iov_len;
3246 				if (nb > 0)
3247 					count -= nb;
3248 			}
3249 			if (showbuf && nb > 0)
3250 				showbuffer(pri, (long)ip->iov_base, nb);
3251 		}
3252 
3253 		/* exit region of lengthy output */
3254 		if (serial)
3255 			Xserialize();
3256 	}
3257 }
3258 
3259 void
3260 show_dents32(private_t *pri, long offset, long count)
3261 {
3262 	long buf[MYBUFSIZ / sizeof (long)];
3263 	struct dirent32 *dp;
3264 	int serial = (count > 100);
3265 
3266 	if (offset == NULL)
3267 		return;
3268 
3269 	/* enter region of lengthy output */
3270 	if (serial)
3271 		Eserialize();
3272 
3273 	while (count > 0 && !interrupt) {
3274 		int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3275 
3276 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3277 			break;
3278 
3279 		dp = (struct dirent32 *)&buf[0];
3280 		if (nb < (int)(dp->d_name - (char *)dp))
3281 			break;
3282 		if ((unsigned)nb < dp->d_reclen) {
3283 			/* getdents() error? */
3284 			(void) printf(
3285 			"%s    ino=%-5u off=%-4d rlen=%-3d\n",
3286 				pri->pname,
3287 				dp->d_ino,
3288 				dp->d_off,
3289 				dp->d_reclen);
3290 			break;
3291 		}
3292 
3293 		while (!interrupt &&
3294 		    nb >= (int)(dp->d_name - (char *)dp) &&
3295 		    (unsigned)nb >= dp->d_reclen) {
3296 			(void) printf(
3297 			"%s    ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n",
3298 				pri->pname,
3299 				dp->d_ino,
3300 				dp->d_off,
3301 				dp->d_reclen,
3302 				dp->d_reclen - (int)(dp->d_name - (char *)dp),
3303 				dp->d_name);
3304 			nb -= dp->d_reclen;
3305 			count -= dp->d_reclen;
3306 			offset += dp->d_reclen;
3307 			/* LINTED improper alignment */
3308 			dp = (struct dirent32 *)((char *)dp + dp->d_reclen);
3309 		}
3310 	}
3311 
3312 	/* exit region of lengthy output */
3313 	if (serial)
3314 		Xserialize();
3315 }
3316 
3317 void
3318 show_dents64(private_t *pri, long offset, long count)
3319 {
3320 	long long buf[MYBUFSIZ / sizeof (long long)];
3321 	struct dirent64 *dp;
3322 	int serial = (count > 100);
3323 
3324 	if (offset == NULL)
3325 		return;
3326 
3327 	/* enter region of lengthy output */
3328 	if (serial)
3329 		Eserialize();
3330 
3331 	while (count > 0 && !interrupt) {
3332 		int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3333 
3334 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3335 			break;
3336 
3337 		dp = (struct dirent64 *)&buf[0];
3338 		if (nb < (int)(dp->d_name - (char *)dp))
3339 			break;
3340 		if ((unsigned)nb < dp->d_reclen) {
3341 			/* getdents() error? */
3342 			(void) printf(
3343 			"%s    ino=%-5llu off=%-4lld rlen=%-3d\n",
3344 				pri->pname,
3345 				(long long)dp->d_ino,
3346 				(long long)dp->d_off,
3347 				dp->d_reclen);
3348 			break;
3349 		}
3350 
3351 		while (!interrupt &&
3352 		    nb >= (int)(dp->d_name - (char *)dp) &&
3353 		    (unsigned)nb >= dp->d_reclen) {
3354 			(void) printf(
3355 			"%s    ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3356 				pri->pname,
3357 				(long long)dp->d_ino,
3358 				(long long)dp->d_off,
3359 				dp->d_reclen,
3360 				dp->d_reclen - (int)(dp->d_name - (char *)dp),
3361 				dp->d_name);
3362 			nb -= dp->d_reclen;
3363 			count -= dp->d_reclen;
3364 			offset += dp->d_reclen;
3365 			/* LINTED improper alignment */
3366 			dp = (struct dirent64 *)((char *)dp + dp->d_reclen);
3367 		}
3368 	}
3369 
3370 	/* exit region of lengthy output */
3371 	if (serial)
3372 		Xserialize();
3373 }
3374 
3375 void
3376 show_rlimit32(private_t *pri, long offset)
3377 {
3378 	struct rlimit32 rlimit;
3379 
3380 	if (offset != NULL &&
3381 	    Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3382 		(void) printf("%s\t", pri->pname);
3383 		switch (rlimit.rlim_cur) {
3384 		case RLIM32_INFINITY:
3385 			(void) fputs("cur = RLIM_INFINITY", stdout);
3386 			break;
3387 		case RLIM32_SAVED_MAX:
3388 			(void) fputs("cur = RLIM_SAVED_MAX", stdout);
3389 			break;
3390 		case RLIM32_SAVED_CUR:
3391 			(void) fputs("cur = RLIM_SAVED_CUR", stdout);
3392 			break;
3393 		default:
3394 			(void) printf("cur = %lu", (long)rlimit.rlim_cur);
3395 			break;
3396 		}
3397 		switch (rlimit.rlim_max) {
3398 		case RLIM32_INFINITY:
3399 			(void) fputs("  max = RLIM_INFINITY\n", stdout);
3400 			break;
3401 		case RLIM32_SAVED_MAX:
3402 			(void) fputs("  max = RLIM_SAVED_MAX\n", stdout);
3403 			break;
3404 		case RLIM32_SAVED_CUR:
3405 			(void) fputs("  max = RLIM_SAVED_CUR\n", stdout);
3406 			break;
3407 		default:
3408 			(void) printf("  max = %lu\n", (long)rlimit.rlim_max);
3409 			break;
3410 		}
3411 	}
3412 }
3413 
3414 void
3415 show_rlimit64(private_t *pri, long offset)
3416 {
3417 	struct rlimit64 rlimit;
3418 
3419 	if (offset != NULL &&
3420 	    Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3421 		(void) printf("%s\t", pri->pname);
3422 		switch (rlimit.rlim_cur) {
3423 		case RLIM64_INFINITY:
3424 			(void) fputs("cur = RLIM64_INFINITY", stdout);
3425 			break;
3426 		case RLIM64_SAVED_MAX:
3427 			(void) fputs("cur = RLIM64_SAVED_MAX", stdout);
3428 			break;
3429 		case RLIM64_SAVED_CUR:
3430 			(void) fputs("cur = RLIM64_SAVED_CUR", stdout);
3431 			break;
3432 		default:
3433 			(void) printf("cur = %llu",
3434 			    (unsigned long long)rlimit.rlim_cur);
3435 			break;
3436 		}
3437 		switch (rlimit.rlim_max) {
3438 		case RLIM64_INFINITY:
3439 			(void) fputs("  max = RLIM64_INFINITY\n", stdout);
3440 			break;
3441 		case RLIM64_SAVED_MAX:
3442 			(void) fputs("  max = RLIM64_SAVED_MAX\n", stdout);
3443 			break;
3444 		case RLIM64_SAVED_CUR:
3445 			(void) fputs("  max = RLIM64_SAVED_CUR\n", stdout);
3446 			break;
3447 		default:
3448 			(void) printf("  max = %llu\n",
3449 			    (unsigned long long)rlimit.rlim_max);
3450 			break;
3451 		}
3452 	}
3453 }
3454 
3455 void
3456 show_nuname(private_t *pri, long offset)
3457 {
3458 	struct utsname ubuf;
3459 
3460 	if (offset != NULL &&
3461 	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3462 		(void) printf(
3463 		"%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3464 			pri->pname,
3465 			ubuf.sysname,
3466 			ubuf.nodename,
3467 			ubuf.release,
3468 			ubuf.version,
3469 			ubuf.machine);
3470 	}
3471 }
3472 
3473 void
3474 show_adjtime(private_t *pri, long off1, long off2)
3475 {
3476 	show_timeval(pri, off1, "   delta");
3477 	show_timeval(pri, off2, "olddelta");
3478 }
3479 
3480 void
3481 show_sockaddr(private_t *pri,
3482 	const char *str, long addroff, long lenoff, long len)
3483 {
3484 	/*
3485 	 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3486 	 * also large enough to store a sockaddr_in or a sockaddr_in6.
3487 	 */
3488 	long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3489 		/ sizeof (long)];
3490 	struct sockaddr *sa = (struct sockaddr *)buf;
3491 	struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3492 	struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3493 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3494 	char addrbuf[INET6_ADDRSTRLEN];
3495 
3496 	if (lenoff != 0) {
3497 		uint_t ilen;
3498 		if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3499 			return;
3500 		len = ilen;
3501 	}
3502 
3503 	if (len >= sizeof (buf))	/* protect against ridiculous length */
3504 		len = sizeof (buf) - 1;
3505 	if (Pread(Proc, buf, len, addroff) != len)
3506 		return;
3507 
3508 	switch (sa->sa_family) {
3509 	case AF_INET6:
3510 		(void) printf("%s\tAF_INET6  %s = %s  port = %u\n",
3511 		    pri->pname, str,
3512 		    inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3513 			sizeof (addrbuf)),
3514 		    ntohs(sin6->sin6_port));
3515 		(void) printf("%s\tscope id = %u  source id = 0x%x\n"
3516 		    "%s\tflow class = 0x%02x  flow label = 0x%05x\n",
3517 		    pri->pname, ntohl(sin6->sin6_scope_id),
3518 		    ntohl(sin6->__sin6_src_id),
3519 		    pri->pname,
3520 		    ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3521 		    ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3522 		break;
3523 	case AF_INET:
3524 	case AF_NCA:
3525 		(void) printf("%s\tAF_%s  %s = %s  port = %u\n",
3526 		    pri->pname, sa->sa_family == AF_INET ? "INET" : "NCA",
3527 		    str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3528 		    sizeof (addrbuf)), ntohs(sin->sin_port));
3529 		break;
3530 	case AF_UNIX:
3531 		len -= sizeof (soun->sun_family);
3532 		if (len >= 0) {
3533 			/* Null terminate */
3534 			soun->sun_path[len] = NULL;
3535 			(void) printf("%s\tAF_UNIX  %s = %s\n", pri->pname,
3536 				str, soun->sun_path);
3537 		}
3538 		break;
3539 	}
3540 }
3541 
3542 void
3543 show_msghdr(private_t *pri, long offset)
3544 {
3545 	const lwpstatus_t *Lsp = pri->lwpstat;
3546 	int what = Lsp->pr_what;
3547 	int err = pri->Errno;
3548 	struct msghdr msg;
3549 	int showbuf = FALSE;
3550 	int i = pri->sys_args[0]+1;
3551 	long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3552 
3553 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3554 		return;
3555 
3556 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
3557 		show_sockaddr(pri, "msg_name",
3558 			(long)msg.msg_name, 0, (long)msg.msg_namelen);
3559 
3560 	/*
3561 	 * Print the iovec if the syscall was successful and the fd is
3562 	 * part of the set being traced.
3563 	 */
3564 	if ((what == SYS_recvmsg && !err &&
3565 	    prismember(&readfd, i)) ||
3566 	    (what == SYS_sendmsg &&
3567 	    prismember(&writefd, i)))
3568 		showbuf = TRUE;
3569 
3570 	show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3571 
3572 }
3573 
3574 #ifdef _LP64
3575 void
3576 show_msghdr32(private_t *pri, long offset)
3577 {
3578 	struct msghdr32 {
3579 		caddr32_t	msg_name;
3580 		uint32_t	msg_namelen;
3581 		caddr32_t 	msg_iov;
3582 		int32_t		msg_iovlen;
3583 	} msg;
3584 	const lwpstatus_t *Lsp = pri->lwpstat;
3585 	int what = Lsp->pr_what;
3586 	int err = pri->Errno;
3587 	int showbuf = FALSE;
3588 	int i = pri->sys_args[0]+1;
3589 	long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3590 
3591 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3592 		return;
3593 
3594 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
3595 		show_sockaddr(pri, "msg_name",
3596 			(long)msg.msg_name, 0, (long)msg.msg_namelen);
3597 	/*
3598 	 * Print the iovec if the syscall was successful and the fd is
3599 	 * part of the set being traced.
3600 	 */
3601 	if ((what == SYS_recvmsg && !err &&
3602 	    prismember(&readfd, i)) ||
3603 	    (what == SYS_sendmsg &&
3604 	    prismember(&writefd, i)))
3605 		showbuf = TRUE;
3606 
3607 	show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3608 
3609 }
3610 #endif	/* _LP64 */
3611 
3612 static void
3613 show_doorargs(private_t *pri, long offset)
3614 {
3615 	door_arg_t args;
3616 
3617 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3618 		(void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3619 		    pri->pname,
3620 		    (ulong_t)args.data_ptr,
3621 		    (ulong_t)args.data_size);
3622 		(void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3623 		    pri->pname,
3624 		    (ulong_t)args.desc_ptr,
3625 		    args.desc_num);
3626 		(void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3627 		    pri->pname,
3628 		    (ulong_t)args.rbuf,
3629 		    (ulong_t)args.rsize);
3630 	}
3631 }
3632 
3633 static void
3634 show_ucred_privsets(private_t *pri, ucred_t *uc)
3635 {
3636 	int i = 0;
3637 	const priv_set_t *s;
3638 	priv_ptype_t sn;
3639 	char *str;
3640 
3641 	while ((sn = priv_getsetbynum(i++)) != NULL) {
3642 		s = ucred_getprivset(uc, sn);
3643 
3644 		if (s == NULL)
3645 			continue;
3646 
3647 		(void) printf("%s\t%c: %s\n",
3648 		    pri->pname,
3649 		    *sn,
3650 		    str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3651 
3652 		free(str);
3653 	}
3654 }
3655 
3656 static void
3657 show_ucred(private_t *pri, long offset)
3658 {
3659 	ucred_t *uc = _ucred_alloc();
3660 	size_t sz;
3661 
3662 	if (uc == NULL)
3663 		return;
3664 
3665 	sz = Pread(Proc, uc, uc->uc_size, offset);
3666 
3667 	/*
3668 	 * A new uc_size is read, it could be smaller than the previously
3669 	 * value.  We accept short reads that fill the whole header.
3670 	 */
3671 	if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3672 		(void) printf("%s\teuid=%d egid=%d\n",
3673 		    pri->pname,
3674 		    (int)ucred_geteuid(uc),
3675 		    (int)ucred_getegid(uc));
3676 		(void) printf("%s\truid=%d rgid=%d\n",
3677 		    pri->pname,
3678 		    (int)ucred_getruid(uc),
3679 		    (int)ucred_getrgid(uc));
3680 		(void) printf("%s\tpid=%d zoneid=%d\n",
3681 		    pri->pname,
3682 		    (int)ucred_getpid(uc),
3683 		    (int)ucred_getzoneid(uc));
3684 		show_ucred_privsets(pri, uc);
3685 	}
3686 	ucred_free(uc);
3687 }
3688 
3689 static void
3690 show_privset(private_t *pri, long offset, size_t size)
3691 {
3692 	priv_set_t *tmp = priv_allocset();
3693 	size_t sz;
3694 
3695 	if (tmp == NULL)
3696 		return;
3697 
3698 	sz = Pread(Proc, tmp, size, offset);
3699 
3700 	if (sz == size) {
3701 		char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3702 		if (str != NULL) {
3703 			(void) printf("%s\t%s\n", pri->pname, str);
3704 			free(str);
3705 		}
3706 	}
3707 	priv_freeset(tmp);
3708 }
3709 
3710 static void
3711 show_doorinfo(private_t *pri, long offset)
3712 {
3713 	door_info_t info;
3714 	door_attr_t attr;
3715 
3716 	if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3717 		return;
3718 	(void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3719 	    pri->pname,
3720 	    (int)info.di_target,
3721 	    info.di_proc,
3722 	    info.di_data);
3723 	attr = info.di_attributes;
3724 	(void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3725 	(void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3726 }
3727 
3728 static void
3729 show_doorparam(private_t *pri, long offset)
3730 {
3731 	ulong_t val;
3732 
3733 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3734 		(void) printf("%s\tvalue=%lu\n",
3735 		    pri->pname,
3736 		    val);
3737 	}
3738 }
3739 
3740 #ifdef _LP64
3741 
3742 static void
3743 show_doorargs32(private_t *pri, long offset)
3744 {
3745 	struct door_arg32 args;
3746 
3747 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3748 		(void) printf("%s\tdata_ptr=%X data_size=%u\n",
3749 		    pri->pname,
3750 		    args.data_ptr,
3751 		    args.data_size);
3752 		(void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3753 		    pri->pname,
3754 		    args.desc_ptr,
3755 		    args.desc_num);
3756 		(void) printf("%s\trbuf=0x%X rsize=%u\n",
3757 		    pri->pname,
3758 		    args.rbuf,
3759 		    args.rsize);
3760 	}
3761 }
3762 
3763 static void
3764 show_doorparam32(private_t *pri, long offset)
3765 {
3766 	uint_t val;
3767 
3768 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3769 		(void) printf("%s\tvalue=%u\n",
3770 		    pri->pname,
3771 		    val);
3772 	}
3773 }
3774 
3775 #endif	/* _LP64 */
3776 
3777 static void
3778 show_doors(private_t *pri)
3779 {
3780 	switch (pri->sys_args[5]) {
3781 	case DOOR_CALL:
3782 #ifdef _LP64
3783 		if (data_model == PR_MODEL_LP64)
3784 			show_doorargs(pri, (long)pri->sys_args[1]);
3785 		else
3786 			show_doorargs32(pri, (long)pri->sys_args[1]);
3787 #else
3788 		show_doorargs(pri, (long)pri->sys_args[1]);
3789 #endif
3790 		break;
3791 	case DOOR_UCRED:
3792 		if (!pri->Errno)
3793 			show_ucred(pri, (long)pri->sys_args[0]);
3794 		break;
3795 	case DOOR_INFO:
3796 		if (!pri->Errno)
3797 			show_doorinfo(pri, (long)pri->sys_args[1]);
3798 		break;
3799 	case DOOR_GETPARAM:
3800 		if (!pri->Errno) {
3801 #ifdef _LP64
3802 			if (data_model == PR_MODEL_LP64)
3803 				show_doorparam(pri, (long)pri->sys_args[2]);
3804 			else
3805 				show_doorparam32(pri, (long)pri->sys_args[2]);
3806 #else
3807 			show_doorparam(pri, (long)pri->sys_args[2]);
3808 #endif
3809 		}
3810 		break;
3811 	}
3812 }
3813 
3814 static void
3815 show_portargs(private_t *pri, long offset)
3816 {
3817 	port_event_t args;
3818 
3819 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3820 		(void) printf("%s\tevents=0x%x source=%u\n",
3821 		    pri->pname,
3822 		    args.portev_events,
3823 		    args.portev_source);
3824 		(void) printf("%s\tobject=0x%p user=0x%p\n",
3825 		    pri->pname,
3826 		    (void *)args.portev_object,
3827 		    (void *)args.portev_user);
3828 	}
3829 }
3830 
3831 
3832 #ifdef _LP64
3833 
3834 static void
3835 show_portargs32(private_t *pri, long offset)
3836 {
3837 	port_event32_t args;
3838 
3839 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3840 		(void) printf("%s\tevents=0x%x source=%u\n",
3841 		    pri->pname,
3842 		    args.portev_events,
3843 		    args.portev_source);
3844 		(void) printf("%s\tobject=0x%x user=0x%x\n",
3845 		    pri->pname,
3846 		    args.portev_object,
3847 		    args.portev_user);
3848 	}
3849 }
3850 
3851 #endif	/* _LP64 */
3852 
3853 static void
3854 show_ports(private_t *pri)
3855 {
3856 	switch (pri->sys_args[0]) {
3857 	case PORT_GET:
3858 #ifdef _LP64
3859 		if (data_model == PR_MODEL_LP64)
3860 			show_portargs(pri, (long)pri->sys_args[2]);
3861 		else
3862 			show_portargs32(pri, (long)pri->sys_args[2]);
3863 #else
3864 		show_portargs(pri, (long)pri->sys_args[2]);
3865 #endif
3866 		break;
3867 	}
3868 }
3869 
3870 #define	MAX_SNDFL_PRD 16
3871 
3872 #ifdef _LP64
3873 
3874 static void
3875 show_ksendfilevec32(private_t *pri, int fd,
3876     ksendfilevec32_t *sndvec, int sfvcnt)
3877 {
3878 	ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3879 	size_t cpy_rqst;
3880 
3881 	Eserialize();
3882 	while (sfvcnt > 0) {
3883 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3884 		sfvcnt -= cpy_rqst;
3885 		cpy_rqst *= sizeof (snd[0]);
3886 
3887 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3888 			break;
3889 
3890 		snd_ptr = &snd[0];
3891 
3892 		while (cpy_rqst) {
3893 			(void) printf(
3894 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3895 			    "sfv_off=%d\tsfv_len=%u\n",
3896 			    snd_ptr->sfv_fd,
3897 			    snd_ptr->sfv_flag,
3898 			    snd_ptr->sfv_off,
3899 			    snd_ptr->sfv_len);
3900 
3901 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3902 			    prismember(&writefd, fd)) {
3903 				showbuffer(pri,
3904 				    (long)snd_ptr->sfv_off & 0xffffffff,
3905 				    (long)snd_ptr->sfv_len);
3906 			}
3907 
3908 			cpy_rqst -= sizeof (snd[0]);
3909 			snd_ptr++;
3910 		}
3911 
3912 		sndvec += MAX_SNDFL_PRD;
3913 	}
3914 	Xserialize();
3915 }
3916 
3917 static void
3918 show_ksendfilevec64(private_t *pri, int fd,
3919     ksendfilevec64_t *sndvec, int sfvcnt)
3920 {
3921 	ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3922 	size_t cpy_rqst;
3923 
3924 	Eserialize();
3925 	while (sfvcnt > 0) {
3926 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3927 		sfvcnt -= cpy_rqst;
3928 		cpy_rqst *= sizeof (snd[0]);
3929 
3930 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3931 			break;
3932 
3933 		snd_ptr = &snd[0];
3934 
3935 		while (cpy_rqst) {
3936 			(void) printf(
3937 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3938 			    "sfv_off=%ld\tsfv_len=%u\n",
3939 			    snd_ptr->sfv_fd,
3940 			    snd_ptr->sfv_flag,
3941 			    snd_ptr->sfv_off,
3942 			    snd_ptr->sfv_len);
3943 
3944 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3945 			    prismember(&writefd, fd)) {
3946 				showbuffer(pri,
3947 				    (long)snd_ptr->sfv_off & 0xffffffff,
3948 				    (long)snd_ptr->sfv_len);
3949 			}
3950 
3951 			cpy_rqst -= sizeof (snd[0]);
3952 			snd_ptr++;
3953 		}
3954 
3955 		sndvec += MAX_SNDFL_PRD;
3956 	}
3957 	Xserialize();
3958 }
3959 
3960 #endif /* _LP64 */
3961 
3962 /*ARGSUSED*/
3963 static void
3964 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3965 {
3966 	sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3967 	size_t cpy_rqst;
3968 
3969 #ifdef _LP64
3970 	if (data_model != PR_MODEL_LP64) {
3971 		show_ksendfilevec32(pri, fd,
3972 		    (ksendfilevec32_t *)sndvec, sfvcnt);
3973 		return;
3974 	}
3975 #endif
3976 	Eserialize();
3977 	while (sfvcnt > 0) {
3978 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3979 		sfvcnt -= cpy_rqst;
3980 		cpy_rqst *= sizeof (snd[0]);
3981 
3982 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3983 			break;
3984 
3985 		snd_ptr = &snd[0];
3986 
3987 		while (cpy_rqst) {
3988 			(void) printf(
3989 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3990 			    "sfv_off=%ld\tsfv_len=%lu\n",
3991 			    snd_ptr->sfv_fd,
3992 			    snd_ptr->sfv_flag,
3993 			    snd_ptr->sfv_off,
3994 			    (ulong_t)snd_ptr->sfv_len);
3995 
3996 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3997 			    prismember(&writefd, fd)) {
3998 				showbuffer(pri, (long)snd_ptr->sfv_off,
3999 					    (long)snd_ptr->sfv_len);
4000 			}
4001 
4002 			cpy_rqst -= sizeof (snd[0]);
4003 			snd_ptr++;
4004 		}
4005 
4006 		sndvec += MAX_SNDFL_PRD;
4007 	}
4008 	Xserialize();
4009 }
4010 
4011 /*ARGSUSED*/
4012 static void
4013 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
4014 {
4015 	sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
4016 	size_t cpy_rqst;
4017 
4018 #ifdef _LP64
4019 	if (data_model != PR_MODEL_LP64) {
4020 		show_ksendfilevec64(pri, fd,
4021 		    (ksendfilevec64_t *)sndvec, sfvcnt);
4022 		return;
4023 	}
4024 #endif
4025 
4026 	Eserialize();
4027 	while (sfvcnt > 0) {
4028 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
4029 		sfvcnt -= cpy_rqst;
4030 		cpy_rqst *= sizeof (snd[0]);
4031 
4032 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
4033 			break;
4034 
4035 		snd_ptr = &snd[0];
4036 
4037 		while (cpy_rqst) {
4038 			(void) printf(
4039 #ifdef _LP64
4040 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
4041 			    "sfv_off=%ld\tsfv_len=%lu\n",
4042 #else
4043 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
4044 			    "sfv_off=%lld\tsfv_len=%lu\n",
4045 #endif
4046 			    snd_ptr->sfv_fd,
4047 			    snd_ptr->sfv_flag,
4048 			    snd_ptr->sfv_off,
4049 			    (ulong_t)snd_ptr->sfv_len);
4050 
4051 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
4052 			    prismember(&writefd, fd)) {
4053 				showbuffer(pri, (long)snd_ptr->sfv_off,
4054 					    (long)snd_ptr->sfv_len);
4055 			}
4056 
4057 			cpy_rqst -= sizeof (snd[0]);
4058 			snd_ptr++;
4059 		}
4060 
4061 		sndvec += MAX_SNDFL_PRD;
4062 	}
4063 	Xserialize();
4064 }
4065 
4066 static void
4067 show_memcntl_mha(private_t *pri, long offset)
4068 {
4069 	struct memcntl_mha mha;
4070 	const char *s = NULL;
4071 
4072 	if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
4073 		switch (mha.mha_cmd) {
4074 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
4075 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
4076 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
4077 		}
4078 		if (s)
4079 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4080 			    " mha_pagesize=%lu\n",
4081 			    pri->pname, s, mha.mha_flags,
4082 			    (ulong_t)mha.mha_pagesize);
4083 		else
4084 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4085 			    " mha_pagesize=%lu\n",
4086 			    pri->pname, mha.mha_cmd, mha.mha_flags,
4087 			    (ulong_t)mha.mha_pagesize);
4088 	}
4089 }
4090 
4091 #ifdef _LP64
4092 
4093 static void
4094 show_memcntl_mha32(private_t *pri, long offset)
4095 {
4096 	struct memcntl_mha32 mha32;
4097 	const char *s = NULL;
4098 
4099 	if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
4100 	    sizeof (mha32)) {
4101 		switch (mha32.mha_cmd) {
4102 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
4103 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
4104 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
4105 		}
4106 		if (s)
4107 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4108 			    " mha_pagesize=%u\n",
4109 			    pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
4110 		else
4111 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4112 			    " mha_pagesize=%u\n",
4113 			    pri->pname, mha32.mha_cmd, mha32.mha_flags,
4114 			    mha32.mha_pagesize);
4115 	}
4116 }
4117 
4118 #endif	/* _LP64 */
4119 
4120 static void
4121 show_memcntl(private_t *pri)
4122 {
4123 
4124 	if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
4125 		return;
4126 #ifdef _LP64
4127 	if (data_model == PR_MODEL_LP64)
4128 		show_memcntl_mha(pri, (long)pri->sys_args[3]);
4129 	else
4130 		show_memcntl_mha32(pri, (long)pri->sys_args[3]);
4131 #else
4132 	show_memcntl_mha(pri, (long)pri->sys_args[3]);
4133 #endif
4134 }
4135 
4136 void
4137 show_ids(private_t *pri, long offset, int count)
4138 {
4139 	id_t buf[MYBUFSIZ / sizeof (id_t)];
4140 	id_t *idp;
4141 	int serial = (count > MYBUFSIZ / 48);
4142 
4143 	if (offset == NULL)
4144 		return;
4145 
4146 	/* enter region of lengthy output */
4147 	if (serial)
4148 		Eserialize();
4149 
4150 	while (count > 0 && !interrupt) {
4151 		ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
4152 			count * sizeof (id_t) : MYBUFSIZ;
4153 
4154 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
4155 		    nb < sizeof (id_t))
4156 			break;
4157 
4158 		idp = buf;
4159 		while (!interrupt && nb >= sizeof (id_t)) {
4160 			(void) printf("%s\t%8d\n", pri->pname, (int)*idp);
4161 			offset += sizeof (id_t);
4162 			nb -= sizeof (id_t);
4163 			idp++;
4164 			count--;
4165 		}
4166 	}
4167 
4168 	/* exit region of lengthy output */
4169 	if (serial)
4170 		Xserialize();
4171 }
4172 
4173 void
4174 show_ntp_gettime(private_t *pri)
4175 {
4176 	struct ntptimeval ntv;
4177 	long offset;
4178 
4179 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4180 		return;
4181 
4182 	if (data_model == PR_MODEL_NATIVE) {
4183 		if (Pread(Proc, &ntv, sizeof (ntv), offset)
4184 		    != sizeof (ntv))
4185 			return;
4186 	} else {
4187 		struct ntptimeval32 ntv32;
4188 
4189 		if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
4190 		    != sizeof (ntv32))
4191 			return;
4192 
4193 		TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
4194 		ntv.maxerror = ntv32.maxerror;
4195 		ntv.esterror = ntv32.esterror;
4196 	}
4197 
4198 	(void) printf("\ttime:     %ld.%6.6ld sec\n",
4199 	    ntv.time.tv_sec, ntv.time.tv_usec);
4200 	(void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
4201 	(void) printf("\testerror: %11d usec\n", ntv.esterror);
4202 }
4203 
4204 static char *
4205 get_timex_modes(private_t *pri, uint32_t val)
4206 {
4207 	char *str = pri->code_buf;
4208 	size_t used = 0;
4209 
4210 	*str = '\0';
4211 	if (val & MOD_OFFSET)
4212 		used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
4213 	if (val & MOD_FREQUENCY)
4214 		used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
4215 	if (val & MOD_MAXERROR)
4216 		used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
4217 	if (val & MOD_ESTERROR)
4218 		used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
4219 	if (val & MOD_STATUS)
4220 		used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
4221 	if (val & MOD_TIMECONST)
4222 		used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
4223 	if (val & MOD_CLKB)
4224 		used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
4225 	if (val & MOD_CLKA)
4226 		used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
4227 
4228 	if (used == 0 || used >= sizeof (pri->code_buf))
4229 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4230 
4231 	return (str + 1);
4232 }
4233 
4234 static char *
4235 get_timex_status(private_t *pri, int32_t val)
4236 {
4237 	char *str = pri->code_buf;
4238 	size_t used = 0;
4239 
4240 	*str = '\0';
4241 	if (val & STA_PLL)
4242 		used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
4243 	if (val & STA_PPSFREQ)
4244 		used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
4245 	if (val & STA_PPSTIME)
4246 		used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
4247 	if (val & STA_FLL)
4248 		used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
4249 
4250 	if (val & STA_INS)
4251 		used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
4252 	if (val & STA_DEL)
4253 		used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
4254 	if (val & STA_UNSYNC)
4255 		used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
4256 	if (val & STA_FREQHOLD)
4257 		used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
4258 
4259 	if (val & STA_PPSSIGNAL)
4260 		used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
4261 	if (val & STA_PPSJITTER)
4262 		used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
4263 	if (val & STA_PPSWANDER)
4264 		used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
4265 	if (val & STA_PPSERROR)
4266 		used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
4267 
4268 	if (val & STA_CLOCKERR)
4269 		used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
4270 
4271 	if (used == 0 || used >= sizeof (pri->code_buf))
4272 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4273 
4274 	return (str + 1);
4275 }
4276 
4277 void
4278 show_ntp_adjtime(private_t *pri)
4279 {
4280 	struct timex timex;
4281 	long offset;
4282 
4283 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4284 		return;
4285 
4286 	if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4287 		return;
4288 
4289 	(void) printf("\tmodes:     %s\n", get_timex_modes(pri, timex.modes));
4290 	(void) printf("\toffset:    %11d usec\n", timex.offset);
4291 	(void) printf("\tfreq:      %11d scaled ppm\n", timex.freq);
4292 	(void) printf("\tmaxerror:  %11d usec\n", timex.maxerror);
4293 	(void) printf("\testerror:  %11d usec\n", timex.esterror);
4294 	(void) printf("\tstatus:    %s\n", get_timex_status(pri, timex.status));
4295 	(void) printf("\tconstant:  %11d\n", timex.constant);
4296 	(void) printf("\tprecision: %11d usec\n", timex.precision);
4297 	(void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4298 	(void) printf("\tppsfreq:   %11d scaled ppm\n", timex.ppsfreq);
4299 	(void) printf("\tjitter:    %11d usec\n", timex.jitter);
4300 	(void) printf("\tshift:     %11d sec\n", timex.shift);
4301 	(void) printf("\tstabil:    %11d scaled ppm\n", timex.stabil);
4302 	(void) printf("\tjitcnt:    %11d\n", timex.jitcnt);
4303 	(void) printf("\tcalcnt:    %11d\n", timex.calcnt);
4304 	(void) printf("\terrcnt:    %11d\n", timex.errcnt);
4305 	(void) printf("\tstbcnt:    %11d\n", timex.stbcnt);
4306 }
4307 
4308 void
4309 show_getrusage(long offset)
4310 {
4311 	struct rusage r;
4312 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4313 		return;
4314 	(void) printf("\t       user time: %ld.%6.6ld sec\n",
4315 	    r.ru_utime.tv_sec,
4316 	    r.ru_utime.tv_usec);
4317 	(void) printf("\t     system time: %ld.%6.6ld sec\n",
4318 	    r.ru_stime.tv_sec,
4319 	    r.ru_stime.tv_usec);
4320 	(void) printf("\t         max rss: <unimpl> %ld\n",
4321 	    r.ru_maxrss);
4322 	(void) printf("\t     shared data: <unimpl> %ld\n",
4323 	    r.ru_ixrss);
4324 	(void) printf("\t   unshared data: <unimpl> %ld\n",
4325 	    r.ru_idrss);
4326 	(void) printf("\t  unshared stack: <unimpl> %ld\n",
4327 	    r.ru_isrss);
4328 	(void) printf("\t    minor faults: %ld\n",
4329 	    r.ru_minflt);
4330 	(void) printf("\t    major faults: %ld\n",
4331 	    r.ru_majflt);
4332 	(void) printf("\t      # of swaps: %ld\n",
4333 	    r.ru_nswap);
4334 	(void) printf("\t  blocked inputs: %ld\n",
4335 	    r.ru_inblock);
4336 	(void) printf("\t blocked outputs: %ld\n",
4337 	    r.ru_oublock);
4338 	(void) printf("\t       msgs sent: %ld\n",
4339 	    r.ru_msgsnd);
4340 	(void) printf("\t      msgs rcv'd: %ld\n",
4341 	    r.ru_msgrcv);
4342 	(void) printf("\t   signals rcv'd: %ld\n",
4343 	    r.ru_nsignals);
4344 	(void) printf("\tvol cntxt swtchs: %ld\n",
4345 	    r.ru_nvcsw);
4346 	(void) printf("\tinv cntxt swtchs: %ld\n",
4347 	    r.ru_nivcsw);
4348 }
4349 
4350 #ifdef _LP64
4351 void
4352 show_getrusage32(long offset)
4353 {
4354 	struct rusage32 r;
4355 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4356 		return;
4357 	(void) printf("\t       user time: %d.%6.6d sec\n",
4358 	    r.ru_utime.tv_sec,
4359 	    r.ru_utime.tv_usec);
4360 	(void) printf("\t     system time: %d.%6.6d sec\n",
4361 	    r.ru_stime.tv_sec,
4362 	    r.ru_stime.tv_usec);
4363 	(void) printf("\t         max rss: <unimpl> %d\n",
4364 	    r.ru_maxrss);
4365 	(void) printf("\t     shared data: <unimpl> %d\n",
4366 	    r.ru_ixrss);
4367 	(void) printf("\t   unshared data: <unimpl> %d\n",
4368 	    r.ru_idrss);
4369 	(void) printf("\t  unshared stack: <unimpl> %d\n",
4370 	    r.ru_isrss);
4371 	(void) printf("\t    minor faults: %d\n",
4372 	    r.ru_minflt);
4373 	(void) printf("\t    major faults: %d\n",
4374 	    r.ru_majflt);
4375 	(void) printf("\t      # of swaps: %d\n",
4376 	    r.ru_nswap);
4377 	(void) printf("\t  blocked inputs: %d\n",
4378 	    r.ru_inblock);
4379 	(void) printf("\t blocked outputs: %d\n",
4380 	    r.ru_oublock);
4381 	(void) printf("\t       msgs sent: %d\n",
4382 	    r.ru_msgsnd);
4383 	(void) printf("\t      msgs rcv'd: %d\n",
4384 	    r.ru_msgrcv);
4385 	(void) printf("\t   signals rcv'd: %d\n",
4386 	    r.ru_nsignals);
4387 	(void) printf("\tvol cntxt swtchs: %d\n",
4388 	    r.ru_nvcsw);
4389 	(void) printf("\tinv cntxt swtchs: %d\n",
4390 	    r.ru_nivcsw);
4391 }
4392 #endif
4393 
4394 /* expound verbosely upon syscall arguments */
4395 /*ARGSUSED*/
4396 void
4397 expound(private_t *pri, long r0, int raw)
4398 {
4399 	const lwpstatus_t *Lsp = pri->lwpstat;
4400 	int lp64 = (data_model == PR_MODEL_LP64);
4401 	int what = Lsp->pr_what;
4402 	int err = pri->Errno;		/* don't display output parameters */
4403 					/* for a failed system call */
4404 #ifndef _LP64
4405 	/* We are a 32-bit truss; we can't grok a 64-bit process */
4406 	if (lp64)
4407 		return;
4408 #endif
4409 	/* for reporting sleeping system calls */
4410 	if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
4411 		what = Lsp->pr_syscall;
4412 
4413 	switch (what) {
4414 	case SYS_utime:
4415 		show_utime(pri);
4416 		break;
4417 	case SYS_utimes:
4418 		show_utimes(pri);
4419 		break;
4420 	case SYS_gettimeofday:
4421 		if (!err)
4422 			show_timeofday(pri);
4423 		break;
4424 	case SYS_getitimer:
4425 		if (!err && pri->sys_nargs > 1)
4426 			show_itimerval(pri, (long)pri->sys_args[1],
4427 				" value");
4428 		break;
4429 	case SYS_setitimer:
4430 		if (pri->sys_nargs > 1)
4431 			show_itimerval(pri, (long)pri->sys_args[1],
4432 				" value");
4433 		if (!err && pri->sys_nargs > 2)
4434 			show_itimerval(pri, (long)pri->sys_args[2],
4435 				"ovalue");
4436 		break;
4437 	case SYS_stime:
4438 		show_stime(pri);
4439 		break;
4440 	case SYS_times:
4441 		if (!err)
4442 			show_times(pri);
4443 		break;
4444 	case SYS_utssys:
4445 		if (err)
4446 			break;
4447 #ifdef _LP64
4448 		if (lp64)
4449 			show_utssys(pri, r0);
4450 		else
4451 			show_utssys32(pri, r0);
4452 #else
4453 		show_utssys(pri, r0);
4454 #endif
4455 		break;
4456 	case SYS_ioctl:
4457 		if (pri->sys_nargs >= 3) /* each case must decide for itself */
4458 			show_ioctl(pri, pri->sys_args[1],
4459 				(long)pri->sys_args[2]);
4460 		break;
4461 	case SYS_stat:
4462 	case SYS_fstat:
4463 	case SYS_lstat:
4464 		if (!err && pri->sys_nargs >= 2)
4465 			show_stat(pri, (long)pri->sys_args[1]);
4466 		break;
4467 	case SYS_stat64:
4468 	case SYS_fstat64:
4469 	case SYS_lstat64:
4470 		if (!err && pri->sys_nargs >= 2)
4471 			show_stat64_32(pri, (long)pri->sys_args[1]);
4472 		break;
4473 	case SYS_fsat:
4474 		/*
4475 		 * subcodes for fstatat() and fstatat64().
4476 		 */
4477 		if (!err && pri->sys_nargs >= 4) {
4478 			if (pri->sys_args[0] == 3)
4479 				show_statat(pri, (long)pri->sys_args[3]);
4480 			else if (pri->sys_args[0] == 2)
4481 				show_stat64_32(pri, (long)pri->sys_args[3]);
4482 		}
4483 		break;
4484 	case SYS_xstat:
4485 	case SYS_fxstat:
4486 	case SYS_lxstat:
4487 		if (!err && pri->sys_nargs >= 3)
4488 			show_xstat(pri, (int)pri->sys_args[0],
4489 				(long)pri->sys_args[2]);
4490 		break;
4491 	case SYS_statvfs:
4492 	case SYS_fstatvfs:
4493 		if (err)
4494 			break;
4495 #ifdef _LP64
4496 		if (!lp64) {
4497 			show_statvfs32(pri);
4498 			break;
4499 		}
4500 #endif
4501 		show_statvfs(pri);
4502 		break;
4503 	case SYS_statvfs64:
4504 	case SYS_fstatvfs64:
4505 		if (err)
4506 			break;
4507 		show_statvfs64(pri);
4508 		break;
4509 	case SYS_statfs:
4510 	case SYS_fstatfs:
4511 		if (err)
4512 			break;
4513 #ifdef _LP64
4514 		if (lp64)
4515 			show_statfs(pri);
4516 		else
4517 			show_statfs32(pri);
4518 #else
4519 		show_statfs(pri);
4520 #endif
4521 		break;
4522 	case SYS_fcntl:
4523 		show_fcntl(pri);
4524 		break;
4525 	case SYS_msgsys:
4526 		show_msgsys(pri, r0); /* each case must decide for itself */
4527 		break;
4528 	case SYS_semsys:
4529 		show_semsys(pri);	/* each case must decide for itself */
4530 		break;
4531 	case SYS_shmsys:
4532 		show_shmsys(pri);	/* each case must decide for itself */
4533 		break;
4534 	case SYS_getdents:
4535 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
4536 			break;
4537 #ifdef _LP64
4538 		if (!lp64) {
4539 			show_dents32(pri, (long)pri->sys_args[1], r0);
4540 			break;
4541 		}
4542 		/* FALLTHROUGH */
4543 #else
4544 		show_dents32(pri, (long)pri->sys_args[1], r0);
4545 		break;
4546 #endif
4547 	case SYS_getdents64:
4548 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
4549 			break;
4550 		show_dents64(pri, (long)pri->sys_args[1], r0);
4551 		break;
4552 	case SYS_getmsg:
4553 		show_gp_msg(pri, what);
4554 		if (pri->sys_nargs > 3)
4555 			show_hhex_int(pri, (long)pri->sys_args[3], "flags");
4556 		break;
4557 	case SYS_getpmsg:
4558 		show_gp_msg(pri, what);
4559 		if (pri->sys_nargs > 3)
4560 			show_hhex_int(pri, (long)pri->sys_args[3], "band");
4561 		if (pri->sys_nargs > 4)
4562 			show_hhex_int(pri, (long)pri->sys_args[4], "flags");
4563 		break;
4564 	case SYS_putmsg:
4565 	case SYS_putpmsg:
4566 		show_gp_msg(pri, what);
4567 		break;
4568 	case SYS_poll:
4569 		show_poll(pri);
4570 		break;
4571 	case SYS_pollsys:
4572 		show_pollsys(pri);
4573 		break;
4574 	case SYS_setgroups:
4575 		if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
4576 			show_groups(pri, (long)pri->sys_args[1], r0);
4577 		break;
4578 	case SYS_getgroups:
4579 		if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
4580 			show_groups(pri, (long)pri->sys_args[1], r0);
4581 		break;
4582 	case SYS_sigprocmask:
4583 		if (pri->sys_nargs > 1)
4584 			show_sigset(pri, (long)pri->sys_args[1], " set");
4585 		if (!err && pri->sys_nargs > 2)
4586 			show_sigset(pri, (long)pri->sys_args[2], "oset");
4587 		break;
4588 	case SYS_sigsuspend:
4589 	case SYS_sigtimedwait:
4590 		if (pri->sys_nargs > 0)
4591 			show_sigset(pri, (long)pri->sys_args[0], "sigmask");
4592 		if (!err && pri->sys_nargs > 1)
4593 			show_siginfo(pri, (long)pri->sys_args[1]);
4594 		if (pri->sys_nargs > 2)
4595 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4596 		break;
4597 	case SYS_sigaltstack:
4598 		if (pri->sys_nargs > 0)
4599 			show_sigaltstack(pri, (long)pri->sys_args[0],
4600 				"new");
4601 		if (!err && pri->sys_nargs > 1)
4602 			show_sigaltstack(pri, (long)pri->sys_args[1],
4603 				"old");
4604 		break;
4605 	case SYS_sigaction:
4606 		if (pri->sys_nargs > 1)
4607 			show_sigaction(pri, (long)pri->sys_args[1],
4608 				"new", NULL);
4609 		if (!err && pri->sys_nargs > 2)
4610 			show_sigaction(pri, (long)pri->sys_args[2],
4611 				"old", r0);
4612 		break;
4613 	case SYS_sigpending:
4614 		if (!err && pri->sys_nargs > 1)
4615 			show_sigset(pri, (long)pri->sys_args[1], "sigmask");
4616 		break;
4617 	case SYS_waitsys:
4618 		if (!err && pri->sys_nargs > 2)
4619 			show_siginfo(pri, (long)pri->sys_args[2]);
4620 		break;
4621 	case SYS_sigsendsys:
4622 		if (pri->sys_nargs > 0)
4623 			show_procset(pri, (long)pri->sys_args[0]);
4624 		break;
4625 	case SYS_priocntlsys:
4626 		if (pri->sys_nargs > 1)
4627 			show_procset(pri, (long)pri->sys_args[1]);
4628 		break;
4629 	case SYS_mincore:
4630 		if (!err && pri->sys_nargs > 2)
4631 			show_bool(pri, (long)pri->sys_args[2],
4632 				(pri->sys_args[1] + pagesize - 1) / pagesize);
4633 		break;
4634 	case SYS_readv:
4635 	case SYS_writev:
4636 		if (pri->sys_nargs > 2) {
4637 			int i = pri->sys_args[0]+1;
4638 			int showbuf = FALSE;
4639 			long nb = (what == SYS_readv)? r0 : 32*1024;
4640 
4641 			if ((what == SYS_readv && !err &&
4642 			    prismember(&readfd, i)) ||
4643 			    (what == SYS_writev &&
4644 			    prismember(&writefd, i)))
4645 				showbuf = TRUE;
4646 			show_iovec(pri, (long)pri->sys_args[1],
4647 				pri->sys_args[2], showbuf, nb);
4648 		}
4649 		break;
4650 	case SYS_getrlimit:
4651 		if (err)
4652 			break;
4653 		/*FALLTHROUGH*/
4654 	case SYS_setrlimit:
4655 		if (pri->sys_nargs <= 1)
4656 			break;
4657 #ifdef _LP64
4658 		if (lp64)
4659 			show_rlimit64(pri, (long)pri->sys_args[1]);
4660 		else
4661 			show_rlimit32(pri, (long)pri->sys_args[1]);
4662 #else
4663 		show_rlimit32(pri, (long)pri->sys_args[1]);
4664 #endif
4665 		break;
4666 	case SYS_getrlimit64:
4667 		if (err)
4668 			break;
4669 		/*FALLTHROUGH*/
4670 	case SYS_setrlimit64:
4671 		if (pri->sys_nargs <= 1)
4672 			break;
4673 		show_rlimit64(pri, (long)pri->sys_args[1]);
4674 		break;
4675 	case SYS_uname:
4676 		if (!err && pri->sys_nargs > 0)
4677 			show_nuname(pri, (long)pri->sys_args[0]);
4678 		break;
4679 	case SYS_adjtime:
4680 		if (!err && pri->sys_nargs > 1)
4681 			show_adjtime(pri, (long)pri->sys_args[0],
4682 				(long)pri->sys_args[1]);
4683 		break;
4684 	case SYS_lwp_info:
4685 		if (!err && pri->sys_nargs > 0)
4686 			show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
4687 		break;
4688 	case SYS_lwp_wait:
4689 		if (!err && pri->sys_nargs > 1)
4690 			show_int(pri, (long)pri->sys_args[1], "lwpid");
4691 		break;
4692 	case SYS_lwp_mutex_wakeup:
4693 	case SYS_lwp_mutex_lock:
4694 	case SYS_lwp_mutex_unlock:
4695 	case SYS_lwp_mutex_trylock:
4696 	case SYS_lwp_mutex_init:
4697 		if (pri->sys_nargs > 0)
4698 			show_mutex(pri, (long)pri->sys_args[0]);
4699 		break;
4700 	case SYS_lwp_mutex_timedlock:
4701 		if (pri->sys_nargs > 0)
4702 			show_mutex(pri, (long)pri->sys_args[0]);
4703 		if (pri->sys_nargs > 1)
4704 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4705 		break;
4706 	case SYS_lwp_cond_wait:
4707 		if (pri->sys_nargs > 0)
4708 			show_condvar(pri, (long)pri->sys_args[0]);
4709 		if (pri->sys_nargs > 1)
4710 			show_mutex(pri, (long)pri->sys_args[1]);
4711 		if (pri->sys_nargs > 2)
4712 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4713 		break;
4714 	case SYS_lwp_cond_signal:
4715 	case SYS_lwp_cond_broadcast:
4716 		if (pri->sys_nargs > 0)
4717 			show_condvar(pri, (long)pri->sys_args[0]);
4718 		break;
4719 	case SYS_lwp_sema_wait:
4720 	case SYS_lwp_sema_trywait:
4721 	case SYS_lwp_sema_post:
4722 		if (pri->sys_nargs > 0)
4723 			show_sema(pri, (long)pri->sys_args[0]);
4724 		break;
4725 	case SYS_lwp_sema_timedwait:
4726 		if (pri->sys_nargs > 0)
4727 			show_sema(pri, (long)pri->sys_args[0]);
4728 		if (pri->sys_nargs > 1)
4729 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4730 		break;
4731 	case SYS_lwp_rwlock_sys:
4732 		if (pri->sys_nargs > 1)
4733 			show_rwlock(pri, (long)pri->sys_args[1]);
4734 		if (pri->sys_nargs > 2 &&
4735 		    (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
4736 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4737 		break;
4738 	case SYS_lwp_create:
4739 		/* XXX print some values in ucontext ??? */
4740 		if (!err && pri->sys_nargs > 2)
4741 			show_int(pri, (long)pri->sys_args[2], "lwpid");
4742 		break;
4743 	case SYS_kaio:
4744 		if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
4745 			show_timeval(pri, (long)pri->sys_args[1], "timeout");
4746 		break;
4747 	case SYS_nanosleep:
4748 		if (pri->sys_nargs > 0)
4749 			show_timestruc(pri, (long)pri->sys_args[0], "tmout");
4750 		if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
4751 			show_timestruc(pri, (long)pri->sys_args[1], "resid");
4752 		break;
4753 	case SYS_privsys:
4754 		switch (pri->sys_args[0]) {
4755 		case PRIVSYS_SETPPRIV:
4756 		case PRIVSYS_GETPPRIV:
4757 			if (!err)
4758 				show_privset(pri, (long)pri->sys_args[3],
4759 					(size_t)pri->sys_args[4]);
4760 		}
4761 		break;
4762 	case SYS_ucredsys:
4763 		switch (pri->sys_args[0]) {
4764 		case UCREDSYS_UCREDGET:
4765 		case UCREDSYS_GETPEERUCRED:
4766 			if (err == 0)
4767 				show_ucred(pri, (long)pri->sys_args[2]);
4768 			break;
4769 		}
4770 		break;
4771 	case SYS_bind:
4772 	case SYS_connect:
4773 		if (pri->sys_nargs > 2)
4774 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4775 				0, (long)pri->sys_args[2]);
4776 		break;
4777 	case SYS_sendto:
4778 		if (pri->sys_nargs > 5)
4779 			show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
4780 				pri->sys_args[5]);
4781 		break;
4782 	case SYS_accept:
4783 		if (!err && pri->sys_nargs > 2)
4784 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4785 				(long)pri->sys_args[2], 0);
4786 		break;
4787 	case SYS_getsockname:
4788 	case SYS_getpeername:
4789 		if (!err && pri->sys_nargs > 2)
4790 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4791 				(long)pri->sys_args[2], 0);
4792 		break;
4793 	case SYS_cladm:
4794 		if (!err && pri->sys_nargs > 2)
4795 			show_cladm(pri, pri->sys_args[0], pri->sys_args[1],
4796 			    (long)pri->sys_args[2]);
4797 		break;
4798 	case SYS_recvfrom:
4799 		if (!err && pri->sys_nargs > 5)
4800 			show_sockaddr(pri, "from", (long)pri->sys_args[4],
4801 				(long)pri->sys_args[5], 0);
4802 		break;
4803 	case SYS_recvmsg:
4804 		if (err)
4805 			break;
4806 		/* FALLTHROUGH */
4807 	case SYS_sendmsg:
4808 		if (pri->sys_nargs <= 2)
4809 			break;
4810 #ifdef _LP64
4811 		if (lp64)
4812 			show_msghdr(pri, pri->sys_args[1]);
4813 		else
4814 			show_msghdr32(pri, pri->sys_args[1]);
4815 #else
4816 		show_msghdr(pri, pri->sys_args[1]);
4817 #endif
4818 		break;
4819 	case SYS_door:
4820 		show_doors(pri);
4821 		break;
4822 	case SYS_sendfilev:
4823 		if (pri->sys_nargs != 5)
4824 			break;
4825 
4826 		if (pri->sys_args[0] == SENDFILEV) {
4827 			show_sendfilevec(pri, (int)pri->sys_args[1],
4828 				(sendfilevec_t *)pri->sys_args[2],
4829 				(int)pri->sys_args[3]);
4830 		} else if (pri->sys_args[0] == SENDFILEV64) {
4831 			show_sendfilevec64(pri, (int)pri->sys_args[1],
4832 				(sendfilevec64_t *)pri->sys_args[2],
4833 				(int)pri->sys_args[3]);
4834 		}
4835 		break;
4836 	case SYS_memcntl:
4837 		show_memcntl(pri);
4838 		break;
4839 	case SYS_lwp_park:
4840 		/* subcode 0: lwp_park(timespec_t *, id_t) */
4841 		if (pri->sys_nargs > 1 && pri->sys_args[0] == 0)
4842 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4843 		/* subcode 2: lwp_unpark_all(id_t *, int) */
4844 		if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
4845 			show_ids(pri, (long)pri->sys_args[1],
4846 				(int)pri->sys_args[2]);
4847 		break;
4848 	case SYS_ntp_gettime:
4849 		if (!err)
4850 			show_ntp_gettime(pri);
4851 		break;
4852 	case SYS_ntp_adjtime:
4853 		if (!err)
4854 			show_ntp_adjtime(pri);
4855 		break;
4856 	case SYS_rusagesys:
4857 		if (!err)
4858 			if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
4859 #ifdef _LP64
4860 				if (!lp64)
4861 				    show_getrusage32(pri->sys_args[1]);
4862 				else
4863 #endif
4864 				    show_getrusage(pri->sys_args[1]);
4865 			}
4866 		break;
4867 	case SYS_port:
4868 		show_ports(pri);
4869 		break;
4870 	}
4871 }
4872