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