xref: /titanic_52/usr/src/cmd/truss/expound.c (revision 9d6538abe73a4bdd28aa48313b013f201c6aed4c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 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 		(void) printf("%s\tAF_%s  %s = %s  port = %u\n",
3528 		    pri->pname, "INET",
3529 		    str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3530 		    sizeof (addrbuf)), ntohs(sin->sin_port));
3531 		break;
3532 	case AF_UNIX:
3533 		len -= sizeof (soun->sun_family);
3534 		if (len >= 0) {
3535 			/* Null terminate */
3536 			soun->sun_path[len] = NULL;
3537 			(void) printf("%s\tAF_UNIX  %s = %s\n", pri->pname,
3538 				str, soun->sun_path);
3539 		}
3540 		break;
3541 	}
3542 }
3543 
3544 void
3545 show_msghdr(private_t *pri, long offset)
3546 {
3547 	const lwpstatus_t *Lsp = pri->lwpstat;
3548 	int what = Lsp->pr_what;
3549 	int err = pri->Errno;
3550 	struct msghdr msg;
3551 	int showbuf = FALSE;
3552 	int i = pri->sys_args[0]+1;
3553 	long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3554 
3555 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3556 		return;
3557 
3558 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
3559 		show_sockaddr(pri, "msg_name",
3560 			(long)msg.msg_name, 0, (long)msg.msg_namelen);
3561 
3562 	/*
3563 	 * Print the iovec if the syscall was successful and the fd is
3564 	 * part of the set being traced.
3565 	 */
3566 	if ((what == SYS_recvmsg && !err &&
3567 	    prismember(&readfd, i)) ||
3568 	    (what == SYS_sendmsg &&
3569 	    prismember(&writefd, i)))
3570 		showbuf = TRUE;
3571 
3572 	show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3573 
3574 }
3575 
3576 #ifdef _LP64
3577 void
3578 show_msghdr32(private_t *pri, long offset)
3579 {
3580 	struct msghdr32 {
3581 		caddr32_t	msg_name;
3582 		uint32_t	msg_namelen;
3583 		caddr32_t 	msg_iov;
3584 		int32_t		msg_iovlen;
3585 	} msg;
3586 	const lwpstatus_t *Lsp = pri->lwpstat;
3587 	int what = Lsp->pr_what;
3588 	int err = pri->Errno;
3589 	int showbuf = FALSE;
3590 	int i = pri->sys_args[0]+1;
3591 	long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3592 
3593 	if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3594 		return;
3595 
3596 	if (msg.msg_name != NULL && msg.msg_namelen != 0)
3597 		show_sockaddr(pri, "msg_name",
3598 			(long)msg.msg_name, 0, (long)msg.msg_namelen);
3599 	/*
3600 	 * Print the iovec if the syscall was successful and the fd is
3601 	 * part of the set being traced.
3602 	 */
3603 	if ((what == SYS_recvmsg && !err &&
3604 	    prismember(&readfd, i)) ||
3605 	    (what == SYS_sendmsg &&
3606 	    prismember(&writefd, i)))
3607 		showbuf = TRUE;
3608 
3609 	show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3610 
3611 }
3612 #endif	/* _LP64 */
3613 
3614 static void
3615 show_doorargs(private_t *pri, long offset)
3616 {
3617 	door_arg_t args;
3618 
3619 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3620 		(void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3621 		    pri->pname,
3622 		    (ulong_t)args.data_ptr,
3623 		    (ulong_t)args.data_size);
3624 		(void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3625 		    pri->pname,
3626 		    (ulong_t)args.desc_ptr,
3627 		    args.desc_num);
3628 		(void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3629 		    pri->pname,
3630 		    (ulong_t)args.rbuf,
3631 		    (ulong_t)args.rsize);
3632 	}
3633 }
3634 
3635 static void
3636 show_ucred_privsets(private_t *pri, ucred_t *uc)
3637 {
3638 	int i = 0;
3639 	const priv_set_t *s;
3640 	priv_ptype_t sn;
3641 	char *str;
3642 
3643 	while ((sn = priv_getsetbynum(i++)) != NULL) {
3644 		s = ucred_getprivset(uc, sn);
3645 
3646 		if (s == NULL)
3647 			continue;
3648 
3649 		(void) printf("%s\t%c: %s\n",
3650 		    pri->pname,
3651 		    *sn,
3652 		    str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3653 
3654 		free(str);
3655 	}
3656 }
3657 
3658 static void
3659 show_ucred(private_t *pri, long offset)
3660 {
3661 	ucred_t *uc = _ucred_alloc();
3662 	size_t sz;
3663 
3664 	if (uc == NULL)
3665 		return;
3666 
3667 	sz = Pread(Proc, uc, uc->uc_size, offset);
3668 
3669 	/*
3670 	 * A new uc_size is read, it could be smaller than the previously
3671 	 * value.  We accept short reads that fill the whole header.
3672 	 */
3673 	if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3674 		(void) printf("%s\teuid=%d egid=%d\n",
3675 		    pri->pname,
3676 		    (int)ucred_geteuid(uc),
3677 		    (int)ucred_getegid(uc));
3678 		(void) printf("%s\truid=%d rgid=%d\n",
3679 		    pri->pname,
3680 		    (int)ucred_getruid(uc),
3681 		    (int)ucred_getrgid(uc));
3682 		(void) printf("%s\tpid=%d zoneid=%d\n",
3683 		    pri->pname,
3684 		    (int)ucred_getpid(uc),
3685 		    (int)ucred_getzoneid(uc));
3686 		show_ucred_privsets(pri, uc);
3687 	}
3688 	ucred_free(uc);
3689 }
3690 
3691 static void
3692 show_privset(private_t *pri, long offset, size_t size, char *label)
3693 {
3694 	priv_set_t *tmp = priv_allocset();
3695 	size_t sz;
3696 
3697 	if (tmp == NULL)
3698 		return;
3699 
3700 	sz = Pread(Proc, tmp, size, offset);
3701 
3702 	if (sz == size) {
3703 		char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3704 		if (str != NULL) {
3705 			(void) printf("%s\t%s%s\n", pri->pname, label, str);
3706 			free(str);
3707 		}
3708 	}
3709 	priv_freeset(tmp);
3710 }
3711 
3712 static void
3713 show_doorinfo(private_t *pri, long offset)
3714 {
3715 	door_info_t info;
3716 	door_attr_t attr;
3717 
3718 	if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3719 		return;
3720 	(void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3721 	    pri->pname,
3722 	    (int)info.di_target,
3723 	    info.di_proc,
3724 	    info.di_data);
3725 	attr = info.di_attributes;
3726 	(void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3727 	(void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3728 }
3729 
3730 static void
3731 show_doorparam(private_t *pri, long offset)
3732 {
3733 	ulong_t val;
3734 
3735 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3736 		(void) printf("%s\tvalue=%lu\n",
3737 		    pri->pname,
3738 		    val);
3739 	}
3740 }
3741 
3742 #ifdef _LP64
3743 
3744 static void
3745 show_doorargs32(private_t *pri, long offset)
3746 {
3747 	struct door_arg32 args;
3748 
3749 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3750 		(void) printf("%s\tdata_ptr=%X data_size=%u\n",
3751 		    pri->pname,
3752 		    args.data_ptr,
3753 		    args.data_size);
3754 		(void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3755 		    pri->pname,
3756 		    args.desc_ptr,
3757 		    args.desc_num);
3758 		(void) printf("%s\trbuf=0x%X rsize=%u\n",
3759 		    pri->pname,
3760 		    args.rbuf,
3761 		    args.rsize);
3762 	}
3763 }
3764 
3765 static void
3766 show_doorparam32(private_t *pri, long offset)
3767 {
3768 	uint_t val;
3769 
3770 	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3771 		(void) printf("%s\tvalue=%u\n",
3772 		    pri->pname,
3773 		    val);
3774 	}
3775 }
3776 
3777 #endif	/* _LP64 */
3778 
3779 static void
3780 show_doors(private_t *pri)
3781 {
3782 	switch (pri->sys_args[5]) {
3783 	case DOOR_CALL:
3784 #ifdef _LP64
3785 		if (data_model == PR_MODEL_LP64)
3786 			show_doorargs(pri, (long)pri->sys_args[1]);
3787 		else
3788 			show_doorargs32(pri, (long)pri->sys_args[1]);
3789 #else
3790 		show_doorargs(pri, (long)pri->sys_args[1]);
3791 #endif
3792 		break;
3793 	case DOOR_UCRED:
3794 		if (!pri->Errno)
3795 			show_ucred(pri, (long)pri->sys_args[0]);
3796 		break;
3797 	case DOOR_INFO:
3798 		if (!pri->Errno)
3799 			show_doorinfo(pri, (long)pri->sys_args[1]);
3800 		break;
3801 	case DOOR_GETPARAM:
3802 		if (!pri->Errno) {
3803 #ifdef _LP64
3804 			if (data_model == PR_MODEL_LP64)
3805 				show_doorparam(pri, (long)pri->sys_args[2]);
3806 			else
3807 				show_doorparam32(pri, (long)pri->sys_args[2]);
3808 #else
3809 			show_doorparam(pri, (long)pri->sys_args[2]);
3810 #endif
3811 		}
3812 		break;
3813 	}
3814 }
3815 
3816 static void
3817 show_portargs(private_t *pri, long offset)
3818 {
3819 	port_event_t args;
3820 
3821 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3822 		(void) printf("%s\tevents=0x%x source=%u\n",
3823 		    pri->pname,
3824 		    args.portev_events,
3825 		    args.portev_source);
3826 		(void) printf("%s\tobject=0x%p user=0x%p\n",
3827 		    pri->pname,
3828 		    (void *)args.portev_object,
3829 		    (void *)args.portev_user);
3830 	}
3831 }
3832 
3833 
3834 #ifdef _LP64
3835 
3836 static void
3837 show_portargs32(private_t *pri, long offset)
3838 {
3839 	port_event32_t args;
3840 
3841 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3842 		(void) printf("%s\tevents=0x%x source=%u\n",
3843 		    pri->pname,
3844 		    args.portev_events,
3845 		    args.portev_source);
3846 		(void) printf("%s\tobject=0x%x user=0x%x\n",
3847 		    pri->pname,
3848 		    args.portev_object,
3849 		    args.portev_user);
3850 	}
3851 }
3852 
3853 #endif	/* _LP64 */
3854 
3855 static void
3856 show_ports(private_t *pri)
3857 {
3858 	switch (pri->sys_args[0]) {
3859 	case PORT_GET:
3860 #ifdef _LP64
3861 		if (data_model == PR_MODEL_LP64)
3862 			show_portargs(pri, (long)pri->sys_args[2]);
3863 		else
3864 			show_portargs32(pri, (long)pri->sys_args[2]);
3865 #else
3866 		show_portargs(pri, (long)pri->sys_args[2]);
3867 #endif
3868 		break;
3869 	}
3870 }
3871 
3872 #define	MAX_SNDFL_PRD 16
3873 
3874 #ifdef _LP64
3875 
3876 static void
3877 show_ksendfilevec32(private_t *pri, int fd,
3878     ksendfilevec32_t *sndvec, int sfvcnt)
3879 {
3880 	ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3881 	size_t cpy_rqst;
3882 
3883 	Eserialize();
3884 	while (sfvcnt > 0) {
3885 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3886 		sfvcnt -= cpy_rqst;
3887 		cpy_rqst *= sizeof (snd[0]);
3888 
3889 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3890 			break;
3891 
3892 		snd_ptr = &snd[0];
3893 
3894 		while (cpy_rqst) {
3895 			(void) printf(
3896 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3897 			    "sfv_off=%d\tsfv_len=%u\n",
3898 			    snd_ptr->sfv_fd,
3899 			    snd_ptr->sfv_flag,
3900 			    snd_ptr->sfv_off,
3901 			    snd_ptr->sfv_len);
3902 
3903 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3904 			    prismember(&writefd, fd)) {
3905 				showbuffer(pri,
3906 				    (long)snd_ptr->sfv_off & 0xffffffff,
3907 				    (long)snd_ptr->sfv_len);
3908 			}
3909 
3910 			cpy_rqst -= sizeof (snd[0]);
3911 			snd_ptr++;
3912 		}
3913 
3914 		sndvec += MAX_SNDFL_PRD;
3915 	}
3916 	Xserialize();
3917 }
3918 
3919 static void
3920 show_ksendfilevec64(private_t *pri, int fd,
3921     ksendfilevec64_t *sndvec, int sfvcnt)
3922 {
3923 	ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3924 	size_t cpy_rqst;
3925 
3926 	Eserialize();
3927 	while (sfvcnt > 0) {
3928 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3929 		sfvcnt -= cpy_rqst;
3930 		cpy_rqst *= sizeof (snd[0]);
3931 
3932 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3933 			break;
3934 
3935 		snd_ptr = &snd[0];
3936 
3937 		while (cpy_rqst) {
3938 			(void) printf(
3939 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3940 			    "sfv_off=%ld\tsfv_len=%u\n",
3941 			    snd_ptr->sfv_fd,
3942 			    snd_ptr->sfv_flag,
3943 			    snd_ptr->sfv_off,
3944 			    snd_ptr->sfv_len);
3945 
3946 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3947 			    prismember(&writefd, fd)) {
3948 				showbuffer(pri,
3949 				    (long)snd_ptr->sfv_off & 0xffffffff,
3950 				    (long)snd_ptr->sfv_len);
3951 			}
3952 
3953 			cpy_rqst -= sizeof (snd[0]);
3954 			snd_ptr++;
3955 		}
3956 
3957 		sndvec += MAX_SNDFL_PRD;
3958 	}
3959 	Xserialize();
3960 }
3961 
3962 #endif /* _LP64 */
3963 
3964 /*ARGSUSED*/
3965 static void
3966 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3967 {
3968 	sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3969 	size_t cpy_rqst;
3970 
3971 #ifdef _LP64
3972 	if (data_model != PR_MODEL_LP64) {
3973 		show_ksendfilevec32(pri, fd,
3974 		    (ksendfilevec32_t *)sndvec, sfvcnt);
3975 		return;
3976 	}
3977 #endif
3978 	Eserialize();
3979 	while (sfvcnt > 0) {
3980 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3981 		sfvcnt -= cpy_rqst;
3982 		cpy_rqst *= sizeof (snd[0]);
3983 
3984 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3985 			break;
3986 
3987 		snd_ptr = &snd[0];
3988 
3989 		while (cpy_rqst) {
3990 			(void) printf(
3991 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
3992 			    "sfv_off=%ld\tsfv_len=%lu\n",
3993 			    snd_ptr->sfv_fd,
3994 			    snd_ptr->sfv_flag,
3995 			    snd_ptr->sfv_off,
3996 			    (ulong_t)snd_ptr->sfv_len);
3997 
3998 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3999 			    prismember(&writefd, fd)) {
4000 				showbuffer(pri, (long)snd_ptr->sfv_off,
4001 					    (long)snd_ptr->sfv_len);
4002 			}
4003 
4004 			cpy_rqst -= sizeof (snd[0]);
4005 			snd_ptr++;
4006 		}
4007 
4008 		sndvec += MAX_SNDFL_PRD;
4009 	}
4010 	Xserialize();
4011 }
4012 
4013 /*ARGSUSED*/
4014 static void
4015 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
4016 {
4017 	sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
4018 	size_t cpy_rqst;
4019 
4020 #ifdef _LP64
4021 	if (data_model != PR_MODEL_LP64) {
4022 		show_ksendfilevec64(pri, fd,
4023 		    (ksendfilevec64_t *)sndvec, sfvcnt);
4024 		return;
4025 	}
4026 #endif
4027 
4028 	Eserialize();
4029 	while (sfvcnt > 0) {
4030 		cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
4031 		sfvcnt -= cpy_rqst;
4032 		cpy_rqst *= sizeof (snd[0]);
4033 
4034 		if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
4035 			break;
4036 
4037 		snd_ptr = &snd[0];
4038 
4039 		while (cpy_rqst) {
4040 			(void) printf(
4041 #ifdef _LP64
4042 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
4043 			    "sfv_off=%ld\tsfv_len=%lu\n",
4044 #else
4045 			    "sfv_fd=%d\tsfv_flag=0x%x\t"
4046 			    "sfv_off=%lld\tsfv_len=%lu\n",
4047 #endif
4048 			    snd_ptr->sfv_fd,
4049 			    snd_ptr->sfv_flag,
4050 			    snd_ptr->sfv_off,
4051 			    (ulong_t)snd_ptr->sfv_len);
4052 
4053 			if (snd_ptr->sfv_fd == SFV_FD_SELF &&
4054 			    prismember(&writefd, fd)) {
4055 				showbuffer(pri, (long)snd_ptr->sfv_off,
4056 					    (long)snd_ptr->sfv_len);
4057 			}
4058 
4059 			cpy_rqst -= sizeof (snd[0]);
4060 			snd_ptr++;
4061 		}
4062 
4063 		sndvec += MAX_SNDFL_PRD;
4064 	}
4065 	Xserialize();
4066 }
4067 
4068 static void
4069 show_memcntl_mha(private_t *pri, long offset)
4070 {
4071 	struct memcntl_mha mha;
4072 	const char *s = NULL;
4073 
4074 	if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
4075 		switch (mha.mha_cmd) {
4076 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
4077 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
4078 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
4079 		}
4080 		if (s)
4081 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4082 			    " mha_pagesize=%lu\n",
4083 			    pri->pname, s, mha.mha_flags,
4084 			    (ulong_t)mha.mha_pagesize);
4085 		else
4086 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4087 			    " mha_pagesize=%lu\n",
4088 			    pri->pname, mha.mha_cmd, mha.mha_flags,
4089 			    (ulong_t)mha.mha_pagesize);
4090 	}
4091 }
4092 
4093 #ifdef _LP64
4094 
4095 static void
4096 show_memcntl_mha32(private_t *pri, long offset)
4097 {
4098 	struct memcntl_mha32 mha32;
4099 	const char *s = NULL;
4100 
4101 	if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
4102 	    sizeof (mha32)) {
4103 		switch (mha32.mha_cmd) {
4104 		case MHA_MAPSIZE_VA:	    s = "MHA_MAPSIZE_VA";	break;
4105 		case MHA_MAPSIZE_BSSBRK:    s = "MHA_MAPSIZE_BSSBRK";	break;
4106 		case MHA_MAPSIZE_STACK:	    s = "MHA_MAPSIZE_STACK";	break;
4107 		}
4108 		if (s)
4109 			(void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4110 			    " mha_pagesize=%u\n",
4111 			    pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
4112 		else
4113 			(void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4114 			    " mha_pagesize=%u\n",
4115 			    pri->pname, mha32.mha_cmd, mha32.mha_flags,
4116 			    mha32.mha_pagesize);
4117 	}
4118 }
4119 
4120 #endif	/* _LP64 */
4121 
4122 static void
4123 show_memcntl(private_t *pri)
4124 {
4125 
4126 	if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
4127 		return;
4128 #ifdef _LP64
4129 	if (data_model == PR_MODEL_LP64)
4130 		show_memcntl_mha(pri, (long)pri->sys_args[3]);
4131 	else
4132 		show_memcntl_mha32(pri, (long)pri->sys_args[3]);
4133 #else
4134 	show_memcntl_mha(pri, (long)pri->sys_args[3]);
4135 #endif
4136 }
4137 
4138 void
4139 show_ids(private_t *pri, long offset, int count)
4140 {
4141 	id_t buf[MYBUFSIZ / sizeof (id_t)];
4142 	id_t *idp;
4143 	int serial = (count > MYBUFSIZ / 48);
4144 
4145 	if (offset == NULL)
4146 		return;
4147 
4148 	/* enter region of lengthy output */
4149 	if (serial)
4150 		Eserialize();
4151 
4152 	while (count > 0 && !interrupt) {
4153 		ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
4154 			count * sizeof (id_t) : MYBUFSIZ;
4155 
4156 		if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
4157 		    nb < sizeof (id_t))
4158 			break;
4159 
4160 		idp = buf;
4161 		while (!interrupt && nb >= sizeof (id_t)) {
4162 			(void) printf("%s\t%8d\n", pri->pname, (int)*idp);
4163 			offset += sizeof (id_t);
4164 			nb -= sizeof (id_t);
4165 			idp++;
4166 			count--;
4167 		}
4168 	}
4169 
4170 	/* exit region of lengthy output */
4171 	if (serial)
4172 		Xserialize();
4173 }
4174 
4175 void
4176 show_ntp_gettime(private_t *pri)
4177 {
4178 	struct ntptimeval ntv;
4179 	long offset;
4180 
4181 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4182 		return;
4183 
4184 	if (data_model == PR_MODEL_NATIVE) {
4185 		if (Pread(Proc, &ntv, sizeof (ntv), offset)
4186 		    != sizeof (ntv))
4187 			return;
4188 	} else {
4189 		struct ntptimeval32 ntv32;
4190 
4191 		if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
4192 		    != sizeof (ntv32))
4193 			return;
4194 
4195 		TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
4196 		ntv.maxerror = ntv32.maxerror;
4197 		ntv.esterror = ntv32.esterror;
4198 	}
4199 
4200 	(void) printf("\ttime:     %ld.%6.6ld sec\n",
4201 	    ntv.time.tv_sec, ntv.time.tv_usec);
4202 	(void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
4203 	(void) printf("\testerror: %11d usec\n", ntv.esterror);
4204 }
4205 
4206 static char *
4207 get_timex_modes(private_t *pri, uint32_t val)
4208 {
4209 	char *str = pri->code_buf;
4210 	size_t used = 0;
4211 
4212 	*str = '\0';
4213 	if (val & MOD_OFFSET)
4214 		used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
4215 	if (val & MOD_FREQUENCY)
4216 		used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
4217 	if (val & MOD_MAXERROR)
4218 		used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
4219 	if (val & MOD_ESTERROR)
4220 		used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
4221 	if (val & MOD_STATUS)
4222 		used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
4223 	if (val & MOD_TIMECONST)
4224 		used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
4225 	if (val & MOD_CLKB)
4226 		used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
4227 	if (val & MOD_CLKA)
4228 		used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
4229 
4230 	if (used == 0 || used >= sizeof (pri->code_buf))
4231 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4232 
4233 	return (str + 1);
4234 }
4235 
4236 static char *
4237 get_timex_status(private_t *pri, int32_t val)
4238 {
4239 	char *str = pri->code_buf;
4240 	size_t used = 0;
4241 
4242 	*str = '\0';
4243 	if (val & STA_PLL)
4244 		used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
4245 	if (val & STA_PPSFREQ)
4246 		used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
4247 	if (val & STA_PPSTIME)
4248 		used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
4249 	if (val & STA_FLL)
4250 		used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
4251 
4252 	if (val & STA_INS)
4253 		used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
4254 	if (val & STA_DEL)
4255 		used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
4256 	if (val & STA_UNSYNC)
4257 		used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
4258 	if (val & STA_FREQHOLD)
4259 		used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
4260 
4261 	if (val & STA_PPSSIGNAL)
4262 		used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
4263 	if (val & STA_PPSJITTER)
4264 		used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
4265 	if (val & STA_PPSWANDER)
4266 		used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
4267 	if (val & STA_PPSERROR)
4268 		used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
4269 
4270 	if (val & STA_CLOCKERR)
4271 		used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
4272 
4273 	if (used == 0 || used >= sizeof (pri->code_buf))
4274 		(void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4275 
4276 	return (str + 1);
4277 }
4278 
4279 void
4280 show_ntp_adjtime(private_t *pri)
4281 {
4282 	struct timex timex;
4283 	long offset;
4284 
4285 	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4286 		return;
4287 
4288 	if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4289 		return;
4290 
4291 	(void) printf("\tmodes:     %s\n", get_timex_modes(pri, timex.modes));
4292 	(void) printf("\toffset:    %11d usec\n", timex.offset);
4293 	(void) printf("\tfreq:      %11d scaled ppm\n", timex.freq);
4294 	(void) printf("\tmaxerror:  %11d usec\n", timex.maxerror);
4295 	(void) printf("\testerror:  %11d usec\n", timex.esterror);
4296 	(void) printf("\tstatus:    %s\n", get_timex_status(pri, timex.status));
4297 	(void) printf("\tconstant:  %11d\n", timex.constant);
4298 	(void) printf("\tprecision: %11d usec\n", timex.precision);
4299 	(void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4300 	(void) printf("\tppsfreq:   %11d scaled ppm\n", timex.ppsfreq);
4301 	(void) printf("\tjitter:    %11d usec\n", timex.jitter);
4302 	(void) printf("\tshift:     %11d sec\n", timex.shift);
4303 	(void) printf("\tstabil:    %11d scaled ppm\n", timex.stabil);
4304 	(void) printf("\tjitcnt:    %11d\n", timex.jitcnt);
4305 	(void) printf("\tcalcnt:    %11d\n", timex.calcnt);
4306 	(void) printf("\terrcnt:    %11d\n", timex.errcnt);
4307 	(void) printf("\tstbcnt:    %11d\n", timex.stbcnt);
4308 }
4309 
4310 void
4311 show_getrusage(long offset)
4312 {
4313 	struct rusage r;
4314 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4315 		return;
4316 	(void) printf("\t       user time: %ld.%6.6ld sec\n",
4317 	    r.ru_utime.tv_sec,
4318 	    r.ru_utime.tv_usec);
4319 	(void) printf("\t     system time: %ld.%6.6ld sec\n",
4320 	    r.ru_stime.tv_sec,
4321 	    r.ru_stime.tv_usec);
4322 	(void) printf("\t         max rss: <unimpl> %ld\n",
4323 	    r.ru_maxrss);
4324 	(void) printf("\t     shared data: <unimpl> %ld\n",
4325 	    r.ru_ixrss);
4326 	(void) printf("\t   unshared data: <unimpl> %ld\n",
4327 	    r.ru_idrss);
4328 	(void) printf("\t  unshared stack: <unimpl> %ld\n",
4329 	    r.ru_isrss);
4330 	(void) printf("\t    minor faults: %ld\n",
4331 	    r.ru_minflt);
4332 	(void) printf("\t    major faults: %ld\n",
4333 	    r.ru_majflt);
4334 	(void) printf("\t      # of swaps: %ld\n",
4335 	    r.ru_nswap);
4336 	(void) printf("\t  blocked inputs: %ld\n",
4337 	    r.ru_inblock);
4338 	(void) printf("\t blocked outputs: %ld\n",
4339 	    r.ru_oublock);
4340 	(void) printf("\t       msgs sent: %ld\n",
4341 	    r.ru_msgsnd);
4342 	(void) printf("\t      msgs rcv'd: %ld\n",
4343 	    r.ru_msgrcv);
4344 	(void) printf("\t   signals rcv'd: %ld\n",
4345 	    r.ru_nsignals);
4346 	(void) printf("\tvol cntxt swtchs: %ld\n",
4347 	    r.ru_nvcsw);
4348 	(void) printf("\tinv cntxt swtchs: %ld\n",
4349 	    r.ru_nivcsw);
4350 }
4351 
4352 #ifdef _LP64
4353 void
4354 show_getrusage32(long offset)
4355 {
4356 	struct rusage32 r;
4357 	if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4358 		return;
4359 	(void) printf("\t       user time: %d.%6.6d sec\n",
4360 	    r.ru_utime.tv_sec,
4361 	    r.ru_utime.tv_usec);
4362 	(void) printf("\t     system time: %d.%6.6d sec\n",
4363 	    r.ru_stime.tv_sec,
4364 	    r.ru_stime.tv_usec);
4365 	(void) printf("\t         max rss: <unimpl> %d\n",
4366 	    r.ru_maxrss);
4367 	(void) printf("\t     shared data: <unimpl> %d\n",
4368 	    r.ru_ixrss);
4369 	(void) printf("\t   unshared data: <unimpl> %d\n",
4370 	    r.ru_idrss);
4371 	(void) printf("\t  unshared stack: <unimpl> %d\n",
4372 	    r.ru_isrss);
4373 	(void) printf("\t    minor faults: %d\n",
4374 	    r.ru_minflt);
4375 	(void) printf("\t    major faults: %d\n",
4376 	    r.ru_majflt);
4377 	(void) printf("\t      # of swaps: %d\n",
4378 	    r.ru_nswap);
4379 	(void) printf("\t  blocked inputs: %d\n",
4380 	    r.ru_inblock);
4381 	(void) printf("\t blocked outputs: %d\n",
4382 	    r.ru_oublock);
4383 	(void) printf("\t       msgs sent: %d\n",
4384 	    r.ru_msgsnd);
4385 	(void) printf("\t      msgs rcv'd: %d\n",
4386 	    r.ru_msgrcv);
4387 	(void) printf("\t   signals rcv'd: %d\n",
4388 	    r.ru_nsignals);
4389 	(void) printf("\tvol cntxt swtchs: %d\n",
4390 	    r.ru_nvcsw);
4391 	(void) printf("\tinv cntxt swtchs: %d\n",
4392 	    r.ru_nivcsw);
4393 }
4394 #endif
4395 
4396 static void
4397 show_zone_create_args(private_t *pri, long offset)
4398 {
4399 	zone_def args;
4400 	char zone_name[ZONENAME_MAX];
4401 	char zone_root[MAXPATHLEN];
4402 	char *zone_zfs = NULL;
4403 
4404 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4405 
4406 		if (Pread_string(Proc, zone_name, sizeof (zone_name),
4407 		    (uintptr_t)args.zone_name) == -1)
4408 			(void) strcpy(zone_name, "<?>");
4409 
4410 		if (Pread_string(Proc, zone_root, sizeof (zone_root),
4411 		    (uintptr_t)args.zone_root) == -1)
4412 			(void) strcpy(zone_root, "<?>");
4413 
4414 		if (args.zfsbufsz > 0) {
4415 			zone_zfs = malloc(MIN(4, args.zfsbufsz));
4416 			if (zone_zfs != NULL) {
4417 				if (Pread(Proc, zone_zfs, args.zfsbufsz,
4418 				    (uintptr_t)args.zfsbuf) == -1)
4419 					(void) strcpy(zone_zfs, "<?>");
4420 			}
4421 		} else {
4422 			zone_zfs = "";
4423 		}
4424 
4425 		(void) printf("%s\t     zone_name: %s\n", pri->pname,
4426 		    zone_name);
4427 		(void) printf("%s\t     zone_root: %s\n", pri->pname,
4428 		    zone_root);
4429 
4430 		show_privset(pri, (uintptr_t)args.zone_privs,
4431 		    args.zone_privssz, "    zone_privs: ");
4432 
4433 		(void) printf("%s\t       rctlbuf: 0x%p\n", pri->pname,
4434 		    (void *)args.rctlbuf);
4435 		(void) printf("%s\t     rctlbufsz: %lu\n", pri->pname,
4436 		    (ulong_t)args.rctlbufsz);
4437 
4438 		(void) printf("%s\t           zfs: %s\n", pri->pname, zone_zfs);
4439 
4440 		(void) printf("%s\textended_error: 0x%p\n", pri->pname,
4441 		    (void *)args.extended_error);
4442 
4443 		if (args.zfsbufsz > 0)
4444 			free(zone_zfs);
4445 	}
4446 }
4447 
4448 
4449 #ifdef _LP64
4450 
4451 static void
4452 show_zone_create_args32(private_t *pri, long offset)
4453 {
4454 	zone_def32 args;
4455 	char zone_name[ZONENAME_MAX];
4456 	char zone_root[MAXPATHLEN];
4457 	char *zone_zfs = NULL;
4458 
4459 	if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4460 
4461 		if (Pread_string(Proc, zone_name, sizeof (zone_name),
4462 		    (uintptr_t)args.zone_name) == -1)
4463 			(void) strcpy(zone_name, "<?>");
4464 
4465 		if (Pread_string(Proc, zone_root, sizeof (zone_root),
4466 		    (uintptr_t)args.zone_root) == -1)
4467 			(void) strcpy(zone_root, "<?>");
4468 
4469 		if (args.zfsbufsz > 0) {
4470 			zone_zfs = malloc(MIN(4, args.zfsbufsz));
4471 			if (zone_zfs != NULL) {
4472 				if (Pread(Proc, zone_zfs, args.zfsbufsz,
4473 				    (uintptr_t)args.zfsbuf) == -1)
4474 					(void) strcpy(zone_zfs, "<?>");
4475 			}
4476 		} else {
4477 			zone_zfs = "";
4478 		}
4479 
4480 		(void) printf("%s\t     zone_name: %s\n", pri->pname,
4481 		    zone_name);
4482 		(void) printf("%s\t     zone_root: %s\n", pri->pname,
4483 		    zone_root);
4484 
4485 		show_privset(pri, (uintptr_t)args.zone_privs,
4486 		    args.zone_privssz, "    zone_privs: ");
4487 
4488 		(void) printf("%s\t       rctlbuf: 0x%x\n", pri->pname,
4489 		    (caddr32_t)args.rctlbuf);
4490 		(void) printf("%s\t     rctlbufsz: %lu\n", pri->pname,
4491 		    (ulong_t)args.rctlbufsz);
4492 
4493 		(void) printf("%s\t           zfs: %s\n", pri->pname, zone_zfs);
4494 
4495 		(void) printf("%s\textended_error: 0x%x\n", pri->pname,
4496 		    (caddr32_t)args.extended_error);
4497 
4498 		if (args.zfsbufsz > 0)
4499 			free(zone_zfs);
4500 	}
4501 }
4502 
4503 #endif
4504 
4505 static void
4506 show_zones(private_t *pri)
4507 {
4508 	switch (pri->sys_args[0]) {
4509 	case ZONE_CREATE:
4510 #ifdef _LP64
4511 		if (data_model == PR_MODEL_LP64)
4512 			show_zone_create_args(pri, (long)pri->sys_args[1]);
4513 		else
4514 			show_zone_create_args32(pri, (long)pri->sys_args[1]);
4515 #else
4516 		show_zone_create_args(pri, (long)pri->sys_args[1]);
4517 #endif
4518 		break;
4519 	}
4520 }
4521 
4522 
4523 /* expound verbosely upon syscall arguments */
4524 /*ARGSUSED*/
4525 void
4526 expound(private_t *pri, long r0, int raw)
4527 {
4528 	const lwpstatus_t *Lsp = pri->lwpstat;
4529 	int lp64 = (data_model == PR_MODEL_LP64);
4530 	int what = Lsp->pr_what;
4531 	int err = pri->Errno;		/* don't display output parameters */
4532 					/* for a failed system call */
4533 #ifndef _LP64
4534 	/* We are a 32-bit truss; we can't grok a 64-bit process */
4535 	if (lp64)
4536 		return;
4537 #endif
4538 	/* for reporting sleeping system calls */
4539 	if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
4540 		what = Lsp->pr_syscall;
4541 
4542 	switch (what) {
4543 	case SYS_utime:
4544 		show_utime(pri);
4545 		break;
4546 	case SYS_utimes:
4547 		show_utimes(pri);
4548 		break;
4549 	case SYS_gettimeofday:
4550 		if (!err)
4551 			show_timeofday(pri);
4552 		break;
4553 	case SYS_getitimer:
4554 		if (!err && pri->sys_nargs > 1)
4555 			show_itimerval(pri, (long)pri->sys_args[1],
4556 				" value");
4557 		break;
4558 	case SYS_setitimer:
4559 		if (pri->sys_nargs > 1)
4560 			show_itimerval(pri, (long)pri->sys_args[1],
4561 				" value");
4562 		if (!err && pri->sys_nargs > 2)
4563 			show_itimerval(pri, (long)pri->sys_args[2],
4564 				"ovalue");
4565 		break;
4566 	case SYS_stime:
4567 		show_stime(pri);
4568 		break;
4569 	case SYS_times:
4570 		if (!err)
4571 			show_times(pri);
4572 		break;
4573 	case SYS_utssys:
4574 		if (err)
4575 			break;
4576 #ifdef _LP64
4577 		if (lp64)
4578 			show_utssys(pri, r0);
4579 		else
4580 			show_utssys32(pri, r0);
4581 #else
4582 		show_utssys(pri, r0);
4583 #endif
4584 		break;
4585 	case SYS_ioctl:
4586 		if (pri->sys_nargs >= 3) /* each case must decide for itself */
4587 			show_ioctl(pri, pri->sys_args[1],
4588 				(long)pri->sys_args[2]);
4589 		break;
4590 	case SYS_stat:
4591 	case SYS_fstat:
4592 	case SYS_lstat:
4593 		if (!err && pri->sys_nargs >= 2)
4594 			show_stat(pri, (long)pri->sys_args[1]);
4595 		break;
4596 	case SYS_stat64:
4597 	case SYS_fstat64:
4598 	case SYS_lstat64:
4599 		if (!err && pri->sys_nargs >= 2)
4600 			show_stat64_32(pri, (long)pri->sys_args[1]);
4601 		break;
4602 	case SYS_fsat:
4603 		/*
4604 		 * subcodes for fstatat() and fstatat64().
4605 		 */
4606 		if (!err && pri->sys_nargs >= 4) {
4607 			if (pri->sys_args[0] == 3)
4608 				show_statat(pri, (long)pri->sys_args[3]);
4609 			else if (pri->sys_args[0] == 2)
4610 				show_stat64_32(pri, (long)pri->sys_args[3]);
4611 		}
4612 		break;
4613 	case SYS_xstat:
4614 	case SYS_fxstat:
4615 	case SYS_lxstat:
4616 		if (!err && pri->sys_nargs >= 3)
4617 			show_xstat(pri, (int)pri->sys_args[0],
4618 				(long)pri->sys_args[2]);
4619 		break;
4620 	case SYS_statvfs:
4621 	case SYS_fstatvfs:
4622 		if (err)
4623 			break;
4624 #ifdef _LP64
4625 		if (!lp64) {
4626 			show_statvfs32(pri);
4627 			break;
4628 		}
4629 #endif
4630 		show_statvfs(pri);
4631 		break;
4632 	case SYS_statvfs64:
4633 	case SYS_fstatvfs64:
4634 		if (err)
4635 			break;
4636 		show_statvfs64(pri);
4637 		break;
4638 	case SYS_statfs:
4639 	case SYS_fstatfs:
4640 		if (err)
4641 			break;
4642 #ifdef _LP64
4643 		if (lp64)
4644 			show_statfs(pri);
4645 		else
4646 			show_statfs32(pri);
4647 #else
4648 		show_statfs(pri);
4649 #endif
4650 		break;
4651 	case SYS_fcntl:
4652 		show_fcntl(pri);
4653 		break;
4654 	case SYS_msgsys:
4655 		show_msgsys(pri, r0); /* each case must decide for itself */
4656 		break;
4657 	case SYS_semsys:
4658 		show_semsys(pri);	/* each case must decide for itself */
4659 		break;
4660 	case SYS_shmsys:
4661 		show_shmsys(pri);	/* each case must decide for itself */
4662 		break;
4663 	case SYS_getdents:
4664 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
4665 			break;
4666 #ifdef _LP64
4667 		if (!lp64) {
4668 			show_dents32(pri, (long)pri->sys_args[1], r0);
4669 			break;
4670 		}
4671 		/* FALLTHROUGH */
4672 #else
4673 		show_dents32(pri, (long)pri->sys_args[1], r0);
4674 		break;
4675 #endif
4676 	case SYS_getdents64:
4677 		if (err || pri->sys_nargs <= 1 || r0 <= 0)
4678 			break;
4679 		show_dents64(pri, (long)pri->sys_args[1], r0);
4680 		break;
4681 	case SYS_getmsg:
4682 		show_gp_msg(pri, what);
4683 		if (pri->sys_nargs > 3)
4684 			show_hhex_int(pri, (long)pri->sys_args[3], "flags");
4685 		break;
4686 	case SYS_getpmsg:
4687 		show_gp_msg(pri, what);
4688 		if (pri->sys_nargs > 3)
4689 			show_hhex_int(pri, (long)pri->sys_args[3], "band");
4690 		if (pri->sys_nargs > 4)
4691 			show_hhex_int(pri, (long)pri->sys_args[4], "flags");
4692 		break;
4693 	case SYS_putmsg:
4694 	case SYS_putpmsg:
4695 		show_gp_msg(pri, what);
4696 		break;
4697 	case SYS_poll:
4698 		show_poll(pri);
4699 		break;
4700 	case SYS_pollsys:
4701 		show_pollsys(pri);
4702 		break;
4703 	case SYS_setgroups:
4704 		if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
4705 			show_groups(pri, (long)pri->sys_args[1], r0);
4706 		break;
4707 	case SYS_getgroups:
4708 		if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
4709 			show_groups(pri, (long)pri->sys_args[1], r0);
4710 		break;
4711 	case SYS_sigprocmask:
4712 		if (pri->sys_nargs > 1)
4713 			show_sigset(pri, (long)pri->sys_args[1], " set");
4714 		if (!err && pri->sys_nargs > 2)
4715 			show_sigset(pri, (long)pri->sys_args[2], "oset");
4716 		break;
4717 	case SYS_sigsuspend:
4718 	case SYS_sigtimedwait:
4719 		if (pri->sys_nargs > 0)
4720 			show_sigset(pri, (long)pri->sys_args[0], "sigmask");
4721 		if (!err && pri->sys_nargs > 1)
4722 			show_siginfo(pri, (long)pri->sys_args[1]);
4723 		if (pri->sys_nargs > 2)
4724 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4725 		break;
4726 	case SYS_sigaltstack:
4727 		if (pri->sys_nargs > 0)
4728 			show_sigaltstack(pri, (long)pri->sys_args[0],
4729 				"new");
4730 		if (!err && pri->sys_nargs > 1)
4731 			show_sigaltstack(pri, (long)pri->sys_args[1],
4732 				"old");
4733 		break;
4734 	case SYS_sigaction:
4735 		if (pri->sys_nargs > 1)
4736 			show_sigaction(pri, (long)pri->sys_args[1],
4737 				"new", NULL);
4738 		if (!err && pri->sys_nargs > 2)
4739 			show_sigaction(pri, (long)pri->sys_args[2],
4740 				"old", r0);
4741 		break;
4742 	case SYS_sigpending:
4743 		if (!err && pri->sys_nargs > 1)
4744 			show_sigset(pri, (long)pri->sys_args[1], "sigmask");
4745 		break;
4746 	case SYS_waitsys:
4747 		if (!err && pri->sys_nargs > 2)
4748 			show_siginfo(pri, (long)pri->sys_args[2]);
4749 		break;
4750 	case SYS_sigsendsys:
4751 		if (pri->sys_nargs > 0)
4752 			show_procset(pri, (long)pri->sys_args[0]);
4753 		break;
4754 	case SYS_priocntlsys:
4755 		if (pri->sys_nargs > 1)
4756 			show_procset(pri, (long)pri->sys_args[1]);
4757 		break;
4758 	case SYS_mincore:
4759 		if (!err && pri->sys_nargs > 2)
4760 			show_bool(pri, (long)pri->sys_args[2],
4761 				(pri->sys_args[1] + pagesize - 1) / pagesize);
4762 		break;
4763 	case SYS_readv:
4764 	case SYS_writev:
4765 		if (pri->sys_nargs > 2) {
4766 			int i = pri->sys_args[0]+1;
4767 			int showbuf = FALSE;
4768 			long nb = (what == SYS_readv)? r0 : 32*1024;
4769 
4770 			if ((what == SYS_readv && !err &&
4771 			    prismember(&readfd, i)) ||
4772 			    (what == SYS_writev &&
4773 			    prismember(&writefd, i)))
4774 				showbuf = TRUE;
4775 			show_iovec(pri, (long)pri->sys_args[1],
4776 				pri->sys_args[2], showbuf, nb);
4777 		}
4778 		break;
4779 	case SYS_getrlimit:
4780 		if (err)
4781 			break;
4782 		/*FALLTHROUGH*/
4783 	case SYS_setrlimit:
4784 		if (pri->sys_nargs <= 1)
4785 			break;
4786 #ifdef _LP64
4787 		if (lp64)
4788 			show_rlimit64(pri, (long)pri->sys_args[1]);
4789 		else
4790 			show_rlimit32(pri, (long)pri->sys_args[1]);
4791 #else
4792 		show_rlimit32(pri, (long)pri->sys_args[1]);
4793 #endif
4794 		break;
4795 	case SYS_getrlimit64:
4796 		if (err)
4797 			break;
4798 		/*FALLTHROUGH*/
4799 	case SYS_setrlimit64:
4800 		if (pri->sys_nargs <= 1)
4801 			break;
4802 		show_rlimit64(pri, (long)pri->sys_args[1]);
4803 		break;
4804 	case SYS_uname:
4805 		if (!err && pri->sys_nargs > 0)
4806 			show_nuname(pri, (long)pri->sys_args[0]);
4807 		break;
4808 	case SYS_adjtime:
4809 		if (!err && pri->sys_nargs > 1)
4810 			show_adjtime(pri, (long)pri->sys_args[0],
4811 				(long)pri->sys_args[1]);
4812 		break;
4813 	case SYS_lwp_info:
4814 		if (!err && pri->sys_nargs > 0)
4815 			show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
4816 		break;
4817 	case SYS_lwp_wait:
4818 		if (!err && pri->sys_nargs > 1)
4819 			show_int(pri, (long)pri->sys_args[1], "lwpid");
4820 		break;
4821 	case SYS_lwp_mutex_wakeup:
4822 	case SYS_lwp_mutex_lock:
4823 	case SYS_lwp_mutex_unlock:
4824 	case SYS_lwp_mutex_trylock:
4825 	case SYS_lwp_mutex_init:
4826 		if (pri->sys_nargs > 0)
4827 			show_mutex(pri, (long)pri->sys_args[0]);
4828 		break;
4829 	case SYS_lwp_mutex_timedlock:
4830 		if (pri->sys_nargs > 0)
4831 			show_mutex(pri, (long)pri->sys_args[0]);
4832 		if (pri->sys_nargs > 1)
4833 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4834 		break;
4835 	case SYS_lwp_cond_wait:
4836 		if (pri->sys_nargs > 0)
4837 			show_condvar(pri, (long)pri->sys_args[0]);
4838 		if (pri->sys_nargs > 1)
4839 			show_mutex(pri, (long)pri->sys_args[1]);
4840 		if (pri->sys_nargs > 2)
4841 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4842 		break;
4843 	case SYS_lwp_cond_signal:
4844 	case SYS_lwp_cond_broadcast:
4845 		if (pri->sys_nargs > 0)
4846 			show_condvar(pri, (long)pri->sys_args[0]);
4847 		break;
4848 	case SYS_lwp_sema_wait:
4849 	case SYS_lwp_sema_trywait:
4850 	case SYS_lwp_sema_post:
4851 		if (pri->sys_nargs > 0)
4852 			show_sema(pri, (long)pri->sys_args[0]);
4853 		break;
4854 	case SYS_lwp_sema_timedwait:
4855 		if (pri->sys_nargs > 0)
4856 			show_sema(pri, (long)pri->sys_args[0]);
4857 		if (pri->sys_nargs > 1)
4858 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4859 		break;
4860 	case SYS_lwp_rwlock_sys:
4861 		if (pri->sys_nargs > 1)
4862 			show_rwlock(pri, (long)pri->sys_args[1]);
4863 		if (pri->sys_nargs > 2 &&
4864 		    (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
4865 			show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4866 		break;
4867 	case SYS_lwp_create:
4868 		/* XXX print some values in ucontext ??? */
4869 		if (!err && pri->sys_nargs > 2)
4870 			show_int(pri, (long)pri->sys_args[2], "lwpid");
4871 		break;
4872 	case SYS_kaio:
4873 		if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
4874 			show_timeval(pri, (long)pri->sys_args[1], "timeout");
4875 		break;
4876 	case SYS_nanosleep:
4877 		if (pri->sys_nargs > 0)
4878 			show_timestruc(pri, (long)pri->sys_args[0], "tmout");
4879 		if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
4880 			show_timestruc(pri, (long)pri->sys_args[1], "resid");
4881 		break;
4882 	case SYS_privsys:
4883 		switch (pri->sys_args[0]) {
4884 		case PRIVSYS_SETPPRIV:
4885 		case PRIVSYS_GETPPRIV:
4886 			if (!err)
4887 				show_privset(pri, (long)pri->sys_args[3],
4888 					(size_t)pri->sys_args[4], "");
4889 		}
4890 		break;
4891 	case SYS_ucredsys:
4892 		switch (pri->sys_args[0]) {
4893 		case UCREDSYS_UCREDGET:
4894 		case UCREDSYS_GETPEERUCRED:
4895 			if (err == 0)
4896 				show_ucred(pri, (long)pri->sys_args[2]);
4897 			break;
4898 		}
4899 		break;
4900 	case SYS_bind:
4901 	case SYS_connect:
4902 		if (pri->sys_nargs > 2)
4903 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4904 				0, (long)pri->sys_args[2]);
4905 		break;
4906 	case SYS_sendto:
4907 		if (pri->sys_nargs > 5)
4908 			show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
4909 				pri->sys_args[5]);
4910 		break;
4911 	case SYS_accept:
4912 		if (!err && pri->sys_nargs > 2)
4913 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4914 				(long)pri->sys_args[2], 0);
4915 		break;
4916 	case SYS_getsockname:
4917 	case SYS_getpeername:
4918 		if (!err && pri->sys_nargs > 2)
4919 			show_sockaddr(pri, "name", (long)pri->sys_args[1],
4920 				(long)pri->sys_args[2], 0);
4921 		break;
4922 	case SYS_cladm:
4923 		if (!err && pri->sys_nargs > 2)
4924 			show_cladm(pri, pri->sys_args[0], pri->sys_args[1],
4925 			    (long)pri->sys_args[2]);
4926 		break;
4927 	case SYS_recvfrom:
4928 		if (!err && pri->sys_nargs > 5)
4929 			show_sockaddr(pri, "from", (long)pri->sys_args[4],
4930 				(long)pri->sys_args[5], 0);
4931 		break;
4932 	case SYS_recvmsg:
4933 		if (err)
4934 			break;
4935 		/* FALLTHROUGH */
4936 	case SYS_sendmsg:
4937 		if (pri->sys_nargs <= 2)
4938 			break;
4939 #ifdef _LP64
4940 		if (lp64)
4941 			show_msghdr(pri, pri->sys_args[1]);
4942 		else
4943 			show_msghdr32(pri, pri->sys_args[1]);
4944 #else
4945 		show_msghdr(pri, pri->sys_args[1]);
4946 #endif
4947 		break;
4948 	case SYS_door:
4949 		show_doors(pri);
4950 		break;
4951 	case SYS_sendfilev:
4952 		if (pri->sys_nargs != 5)
4953 			break;
4954 
4955 		if (pri->sys_args[0] == SENDFILEV) {
4956 			show_sendfilevec(pri, (int)pri->sys_args[1],
4957 				(sendfilevec_t *)pri->sys_args[2],
4958 				(int)pri->sys_args[3]);
4959 		} else if (pri->sys_args[0] == SENDFILEV64) {
4960 			show_sendfilevec64(pri, (int)pri->sys_args[1],
4961 				(sendfilevec64_t *)pri->sys_args[2],
4962 				(int)pri->sys_args[3]);
4963 		}
4964 		break;
4965 	case SYS_memcntl:
4966 		show_memcntl(pri);
4967 		break;
4968 	case SYS_lwp_park:
4969 		/* subcode 0: lwp_park(timespec_t *, id_t) */
4970 		if (pri->sys_nargs > 1 && pri->sys_args[0] == 0)
4971 			show_timestruc(pri, (long)pri->sys_args[1], "timeout");
4972 		/* subcode 2: lwp_unpark_all(id_t *, int) */
4973 		if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
4974 			show_ids(pri, (long)pri->sys_args[1],
4975 				(int)pri->sys_args[2]);
4976 		break;
4977 	case SYS_ntp_gettime:
4978 		if (!err)
4979 			show_ntp_gettime(pri);
4980 		break;
4981 	case SYS_ntp_adjtime:
4982 		if (!err)
4983 			show_ntp_adjtime(pri);
4984 		break;
4985 	case SYS_rusagesys:
4986 		if (!err)
4987 			if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
4988 #ifdef _LP64
4989 				if (!lp64)
4990 				    show_getrusage32(pri->sys_args[1]);
4991 				else
4992 #endif
4993 				    show_getrusage(pri->sys_args[1]);
4994 			}
4995 		break;
4996 	case SYS_port:
4997 		show_ports(pri);
4998 		break;
4999 
5000 	case SYS_zone:
5001 		show_zones(pri);
5002 		break;
5003 	}
5004 }
5005