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