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