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