kill tsol ("Trusted Solaris") aka TX ("Trusted Extensions")
[unleashed.git] / usr / src / cmd / truss / expound.c
blobbb0619e8405940a833cda2132f61dab4a1c62f9b
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
26 * Copyright 2015 Joyent, Inc.
29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
30 /* All Rights Reserved */
32 #define _SYSCALL32
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <unistd.h>
37 #include <ctype.h>
38 #include <sys/types.h>
39 #include <sys/mman.h>
40 #include <libproc.h>
41 #include <string.h>
42 #include <limits.h>
43 #include <sys/statfs.h>
44 #include <sys/times.h>
45 #include <sys/timex.h>
46 #include <sys/utssys.h>
47 #include <sys/utsname.h>
48 #include <sys/ipc.h>
49 #include <sys/ipc_impl.h>
50 #include <sys/msg.h>
51 #include <sys/msg_impl.h>
52 #include <sys/sem.h>
53 #include <sys/sem_impl.h>
54 #include <sys/shm.h>
55 #include <sys/shm_impl.h>
56 #include <sys/dirent.h>
57 #include <ustat.h>
58 #include <fcntl.h>
59 #include <time.h>
60 #include <sys/termios.h>
61 #include <sys/termiox.h>
62 #include <sys/termio.h>
63 #include <sys/ttold.h>
64 #include <sys/jioctl.h>
65 #include <sys/filio.h>
66 #include <stropts.h>
67 #include <poll.h>
68 #include <sys/uio.h>
69 #include <sys/resource.h>
70 #include <sys/statvfs.h>
71 #include <sys/time.h>
72 #include <sys/aio.h>
73 #include <sys/socket.h>
74 #include <netinet/in.h>
75 #include <sys/un.h>
76 #include <sys/byteorder.h>
77 #include <arpa/inet.h>
78 #include <sys/audioio.h>
79 #include <sys/cladm.h>
80 #include <sys/synch.h>
81 #include <sys/synch32.h>
82 #include <sys/sysmacros.h>
83 #include <sys/sendfile.h>
84 #include <priv.h>
85 #include <ucred.h>
86 #include <sys/ucred.h>
87 #include <sys/port_impl.h>
88 #include <sys/zone.h>
89 #include <sys/priv_impl.h>
90 #include <sys/priv.h>
91 #include <sys/nvpair.h>
92 #include <libnvpair.h>
93 #include <sys/rctl_impl.h>
94 #include <sys/socketvar.h>
95 #include <sys/fs/zfs.h>
96 #include <sys/zfs_ioctl.h>
98 #include "ramdata.h"
99 #include "systable.h"
100 #include "proto.h"
102 void show_sigset(private_t *, long, const char *);
103 void show_ioctl(private_t *, int, long);
104 void show_zfs_ioc(private_t *, long);
106 static void
107 mk_ctime(char *str, size_t maxsize, time_t value)
109 (void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
110 localtime(&value));
113 void
114 prtime(private_t *pri, const char *name, time_t value)
116 char str[80];
118 mk_ctime(str, sizeof (str), value);
119 (void) printf("%s\t%s%s [ %lu ]\n",
120 pri->pname,
121 name,
122 str,
123 value);
126 void
127 prtimeval(private_t *pri, const char *name, struct timeval *value)
129 char str[80];
131 mk_ctime(str, sizeof (str), value->tv_sec);
132 (void) printf("%s\t%s%s [ %lu.%6.6lu ]\n",
133 pri->pname,
134 name,
135 str,
136 value->tv_sec,
137 value->tv_usec);
140 void
141 prtimestruc(private_t *pri, const char *name, timestruc_t *value)
143 char str[80];
145 mk_ctime(str, sizeof (str), value->tv_sec);
146 (void) printf("%s\t%s%s [ %lu.%9.9lu ]\n",
147 pri->pname,
148 name,
149 str,
150 value->tv_sec,
151 value->tv_nsec);
154 static void
155 show_utimens(private_t *pri, long offset)
157 struct {
158 timespec_t atime;
159 timespec_t mtime;
160 } utimbuf;
162 if (offset == 0)
163 return;
165 if (data_model == PR_MODEL_NATIVE) {
166 if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
167 != sizeof (utimbuf))
168 return;
169 } else {
170 struct {
171 timespec32_t atime;
172 timespec32_t mtime;
173 } utimbuf32;
175 if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
176 != sizeof (utimbuf32))
177 return;
179 TIMESPEC32_TO_TIMESPEC(&utimbuf.atime, &utimbuf32.atime);
180 TIMESPEC32_TO_TIMESPEC(&utimbuf.mtime, &utimbuf32.mtime);
183 /* print access and modification times */
184 if (utimbuf.atime.tv_nsec == UTIME_OMIT)
185 (void) printf("%s\tat = UTIME_OMIT\n", pri->pname);
186 else if (utimbuf.atime.tv_nsec == UTIME_NOW)
187 (void) printf("%s\tat = UTIME_NOW\n", pri->pname);
188 else
189 prtimestruc(pri, "at = ", &utimbuf.atime);
190 if (utimbuf.mtime.tv_nsec == UTIME_OMIT)
191 (void) printf("%s\tmt = UTIME_OMIT\n", pri->pname);
192 else if (utimbuf.mtime.tv_nsec == UTIME_NOW)
193 (void) printf("%s\tmt = UTIME_NOW\n", pri->pname);
194 else
195 prtimestruc(pri, "mt = ", &utimbuf.mtime);
198 void
199 show_timeofday(private_t *pri)
201 struct timeval tod;
202 long offset;
204 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
205 return;
207 if (data_model == PR_MODEL_NATIVE) {
208 if (Pread(Proc, &tod, sizeof (tod), offset)
209 != sizeof (tod))
210 return;
211 } else {
212 struct timeval32 tod32;
214 if (Pread(Proc, &tod32, sizeof (tod32), offset)
215 != sizeof (tod32))
216 return;
218 TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
221 prtimeval(pri, "time: ", &tod);
224 void
225 show_itimerval(private_t *pri, long offset, const char *name)
227 struct itimerval itimerval;
229 if (offset == 0)
230 return;
232 if (data_model == PR_MODEL_NATIVE) {
233 if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
234 != sizeof (itimerval))
235 return;
236 } else {
237 struct itimerval32 itimerval32;
239 if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
240 != sizeof (itimerval32))
241 return;
243 ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
246 (void) printf(
247 "%s\t%s: interval: %4ld.%6.6ld sec value: %4ld.%6.6ld sec\n",
248 pri->pname,
249 name,
250 itimerval.it_interval.tv_sec,
251 itimerval.it_interval.tv_usec,
252 itimerval.it_value.tv_sec,
253 itimerval.it_value.tv_usec);
256 void
257 show_timeval(private_t *pri, long offset, const char *name)
259 struct timeval timeval;
261 if (offset == 0)
262 return;
264 if (data_model == PR_MODEL_NATIVE) {
265 if (Pread(Proc, &timeval, sizeof (timeval), offset)
266 != sizeof (timeval))
267 return;
268 } else {
269 struct timeval32 timeval32;
271 if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
272 != sizeof (timeval32))
273 return;
275 TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
278 (void) printf(
279 "%s\t%s: %ld.%6.6ld sec\n",
280 pri->pname,
281 name,
282 timeval.tv_sec,
283 timeval.tv_usec);
286 void
287 show_timestruc(private_t *pri, long offset, const char *name)
289 timestruc_t timestruc;
291 if (offset == 0)
292 return;
294 if (data_model == PR_MODEL_NATIVE) {
295 if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
296 != sizeof (timestruc))
297 return;
298 } else {
299 timestruc32_t timestruc32;
301 if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
302 != sizeof (timestruc32))
303 return;
305 TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
308 (void) printf(
309 "%s\t%s: %ld.%9.9ld sec\n",
310 pri->pname,
311 name,
312 timestruc.tv_sec,
313 timestruc.tv_nsec);
316 void
317 show_stime(private_t *pri)
319 if (pri->sys_nargs >= 1) {
320 /* print new system time */
321 prtime(pri, "systime = ", (time_t)pri->sys_args[0]);
325 void
326 show_times(private_t *pri)
328 long hz = sysconf(_SC_CLK_TCK);
329 long offset;
330 struct tms tms;
332 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
333 return;
335 if (data_model == PR_MODEL_NATIVE) {
336 if (Pread(Proc, &tms, sizeof (tms), offset)
337 != sizeof (tms))
338 return;
339 } else {
340 struct tms32 tms32;
342 if (Pread(Proc, &tms32, sizeof (tms32), offset)
343 != sizeof (tms32))
344 return;
347 * This looks a bit odd (since the values are actually
348 * signed), but we need to suppress sign extension to
349 * preserve compatibility (we've always printed these
350 * numbers as unsigned quantities).
352 tms.tms_utime = (unsigned)tms32.tms_utime;
353 tms.tms_stime = (unsigned)tms32.tms_stime;
354 tms.tms_cutime = (unsigned)tms32.tms_cutime;
355 tms.tms_cstime = (unsigned)tms32.tms_cstime;
358 (void) printf(
359 "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
360 pri->pname,
361 tms.tms_utime,
362 tms.tms_stime,
363 tms.tms_cutime,
364 tms.tms_cstime,
365 hz);
368 void
369 show_uname(private_t *pri, long offset)
372 * Old utsname buffer (no longer accessible in <sys/utsname.h>).
374 struct {
375 char sysname[9];
376 char nodename[9];
377 char release[9];
378 char version[9];
379 char machine[9];
380 } ubuf;
382 if (offset != NULL &&
383 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
384 (void) printf(
385 "%s\tsys=%-9.9snod=%-9.9srel=%-9.9sver=%-9.9smch=%.9s\n",
386 pri->pname,
387 ubuf.sysname,
388 ubuf.nodename,
389 ubuf.release,
390 ubuf.version,
391 ubuf.machine);
395 /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
396 void
397 show_ustat(private_t *pri, long offset)
399 struct ustat ubuf;
401 if (offset != NULL &&
402 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
403 (void) printf(
404 "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
405 pri->pname,
406 ubuf.f_tfree,
407 ubuf.f_tinode,
408 ubuf.f_fname,
409 ubuf.f_fpack);
413 #ifdef _LP64
414 void
415 show_ustat32(private_t *pri, long offset)
417 struct ustat32 ubuf;
419 if (offset != NULL &&
420 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
421 (void) printf(
422 "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
423 pri->pname,
424 ubuf.f_tfree,
425 ubuf.f_tinode,
426 ubuf.f_fname,
427 ubuf.f_fpack);
430 #endif /* _LP64 */
432 void
433 show_fusers(private_t *pri, long offset, long nproc)
435 f_user_t fubuf;
436 int serial = (nproc > 4);
438 if (offset == 0)
439 return;
441 /* enter region of lengthy output */
442 if (serial)
443 Eserialize();
445 while (nproc > 0 &&
446 Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
447 (void) printf("%s\tpid=%-5d uid=%-5u flags=%s\n",
448 pri->pname,
449 (int)fubuf.fu_pid,
450 fubuf.fu_uid,
451 fuflags(pri, fubuf.fu_flags));
452 nproc--;
453 offset += sizeof (fubuf);
456 /* exit region of lengthy output */
457 if (serial)
458 Xserialize();
461 void
462 show_utssys(private_t *pri, long r0)
464 if (pri->sys_nargs >= 3) {
465 switch (pri->sys_args[2]) {
466 case UTS_UNAME:
467 show_uname(pri, (long)pri->sys_args[0]);
468 break;
469 case UTS_USTAT:
470 show_ustat(pri, (long)pri->sys_args[0]);
471 break;
472 case UTS_FUSERS:
473 show_fusers(pri, (long)pri->sys_args[3], r0);
474 break;
479 #ifdef _LP64
480 void
481 show_utssys32(private_t *pri, long r0)
483 if (pri->sys_nargs >= 3) {
484 switch (pri->sys_args[2]) {
485 case UTS_UNAME:
486 show_uname(pri, (long)pri->sys_args[0]);
487 break;
488 case UTS_USTAT:
489 show_ustat32(pri, (long)pri->sys_args[0]);
490 break;
491 case UTS_FUSERS:
492 show_fusers(pri, (long)pri->sys_args[3], r0);
493 break;
497 #endif /* _LP64 */
499 void
500 show_cladm(private_t *pri, int code, int function, long offset)
502 int arg;
504 switch (code) {
505 case CL_INITIALIZE:
506 switch (function) {
507 case CL_GET_BOOTFLAG:
508 if (Pread(Proc, &arg, sizeof (arg), offset)
509 == sizeof (arg)) {
510 if (arg & CLUSTER_CONFIGURED)
511 (void) printf("%s\tbootflags="
512 "CLUSTER_CONFIGURED", pri->pname);
513 if (arg & CLUSTER_BOOTED)
514 (void) printf("|CLUSTER_BOOTED\n");
516 break;
518 break;
519 case CL_CONFIG:
520 switch (function) {
521 case CL_NODEID:
522 case CL_HIGHEST_NODEID:
523 if (Pread(Proc, &arg, sizeof (arg), offset)
524 == sizeof (arg))
525 (void) printf("%s\tnodeid=%d\n",
526 pri->pname, arg);
528 break;
532 #define ALL_LOCK_TYPES \
533 (USYNC_PROCESS | LOCK_ERRORCHECK | LOCK_RECURSIVE | \
534 LOCK_PRIO_INHERIT | LOCK_PRIO_PROTECT | LOCK_ROBUST | \
535 USYNC_PROCESS_ROBUST)
537 /* return cv and mutex types */
538 const char *
539 synch_type(private_t *pri, uint_t type)
541 char *str = pri->code_buf;
543 if (type & USYNC_PROCESS)
544 (void) strcpy(str, "USYNC_PROCESS");
545 else
546 (void) strcpy(str, "USYNC_THREAD");
548 if (type & LOCK_ERRORCHECK)
549 (void) strcat(str, "|LOCK_ERRORCHECK");
550 if (type & LOCK_RECURSIVE)
551 (void) strcat(str, "|LOCK_RECURSIVE");
552 if (type & LOCK_PRIO_INHERIT)
553 (void) strcat(str, "|LOCK_PRIO_INHERIT");
554 if (type & LOCK_PRIO_PROTECT)
555 (void) strcat(str, "|LOCK_PRIO_PROTECT");
556 if (type & LOCK_ROBUST)
557 (void) strcat(str, "|LOCK_ROBUST");
558 if (type & USYNC_PROCESS_ROBUST)
559 (void) strcat(str, "|USYNC_PROCESS_ROBUST");
561 if ((type &= ~ALL_LOCK_TYPES) != 0)
562 (void) sprintf(str + strlen(str), "|0x%.4X", type);
564 return ((const char *)str);
567 void
568 show_mutex(private_t *pri, long offset)
570 lwp_mutex_t mutex;
572 if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
573 (void) printf("%s\tmutex type: %s\n",
574 pri->pname,
575 synch_type(pri, mutex.mutex_type));
579 void
580 show_condvar(private_t *pri, long offset)
582 lwp_cond_t condvar;
584 if (Pread(Proc, &condvar, sizeof (condvar), offset)
585 == sizeof (condvar)) {
586 (void) printf("%s\tcondvar type: %s\n",
587 pri->pname,
588 synch_type(pri, condvar.cond_type));
592 void
593 show_sema(private_t *pri, long offset)
595 lwp_sema_t sema;
597 if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
598 (void) printf("%s\tsema type: %s count = %u\n",
599 pri->pname,
600 synch_type(pri, sema.sema_type),
601 sema.sema_count);
605 void
606 show_rwlock(private_t *pri, long offset)
608 lwp_rwlock_t rwlock;
610 if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
611 (void) printf("%s\trwlock type: %s readers = %d\n",
612 pri->pname,
613 synch_type(pri, rwlock.rwlock_type),
614 rwlock.rwlock_readers);
618 /* represent character as itself ('c') or octal (012) */
619 char *
620 show_char(char *buf, int c)
622 const char *fmt;
624 if (c >= ' ' && c < 0177)
625 fmt = "'%c'";
626 else
627 fmt = "%.3o";
629 (void) sprintf(buf, fmt, c&0xff);
630 return (buf);
633 void
634 show_termio(private_t *pri, long offset)
636 struct termio termio;
637 char cbuf[8];
638 int i;
640 if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
641 (void) printf(
642 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
643 pri->pname,
644 termio.c_iflag,
645 termio.c_oflag,
646 termio.c_cflag,
647 termio.c_lflag,
648 termio.c_line);
649 (void) printf("%s\t cc: ", pri->pname);
650 for (i = 0; i < NCC; i++)
651 (void) printf(" %s",
652 show_char(cbuf, (int)termio.c_cc[i]));
653 (void) fputc('\n', stdout);
657 void
658 show_termios(private_t *pri, long offset)
660 struct termios termios;
661 char cbuf[8];
662 int i;
664 if (Pread(Proc, &termios, sizeof (termios), offset)
665 == sizeof (termios)) {
666 (void) printf(
667 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
668 pri->pname,
669 termios.c_iflag,
670 termios.c_oflag,
671 termios.c_cflag,
672 termios.c_lflag);
673 (void) printf("%s\t cc: ", pri->pname);
674 for (i = 0; i < NCCS; i++) {
675 if (i == NCC) /* show new chars on new line */
676 (void) printf("\n%s\t\t", pri->pname);
677 (void) printf(" %s",
678 show_char(cbuf, (int)termios.c_cc[i]));
680 (void) fputc('\n', stdout);
684 void
685 show_termiox(private_t *pri, long offset)
687 struct termiox termiox;
688 int i;
690 if (Pread(Proc, &termiox, sizeof (termiox), offset)
691 == sizeof (termiox)) {
692 (void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
693 pri->pname,
694 termiox.x_hflag,
695 termiox.x_cflag,
696 termiox.x_rflag[0]);
697 for (i = 1; i < NFF; i++)
698 (void) printf(",0%.3o", termiox.x_rflag[i]);
699 (void) printf(" sflag=0%.3o\n",
700 termiox.x_sflag);
704 void
705 show_sgttyb(private_t *pri, long offset)
707 struct sgttyb sgttyb;
709 if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
710 char erase[8];
711 char kill[8];
713 (void) printf(
714 "%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
715 pri->pname,
716 sgttyb.sg_ispeed&0xff,
717 sgttyb.sg_ospeed&0xff,
718 show_char(erase, sgttyb.sg_erase),
719 show_char(kill, sgttyb.sg_kill),
720 sgttyb.sg_flags);
724 void
725 show_ltchars(private_t *pri, long offset)
727 struct ltchars ltchars;
728 char *p;
729 char cbuf[8];
730 int i;
732 if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
733 == sizeof (ltchars)) {
734 (void) printf("%s\t cc: ", pri->pname);
735 for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
736 (void) printf(" %s", show_char(cbuf, (int)*p++));
737 (void) fputc('\n', stdout);
741 void
742 show_tchars(private_t *pri, long offset)
744 struct tchars tchars;
745 char *p;
746 char cbuf[8];
747 int i;
749 if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) {
750 (void) printf("%s\t cc: ", pri->pname);
751 for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++)
752 (void) printf(" %s", show_char(cbuf, (int)*p++));
753 (void) fputc('\n', stdout);
757 void
758 show_termcb(private_t *pri, long offset)
760 struct termcb termcb;
762 if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
763 (void) printf(
764 "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
765 pri->pname,
766 termcb.st_flgs&0xff,
767 termcb.st_termt&0xff,
768 termcb.st_crow&0xff,
769 termcb.st_ccol&0xff,
770 termcb.st_vrow&0xff,
771 termcb.st_lrow&0xff);
775 /* integer value pointed to by ioctl() arg */
776 void
777 show_strint(private_t *pri, int code, long offset)
779 int val;
781 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
782 const char *s = NULL;
784 switch (code) { /* interpret these symbolically */
785 case I_GRDOPT:
786 s = strrdopt(val);
787 break;
788 case I_GETSIG:
789 s = strevents(pri, val);
790 break;
791 case TIOCFLUSH:
792 s = tiocflush(pri, val);
793 break;
796 if (s == NULL)
797 (void) printf("%s\t0x%.8lX: %d\n",
798 pri->pname, offset, val);
799 else
800 (void) printf("%s\t0x%.8lX: %s\n",
801 pri->pname, offset, s);
805 void
806 show_strioctl(private_t *pri, long offset)
808 struct strioctl strioctl;
810 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
811 sizeof (strioctl)) {
812 (void) printf(
813 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
814 pri->pname,
815 ioctlname(pri, strioctl.ic_cmd),
816 strioctl.ic_timout,
817 strioctl.ic_len,
818 (long)strioctl.ic_dp);
820 if (pri->recur++ == 0) /* avoid indefinite recursion */
821 show_ioctl(pri, strioctl.ic_cmd,
822 (long)strioctl.ic_dp);
823 --pri->recur;
827 #ifdef _LP64
828 void
829 show_strioctl32(private_t *pri, long offset)
831 struct strioctl32 strioctl;
833 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
834 sizeof (strioctl)) {
835 (void) printf(
836 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
837 pri->pname,
838 ioctlname(pri, strioctl.ic_cmd),
839 strioctl.ic_timout,
840 strioctl.ic_len,
841 (long)strioctl.ic_dp);
843 if (pri->recur++ == 0) /* avoid indefinite recursion */
844 show_ioctl(pri, strioctl.ic_cmd,
845 (long)strioctl.ic_dp);
846 --pri->recur;
849 #endif /* _LP64 */
851 void
852 print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
854 (void) printf(
855 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
856 pri->pname,
857 name,
858 sp->maxlen,
859 sp->len,
860 (long)sp->buf);
862 * Should we show the buffer contents?
863 * Keyed to the '-r fds' and '-w fds' options?
865 if (sp->buf == NULL || sp->len <= 0)
866 (void) fputc('\n', stdout);
867 else {
868 int nb = (sp->len > 8)? 8 : sp->len;
869 char buffer[8];
870 char obuf[40];
872 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
873 (void) strcpy(obuf, ": \"");
874 showbytes(buffer, nb, obuf+3);
875 (void) strcat(obuf,
876 (nb == sp->len)?
877 (const char *)"\"" : (const char *)"\"..");
878 (void) fputs(obuf, stdout);
880 (void) fputc('\n', stdout);
881 if (dump && sp->len > 8)
882 showbuffer(pri, (long)sp->buf, (long)sp->len);
886 #ifdef _LP64
887 void
888 print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
890 (void) printf(
891 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
892 pri->pname,
893 name,
894 sp->maxlen,
895 sp->len,
896 (long)sp->buf);
898 * Should we show the buffer contents?
899 * Keyed to the '-r fds' and '-w fds' options?
901 if (sp->buf == NULL || sp->len <= 0)
902 (void) fputc('\n', stdout);
903 else {
904 int nb = (sp->len > 8)? 8 : sp->len;
905 char buffer[8];
906 char obuf[40];
908 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
909 (void) strcpy(obuf, ": \"");
910 showbytes(buffer, nb, obuf+3);
911 (void) strcat(obuf,
912 (nb == sp->len)?
913 (const char *)"\"" : (const char *)"\"..");
914 (void) fputs(obuf, stdout);
916 (void) fputc('\n', stdout);
917 if (dump && sp->len > 8)
918 showbuffer(pri, (long)sp->buf, (long)sp->len);
921 #endif /* _LP64 */
923 /* strpeek and strfdinsert flags word */
924 const char *
925 strflags(private_t *pri, int flags)
927 const char *s;
929 switch (flags) {
930 case 0:
931 s = "0";
932 break;
933 case RS_HIPRI:
934 s = "RS_HIPRI";
935 break;
936 default:
937 (void) sprintf(pri->code_buf, "0x%.4X", flags);
938 s = pri->code_buf;
941 return (s);
944 void
945 show_strpeek(private_t *pri, long offset)
947 struct strpeek strpeek;
949 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
950 == sizeof (strpeek)) {
952 print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
953 print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
955 (void) printf("%s\tflags=%s\n",
956 pri->pname,
957 strflags(pri, strpeek.flags));
961 #ifdef _LP64
962 void
963 show_strpeek32(private_t *pri, long offset)
965 struct strpeek32 strpeek;
967 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
968 == sizeof (strpeek)) {
970 print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
971 print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
973 (void) printf("%s\tflags=%s\n",
974 pri->pname,
975 strflags(pri, strpeek.flags));
978 #endif /* _LP64 */
980 void
981 show_strfdinsert(private_t *pri, long offset)
983 struct strfdinsert strfdinsert;
985 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
986 sizeof (strfdinsert)) {
988 print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
989 print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
991 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
992 pri->pname,
993 strflags(pri, strfdinsert.flags),
994 strfdinsert.fildes,
995 strfdinsert.offset);
999 #ifdef _LP64
1000 void
1001 show_strfdinsert32(private_t *pri, long offset)
1003 struct strfdinsert32 strfdinsert;
1005 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
1006 sizeof (strfdinsert)) {
1008 print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
1009 print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
1011 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
1012 pri->pname,
1013 strflags(pri, strfdinsert.flags),
1014 strfdinsert.fildes,
1015 strfdinsert.offset);
1018 #endif /* _LP64 */
1020 void
1021 show_strrecvfd(private_t *pri, long offset)
1023 struct strrecvfd strrecvfd;
1025 if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
1026 sizeof (strrecvfd)) {
1027 (void) printf(
1028 "%s\tfd=%-5d uid=%-5u gid=%u\n",
1029 pri->pname,
1030 strrecvfd.fd,
1031 strrecvfd.uid,
1032 strrecvfd.gid);
1036 void
1037 show_strlist(private_t *pri, long offset)
1039 struct str_list strlist;
1040 struct str_mlist list;
1041 int count;
1043 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1044 sizeof (strlist)) {
1045 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
1046 pri->pname,
1047 strlist.sl_nmods,
1048 (long)strlist.sl_modlist);
1050 count = strlist.sl_nmods;
1051 offset = (long)strlist.sl_modlist;
1052 while (!interrupt && --count >= 0) {
1053 if (Pread(Proc, &list, sizeof (list), offset) !=
1054 sizeof (list))
1055 break;
1056 (void) printf("%s\t\t\"%.*s\"\n",
1057 pri->pname,
1058 (int)sizeof (list.l_name),
1059 list.l_name);
1060 offset += sizeof (struct str_mlist);
1065 #ifdef _LP64
1066 void
1067 show_strlist32(private_t *pri, long offset)
1069 struct str_list32 strlist;
1070 struct str_mlist list;
1071 int count;
1073 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1074 sizeof (strlist)) {
1075 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
1076 pri->pname,
1077 strlist.sl_nmods,
1078 (long)strlist.sl_modlist);
1080 count = strlist.sl_nmods;
1081 offset = (long)strlist.sl_modlist;
1082 while (!interrupt && --count >= 0) {
1083 if (Pread(Proc, &list, sizeof (list), offset) !=
1084 sizeof (list))
1085 break;
1086 (void) printf("%s\t\t\"%.*s\"\n",
1087 pri->pname,
1088 (int)sizeof (list.l_name),
1089 list.l_name);
1090 offset += sizeof (struct str_mlist);
1094 #endif /* _LP64 */
1096 void
1097 show_jwinsize(private_t *pri, long offset)
1099 struct jwinsize jwinsize;
1101 if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
1102 sizeof (jwinsize)) {
1103 (void) printf(
1104 "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1105 pri->pname,
1106 (unsigned)jwinsize.bytesx,
1107 (unsigned)jwinsize.bytesy,
1108 (unsigned)jwinsize.bitsx,
1109 (unsigned)jwinsize.bitsy);
1113 void
1114 show_winsize(private_t *pri, long offset)
1116 struct winsize winsize;
1118 if (Pread(Proc, &winsize, sizeof (winsize), offset)
1119 == sizeof (winsize)) {
1120 (void) printf(
1121 "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1122 pri->pname,
1123 winsize.ws_row,
1124 winsize.ws_col,
1125 winsize.ws_xpixel,
1126 winsize.ws_ypixel);
1130 struct audio_stuff {
1131 uint_t bit;
1132 const char *str;
1135 const struct audio_stuff audio_output_ports[] = {
1136 { AUDIO_SPEAKER, "SPEAKER" },
1137 { AUDIO_HEADPHONE, "HEADPHONE" },
1138 { AUDIO_LINE_OUT, "LINE_OUT" },
1139 { AUDIO_SPDIF_OUT, "SPDIF_OUT" },
1140 { AUDIO_AUX1_OUT, "AUX1_OUT" },
1141 { AUDIO_AUX2_OUT, "AUX2_OUT" },
1142 { 0, NULL }
1145 const struct audio_stuff audio_input_ports[] = {
1146 { AUDIO_MICROPHONE, "MICROPHONE" },
1147 { AUDIO_LINE_IN, "LINE_IN" },
1148 { AUDIO_CD, "CD" },
1149 { AUDIO_SPDIF_IN, "SPDIF_IN" },
1150 { AUDIO_AUX1_IN, "AUX1_IN" },
1151 { AUDIO_AUX2_IN, "AUX2_IN" },
1152 { AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
1153 { AUDIO_SUNVTS, "SUNVTS" },
1154 { 0, NULL }
1157 static const struct audio_stuff audio_hw_features[] = {
1158 { AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
1159 { AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
1160 { AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
1161 { AUDIO_HWFEATURE_PLAY, "PLAY" },
1162 { AUDIO_HWFEATURE_RECORD, "RECORD" },
1163 { 0, NULL }
1166 static const struct audio_stuff audio_sw_features[] = {
1167 { AUDIO_SWFEATURE_MIXER, "MIXER" },
1168 { 0, NULL }
1171 void
1172 show_audio_features(const private_t *pri,
1173 const struct audio_stuff *audio_porttab, uint_t features,
1174 const char *name)
1176 (void) printf("%s\t%s=", pri->pname, name);
1177 if (features == 0) {
1178 (void) printf("0\n");
1179 return;
1182 for (; audio_porttab->bit != 0; ++audio_porttab) {
1183 if (features & audio_porttab->bit) {
1184 (void) printf(audio_porttab->str);
1185 features &= ~audio_porttab->bit;
1186 if (features)
1187 (void) putchar('|');
1190 if (features)
1191 (void) printf("0x%x", features);
1192 (void) putchar('\n');
1195 void
1196 show_audio_ports(private_t *pri, const char *mode,
1197 const char *field, uint_t ports)
1199 const struct audio_stuff *audio_porttab;
1201 (void) printf("%s\t%s\t%s=", pri->pname, mode, field);
1202 if (ports == 0) {
1203 (void) printf("0\n");
1204 return;
1206 if (*mode == 'p')
1207 audio_porttab = audio_output_ports;
1208 else
1209 audio_porttab = audio_input_ports;
1210 for (; audio_porttab->bit != 0; ++audio_porttab) {
1211 if (ports & audio_porttab->bit) {
1212 (void) printf(audio_porttab->str);
1213 ports &= ~audio_porttab->bit;
1214 if (ports)
1215 (void) putchar('|');
1218 if (ports)
1219 (void) printf("0x%x", ports);
1220 (void) putchar('\n');
1223 void
1224 show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
1226 const char *s;
1229 * The following values describe the audio data encoding.
1232 (void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1233 pri->pname, mode,
1234 au_pr->sample_rate,
1235 au_pr->channels,
1236 au_pr->precision);
1238 s = NULL;
1239 switch (au_pr->encoding) {
1240 case AUDIO_ENCODING_NONE: s = "NONE"; break;
1241 case AUDIO_ENCODING_ULAW: s = "ULAW"; break;
1242 case AUDIO_ENCODING_ALAW: s = "ALAW"; break;
1243 case AUDIO_ENCODING_LINEAR: s = "LINEAR"; break;
1244 case AUDIO_ENCODING_DVI: s = "DVI"; break;
1245 case AUDIO_ENCODING_LINEAR8: s = "LINEAR8"; break;
1247 if (s)
1248 (void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
1249 else {
1250 (void) printf("%s\t%s\tencoding=%u\n",
1251 pri->pname, mode, au_pr->encoding);
1255 * The following values control audio device configuration
1258 (void) printf(
1259 "%s\t%s\tgain=%u buffer_size=%u\n",
1260 pri->pname, mode,
1261 au_pr->gain,
1262 au_pr->buffer_size);
1263 show_audio_ports(pri, mode, "port", au_pr->port);
1264 show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
1265 show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
1268 * The following values describe driver state
1271 (void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1272 pri->pname, mode,
1273 au_pr->samples,
1274 au_pr->eof,
1275 au_pr->pause,
1276 au_pr->error);
1277 (void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1278 pri->pname, mode,
1279 au_pr->waiting,
1280 au_pr->balance,
1281 au_pr->minordev);
1284 * The following values are read-only state flags
1286 (void) printf("%s\t%s\topen=%u active=%u\n",
1287 pri->pname, mode,
1288 au_pr->open,
1289 au_pr->active);
1292 void
1293 show_audio_info(private_t *pri, long offset)
1295 struct audio_info au;
1297 if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
1298 show_audio_prinfo(pri, "play", &au.play);
1299 show_audio_prinfo(pri, "record", &au.record);
1300 (void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1301 pri->pname, au.monitor_gain, au.output_muted);
1302 show_audio_features(pri, audio_hw_features, au.hw_features,
1303 "hw_features");
1304 show_audio_features(pri, audio_sw_features, au.sw_features,
1305 "sw_features");
1306 show_audio_features(pri, audio_sw_features,
1307 au.sw_features_enabled, "sw_features_enabled");
1311 void
1312 show_ioctl(private_t *pri, int code, long offset)
1314 int lp64 = (data_model == PR_MODEL_LP64);
1315 int err = pri->Errno; /* don't display output parameters */
1316 /* for a failed system call */
1317 #ifndef _LP64
1318 if (lp64)
1319 return;
1320 #endif
1321 if (offset == 0)
1322 return;
1324 switch (code) {
1325 case TCGETA:
1326 if (err)
1327 break;
1328 /*FALLTHROUGH*/
1329 case TCSETA:
1330 case TCSETAW:
1331 case TCSETAF:
1332 show_termio(pri, offset);
1333 break;
1334 case TCGETS:
1335 if (err)
1336 break;
1337 /*FALLTHROUGH*/
1338 case TCSETS:
1339 case TCSETSW:
1340 case TCSETSF:
1341 show_termios(pri, offset);
1342 break;
1343 case TCGETX:
1344 if (err)
1345 break;
1346 /*FALLTHROUGH*/
1347 case TCSETX:
1348 case TCSETXW:
1349 case TCSETXF:
1350 show_termiox(pri, offset);
1351 break;
1352 case TIOCGETP:
1353 if (err)
1354 break;
1355 /*FALLTHROUGH*/
1356 case TIOCSETN:
1357 case TIOCSETP:
1358 show_sgttyb(pri, offset);
1359 break;
1360 case TIOCGLTC:
1361 if (err)
1362 break;
1363 /*FALLTHROUGH*/
1364 case TIOCSLTC:
1365 show_ltchars(pri, offset);
1366 break;
1367 case TIOCGETC:
1368 if (err)
1369 break;
1370 /*FALLTHROUGH*/
1371 case TIOCSETC:
1372 show_tchars(pri, offset);
1373 break;
1374 case LDGETT:
1375 if (err)
1376 break;
1377 /*FALLTHROUGH*/
1378 case LDSETT:
1379 show_termcb(pri, offset);
1380 break;
1381 /* streams ioctl()s */
1382 #if 0
1383 /* these are displayed as strings in the arg list */
1384 /* by prt_ioa(). don't display them again here */
1385 case I_PUSH:
1386 case I_LOOK:
1387 case I_FIND:
1388 /* these are displayed as decimal in the arg list */
1389 /* by prt_ioa(). don't display them again here */
1390 case I_LINK:
1391 case I_UNLINK:
1392 case I_SENDFD:
1393 /* these are displayed symbolically in the arg list */
1394 /* by prt_ioa(). don't display them again here */
1395 case I_SRDOPT:
1396 case I_SETSIG:
1397 case I_FLUSH:
1398 break;
1399 /* this one just ignores the argument */
1400 case I_POP:
1401 break;
1402 #endif
1403 /* these return something in an int pointed to by arg */
1404 case I_NREAD:
1405 case I_GRDOPT:
1406 case I_GETSIG:
1407 case TIOCGSID:
1408 case TIOCGPGRP:
1409 case TIOCLGET:
1410 case FIONREAD:
1411 case FIORDCHK:
1412 if (err)
1413 break;
1414 /*FALLTHROUGH*/
1415 /* these pass something in an int pointed to by arg */
1416 case TIOCSPGRP:
1417 case TIOCFLUSH:
1418 case TIOCLBIS:
1419 case TIOCLBIC:
1420 case TIOCLSET:
1421 show_strint(pri, code, offset);
1422 break;
1423 /* these all point to structures */
1424 case I_STR:
1425 #ifdef _LP64
1426 if (lp64)
1427 show_strioctl(pri, offset);
1428 else
1429 show_strioctl32(pri, offset);
1430 #else
1431 show_strioctl(pri, offset);
1432 #endif
1433 break;
1434 case I_PEEK:
1435 #ifdef _LP64
1436 if (lp64)
1437 show_strpeek(pri, offset);
1438 else
1439 show_strpeek32(pri, offset);
1440 #else
1441 show_strpeek(pri, offset);
1442 #endif
1443 break;
1444 case I_FDINSERT:
1445 #ifdef _LP64
1446 if (lp64)
1447 show_strfdinsert(pri, offset);
1448 else
1449 show_strfdinsert32(pri, offset);
1450 #else
1451 show_strfdinsert(pri, offset);
1452 #endif
1453 break;
1454 case I_RECVFD:
1455 if (err)
1456 break;
1457 show_strrecvfd(pri, offset);
1458 break;
1459 case I_LIST:
1460 if (err)
1461 break;
1462 #ifdef _LP64
1463 if (lp64)
1464 show_strlist(pri, offset);
1465 else
1466 show_strlist32(pri, offset);
1467 #else
1468 show_strlist(pri, offset);
1469 #endif
1470 break;
1471 case JWINSIZE:
1472 if (err)
1473 break;
1474 show_jwinsize(pri, offset);
1475 break;
1476 case TIOCGWINSZ:
1477 if (err)
1478 break;
1479 /*FALLTHROUGH*/
1480 case TIOCSWINSZ:
1481 show_winsize(pri, offset);
1482 break;
1483 case AUDIO_GETINFO:
1484 case (int)AUDIO_SETINFO:
1485 show_audio_info(pri, offset);
1486 break;
1488 default:
1489 if ((code & ~0xff) == ZFS_IOC) {
1490 show_zfs_ioc(pri, offset);
1491 break;
1494 if (code & IOC_INOUT) {
1495 const char *str = ioctldatastruct(code);
1497 (void) printf("\t\t%s",
1498 (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1499 code & IOC_IN ? "write" : "read");
1500 if (str != NULL) {
1501 (void) printf(" (struct %s)\n", str);
1502 } else {
1503 (void) printf(" %d bytes\n",
1504 (code >> 16) & IOCPARM_MASK);
1510 void
1511 show_statvfs(private_t *pri)
1513 long offset;
1514 struct statvfs statvfs;
1515 char *cp;
1517 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1518 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1519 == sizeof (statvfs)) {
1520 (void) printf(
1521 "%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1522 pri->pname,
1523 statvfs.f_bsize,
1524 statvfs.f_frsize,
1525 (u_longlong_t)statvfs.f_blocks,
1526 (u_longlong_t)statvfs.f_bfree);
1527 (void) printf(
1528 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1529 pri->pname,
1530 (u_longlong_t)statvfs.f_bavail,
1531 (u_longlong_t)statvfs.f_files,
1532 (u_longlong_t)statvfs.f_ffree,
1533 (u_longlong_t)statvfs.f_favail);
1534 (void) printf(
1535 "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1536 pri->pname,
1537 statvfs.f_fsid,
1538 statvfs.f_basetype,
1539 (long)statvfs.f_namemax);
1540 (void) printf(
1541 "%s\tflag=%s\n",
1542 pri->pname,
1543 svfsflags(pri, (ulong_t)statvfs.f_flag));
1544 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1545 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1546 *(cp+1) != '\0')
1547 *cp = ' ';
1548 (void) printf("%s\tfstr=\"%.*s\"\n",
1549 pri->pname,
1550 (int)sizeof (statvfs.f_fstr),
1551 statvfs.f_fstr);
1555 #ifdef _LP64
1556 void
1557 show_statvfs32(private_t *pri)
1559 long offset;
1560 struct statvfs32 statvfs;
1561 char *cp;
1563 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1564 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1565 == sizeof (statvfs)) {
1566 (void) printf(
1567 "%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
1568 pri->pname,
1569 statvfs.f_bsize,
1570 statvfs.f_frsize,
1571 statvfs.f_blocks,
1572 statvfs.f_bfree);
1573 (void) printf(
1574 "%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
1575 pri->pname,
1576 statvfs.f_bavail,
1577 statvfs.f_files,
1578 statvfs.f_ffree,
1579 statvfs.f_favail);
1580 (void) printf(
1581 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1582 pri->pname,
1583 statvfs.f_fsid,
1584 statvfs.f_basetype,
1585 (int)statvfs.f_namemax);
1586 (void) printf(
1587 "%s\tflag=%s\n",
1588 pri->pname,
1589 svfsflags(pri, (ulong_t)statvfs.f_flag));
1590 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1591 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1592 *(cp+1) != '\0')
1593 *cp = ' ';
1594 (void) printf("%s\tfstr=\"%.*s\"\n",
1595 pri->pname,
1596 (int)sizeof (statvfs.f_fstr),
1597 statvfs.f_fstr);
1600 #endif /* _LP64 */
1602 void
1603 show_statvfs64(private_t *pri)
1605 long offset;
1606 struct statvfs64_32 statvfs;
1607 char *cp;
1609 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != NULL &&
1610 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1611 == sizeof (statvfs)) {
1612 (void) printf(
1613 "%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
1614 pri->pname,
1615 statvfs.f_bsize,
1616 statvfs.f_frsize,
1617 (u_longlong_t)statvfs.f_blocks,
1618 (u_longlong_t)statvfs.f_bfree);
1619 (void) printf(
1620 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1621 pri->pname,
1622 (u_longlong_t)statvfs.f_bavail,
1623 (u_longlong_t)statvfs.f_files,
1624 (u_longlong_t)statvfs.f_ffree,
1625 (u_longlong_t)statvfs.f_favail);
1626 (void) printf(
1627 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1628 pri->pname,
1629 statvfs.f_fsid,
1630 statvfs.f_basetype,
1631 (int)statvfs.f_namemax);
1632 (void) printf(
1633 "%s\tflag=%s\n",
1634 pri->pname,
1635 svfsflags(pri, (ulong_t)statvfs.f_flag));
1636 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1637 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1638 *(cp+1) != '\0')
1639 *cp = ' ';
1640 (void) printf("%s\tfstr=\"%.*s\"\n",
1641 pri->pname,
1642 (int)sizeof (statvfs.f_fstr),
1643 statvfs.f_fstr);
1647 void
1648 show_statfs(private_t *pri)
1650 long offset;
1651 struct statfs statfs;
1653 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
1654 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1655 (void) printf(
1656 "%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1657 pri->pname,
1658 statfs.f_fstyp,
1659 statfs.f_bsize,
1660 statfs.f_frsize,
1661 statfs.f_blocks,
1662 statfs.f_bfree,
1663 statfs.f_files,
1664 statfs.f_ffree);
1665 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1666 pri->pname,
1667 statfs.f_fname,
1668 statfs.f_fpack);
1672 #ifdef _LP64
1673 void
1674 show_statfs32(private_t *pri)
1676 long offset;
1677 struct statfs32 statfs;
1679 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL &&
1680 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1681 (void) printf(
1682 "%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
1683 pri->pname,
1684 statfs.f_fstyp,
1685 statfs.f_bsize,
1686 statfs.f_frsize,
1687 statfs.f_blocks,
1688 statfs.f_bfree,
1689 statfs.f_files,
1690 statfs.f_ffree);
1691 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1692 pri->pname,
1693 statfs.f_fname,
1694 statfs.f_fpack);
1697 #endif /* _LP64 */
1699 void
1700 show_flock32(private_t *pri, long offset)
1702 struct flock32 flock;
1704 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1705 const char *str = NULL;
1707 (void) printf("%s\ttyp=", pri->pname);
1709 switch (flock.l_type) {
1710 case F_RDLCK:
1711 str = "F_RDLCK";
1712 break;
1713 case F_WRLCK:
1714 str = "F_WRLCK";
1715 break;
1716 case F_UNLCK:
1717 str = "F_UNLCK";
1718 break;
1720 if (str != NULL)
1721 (void) printf("%s", str);
1722 else
1723 (void) printf("%-7d", flock.l_type);
1725 str = whencearg(flock.l_whence);
1726 if (str != NULL)
1727 (void) printf(" whence=%s", str);
1728 else
1729 (void) printf(" whence=%-8u", flock.l_whence);
1731 (void) printf(
1732 " start=%-5d len=%-5d sys=%-2u pid=%d\n",
1733 flock.l_start,
1734 flock.l_len,
1735 flock.l_sysid,
1736 flock.l_pid);
1740 void
1741 show_flock64(private_t *pri, long offset)
1743 struct flock64 flock;
1745 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1746 const char *str = NULL;
1748 (void) printf("%s\ttyp=", pri->pname);
1750 switch (flock.l_type) {
1751 case F_RDLCK:
1752 str = "F_RDLCK";
1753 break;
1754 case F_WRLCK:
1755 str = "F_WRLCK";
1756 break;
1757 case F_UNLCK:
1758 str = "F_UNLCK";
1759 break;
1761 if (str != NULL)
1762 (void) printf("%s", str);
1763 else
1764 (void) printf("%-7d", flock.l_type);
1766 str = whencearg(flock.l_whence);
1767 if (str != NULL)
1768 (void) printf(" whence=%s", str);
1769 else
1770 (void) printf(" whence=%-8u", flock.l_whence);
1772 (void) printf(
1773 " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1774 (long long)flock.l_start,
1775 (long long)flock.l_len,
1776 flock.l_sysid,
1777 (int)flock.l_pid);
1781 void
1782 show_share(private_t *pri, long offset)
1784 struct fshare fshare;
1786 if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
1787 const char *str = NULL;
1788 int manddny = 0;
1790 (void) printf("%s\taccess=", pri->pname);
1792 switch (fshare.f_access) {
1793 case F_RDACC:
1794 str = "F_RDACC";
1795 break;
1796 case F_WRACC:
1797 str = "F_WRACC";
1798 break;
1799 case F_RWACC:
1800 str = "F_RWACC";
1801 break;
1803 if (str != NULL)
1804 (void) printf("%s", str);
1805 else
1806 (void) printf("%-7d", fshare.f_access);
1808 str = NULL;
1809 if (fshare.f_deny & F_MANDDNY) {
1810 fshare.f_deny &= ~F_MANDDNY;
1811 manddny = 1;
1813 switch (fshare.f_deny) {
1814 case F_NODNY:
1815 str = "F_NODNY";
1816 break;
1817 case F_RDDNY:
1818 str = "F_RDDNY";
1819 break;
1820 case F_WRDNY:
1821 str = "F_WRDNY";
1822 break;
1823 case F_RWDNY:
1824 str = "F_RWDNY";
1825 break;
1826 case F_COMPAT:
1827 str = "F_COMPAT";
1828 break;
1830 if (str != NULL) {
1831 if (manddny)
1832 (void) printf(" deny=F_MANDDNY|%s", str);
1833 else
1834 (void) printf(" deny=%s", str);
1835 } else {
1836 (void) printf(" deny=0x%x", manddny?
1837 fshare.f_deny | F_MANDDNY : fshare.f_deny);
1840 (void) printf(" id=%x\n", fshare.f_id);
1844 void
1845 show_ffg(private_t *pri)
1847 (void) putchar('\t');
1848 (void) putchar('\t');
1849 prt_ffg(pri, 0, pri->Rval1);
1850 (void) puts(pri->sys_string);
1853 /* print values in fcntl() pointed-to structure */
1854 void
1855 show_fcntl(private_t *pri)
1857 long offset;
1859 if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
1860 show_ffg(pri);
1861 return;
1864 if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == NULL)
1865 return;
1867 switch (pri->sys_args[1]) {
1868 #ifdef _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 case F_OFD_GETLK:
1876 case F_OFD_SETLK:
1877 case F_OFD_SETLKW:
1878 case F_FLOCK:
1879 case F_FLOCKW:
1880 if (data_model == PR_MODEL_LP64)
1881 show_flock64(pri, offset);
1882 else
1883 show_flock32(pri, offset);
1884 break;
1885 case 33: /* F_GETLK64 */
1886 case 34: /* F_SETLK64 */
1887 case 35: /* F_SETLKW64 */
1888 case 27: /* F_FREESP64 */
1889 case 28: /* F_ALLOCSP64 */
1890 case 44: /* F_SETLK64_NBMAND */
1891 case 50: /* F_OFD_GETLK64 */
1892 case 51: /* F_OFD_SETLK64 */
1893 case 52: /* F_OFD_SETLKW64 */
1894 case 55: /* F_FLOCK64 */
1895 case 56: /* F_FLOCKW64 */
1896 show_flock64(pri, offset);
1897 break;
1898 #else /* _LP64 */
1899 case F_GETLK:
1900 case F_SETLK:
1901 case F_SETLKW:
1902 case F_FREESP:
1903 case F_ALLOCSP:
1904 case F_SETLK_NBMAND:
1905 show_flock32(pri, offset);
1906 break;
1907 case F_GETLK64:
1908 case F_SETLK64:
1909 case F_SETLKW64:
1910 case F_FREESP64:
1911 case F_ALLOCSP64:
1912 case F_SETLK64_NBMAND:
1913 case F_OFD_GETLK64:
1914 case F_OFD_SETLK64:
1915 case F_OFD_SETLKW64:
1916 case F_FLOCK64:
1917 case F_FLOCKW64:
1918 show_flock64(pri, offset);
1919 break;
1920 #endif /* _LP64 */
1921 case F_SHARE:
1922 case F_UNSHARE:
1923 show_share(pri, offset);
1924 break;
1928 void
1929 show_strbuf(private_t *pri, long offset, const char *name, int dump)
1931 struct strbuf strbuf;
1933 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1934 print_strbuf(pri, &strbuf, name, dump);
1937 #ifdef _LP64
1938 void
1939 show_strbuf32(private_t *pri, long offset, const char *name, int dump)
1941 struct strbuf32 strbuf;
1943 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1944 print_strbuf32(pri, &strbuf, name, dump);
1946 #endif /* _LP64 */
1948 void
1949 show_gp_msg(private_t *pri, int what)
1951 long offset;
1952 int dump = FALSE;
1953 int fdp1 = pri->sys_args[0] + 1;
1955 switch (what) {
1956 case SYS_getmsg:
1957 case SYS_getpmsg:
1958 if (pri->Errno == 0 && prismember(&readfd, fdp1))
1959 dump = TRUE;
1960 break;
1961 case SYS_putmsg:
1962 case SYS_putpmsg:
1963 if (prismember(&writefd, fdp1))
1964 dump = TRUE;
1965 break;
1968 /* enter region of lengthy output */
1969 if (dump)
1970 Eserialize();
1972 #ifdef _LP64
1973 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL) {
1974 if (data_model == PR_MODEL_LP64)
1975 show_strbuf(pri, offset, "ctl", dump);
1976 else
1977 show_strbuf32(pri, offset, "ctl", dump);
1979 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL) {
1980 if (data_model == PR_MODEL_LP64)
1981 show_strbuf(pri, offset, "dat", dump);
1982 else
1983 show_strbuf32(pri, offset, "dat", dump);
1985 #else /* _LP64 */
1986 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != NULL)
1987 show_strbuf(pri, offset, "ctl", dump);
1988 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != NULL)
1989 show_strbuf(pri, offset, "dat", dump);
1990 #endif /* _LP64 */
1992 /* exit region of lengthy output */
1993 if (dump)
1994 Xserialize();
1997 void
1998 show_int(private_t *pri, long offset, const char *name)
2000 int value;
2002 if (offset != 0 &&
2003 Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
2004 (void) printf("%s\t%s:\t%d\n",
2005 pri->pname,
2006 name,
2007 value);
2010 void
2011 show_hhex_int(private_t *pri, long offset, const char *name)
2013 int value;
2015 if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
2016 (void) printf("%s\t%s:\t0x%.4X\n",
2017 pri->pname,
2018 name,
2019 value);
2022 #define ALL_POLL_FLAGS (POLLIN|POLLPRI|POLLOUT| \
2023 POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
2025 const char *
2026 pollevent(private_t *pri, int arg)
2028 char *str = pri->code_buf;
2030 if (arg == 0)
2031 return ("0");
2032 if (arg & ~ALL_POLL_FLAGS) {
2033 (void) sprintf(str, "0x%-5X", arg);
2034 return ((const char *)str);
2037 *str = '\0';
2038 if (arg & POLLIN)
2039 (void) strcat(str, "|POLLIN");
2040 if (arg & POLLPRI)
2041 (void) strcat(str, "|POLLPRI");
2042 if (arg & POLLOUT)
2043 (void) strcat(str, "|POLLOUT");
2044 if (arg & POLLRDNORM)
2045 (void) strcat(str, "|POLLRDNORM");
2046 if (arg & POLLRDBAND)
2047 (void) strcat(str, "|POLLRDBAND");
2048 if (arg & POLLWRBAND)
2049 (void) strcat(str, "|POLLWRBAND");
2050 if (arg & POLLERR)
2051 (void) strcat(str, "|POLLERR");
2052 if (arg & POLLHUP)
2053 (void) strcat(str, "|POLLHUP");
2054 if (arg & POLLNVAL)
2055 (void) strcat(str, "|POLLNVAL");
2057 return ((const char *)(str+1));
2060 static void
2061 show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
2064 * can't print both events and revents in same printf.
2065 * pollevent() returns a pointer to a TSD location.
2067 (void) printf("%s\tfd=%-2d ev=%s",
2068 pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
2069 (void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
2072 static void
2073 show_all_pollfds(private_t *pri, long offset, int nfds)
2075 struct pollfd pollfd[2];
2076 int skip = -1;
2078 for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
2079 if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
2080 sizeof (struct pollfd))
2081 continue;
2083 if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
2084 pollfd[0].events == pollfd[1].events &&
2085 pollfd[0].revents == pollfd[1].revents) {
2086 skip++;
2087 continue;
2090 if (skip > 0)
2091 (void) printf("%s\t...last pollfd structure"
2092 " repeated %d time%s...\n",
2093 pri->pname, skip, (skip == 1 ? "" : "s"));
2095 skip = 0;
2096 show_one_pollfd(pri, &pollfd[0]);
2097 pollfd[1] = pollfd[0];
2100 if (skip > 0)
2101 (void) printf(
2102 "%s\t...last pollfd structure repeated %d time%s...\n",
2103 pri->pname, skip, (skip == 1 ? "" : "s"));
2106 void
2107 show_pollsys(private_t *pri)
2109 long offset;
2110 int nfds;
2111 int serial = 0;
2113 if (pri->sys_nargs < 2)
2114 return;
2116 offset = pri->sys_args[0];
2117 nfds = pri->sys_args[1];
2119 /* enter region of lengthy output */
2120 if (offset != NULL && nfds > 32) {
2121 Eserialize();
2122 serial = 1;
2125 if (offset != NULL && nfds > 0)
2126 show_all_pollfds(pri, offset, nfds);
2128 if (pri->sys_nargs > 2)
2129 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
2131 if (pri->sys_nargs > 3)
2132 show_sigset(pri, (long)pri->sys_args[3], "sigmask");
2134 /* exit region of lengthy output */
2135 if (serial)
2136 Xserialize();
2139 static void
2140 show_perm64(private_t *pri, struct ipc_perm64 *ip)
2142 (void) printf("%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u z=%-5d "
2143 "m=0%.6o key=%d projid=%-5d\n",
2144 pri->pname,
2145 ip->ipcx_uid,
2146 ip->ipcx_gid,
2147 ip->ipcx_cuid,
2148 ip->ipcx_cgid,
2149 (int)ip->ipcx_zoneid,
2150 (unsigned int)ip->ipcx_mode,
2151 ip->ipcx_key,
2152 (int)ip->ipcx_projid);
2155 void
2156 show_perm(private_t *pri, struct ipc_perm *ip)
2158 (void) printf(
2159 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2160 pri->pname,
2161 ip->uid,
2162 ip->gid,
2163 ip->cuid,
2164 ip->cgid,
2165 (int)ip->mode,
2166 ip->seq,
2167 ip->key);
2170 #ifdef _LP64
2171 void
2172 show_perm32(private_t *pri, struct ipc_perm32 *ip)
2174 (void) printf(
2175 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2176 pri->pname,
2177 ip->uid,
2178 ip->gid,
2179 ip->cuid,
2180 ip->cgid,
2181 ip->mode,
2182 ip->seq,
2183 ip->key);
2185 #endif /* _LP64 */
2187 static void
2188 show_msgctl64(private_t *pri, long offset)
2190 struct msqid_ds64 msgq;
2192 if (offset != NULL &&
2193 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2194 show_perm64(pri, &msgq.msgx_perm);
2196 (void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2197 "lspid=%-5d lrpid=%-5d\n", pri->pname,
2198 (unsigned long long)msgq.msgx_cbytes,
2199 (unsigned long long)msgq.msgx_qnum,
2200 (unsigned long long)msgq.msgx_qbytes,
2201 (int)msgq.msgx_lspid,
2202 (int)msgq.msgx_lrpid);
2204 prtime(pri, " st = ", (time_t)msgq.msgx_stime);
2205 prtime(pri, " rt = ", (time_t)msgq.msgx_rtime);
2206 prtime(pri, " ct = ", (time_t)msgq.msgx_ctime);
2210 void
2211 show_msgctl(private_t *pri, long offset)
2213 struct msqid_ds msgq;
2215 if (offset != NULL &&
2216 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2217 show_perm(pri, &msgq.msg_perm);
2219 (void) printf(
2220 "%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2221 pri->pname,
2222 msgq.msg_cbytes,
2223 msgq.msg_qnum,
2224 msgq.msg_qbytes,
2225 (int)msgq.msg_lspid,
2226 (int)msgq.msg_lrpid);
2228 prtime(pri, " st = ", msgq.msg_stime);
2229 prtime(pri, " rt = ", msgq.msg_rtime);
2230 prtime(pri, " ct = ", msgq.msg_ctime);
2234 #ifdef _LP64
2235 void
2236 show_msgctl32(private_t *pri, long offset)
2238 struct msqid_ds32 msgq;
2240 if (offset != NULL &&
2241 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2242 show_perm32(pri, &msgq.msg_perm);
2244 (void) printf(
2245 "%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2246 pri->pname,
2247 msgq.msg_cbytes,
2248 msgq.msg_qnum,
2249 msgq.msg_qbytes,
2250 msgq.msg_lspid,
2251 msgq.msg_lrpid);
2253 prtime(pri, " st = ", msgq.msg_stime);
2254 prtime(pri, " rt = ", msgq.msg_rtime);
2255 prtime(pri, " ct = ", msgq.msg_ctime);
2258 #endif /* _LP64 */
2260 void
2261 show_msgbuf(private_t *pri, long offset, long msgsz)
2263 struct msgbuf msgb;
2265 if (offset != NULL &&
2266 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2267 sizeof (msgb.mtype)) {
2268 /* enter region of lengthy output */
2269 if (msgsz > MYBUFSIZ / 4)
2270 Eserialize();
2272 (void) printf("%s\tmtype=%lu mtext[]=\n",
2273 pri->pname,
2274 msgb.mtype);
2275 showbuffer(pri,
2276 (long)(offset + sizeof (msgb.mtype)), msgsz);
2278 /* exit region of lengthy output */
2279 if (msgsz > MYBUFSIZ / 4)
2280 Xserialize();
2284 #ifdef _LP64
2285 void
2286 show_msgbuf32(private_t *pri, long offset, long msgsz)
2288 struct ipcmsgbuf32 msgb;
2290 if (offset != NULL &&
2291 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2292 sizeof (msgb.mtype)) {
2293 /* enter region of lengthy output */
2294 if (msgsz > MYBUFSIZ / 4)
2295 Eserialize();
2297 (void) printf("%s\tmtype=%u mtext[]=\n",
2298 pri->pname,
2299 msgb.mtype);
2300 showbuffer(pri,
2301 (long)(offset + sizeof (msgb.mtype)), msgsz);
2303 /* exit region of lengthy output */
2304 if (msgsz > MYBUFSIZ / 4)
2305 Xserialize();
2308 #endif /* _LP64 */
2310 #ifdef _LP64
2311 void
2312 show_msgsys(private_t *pri, long msgsz)
2314 switch (pri->sys_args[0]) {
2315 case 0: /* msgget() */
2316 break;
2317 case 1: /* msgctl() */
2318 if (pri->sys_nargs > 3) {
2319 switch (pri->sys_args[2]) {
2320 case IPC_STAT:
2321 if (pri->Errno)
2322 break;
2323 /*FALLTHROUGH*/
2324 case IPC_SET:
2325 if (data_model == PR_MODEL_LP64)
2326 show_msgctl(pri,
2327 (long)pri->sys_args[3]);
2328 else
2329 show_msgctl32(pri,
2330 (long)pri->sys_args[3]);
2331 break;
2332 case IPC_STAT64:
2333 if (pri->Errno)
2334 break;
2335 /*FALLTHROUGH*/
2336 case IPC_SET64:
2337 show_msgctl64(pri, (long)pri->sys_args[3]);
2338 break;
2341 break;
2342 case 2: /* msgrcv() */
2343 if (!pri->Errno && pri->sys_nargs > 2) {
2344 if (data_model == PR_MODEL_LP64)
2345 show_msgbuf(pri, pri->sys_args[2], msgsz);
2346 else
2347 show_msgbuf32(pri, pri->sys_args[2], msgsz);
2349 break;
2350 case 3: /* msgsnd() */
2351 if (pri->sys_nargs > 3) {
2352 if (data_model == PR_MODEL_LP64)
2353 show_msgbuf(pri, pri->sys_args[2],
2354 pri->sys_args[3]);
2355 else
2356 show_msgbuf32(pri, pri->sys_args[2],
2357 pri->sys_args[3]);
2359 break;
2360 case 4: /* msgids() */
2361 case 5: /* msgsnap() */
2362 default: /* unexpected subcode */
2363 break;
2366 #else /* _LP64 */
2367 void
2368 show_msgsys(private_t *pri, long msgsz)
2370 switch (pri->sys_args[0]) {
2371 case 0: /* msgget() */
2372 break;
2373 case 1: /* msgctl() */
2374 if (pri->sys_nargs > 3) {
2375 switch (pri->sys_args[2]) {
2376 case IPC_STAT:
2377 if (pri->Errno)
2378 break;
2379 /*FALLTHROUGH*/
2380 case IPC_SET:
2381 show_msgctl(pri, (long)pri->sys_args[3]);
2382 break;
2383 case IPC_STAT64:
2384 if (pri->Errno)
2385 break;
2386 /*FALLTHROUGH*/
2387 case IPC_SET64:
2388 show_msgctl64(pri, (long)pri->sys_args[3]);
2389 break;
2392 break;
2393 case 2: /* msgrcv() */
2394 if (!pri->Errno && pri->sys_nargs > 2)
2395 show_msgbuf(pri, pri->sys_args[2], msgsz);
2396 break;
2397 case 3: /* msgsnd() */
2398 if (pri->sys_nargs > 3)
2399 show_msgbuf(pri, pri->sys_args[2],
2400 pri->sys_args[3]);
2401 break;
2402 case 4: /* msgids() */
2403 case 5: /* msgsnap() */
2404 default: /* unexpected subcode */
2405 break;
2408 #endif /* _LP64 */
2410 static void
2411 show_semctl64(private_t *pri, long offset)
2413 struct semid_ds64 semds;
2415 if (offset != NULL &&
2416 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2417 show_perm64(pri, &semds.semx_perm);
2419 (void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
2421 prtime(pri, " ot = ", (time_t)semds.semx_otime);
2422 prtime(pri, " ct = ", (time_t)semds.semx_ctime);
2426 void
2427 show_semctl(private_t *pri, long offset)
2429 struct semid_ds semds;
2431 if (offset != NULL &&
2432 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2433 show_perm(pri, &semds.sem_perm);
2435 (void) printf("%s\tnsems=%u\n",
2436 pri->pname,
2437 semds.sem_nsems);
2439 prtime(pri, " ot = ", semds.sem_otime);
2440 prtime(pri, " ct = ", semds.sem_ctime);
2444 #ifdef _LP64
2445 void
2446 show_semctl32(private_t *pri, long offset)
2448 struct semid_ds32 semds;
2450 if (offset != NULL &&
2451 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2452 show_perm32(pri, &semds.sem_perm);
2454 (void) printf("%s\tnsems=%u\n",
2455 pri->pname,
2456 semds.sem_nsems);
2458 prtime(pri, " ot = ", semds.sem_otime);
2459 prtime(pri, " ct = ", semds.sem_ctime);
2462 #endif /* _LP64 */
2464 void
2465 show_semop(private_t *pri, long offset, long nsops, long timeout)
2467 struct sembuf sembuf;
2468 const char *str;
2470 if (offset == 0)
2471 return;
2473 if (nsops > 40) /* let's not be ridiculous */
2474 nsops = 40;
2476 for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
2477 if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
2478 sizeof (sembuf))
2479 break;
2481 (void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2482 pri->pname,
2483 sembuf.sem_num,
2484 sembuf.sem_op);
2486 if (sembuf.sem_flg == 0)
2487 (void) printf("0\n");
2488 else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
2489 (void) printf("%s\n", str);
2490 else
2491 (void) printf("0%.6o\n", sembuf.sem_flg);
2493 if (timeout)
2494 show_timestruc(pri, timeout, "timeout");
2497 void
2498 show_semsys(private_t *pri)
2500 switch (pri->sys_args[0]) {
2501 case 0: /* semctl() */
2502 if (pri->sys_nargs > 4) {
2503 switch (pri->sys_args[3]) {
2504 case IPC_STAT:
2505 if (pri->Errno)
2506 break;
2507 /*FALLTHROUGH*/
2508 case IPC_SET:
2509 #ifdef _LP64
2510 if (data_model == PR_MODEL_LP64)
2511 show_semctl(pri,
2512 (long)pri->sys_args[4]);
2513 else
2514 show_semctl32(pri,
2515 (long)pri->sys_args[4]);
2516 #else
2517 show_semctl(pri, (long)pri->sys_args[4]);
2518 #endif
2519 break;
2520 case IPC_STAT64:
2521 if (pri->Errno)
2522 break;
2523 /*FALLTHROUGH*/
2524 case IPC_SET64:
2525 show_semctl64(pri, (long)pri->sys_args[4]);
2526 break;
2529 break;
2530 case 1: /* semget() */
2531 break;
2532 case 2: /* semop() */
2533 if (pri->sys_nargs > 3)
2534 show_semop(pri, (long)pri->sys_args[2],
2535 pri->sys_args[3], 0);
2536 break;
2537 case 3: /* semids() */
2538 break;
2539 case 4: /* semtimedop() */
2540 if (pri->sys_nargs > 4)
2541 show_semop(pri, (long)pri->sys_args[2],
2542 pri->sys_args[3], pri->sys_args[4]);
2543 break;
2544 default: /* unexpected subcode */
2545 break;
2549 static void
2550 show_shmctl64(private_t *pri, long offset)
2552 struct shmid_ds64 shmds;
2554 if (offset != NULL &&
2555 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2556 show_perm64(pri, &shmds.shmx_perm);
2558 (void) printf(
2559 "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2560 pri->pname,
2561 (unsigned long long)shmds.shmx_segsz,
2562 (int)shmds.shmx_lpid,
2563 (int)shmds.shmx_cpid,
2564 (unsigned long long)shmds.shmx_nattch,
2565 (unsigned long long)shmds.shmx_cnattch);
2567 prtime(pri, " at = ", (time_t)shmds.shmx_atime);
2568 prtime(pri, " dt = ", (time_t)shmds.shmx_dtime);
2569 prtime(pri, " ct = ", (time_t)shmds.shmx_ctime);
2573 void
2574 show_shmctl(private_t *pri, long offset)
2576 struct shmid_ds shmds;
2578 if (offset != NULL &&
2579 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2580 show_perm(pri, &shmds.shm_perm);
2582 (void) printf(
2583 "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2584 pri->pname,
2585 (ulong_t)shmds.shm_segsz,
2586 (int)shmds.shm_lpid,
2587 (int)shmds.shm_cpid,
2588 shmds.shm_nattch,
2589 shmds.shm_cnattch);
2591 prtime(pri, " at = ", shmds.shm_atime);
2592 prtime(pri, " dt = ", shmds.shm_dtime);
2593 prtime(pri, " ct = ", shmds.shm_ctime);
2597 #ifdef _LP64
2598 void
2599 show_shmctl32(private_t *pri, long offset)
2601 struct shmid_ds32 shmds;
2603 if (offset != NULL &&
2604 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2605 show_perm32(pri, &shmds.shm_perm);
2607 (void) printf(
2608 "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2609 pri->pname,
2610 shmds.shm_segsz,
2611 shmds.shm_lpid,
2612 shmds.shm_cpid,
2613 shmds.shm_nattch,
2614 shmds.shm_cnattch);
2616 prtime(pri, " at = ", shmds.shm_atime);
2617 prtime(pri, " dt = ", shmds.shm_dtime);
2618 prtime(pri, " ct = ", shmds.shm_ctime);
2621 #endif /* _LP64 */
2623 void
2624 show_shmsys(private_t *pri)
2626 switch (pri->sys_args[0]) {
2627 case 0: /* shmat() */
2628 break;
2629 case 1: /* shmctl() */
2630 if (pri->sys_nargs > 3) {
2631 switch (pri->sys_args[2]) {
2632 case IPC_STAT:
2633 if (pri->Errno)
2634 break;
2635 /*FALLTHROUGH*/
2636 case IPC_SET:
2637 #ifdef _LP64
2638 if (data_model == PR_MODEL_LP64)
2639 show_shmctl(pri,
2640 (long)pri->sys_args[3]);
2641 else
2642 show_shmctl32(pri,
2643 (long)pri->sys_args[3]);
2644 #else
2645 show_shmctl(pri, (long)pri->sys_args[3]);
2646 #endif
2647 break;
2648 case IPC_STAT64:
2649 if (pri->Errno)
2650 break;
2651 /*FALLTHROUGH*/
2652 case IPC_SET64:
2653 show_shmctl64(pri, (long)pri->sys_args[3]);
2654 break;
2657 break;
2658 case 2: /* shmdt() */
2659 case 3: /* shmget() */
2660 case 4: /* shmids() */
2661 default: /* unexpected subcode */
2662 break;
2666 void
2667 show_groups(private_t *pri, long offset, long count)
2669 int groups[100];
2671 if (count > 100)
2672 count = 100;
2674 if (count > 0 && offset != NULL &&
2675 Pread(Proc, &groups[0], count*sizeof (int), offset) ==
2676 count*sizeof (int)) {
2677 int n;
2679 (void) printf("%s\t", pri->pname);
2680 for (n = 0; !interrupt && n < count; n++) {
2681 if (n != 0 && n%10 == 0)
2682 (void) printf("\n%s\t", pri->pname);
2683 (void) printf(" %5d", groups[n]);
2685 (void) fputc('\n', stdout);
2690 * This assumes that a sigset_t is simply an array of ints.
2692 char *
2693 sigset_string(private_t *pri, sigset_t *sp)
2695 char *s = pri->code_buf;
2696 int n = sizeof (*sp) / sizeof (int32_t);
2697 int32_t *lp = (int32_t *)sp;
2699 while (--n >= 0) {
2700 int32_t val = *lp++;
2702 if (val == 0)
2703 s += sprintf(s, " 0");
2704 else
2705 s += sprintf(s, " 0x%.8X", val);
2708 return (pri->code_buf);
2711 void
2712 show_sigset(private_t *pri, long offset, const char *name)
2714 sigset_t sigset;
2716 if (offset != NULL &&
2717 Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
2718 (void) printf("%s\t%s =%s\n",
2719 pri->pname, name, sigset_string(pri, &sigset));
2723 #ifdef _LP64
2724 void
2725 show_sigaltstack32(private_t *pri, long offset, const char *name)
2727 struct sigaltstack32 altstack;
2729 if (offset != NULL &&
2730 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2731 sizeof (altstack)) {
2732 (void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2733 pri->pname,
2734 name,
2735 altstack.ss_sp,
2736 altstack.ss_size,
2737 altstack.ss_flags);
2740 #endif /* _LP64 */
2742 void
2743 show_sigaltstack(private_t *pri, long offset, const char *name)
2745 struct sigaltstack altstack;
2747 #ifdef _LP64
2748 if (data_model != PR_MODEL_LP64) {
2749 show_sigaltstack32(pri, offset, name);
2750 return;
2752 #endif
2753 if (offset != NULL &&
2754 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2755 sizeof (altstack)) {
2756 (void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2757 pri->pname,
2758 name,
2759 (ulong_t)altstack.ss_sp,
2760 (ulong_t)altstack.ss_size,
2761 altstack.ss_flags);
2765 #ifdef _LP64
2766 void
2767 show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
2769 struct sigaction32 sigaction;
2771 if (offset != NULL &&
2772 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2773 sizeof (sigaction)) {
2774 /* This is stupid, we shouldn't have to do this */
2775 if (odisp != NULL)
2776 sigaction.sa_handler = (caddr32_t)odisp;
2777 (void) printf(
2778 "%s %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2779 pri->pname,
2780 name,
2781 sigaction.sa_handler,
2782 sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
2783 sigaction.sa_flags);
2786 #endif /* _LP64 */
2788 void
2789 show_sigaction(private_t *pri, long offset, const char *name, long odisp)
2791 struct sigaction sigaction;
2793 #ifdef _LP64
2794 if (data_model != PR_MODEL_LP64) {
2795 show_sigaction32(pri, offset, name, odisp);
2796 return;
2798 #endif
2799 if (offset != NULL &&
2800 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2801 sizeof (sigaction)) {
2802 /* This is stupid, we shouldn't have to do this */
2803 if (odisp != NULL)
2804 sigaction.sa_handler = (void (*)())odisp;
2805 (void) printf(
2806 "%s %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2807 pri->pname,
2808 name,
2809 (long)sigaction.sa_handler,
2810 sigset_string(pri, &sigaction.sa_mask),
2811 sigaction.sa_flags);
2815 #ifdef _LP64
2816 void
2817 print_siginfo32(private_t *pri, const siginfo32_t *sip)
2819 const char *code = NULL;
2821 (void) printf("%s siginfo: %s", pri->pname,
2822 signame(pri, sip->si_signo));
2824 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2825 (void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
2826 if (sip->si_code != 0)
2827 (void) printf(" code=%d", sip->si_code);
2828 (void) fputc('\n', stdout);
2829 return;
2832 switch (sip->si_signo) {
2833 default:
2834 (void) fputc('\n', stdout);
2835 return;
2836 case SIGILL:
2837 case SIGTRAP:
2838 case SIGFPE:
2839 case SIGSEGV:
2840 case SIGBUS:
2841 case SIGEMT:
2842 case SIGCLD:
2843 case SIGPOLL:
2844 case SIGXFSZ:
2845 break;
2848 switch (sip->si_signo) {
2849 case SIGILL:
2850 switch (sip->si_code) {
2851 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2852 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2853 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2854 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2855 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2856 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2857 case ILL_COPROC: code = "ILL_COPROC"; break;
2858 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2860 break;
2861 case SIGTRAP:
2862 switch (sip->si_code) {
2863 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2864 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2865 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2866 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2867 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2868 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2870 break;
2871 case SIGFPE:
2872 switch (sip->si_code) {
2873 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2874 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2875 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2876 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2877 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2878 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2879 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2880 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2881 #if defined(FPE_FLTDEN)
2882 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2883 #endif
2885 break;
2886 case SIGSEGV:
2887 switch (sip->si_code) {
2888 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2889 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2891 break;
2892 case SIGEMT:
2893 switch (sip->si_code) {
2894 #ifdef EMT_TAGOVF
2895 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2896 #endif
2897 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2899 break;
2900 case SIGBUS:
2901 switch (sip->si_code) {
2902 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2903 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2904 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2906 break;
2907 case SIGCLD:
2908 switch (sip->si_code) {
2909 case CLD_EXITED: code = "CLD_EXITED"; break;
2910 case CLD_KILLED: code = "CLD_KILLED"; break;
2911 case CLD_DUMPED: code = "CLD_DUMPED"; break;
2912 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
2913 case CLD_STOPPED: code = "CLD_STOPPED"; break;
2914 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
2916 break;
2917 case SIGPOLL:
2918 switch (sip->si_code) {
2919 case POLL_IN: code = "POLL_IN"; break;
2920 case POLL_OUT: code = "POLL_OUT"; break;
2921 case POLL_MSG: code = "POLL_MSG"; break;
2922 case POLL_ERR: code = "POLL_ERR"; break;
2923 case POLL_PRI: code = "POLL_PRI"; break;
2924 case POLL_HUP: code = "POLL_HUP"; break;
2926 break;
2929 if (code == NULL) {
2930 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2931 code = (const char *)pri->code_buf;
2934 switch (sip->si_signo) {
2935 case SIGILL:
2936 case SIGTRAP:
2937 case SIGFPE:
2938 case SIGSEGV:
2939 case SIGBUS:
2940 case SIGEMT:
2941 (void) printf(" %s addr=0x%.8X",
2942 code,
2943 sip->si_addr);
2944 break;
2945 case SIGCLD:
2946 (void) printf(" %s pid=%d status=0x%.4X",
2947 code,
2948 sip->si_pid,
2949 sip->si_status);
2950 break;
2951 case SIGPOLL:
2952 case SIGXFSZ:
2953 (void) printf(" %s fd=%d band=%d",
2954 code,
2955 sip->si_fd,
2956 sip->si_band);
2957 break;
2960 if (sip->si_errno != 0) {
2961 const char *ename = errname(sip->si_errno);
2963 (void) printf(" errno=%d", sip->si_errno);
2964 if (ename != NULL)
2965 (void) printf("(%s)", ename);
2968 (void) fputc('\n', stdout);
2970 #endif /* _LP64 */
2972 void
2973 print_siginfo(private_t *pri, const siginfo_t *sip)
2975 const char *code = NULL;
2977 (void) printf("%s siginfo: %s", pri->pname,
2978 signame(pri, sip->si_signo));
2980 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2981 (void) printf(" pid=%d uid=%u",
2982 (int)sip->si_pid,
2983 sip->si_uid);
2984 if (sip->si_code != 0)
2985 (void) printf(" code=%d", sip->si_code);
2986 (void) fputc('\n', stdout);
2987 return;
2990 switch (sip->si_signo) {
2991 default:
2992 (void) fputc('\n', stdout);
2993 return;
2994 case SIGILL:
2995 case SIGTRAP:
2996 case SIGFPE:
2997 case SIGSEGV:
2998 case SIGBUS:
2999 case SIGEMT:
3000 case SIGCLD:
3001 case SIGPOLL:
3002 case SIGXFSZ:
3003 break;
3006 switch (sip->si_signo) {
3007 case SIGILL:
3008 switch (sip->si_code) {
3009 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
3010 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
3011 case ILL_ILLADR: code = "ILL_ILLADR"; break;
3012 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
3013 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
3014 case ILL_PRVREG: code = "ILL_PRVREG"; break;
3015 case ILL_COPROC: code = "ILL_COPROC"; break;
3016 case ILL_BADSTK: code = "ILL_BADSTK"; break;
3018 break;
3019 case SIGTRAP:
3020 switch (sip->si_code) {
3021 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
3022 case TRAP_TRACE: code = "TRAP_TRACE"; break;
3023 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
3024 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
3025 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
3026 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
3028 break;
3029 case SIGFPE:
3030 switch (sip->si_code) {
3031 case FPE_INTDIV: code = "FPE_INTDIV"; break;
3032 case FPE_INTOVF: code = "FPE_INTOVF"; break;
3033 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
3034 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
3035 case FPE_FLTUND: code = "FPE_FLTUND"; break;
3036 case FPE_FLTRES: code = "FPE_FLTRES"; break;
3037 case FPE_FLTINV: code = "FPE_FLTINV"; break;
3038 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
3039 #if defined(FPE_FLTDEN)
3040 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
3041 #endif
3043 break;
3044 case SIGSEGV:
3045 switch (sip->si_code) {
3046 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
3047 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
3049 break;
3050 case SIGEMT:
3051 switch (sip->si_code) {
3052 #ifdef EMT_TAGOVF
3053 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
3054 #endif
3055 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
3057 break;
3058 case SIGBUS:
3059 switch (sip->si_code) {
3060 case BUS_ADRALN: code = "BUS_ADRALN"; break;
3061 case BUS_ADRERR: code = "BUS_ADRERR"; break;
3062 case BUS_OBJERR: code = "BUS_OBJERR"; break;
3064 break;
3065 case SIGCLD:
3066 switch (sip->si_code) {
3067 case CLD_EXITED: code = "CLD_EXITED"; break;
3068 case CLD_KILLED: code = "CLD_KILLED"; break;
3069 case CLD_DUMPED: code = "CLD_DUMPED"; break;
3070 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
3071 case CLD_STOPPED: code = "CLD_STOPPED"; break;
3072 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
3074 break;
3075 case SIGPOLL:
3076 switch (sip->si_code) {
3077 case POLL_IN: code = "POLL_IN"; break;
3078 case POLL_OUT: code = "POLL_OUT"; break;
3079 case POLL_MSG: code = "POLL_MSG"; break;
3080 case POLL_ERR: code = "POLL_ERR"; break;
3081 case POLL_PRI: code = "POLL_PRI"; break;
3082 case POLL_HUP: code = "POLL_HUP"; break;
3084 break;
3087 if (code == NULL) {
3088 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
3089 code = (const char *)pri->code_buf;
3092 switch (sip->si_signo) {
3093 case SIGILL:
3094 case SIGTRAP:
3095 case SIGFPE:
3096 case SIGSEGV:
3097 case SIGBUS:
3098 case SIGEMT:
3099 (void) printf(" %s addr=0x%.8lX",
3100 code,
3101 (long)sip->si_addr);
3102 break;
3103 case SIGCLD:
3104 (void) printf(" %s pid=%d status=0x%.4X",
3105 code,
3106 (int)sip->si_pid,
3107 sip->si_status);
3108 break;
3109 case SIGPOLL:
3110 case SIGXFSZ:
3111 (void) printf(" %s fd=%d band=%ld",
3112 code,
3113 sip->si_fd,
3114 sip->si_band);
3115 break;
3118 if (sip->si_errno != 0) {
3119 const char *ename = errname(sip->si_errno);
3121 (void) printf(" errno=%d", sip->si_errno);
3122 if (ename != NULL)
3123 (void) printf("(%s)", ename);
3126 (void) fputc('\n', stdout);
3129 #ifdef _LP64
3130 void
3131 show_siginfo32(private_t *pri, long offset)
3133 struct siginfo32 siginfo;
3135 if (offset != NULL &&
3136 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3137 print_siginfo32(pri, &siginfo);
3139 #endif /* _LP64 */
3141 void
3142 show_siginfo(private_t *pri, long offset)
3144 struct siginfo siginfo;
3146 #ifdef _LP64
3147 if (data_model != PR_MODEL_LP64) {
3148 show_siginfo32(pri, offset);
3149 return;
3151 #endif
3152 if (offset != NULL &&
3153 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3154 print_siginfo(pri, &siginfo);
3157 void
3158 show_bool(private_t *pri, long offset, int count)
3160 int serial = (count > MYBUFSIZ / 4);
3162 /* enter region of lengthy output */
3163 if (serial)
3164 Eserialize();
3166 while (count > 0) {
3167 char buf[32];
3168 int nb = (count < 32)? count : 32;
3169 int i;
3171 if (Pread(Proc, buf, (size_t)nb, offset) != nb)
3172 break;
3174 (void) printf("%s ", pri->pname);
3175 for (i = 0; i < nb; i++)
3176 (void) printf(" %d", buf[i]);
3177 (void) fputc('\n', stdout);
3179 count -= nb;
3180 offset += nb;
3183 /* exit region of lengthy output */
3184 if (serial)
3185 Xserialize();
3188 #ifdef _LP64
3189 void
3190 show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
3192 iovec32_t iovec[16];
3193 iovec32_t *ip;
3194 long nb;
3195 int serial = (count > MYBUFSIZ / 4 && showbuf);
3197 if (niov > 16) /* is this the real limit? */
3198 niov = 16;
3200 if (offset != NULL && niov > 0 &&
3201 Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
3202 == niov*sizeof (iovec32_t)) {
3203 /* enter region of lengthy output */
3204 if (serial)
3205 Eserialize();
3207 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3208 (void) printf("%s\tiov_base = 0x%.8X iov_len = %d\n",
3209 pri->pname,
3210 ip->iov_base,
3211 ip->iov_len);
3212 if ((nb = count) > 0) {
3213 if (nb > ip->iov_len)
3214 nb = ip->iov_len;
3215 if (nb > 0)
3216 count -= nb;
3218 if (showbuf && nb > 0)
3219 showbuffer(pri, (long)ip->iov_base, nb);
3222 /* exit region of lengthy output */
3223 if (serial)
3224 Xserialize();
3227 #endif /* _LP64 */
3229 void
3230 show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
3232 iovec_t iovec[16];
3233 iovec_t *ip;
3234 long nb;
3235 int serial = (count > MYBUFSIZ / 4 && showbuf);
3237 #ifdef _LP64
3238 if (data_model != PR_MODEL_LP64) {
3239 show_iovec32(pri, offset, niov, showbuf, count);
3240 return;
3242 #endif
3243 if (niov > 16) /* is this the real limit? */
3244 niov = 16;
3246 if (offset != NULL && niov > 0 &&
3247 Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
3248 == niov*sizeof (iovec_t)) {
3249 /* enter region of lengthy output */
3250 if (serial)
3251 Eserialize();
3253 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3254 (void) printf("%s\tiov_base = 0x%.8lX iov_len = %lu\n",
3255 pri->pname,
3256 (long)ip->iov_base,
3257 ip->iov_len);
3258 if ((nb = count) > 0) {
3259 if (nb > ip->iov_len)
3260 nb = ip->iov_len;
3261 if (nb > 0)
3262 count -= nb;
3264 if (showbuf && nb > 0)
3265 showbuffer(pri, (long)ip->iov_base, nb);
3268 /* exit region of lengthy output */
3269 if (serial)
3270 Xserialize();
3274 void
3275 show_dents32(private_t *pri, long offset, long count)
3277 long buf[MYBUFSIZ / sizeof (long)];
3278 struct dirent32 *dp;
3279 int serial = (count > 100);
3281 if (offset == 0)
3282 return;
3284 /* enter region of lengthy output */
3285 if (serial)
3286 Eserialize();
3288 while (count > 0 && !interrupt) {
3289 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3291 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3292 break;
3294 dp = (struct dirent32 *)&buf[0];
3295 if (nb < (int)(dp->d_name - (char *)dp))
3296 break;
3297 if ((unsigned)nb < dp->d_reclen) {
3298 /* getdents() error? */
3299 (void) printf(
3300 "%s ino=%-5u off=%-4d rlen=%-3d\n",
3301 pri->pname,
3302 dp->d_ino,
3303 dp->d_off,
3304 dp->d_reclen);
3305 break;
3308 while (!interrupt &&
3309 nb >= (int)(dp->d_name - (char *)dp) &&
3310 (unsigned)nb >= dp->d_reclen) {
3311 (void) printf(
3312 "%s ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n",
3313 pri->pname,
3314 dp->d_ino,
3315 dp->d_off,
3316 dp->d_reclen,
3317 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3318 dp->d_name);
3319 nb -= dp->d_reclen;
3320 count -= dp->d_reclen;
3321 offset += dp->d_reclen;
3322 /* LINTED improper alignment */
3323 dp = (struct dirent32 *)((char *)dp + dp->d_reclen);
3327 /* exit region of lengthy output */
3328 if (serial)
3329 Xserialize();
3332 void
3333 show_dents64(private_t *pri, long offset, long count)
3335 long long buf[MYBUFSIZ / sizeof (long long)];
3336 struct dirent64 *dp;
3337 int serial = (count > 100);
3339 if (offset == 0)
3340 return;
3342 /* enter region of lengthy output */
3343 if (serial)
3344 Eserialize();
3346 while (count > 0 && !interrupt) {
3347 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3349 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3350 break;
3352 dp = (struct dirent64 *)&buf[0];
3353 if (nb < (int)(dp->d_name - (char *)dp))
3354 break;
3355 if ((unsigned)nb < dp->d_reclen) {
3356 /* getdents() error? */
3357 (void) printf(
3358 "%s ino=%-5llu off=%-4lld rlen=%-3d\n",
3359 pri->pname,
3360 (long long)dp->d_ino,
3361 (long long)dp->d_off,
3362 dp->d_reclen);
3363 break;
3366 while (!interrupt &&
3367 nb >= (int)(dp->d_name - (char *)dp) &&
3368 (unsigned)nb >= dp->d_reclen) {
3369 (void) printf(
3370 "%s ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3371 pri->pname,
3372 (long long)dp->d_ino,
3373 (long long)dp->d_off,
3374 dp->d_reclen,
3375 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3376 dp->d_name);
3377 nb -= dp->d_reclen;
3378 count -= dp->d_reclen;
3379 offset += dp->d_reclen;
3380 /* LINTED improper alignment */
3381 dp = (struct dirent64 *)((char *)dp + dp->d_reclen);
3385 /* exit region of lengthy output */
3386 if (serial)
3387 Xserialize();
3390 void
3391 show_rlimit32(private_t *pri, long offset)
3393 struct rlimit32 rlimit;
3395 if (offset != NULL &&
3396 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3397 (void) printf("%s\t", pri->pname);
3398 switch (rlimit.rlim_cur) {
3399 case RLIM32_INFINITY:
3400 (void) fputs("cur = RLIM_INFINITY", stdout);
3401 break;
3402 case RLIM32_SAVED_MAX:
3403 (void) fputs("cur = RLIM_SAVED_MAX", stdout);
3404 break;
3405 case RLIM32_SAVED_CUR:
3406 (void) fputs("cur = RLIM_SAVED_CUR", stdout);
3407 break;
3408 default:
3409 (void) printf("cur = %lu", (long)rlimit.rlim_cur);
3410 break;
3412 switch (rlimit.rlim_max) {
3413 case RLIM32_INFINITY:
3414 (void) fputs(" max = RLIM_INFINITY\n", stdout);
3415 break;
3416 case RLIM32_SAVED_MAX:
3417 (void) fputs(" max = RLIM_SAVED_MAX\n", stdout);
3418 break;
3419 case RLIM32_SAVED_CUR:
3420 (void) fputs(" max = RLIM_SAVED_CUR\n", stdout);
3421 break;
3422 default:
3423 (void) printf(" max = %lu\n", (long)rlimit.rlim_max);
3424 break;
3429 void
3430 show_rlimit64(private_t *pri, long offset)
3432 struct rlimit64 rlimit;
3434 if (offset != NULL &&
3435 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3436 (void) printf("%s\t", pri->pname);
3437 switch (rlimit.rlim_cur) {
3438 case RLIM64_INFINITY:
3439 (void) fputs("cur = RLIM64_INFINITY", stdout);
3440 break;
3441 case RLIM64_SAVED_MAX:
3442 (void) fputs("cur = RLIM64_SAVED_MAX", stdout);
3443 break;
3444 case RLIM64_SAVED_CUR:
3445 (void) fputs("cur = RLIM64_SAVED_CUR", stdout);
3446 break;
3447 default:
3448 (void) printf("cur = %llu",
3449 (unsigned long long)rlimit.rlim_cur);
3450 break;
3452 switch (rlimit.rlim_max) {
3453 case RLIM64_INFINITY:
3454 (void) fputs(" max = RLIM64_INFINITY\n", stdout);
3455 break;
3456 case RLIM64_SAVED_MAX:
3457 (void) fputs(" max = RLIM64_SAVED_MAX\n", stdout);
3458 break;
3459 case RLIM64_SAVED_CUR:
3460 (void) fputs(" max = RLIM64_SAVED_CUR\n", stdout);
3461 break;
3462 default:
3463 (void) printf(" max = %llu\n",
3464 (unsigned long long)rlimit.rlim_max);
3465 break;
3470 void
3471 show_nuname(private_t *pri, long offset)
3473 struct utsname ubuf;
3475 if (offset != NULL &&
3476 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3477 (void) printf(
3478 "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3479 pri->pname,
3480 ubuf.sysname,
3481 ubuf.nodename,
3482 ubuf.release,
3483 ubuf.version,
3484 ubuf.machine);
3488 void
3489 show_adjtime(private_t *pri, long off1, long off2)
3491 show_timeval(pri, off1, " delta");
3492 show_timeval(pri, off2, "olddelta");
3495 void
3496 show_sockaddr(private_t *pri,
3497 const char *str, long addroff, long lenoff, long len)
3500 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3501 * also large enough to store a sockaddr_in or a sockaddr_in6.
3503 long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3504 / sizeof (long)];
3505 struct sockaddr *sa = (struct sockaddr *)buf;
3506 struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3507 struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3508 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3509 char addrbuf[INET6_ADDRSTRLEN];
3511 if (lenoff != 0) {
3512 uint_t ilen;
3513 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3514 return;
3515 len = ilen;
3518 if (len >= sizeof (buf)) /* protect against ridiculous length */
3519 len = sizeof (buf) - 1;
3520 if (Pread(Proc, buf, len, addroff) != len)
3521 return;
3523 switch (sa->sa_family) {
3524 case AF_INET6:
3525 (void) printf("%s\tAF_INET6 %s = %s port = %u\n",
3526 pri->pname, str,
3527 inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3528 sizeof (addrbuf)),
3529 ntohs(sin6->sin6_port));
3530 (void) printf("%s\tscope id = %u source id = 0x%x\n"
3531 "%s\tflow class = 0x%02x flow label = 0x%05x\n",
3532 pri->pname, ntohl(sin6->sin6_scope_id),
3533 ntohl(sin6->__sin6_src_id),
3534 pri->pname,
3535 ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3536 ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3537 break;
3538 case AF_INET:
3539 (void) printf("%s\tAF_%s %s = %s port = %u\n",
3540 pri->pname, "INET",
3541 str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3542 sizeof (addrbuf)), ntohs(sin->sin_port));
3543 break;
3544 case AF_UNIX:
3545 len -= sizeof (soun->sun_family);
3546 if (len >= 0) {
3547 /* Null terminate */
3548 soun->sun_path[len] = NULL;
3549 (void) printf("%s\tAF_UNIX %s = %s\n", pri->pname,
3550 str, soun->sun_path);
3552 break;
3556 void
3557 show_msghdr(private_t *pri, long offset)
3559 const lwpstatus_t *Lsp = pri->lwpstat;
3560 int what = Lsp->pr_what;
3561 int err = pri->Errno;
3562 struct msghdr msg;
3563 int showbuf = FALSE;
3564 int i = pri->sys_args[0]+1;
3565 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3567 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3568 return;
3570 if (msg.msg_name != NULL && msg.msg_namelen != 0)
3571 show_sockaddr(pri, "msg_name",
3572 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3575 * Print the iovec if the syscall was successful and the fd is
3576 * part of the set being traced.
3578 if ((what == SYS_recvmsg && !err &&
3579 prismember(&readfd, i)) ||
3580 (what == SYS_sendmsg &&
3581 prismember(&writefd, i)))
3582 showbuf = TRUE;
3584 show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3588 #ifdef _LP64
3589 void
3590 show_msghdr32(private_t *pri, long offset)
3592 struct msghdr32 {
3593 caddr32_t msg_name;
3594 uint32_t msg_namelen;
3595 caddr32_t msg_iov;
3596 int32_t msg_iovlen;
3597 } msg;
3598 const lwpstatus_t *Lsp = pri->lwpstat;
3599 int what = Lsp->pr_what;
3600 int err = pri->Errno;
3601 int showbuf = FALSE;
3602 int i = pri->sys_args[0]+1;
3603 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3605 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3606 return;
3608 if (msg.msg_name != NULL && msg.msg_namelen != 0)
3609 show_sockaddr(pri, "msg_name",
3610 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3612 * Print the iovec if the syscall was successful and the fd is
3613 * part of the set being traced.
3615 if ((what == SYS_recvmsg && !err &&
3616 prismember(&readfd, i)) ||
3617 (what == SYS_sendmsg &&
3618 prismember(&writefd, i)))
3619 showbuf = TRUE;
3621 show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3624 #endif /* _LP64 */
3626 static void
3627 show_doorargs(private_t *pri, long offset)
3629 door_arg_t args;
3631 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3632 (void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3633 pri->pname,
3634 (ulong_t)args.data_ptr,
3635 (ulong_t)args.data_size);
3636 (void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3637 pri->pname,
3638 (ulong_t)args.desc_ptr,
3639 args.desc_num);
3640 (void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3641 pri->pname,
3642 (ulong_t)args.rbuf,
3643 (ulong_t)args.rsize);
3647 static void
3648 show_ucred_privsets(private_t *pri, ucred_t *uc)
3650 int i = 0;
3651 const priv_set_t *s;
3652 priv_ptype_t sn;
3653 char *str;
3655 while ((sn = priv_getsetbynum(i++)) != NULL) {
3656 s = ucred_getprivset(uc, sn);
3658 if (s == NULL)
3659 continue;
3661 (void) printf("%s\t%c: %s\n",
3662 pri->pname,
3663 *sn,
3664 str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3666 free(str);
3670 static void
3671 show_ucred(private_t *pri, long offset)
3673 ucred_t *uc = _ucred_alloc();
3674 size_t sz;
3676 if (uc == NULL)
3677 return;
3679 sz = Pread(Proc, uc, uc->uc_size, offset);
3682 * A new uc_size is read, it could be smaller than the previously
3683 * value. We accept short reads that fill the whole header.
3685 if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3686 (void) printf("%s\teuid=%u egid=%u\n",
3687 pri->pname,
3688 ucred_geteuid(uc),
3689 ucred_getegid(uc));
3690 (void) printf("%s\truid=%u rgid=%u\n",
3691 pri->pname,
3692 ucred_getruid(uc),
3693 ucred_getrgid(uc));
3694 (void) printf("%s\tpid=%d zoneid=%d\n",
3695 pri->pname,
3696 (int)ucred_getpid(uc),
3697 (int)ucred_getzoneid(uc));
3698 show_ucred_privsets(pri, uc);
3700 ucred_free(uc);
3703 static void
3704 show_privset(private_t *pri, long offset, size_t size, char *label)
3706 priv_set_t *tmp = priv_allocset();
3707 size_t sz;
3709 if (tmp == NULL)
3710 return;
3712 sz = Pread(Proc, tmp, size, offset);
3714 if (sz == size) {
3715 char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3716 if (str != NULL) {
3717 (void) printf("%s\t%s%s\n", pri->pname, label, str);
3718 free(str);
3721 priv_freeset(tmp);
3724 static void
3725 show_doorinfo(private_t *pri, long offset)
3727 door_info_t info;
3728 door_attr_t attr;
3730 if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3731 return;
3732 (void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3733 pri->pname,
3734 (int)info.di_target,
3735 info.di_proc,
3736 info.di_data);
3737 attr = info.di_attributes;
3738 (void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3739 (void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3742 static void
3743 show_doorparam(private_t *pri, long offset)
3745 ulong_t val;
3747 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3748 (void) printf("%s\tvalue=%lu\n",
3749 pri->pname,
3750 val);
3754 #ifdef _LP64
3756 static void
3757 show_doorargs32(private_t *pri, long offset)
3759 struct door_arg32 args;
3761 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3762 (void) printf("%s\tdata_ptr=%X data_size=%u\n",
3763 pri->pname,
3764 args.data_ptr,
3765 args.data_size);
3766 (void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3767 pri->pname,
3768 args.desc_ptr,
3769 args.desc_num);
3770 (void) printf("%s\trbuf=0x%X rsize=%u\n",
3771 pri->pname,
3772 args.rbuf,
3773 args.rsize);
3777 static void
3778 show_doorparam32(private_t *pri, long offset)
3780 uint_t val;
3782 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3783 (void) printf("%s\tvalue=%u\n",
3784 pri->pname,
3785 val);
3789 #endif /* _LP64 */
3791 static void
3792 show_doors(private_t *pri)
3794 switch (pri->sys_args[5]) {
3795 case DOOR_CALL:
3796 #ifdef _LP64
3797 if (data_model == PR_MODEL_LP64)
3798 show_doorargs(pri, (long)pri->sys_args[1]);
3799 else
3800 show_doorargs32(pri, (long)pri->sys_args[1]);
3801 #else
3802 show_doorargs(pri, (long)pri->sys_args[1]);
3803 #endif
3804 break;
3805 case DOOR_UCRED:
3806 if (!pri->Errno)
3807 show_ucred(pri, (long)pri->sys_args[0]);
3808 break;
3809 case DOOR_INFO:
3810 if (!pri->Errno)
3811 show_doorinfo(pri, (long)pri->sys_args[1]);
3812 break;
3813 case DOOR_GETPARAM:
3814 if (!pri->Errno) {
3815 #ifdef _LP64
3816 if (data_model == PR_MODEL_LP64)
3817 show_doorparam(pri, (long)pri->sys_args[2]);
3818 else
3819 show_doorparam32(pri, (long)pri->sys_args[2]);
3820 #else
3821 show_doorparam(pri, (long)pri->sys_args[2]);
3822 #endif
3824 break;
3828 static void
3829 show_portargs(private_t *pri, long offset)
3831 port_event_t args;
3833 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3834 (void) printf("%s\tevents=0x%x source=%u\n",
3835 pri->pname,
3836 args.portev_events,
3837 args.portev_source);
3838 (void) printf("%s\tobject=0x%p user=0x%p\n",
3839 pri->pname,
3840 (void *)args.portev_object,
3841 (void *)args.portev_user);
3846 #ifdef _LP64
3848 static void
3849 show_portargs32(private_t *pri, long offset)
3851 port_event32_t args;
3853 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3854 (void) printf("%s\tevents=0x%x source=%u\n",
3855 pri->pname,
3856 args.portev_events,
3857 args.portev_source);
3858 (void) printf("%s\tobject=0x%x user=0x%x\n",
3859 pri->pname,
3860 args.portev_object,
3861 args.portev_user);
3865 #endif /* _LP64 */
3867 static void
3868 show_ports(private_t *pri)
3870 switch (pri->sys_args[0]) {
3871 case PORT_GET:
3872 #ifdef _LP64
3873 if (data_model == PR_MODEL_LP64)
3874 show_portargs(pri, (long)pri->sys_args[2]);
3875 else
3876 show_portargs32(pri, (long)pri->sys_args[2]);
3877 #else
3878 show_portargs(pri, (long)pri->sys_args[2]);
3879 #endif
3880 break;
3884 #define MAX_SNDFL_PRD 16
3886 #ifdef _LP64
3888 static void
3889 show_ksendfilevec32(private_t *pri, int fd,
3890 ksendfilevec32_t *sndvec, int sfvcnt)
3892 ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3893 size_t cpy_rqst;
3895 Eserialize();
3896 while (sfvcnt > 0) {
3897 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3898 sfvcnt -= cpy_rqst;
3899 cpy_rqst *= sizeof (snd[0]);
3901 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3902 break;
3904 snd_ptr = &snd[0];
3906 while (cpy_rqst) {
3907 (void) printf(
3908 "sfv_fd=%d\tsfv_flag=0x%x\t"
3909 "sfv_off=%d\tsfv_len=%u\n",
3910 snd_ptr->sfv_fd,
3911 snd_ptr->sfv_flag,
3912 snd_ptr->sfv_off,
3913 snd_ptr->sfv_len);
3915 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3916 prismember(&writefd, fd)) {
3917 showbuffer(pri,
3918 (long)snd_ptr->sfv_off & 0xffffffff,
3919 (long)snd_ptr->sfv_len);
3922 cpy_rqst -= sizeof (snd[0]);
3923 snd_ptr++;
3926 sndvec += MAX_SNDFL_PRD;
3928 Xserialize();
3931 static void
3932 show_ksendfilevec64(private_t *pri, int fd,
3933 ksendfilevec64_t *sndvec, int sfvcnt)
3935 ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3936 size_t cpy_rqst;
3938 Eserialize();
3939 while (sfvcnt > 0) {
3940 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3941 sfvcnt -= cpy_rqst;
3942 cpy_rqst *= sizeof (snd[0]);
3944 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3945 break;
3947 snd_ptr = &snd[0];
3949 while (cpy_rqst) {
3950 (void) printf(
3951 "sfv_fd=%d\tsfv_flag=0x%x\t"
3952 "sfv_off=%ld\tsfv_len=%u\n",
3953 snd_ptr->sfv_fd,
3954 snd_ptr->sfv_flag,
3955 snd_ptr->sfv_off,
3956 snd_ptr->sfv_len);
3958 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3959 prismember(&writefd, fd)) {
3960 showbuffer(pri,
3961 (long)snd_ptr->sfv_off & 0xffffffff,
3962 (long)snd_ptr->sfv_len);
3965 cpy_rqst -= sizeof (snd[0]);
3966 snd_ptr++;
3969 sndvec += MAX_SNDFL_PRD;
3971 Xserialize();
3974 #endif /* _LP64 */
3976 /*ARGSUSED*/
3977 static void
3978 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3980 sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3981 size_t cpy_rqst;
3983 #ifdef _LP64
3984 if (data_model != PR_MODEL_LP64) {
3985 show_ksendfilevec32(pri, fd,
3986 (ksendfilevec32_t *)sndvec, sfvcnt);
3987 return;
3989 #endif
3990 Eserialize();
3991 while (sfvcnt > 0) {
3992 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3993 sfvcnt -= cpy_rqst;
3994 cpy_rqst *= sizeof (snd[0]);
3996 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3997 break;
3999 snd_ptr = &snd[0];
4001 while (cpy_rqst) {
4002 (void) printf(
4003 "sfv_fd=%d\tsfv_flag=0x%x\t"
4004 "sfv_off=%ld\tsfv_len=%lu\n",
4005 snd_ptr->sfv_fd,
4006 snd_ptr->sfv_flag,
4007 snd_ptr->sfv_off,
4008 (ulong_t)snd_ptr->sfv_len);
4010 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
4011 prismember(&writefd, fd)) {
4012 showbuffer(pri, (long)snd_ptr->sfv_off,
4013 (long)snd_ptr->sfv_len);
4016 cpy_rqst -= sizeof (snd[0]);
4017 snd_ptr++;
4020 sndvec += MAX_SNDFL_PRD;
4022 Xserialize();
4025 /*ARGSUSED*/
4026 static void
4027 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
4029 sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
4030 size_t cpy_rqst;
4032 #ifdef _LP64
4033 if (data_model != PR_MODEL_LP64) {
4034 show_ksendfilevec64(pri, fd,
4035 (ksendfilevec64_t *)sndvec, sfvcnt);
4036 return;
4038 #endif
4040 Eserialize();
4041 while (sfvcnt > 0) {
4042 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
4043 sfvcnt -= cpy_rqst;
4044 cpy_rqst *= sizeof (snd[0]);
4046 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
4047 break;
4049 snd_ptr = &snd[0];
4051 while (cpy_rqst) {
4052 (void) printf(
4053 #ifdef _LP64
4054 "sfv_fd=%d\tsfv_flag=0x%x\t"
4055 "sfv_off=%ld\tsfv_len=%lu\n",
4056 #else
4057 "sfv_fd=%d\tsfv_flag=0x%x\t"
4058 "sfv_off=%lld\tsfv_len=%lu\n",
4059 #endif
4060 snd_ptr->sfv_fd,
4061 snd_ptr->sfv_flag,
4062 snd_ptr->sfv_off,
4063 (ulong_t)snd_ptr->sfv_len);
4065 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
4066 prismember(&writefd, fd)) {
4067 showbuffer(pri, (long)snd_ptr->sfv_off,
4068 (long)snd_ptr->sfv_len);
4071 cpy_rqst -= sizeof (snd[0]);
4072 snd_ptr++;
4075 sndvec += MAX_SNDFL_PRD;
4077 Xserialize();
4080 static void
4081 show_memcntl_mha(private_t *pri, long offset)
4083 struct memcntl_mha mha;
4084 const char *s = NULL;
4086 if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
4087 switch (mha.mha_cmd) {
4088 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
4089 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
4090 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
4092 if (s)
4093 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4094 " mha_pagesize=%lu\n",
4095 pri->pname, s, mha.mha_flags,
4096 (ulong_t)mha.mha_pagesize);
4097 else
4098 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4099 " mha_pagesize=%lu\n",
4100 pri->pname, mha.mha_cmd, mha.mha_flags,
4101 (ulong_t)mha.mha_pagesize);
4105 #ifdef _LP64
4107 static void
4108 show_memcntl_mha32(private_t *pri, long offset)
4110 struct memcntl_mha32 mha32;
4111 const char *s = NULL;
4113 if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
4114 sizeof (mha32)) {
4115 switch (mha32.mha_cmd) {
4116 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
4117 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
4118 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
4120 if (s)
4121 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4122 " mha_pagesize=%u\n",
4123 pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
4124 else
4125 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4126 " mha_pagesize=%u\n",
4127 pri->pname, mha32.mha_cmd, mha32.mha_flags,
4128 mha32.mha_pagesize);
4132 #endif /* _LP64 */
4134 static void
4135 show_memcntl(private_t *pri)
4138 if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
4139 return;
4140 #ifdef _LP64
4141 if (data_model == PR_MODEL_LP64)
4142 show_memcntl_mha(pri, (long)pri->sys_args[3]);
4143 else
4144 show_memcntl_mha32(pri, (long)pri->sys_args[3]);
4145 #else
4146 show_memcntl_mha(pri, (long)pri->sys_args[3]);
4147 #endif
4150 void
4151 show_ids(private_t *pri, long offset, int count)
4153 id_t buf[MYBUFSIZ / sizeof (id_t)];
4154 id_t *idp;
4155 int serial = (count > MYBUFSIZ / 48);
4157 if (offset == 0)
4158 return;
4160 /* enter region of lengthy output */
4161 if (serial)
4162 Eserialize();
4164 while (count > 0 && !interrupt) {
4165 ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
4166 count * sizeof (id_t) : MYBUFSIZ;
4168 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
4169 nb < sizeof (id_t))
4170 break;
4172 idp = buf;
4173 while (!interrupt && nb >= sizeof (id_t)) {
4174 (void) printf("%s\t%8d\n", pri->pname, (int)*idp);
4175 offset += sizeof (id_t);
4176 nb -= sizeof (id_t);
4177 idp++;
4178 count--;
4182 /* exit region of lengthy output */
4183 if (serial)
4184 Xserialize();
4187 void
4188 show_ntp_gettime(private_t *pri)
4190 struct ntptimeval ntv;
4191 long offset;
4193 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4194 return;
4196 if (data_model == PR_MODEL_NATIVE) {
4197 if (Pread(Proc, &ntv, sizeof (ntv), offset)
4198 != sizeof (ntv))
4199 return;
4200 } else {
4201 struct ntptimeval32 ntv32;
4203 if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
4204 != sizeof (ntv32))
4205 return;
4207 TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
4208 ntv.maxerror = ntv32.maxerror;
4209 ntv.esterror = ntv32.esterror;
4212 (void) printf("\ttime: %ld.%6.6ld sec\n",
4213 ntv.time.tv_sec, ntv.time.tv_usec);
4214 (void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
4215 (void) printf("\testerror: %11d usec\n", ntv.esterror);
4218 static char *
4219 get_timex_modes(private_t *pri, uint32_t val)
4221 char *str = pri->code_buf;
4222 size_t used = 0;
4224 *str = '\0';
4225 if (val & MOD_OFFSET)
4226 used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
4227 if (val & MOD_FREQUENCY)
4228 used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
4229 if (val & MOD_MAXERROR)
4230 used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
4231 if (val & MOD_ESTERROR)
4232 used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
4233 if (val & MOD_STATUS)
4234 used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
4235 if (val & MOD_TIMECONST)
4236 used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
4237 if (val & MOD_CLKB)
4238 used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
4239 if (val & MOD_CLKA)
4240 used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
4242 if (used == 0 || used >= sizeof (pri->code_buf))
4243 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4245 return (str + 1);
4248 static char *
4249 get_timex_status(private_t *pri, int32_t val)
4251 char *str = pri->code_buf;
4252 size_t used = 0;
4254 *str = '\0';
4255 if (val & STA_PLL)
4256 used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
4257 if (val & STA_PPSFREQ)
4258 used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
4259 if (val & STA_PPSTIME)
4260 used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
4261 if (val & STA_FLL)
4262 used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
4264 if (val & STA_INS)
4265 used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
4266 if (val & STA_DEL)
4267 used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
4268 if (val & STA_UNSYNC)
4269 used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
4270 if (val & STA_FREQHOLD)
4271 used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
4273 if (val & STA_PPSSIGNAL)
4274 used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
4275 if (val & STA_PPSJITTER)
4276 used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
4277 if (val & STA_PPSWANDER)
4278 used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
4279 if (val & STA_PPSERROR)
4280 used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
4282 if (val & STA_CLOCKERR)
4283 used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
4285 if (used == 0 || used >= sizeof (pri->code_buf))
4286 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4288 return (str + 1);
4291 void
4292 show_ntp_adjtime(private_t *pri)
4294 struct timex timex;
4295 long offset;
4297 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == NULL)
4298 return;
4300 if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4301 return;
4303 (void) printf("\tmodes: %s\n", get_timex_modes(pri, timex.modes));
4304 (void) printf("\toffset: %11d usec\n", timex.offset);
4305 (void) printf("\tfreq: %11d scaled ppm\n", timex.freq);
4306 (void) printf("\tmaxerror: %11d usec\n", timex.maxerror);
4307 (void) printf("\testerror: %11d usec\n", timex.esterror);
4308 (void) printf("\tstatus: %s\n", get_timex_status(pri, timex.status));
4309 (void) printf("\tconstant: %11d\n", timex.constant);
4310 (void) printf("\tprecision: %11d usec\n", timex.precision);
4311 (void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4312 (void) printf("\tppsfreq: %11d scaled ppm\n", timex.ppsfreq);
4313 (void) printf("\tjitter: %11d usec\n", timex.jitter);
4314 (void) printf("\tshift: %11d sec\n", timex.shift);
4315 (void) printf("\tstabil: %11d scaled ppm\n", timex.stabil);
4316 (void) printf("\tjitcnt: %11d\n", timex.jitcnt);
4317 (void) printf("\tcalcnt: %11d\n", timex.calcnt);
4318 (void) printf("\terrcnt: %11d\n", timex.errcnt);
4319 (void) printf("\tstbcnt: %11d\n", timex.stbcnt);
4322 void
4323 show_getrusage(long offset)
4325 struct rusage r;
4326 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4327 return;
4328 (void) printf("\t user time: %ld.%6.6ld sec\n",
4329 r.ru_utime.tv_sec,
4330 r.ru_utime.tv_usec);
4331 (void) printf("\t system time: %ld.%6.6ld sec\n",
4332 r.ru_stime.tv_sec,
4333 r.ru_stime.tv_usec);
4334 (void) printf("\t max rss: <unimpl> %ld\n",
4335 r.ru_maxrss);
4336 (void) printf("\t shared data: <unimpl> %ld\n",
4337 r.ru_ixrss);
4338 (void) printf("\t unshared data: <unimpl> %ld\n",
4339 r.ru_idrss);
4340 (void) printf("\t unshared stack: <unimpl> %ld\n",
4341 r.ru_isrss);
4342 (void) printf("\t minor faults: %ld\n",
4343 r.ru_minflt);
4344 (void) printf("\t major faults: %ld\n",
4345 r.ru_majflt);
4346 (void) printf("\t # of swaps: %ld\n",
4347 r.ru_nswap);
4348 (void) printf("\t blocked inputs: %ld\n",
4349 r.ru_inblock);
4350 (void) printf("\t blocked outputs: %ld\n",
4351 r.ru_oublock);
4352 (void) printf("\t msgs sent: %ld\n",
4353 r.ru_msgsnd);
4354 (void) printf("\t msgs rcv'd: %ld\n",
4355 r.ru_msgrcv);
4356 (void) printf("\t signals rcv'd: %ld\n",
4357 r.ru_nsignals);
4358 (void) printf("\tvol cntxt swtchs: %ld\n",
4359 r.ru_nvcsw);
4360 (void) printf("\tinv cntxt swtchs: %ld\n",
4361 r.ru_nivcsw);
4364 #ifdef _LP64
4365 void
4366 show_getrusage32(long offset)
4368 struct rusage32 r;
4369 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4370 return;
4371 (void) printf("\t user time: %d.%6.6d sec\n",
4372 r.ru_utime.tv_sec,
4373 r.ru_utime.tv_usec);
4374 (void) printf("\t system time: %d.%6.6d sec\n",
4375 r.ru_stime.tv_sec,
4376 r.ru_stime.tv_usec);
4377 (void) printf("\t max rss: <unimpl> %d\n",
4378 r.ru_maxrss);
4379 (void) printf("\t shared data: <unimpl> %d\n",
4380 r.ru_ixrss);
4381 (void) printf("\t unshared data: <unimpl> %d\n",
4382 r.ru_idrss);
4383 (void) printf("\t unshared stack: <unimpl> %d\n",
4384 r.ru_isrss);
4385 (void) printf("\t minor faults: %d\n",
4386 r.ru_minflt);
4387 (void) printf("\t major faults: %d\n",
4388 r.ru_majflt);
4389 (void) printf("\t # of swaps: %d\n",
4390 r.ru_nswap);
4391 (void) printf("\t blocked inputs: %d\n",
4392 r.ru_inblock);
4393 (void) printf("\t blocked outputs: %d\n",
4394 r.ru_oublock);
4395 (void) printf("\t msgs sent: %d\n",
4396 r.ru_msgsnd);
4397 (void) printf("\t msgs rcv'd: %d\n",
4398 r.ru_msgrcv);
4399 (void) printf("\t signals rcv'd: %d\n",
4400 r.ru_nsignals);
4401 (void) printf("\tvol cntxt swtchs: %d\n",
4402 r.ru_nvcsw);
4403 (void) printf("\tinv cntxt swtchs: %d\n",
4404 r.ru_nivcsw);
4406 #endif
4409 * Utility function to print a packed nvlist by unpacking
4410 * and calling the libnvpair pretty printer. Frees all
4411 * allocated memory internally.
4413 static void
4414 show_packed_nvlist(private_t *pri, uintptr_t offset, size_t size)
4416 nvlist_t *nvl = NULL;
4417 size_t readsize;
4418 char *buf;
4420 if ((offset == 0) || (size == 0)) {
4421 return;
4424 buf = my_malloc(size, "nvlist decode buffer");
4425 readsize = Pread(Proc, buf, size, offset);
4426 if (readsize != size) {
4427 (void) printf("%s\t<?>", pri->pname);
4428 } else {
4429 int result;
4431 result = nvlist_unpack(buf, size, &nvl, 0);
4432 if (result == 0) {
4433 dump_nvlist(nvl, 8);
4434 nvlist_free(nvl);
4435 } else {
4436 (void) printf("%s\tunpack of nvlist"
4437 " failed: %d\n", pri->pname, result);
4440 free(buf);
4443 static void
4444 show_zone_create_args(private_t *pri, long offset)
4446 zone_def args;
4447 char zone_name[ZONENAME_MAX];
4448 char zone_root[MAXPATHLEN];
4449 char *zone_zfs = NULL;
4451 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4453 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4454 (uintptr_t)args.zone_name) == -1)
4455 (void) strcpy(zone_name, "<?>");
4457 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4458 (uintptr_t)args.zone_root) == -1)
4459 (void) strcpy(zone_root, "<?>");
4461 if (args.zfsbufsz > 0) {
4462 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4463 if (zone_zfs != NULL) {
4464 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4465 (uintptr_t)args.zfsbuf) == -1)
4466 (void) strcpy(zone_zfs, "<?>");
4468 } else {
4469 zone_zfs = "";
4472 (void) printf("%s\t zone_name: %s\n", pri->pname,
4473 zone_name);
4474 (void) printf("%s\t zone_root: %s\n", pri->pname,
4475 zone_root);
4477 show_privset(pri, (uintptr_t)args.zone_privs,
4478 args.zone_privssz, " zone_privs: ");
4480 (void) printf("%s\t rctlbuf: 0x%p\n", pri->pname,
4481 (void *)args.rctlbuf);
4482 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4483 (ulong_t)args.rctlbufsz);
4485 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4486 args.rctlbufsz);
4488 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4490 (void) printf("%s\textended_error: 0x%p\n", pri->pname,
4491 (void *)args.extended_error);
4493 if (args.zfsbufsz > 0)
4494 free(zone_zfs);
4499 #ifdef _LP64
4501 static void
4502 show_zone_create_args32(private_t *pri, long offset)
4504 zone_def32 args;
4505 char zone_name[ZONENAME_MAX];
4506 char zone_root[MAXPATHLEN];
4507 char *zone_zfs = NULL;
4509 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4511 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4512 (uintptr_t)args.zone_name) == -1)
4513 (void) strcpy(zone_name, "<?>");
4515 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4516 (uintptr_t)args.zone_root) == -1)
4517 (void) strcpy(zone_root, "<?>");
4519 if (args.zfsbufsz > 0) {
4520 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4521 if (zone_zfs != NULL) {
4522 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4523 (uintptr_t)args.zfsbuf) == -1)
4524 (void) strcpy(zone_zfs, "<?>");
4526 } else {
4527 zone_zfs = "";
4530 (void) printf("%s\t zone_name: %s\n", pri->pname,
4531 zone_name);
4532 (void) printf("%s\t zone_root: %s\n", pri->pname,
4533 zone_root);
4535 show_privset(pri, (uintptr_t)args.zone_privs,
4536 args.zone_privssz, " zone_privs: ");
4538 (void) printf("%s\t rctlbuf: 0x%x\n", pri->pname,
4539 (caddr32_t)args.rctlbuf);
4540 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4541 (ulong_t)args.rctlbufsz);
4543 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4544 args.rctlbufsz);
4546 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4548 (void) printf("%s\textended_error: 0x%x\n", pri->pname,
4549 (caddr32_t)args.extended_error);
4551 if (args.zfsbufsz > 0)
4552 free(zone_zfs);
4556 #endif
4558 static void
4559 show_zones(private_t *pri)
4561 switch (pri->sys_args[0]) {
4562 case ZONE_CREATE:
4563 #ifdef _LP64
4564 if (data_model == PR_MODEL_LP64)
4565 show_zone_create_args(pri, (long)pri->sys_args[1]);
4566 else
4567 show_zone_create_args32(pri, (long)pri->sys_args[1]);
4568 #else
4569 show_zone_create_args(pri, (long)pri->sys_args[1]);
4570 #endif
4571 break;
4575 static void
4576 show_rctlblk(private_t *pri, long _rctlblk)
4578 rctlblk_t *blk;
4579 int size = rctlblk_size();
4580 size_t readsize;
4581 const char *s;
4583 blk = my_malloc(size, "rctlblk decode buffer");
4584 readsize = Pread(Proc, blk, size, _rctlblk);
4585 if (readsize != size) {
4586 (void) printf("%s\t\t<?>", pri->pname);
4587 } else {
4588 (void) printf("%s\t\t Privilege: 0x%x\n",
4589 pri->pname,
4590 rctlblk_get_privilege(blk));
4591 (void) printf("%s\t\t Value: %lld\n",
4592 pri->pname,
4593 rctlblk_get_value(blk));
4594 (void) printf("%s\t\tEnforced Value: %lld\n",
4595 pri->pname,
4596 rctlblk_get_enforced_value(blk));
4599 int sig, act;
4600 act = rctlblk_get_local_action(blk, &sig);
4602 s = rctl_local_action(pri, act);
4603 if (s == NULL) {
4604 (void) printf("%s\t\t Local action: 0x%x\n",
4605 pri->pname, act);
4606 } else {
4607 (void) printf("%s\t\t Local action: %s\n",
4608 pri->pname, s);
4611 if (act & RCTL_LOCAL_SIGNAL) {
4612 (void) printf("%s\t\t "
4613 "For signal %s\n",
4614 pri->pname, signame(pri, sig));
4618 s = rctl_local_flags(pri, rctlblk_get_local_flags(blk));
4619 if (s == NULL) {
4620 (void) printf("%s\t\t Local flags: 0x%x\n",
4621 pri->pname, rctlblk_get_local_flags(blk));
4622 } else {
4623 (void) printf("%s\t\t Local flags: %s\n",
4624 pri->pname, s);
4627 #ifdef _LP64
4628 (void) printf("%s\t\t Recipient PID: %d\n",
4629 pri->pname,
4630 rctlblk_get_recipient_pid(blk));
4631 #else
4632 (void) printf("%s\t\t Recipient PID: %ld\n",
4633 pri->pname,
4634 rctlblk_get_recipient_pid(blk));
4635 #endif
4636 (void) printf("%s\t\t Firing Time: %lld\n",
4637 pri->pname,
4638 rctlblk_get_firing_time(blk));
4640 free(blk);
4643 static void
4644 show_rctls(private_t *pri)
4646 int entry;
4648 switch (pri->sys_args[0]) {
4649 case 0: /* getrctl */
4650 case 1: /* setrctl */
4652 * If these offsets look a little odd, remember that they're
4653 * into the _raw_ system call
4655 (void) printf("%s\tOld rctlblk: 0x%lx\n", pri->pname,
4656 pri->sys_args[2]);
4657 if (pri->sys_args[2] != NULL) {
4658 show_rctlblk(pri, pri->sys_args[2]);
4660 (void) printf("%s\tNew rctlblk: 0x%lx\n", pri->pname,
4661 pri->sys_args[3]);
4662 if (pri->sys_args[3] != NULL) {
4663 show_rctlblk(pri, pri->sys_args[3]);
4665 break;
4666 case 4: /* setprojrctl */
4667 for (entry = 0; entry < pri->sys_args[4]; entry++) {
4668 (void) printf("%s\tNew rctlblk[%d]: 0x%lx\n",
4669 pri->pname, entry,
4670 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4671 if (RCTLBLK_INC(pri->sys_args[3], entry) != NULL) {
4672 show_rctlblk(pri,
4673 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4679 void
4680 show_utimesys(private_t *pri)
4682 switch (pri->sys_args[0]) {
4683 case 0: /* futimens() */
4684 if (pri->sys_nargs > 2)
4685 show_utimens(pri, (long)pri->sys_args[2]);
4686 break;
4687 case 1: /* utimensat */
4688 if (pri->sys_nargs > 3)
4689 show_utimens(pri, (long)pri->sys_args[3]);
4690 break;
4691 default: /* unexpected subcode */
4692 break;
4696 #ifdef _LP64
4697 static void
4698 show_sockconfig_filter_prop32(private_t *pri, long addr)
4700 struct sockconfig_filter_props32 props;
4701 const char *s = NULL;
4702 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4703 sof_socktuple32_t *tup;
4704 size_t sz;
4705 int i;
4707 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4708 if (Pread_string(Proc, buf, sizeof (buf),
4709 (uintptr_t)props.sfp_modname) == -1)
4710 (void) strcpy(buf, "<?>");
4711 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4712 (void) printf("%s\tattach semantics: %s", pri->pname,
4713 props.sfp_autoattach ? "automatic" : "progammatic");
4714 if (props.sfp_autoattach) {
4715 buf[0] = '\0';
4716 switch (props.sfp_hint) {
4717 case SOF_HINT_TOP: s = "top"; break;
4718 case SOF_HINT_BOTTOM: s = "bottom"; break;
4719 case SOF_HINT_BEFORE:
4720 case SOF_HINT_AFTER:
4721 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4722 "before" : "after";
4723 if (Pread_string(Proc, buf, sizeof (buf),
4724 (uintptr_t)props.sfp_hintarg) == -1)
4725 (void) strcpy(buf, "<?>");
4727 if (s != NULL) {
4728 (void) printf(", placement: %s %s", s, buf);
4731 (void) printf("\n");
4732 (void) printf("%s\tsocket tuples:\n", pri->pname);
4733 if (props.sfp_socktuple_cnt == 0) {
4734 (void) printf("\t\t<empty>\n");
4735 return;
4737 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4738 tup = my_malloc(sz, "socket tuple buffer");
4739 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4740 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4741 (void) printf(
4742 "\t\tfamily: %d, type: %d, proto: %d\n",
4743 tup[i].sofst_family, tup[i].sofst_type,
4744 tup[i].sofst_protocol);
4748 #endif /* _LP64 */
4749 static void
4750 show_sockconfig_filter_prop(private_t *pri, long addr)
4752 struct sockconfig_filter_props props;
4753 const char *s = NULL;
4754 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4755 sof_socktuple_t *tup;
4756 size_t sz;
4757 int i;
4759 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4760 if (Pread_string(Proc, buf, sizeof (buf),
4761 (uintptr_t)props.sfp_modname) == -1)
4762 (void) strcpy(buf, "<?>");
4763 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4764 (void) printf("%s\tattach semantics: %s", pri->pname,
4765 props.sfp_autoattach ? "automatic" : "progammatic");
4766 if (props.sfp_autoattach) {
4767 buf[0] = '\0';
4768 switch (props.sfp_hint) {
4769 case SOF_HINT_TOP: s = "top"; break;
4770 case SOF_HINT_BOTTOM: s = "bottom"; break;
4771 case SOF_HINT_BEFORE:
4772 case SOF_HINT_AFTER:
4773 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4774 "before" : "after";
4775 if (Pread_string(Proc, buf, sizeof (buf),
4776 (uintptr_t)props.sfp_hintarg) == -1)
4777 (void) strcpy(buf, "<?>");
4779 if (s != NULL) {
4780 (void) printf(", placement: %s", s);
4783 (void) printf("\n");
4784 (void) printf("%s\tsocket tuples:\n", pri->pname);
4785 if (props.sfp_socktuple_cnt == 0) {
4786 (void) printf("\t\t<empty>\n");
4787 return;
4789 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4790 tup = my_malloc(sz, "socket tuple buffer");
4791 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4792 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4793 (void) printf(
4794 "\t\tfamily: %d, type: %d, proto: %d\n",
4795 tup[i].sofst_family, tup[i].sofst_type,
4796 tup[i].sofst_protocol);
4801 void
4802 show_sockconfig(private_t *pri)
4804 switch (pri->sys_args[0]) {
4805 case SOCKCONFIG_ADD_FILTER:
4806 #ifdef _LP64
4807 if (data_model == PR_MODEL_LP64)
4808 show_sockconfig_filter_prop(pri,
4809 (long)pri->sys_args[2]);
4810 else
4811 show_sockconfig_filter_prop32(pri,
4812 (long)pri->sys_args[2]);
4813 #else
4814 show_sockconfig_filter_prop(pri, (long)pri->sys_args[2]);
4815 #endif
4816 break;
4817 default:
4818 break;
4822 void
4823 show_zfs_ioc(private_t *pri, long addr)
4825 static const zfs_share_t zero_share = {0};
4826 static const dmu_objset_stats_t zero_objstats = {0};
4827 static const struct drr_begin zero_drrbegin = {0};
4828 static const zinject_record_t zero_injectrec = {0};
4829 static const zfs_stat_t zero_zstat = {0};
4830 zfs_cmd_t zc;
4832 if (Pread(Proc, &zc, sizeof (zc), addr) != sizeof (zc)) {
4833 (void) printf(" zfs_ioctl read failed\n");
4834 return;
4837 if (zc.zc_name[0])
4838 (void) printf(" zc_name=%s\n", zc.zc_name);
4839 if (zc.zc_value[0])
4840 (void) printf(" zc_value=%s\n", zc.zc_value);
4841 if (zc.zc_string[0])
4842 (void) printf(" zc_string=%s\n", zc.zc_string);
4843 if (zc.zc_guid != 0) {
4844 (void) printf(" zc_guid=%llu\n",
4845 (u_longlong_t)zc.zc_guid);
4847 if (zc.zc_nvlist_conf_size) {
4848 (void) printf(" nvlist_conf:\n");
4849 show_packed_nvlist(pri, zc.zc_nvlist_conf,
4850 zc.zc_nvlist_conf_size);
4852 if (zc.zc_nvlist_src_size) {
4853 (void) printf(" nvlist_src:\n");
4854 show_packed_nvlist(pri, zc.zc_nvlist_src,
4855 zc.zc_nvlist_src_size);
4857 if (zc.zc_nvlist_dst_size) {
4858 (void) printf(" nvlist_dst:\n");
4859 show_packed_nvlist(pri, zc.zc_nvlist_dst,
4860 zc.zc_nvlist_dst_size);
4862 if (zc.zc_cookie != 0) {
4863 (void) printf(" zc_cookie=%llu\n",
4864 (u_longlong_t)zc.zc_cookie);
4866 if (zc.zc_objset_type != 0) {
4867 (void) printf(" zc_objset_type=%llu\n",
4868 (u_longlong_t)zc.zc_objset_type);
4870 if (zc.zc_perm_action != 0) {
4871 (void) printf(" zc_perm_action=%llu\n",
4872 (u_longlong_t)zc.zc_perm_action);
4874 if (zc.zc_history != 0) {
4875 (void) printf(" zc_history=%llu\n",
4876 (u_longlong_t)zc.zc_history);
4878 if (zc.zc_obj != 0) {
4879 (void) printf(" zc_obj=%llu\n",
4880 (u_longlong_t)zc.zc_obj);
4882 if (zc.zc_iflags != 0) {
4883 (void) printf(" zc_obj=0x%llx\n",
4884 (u_longlong_t)zc.zc_iflags);
4887 if (memcmp(&zc.zc_share, &zero_share, sizeof (zc.zc_share))) {
4888 zfs_share_t *z = &zc.zc_share;
4889 (void) printf(" zc_share:\n");
4890 if (z->z_exportdata) {
4891 (void) printf("\tz_exportdata=0x%llx\n",
4892 (u_longlong_t)z->z_exportdata);
4894 if (z->z_sharedata) {
4895 (void) printf("\tz_sharedata=0x%llx\n",
4896 (u_longlong_t)z->z_sharedata);
4898 if (z->z_sharetype) {
4899 (void) printf("\tz_sharetype=%llu\n",
4900 (u_longlong_t)z->z_sharetype);
4902 if (z->z_sharemax) {
4903 (void) printf("\tz_sharemax=%llu\n",
4904 (u_longlong_t)z->z_sharemax);
4908 if (memcmp(&zc.zc_objset_stats, &zero_objstats,
4909 sizeof (zc.zc_objset_stats))) {
4910 dmu_objset_stats_t *dds = &zc.zc_objset_stats;
4911 (void) printf(" zc_objset_stats:\n");
4912 if (dds->dds_num_clones) {
4913 (void) printf("\tdds_num_clones=%llu\n",
4914 (u_longlong_t)dds->dds_num_clones);
4916 if (dds->dds_creation_txg) {
4917 (void) printf("\tdds_creation_txg=%llu\n",
4918 (u_longlong_t)dds->dds_creation_txg);
4920 if (dds->dds_guid) {
4921 (void) printf("\tdds_guid=%llu\n",
4922 (u_longlong_t)dds->dds_guid);
4924 if (dds->dds_type)
4925 (void) printf("\tdds_type=%u\n", dds->dds_type);
4926 if (dds->dds_is_snapshot) {
4927 (void) printf("\tdds_is_snapshot=%u\n",
4928 dds->dds_is_snapshot);
4930 if (dds->dds_inconsistent) {
4931 (void) printf("\tdds_inconsitent=%u\n",
4932 dds->dds_inconsistent);
4934 if (dds->dds_origin[0]) {
4935 (void) printf("\tdds_origin=%s\n", dds->dds_origin);
4939 if (memcmp(&zc.zc_begin_record, &zero_drrbegin,
4940 sizeof (zc.zc_begin_record))) {
4941 struct drr_begin *drr = &zc.zc_begin_record.drr_u.drr_begin;
4942 (void) printf(" zc_begin_record:\n");
4943 if (drr->drr_magic) {
4944 (void) printf("\tdrr_magic=%llu\n",
4945 (u_longlong_t)drr->drr_magic);
4947 if (drr->drr_versioninfo) {
4948 (void) printf("\tdrr_versioninfo=%llu\n",
4949 (u_longlong_t)drr->drr_versioninfo);
4951 if (drr->drr_creation_time) {
4952 (void) printf("\tdrr_creation_time=%llu\n",
4953 (u_longlong_t)drr->drr_creation_time);
4955 if (drr->drr_type)
4956 (void) printf("\tdrr_type=%u\n", drr->drr_type);
4957 if (drr->drr_flags)
4958 (void) printf("\tdrr_flags=0x%x\n", drr->drr_flags);
4959 if (drr->drr_toguid) {
4960 (void) printf("\tdrr_toguid=%llu\n",
4961 (u_longlong_t)drr->drr_toguid);
4963 if (drr->drr_fromguid) {
4964 (void) printf("\tdrr_fromguid=%llu\n",
4965 (u_longlong_t)drr->drr_fromguid);
4967 if (drr->drr_toname[0]) {
4968 (void) printf("\tdrr_toname=%s\n", drr->drr_toname);
4972 if (memcmp(&zc.zc_inject_record, &zero_injectrec,
4973 sizeof (zc.zc_inject_record))) {
4974 zinject_record_t *zi = &zc.zc_inject_record;
4975 (void) printf(" zc_inject_record:\n");
4976 if (zi->zi_objset) {
4977 (void) printf("\tzi_objset=%llu\n",
4978 (u_longlong_t)zi->zi_objset);
4980 if (zi->zi_object) {
4981 (void) printf("\tzi_object=%llu\n",
4982 (u_longlong_t)zi->zi_object);
4984 if (zi->zi_start) {
4985 (void) printf("\tzi_start=%llu\n",
4986 (u_longlong_t)zi->zi_start);
4988 if (zi->zi_end) {
4989 (void) printf("\tzi_end=%llu\n",
4990 (u_longlong_t)zi->zi_end);
4992 if (zi->zi_guid) {
4993 (void) printf("\tzi_guid=%llu\n",
4994 (u_longlong_t)zi->zi_guid);
4996 if (zi->zi_level) {
4997 (void) printf("\tzi_level=%lu\n",
4998 (ulong_t)zi->zi_level);
5000 if (zi->zi_error) {
5001 (void) printf("\tzi_error=%lu\n",
5002 (ulong_t)zi->zi_error);
5004 if (zi->zi_type) {
5005 (void) printf("\tzi_type=%llu\n",
5006 (u_longlong_t)zi->zi_type);
5008 if (zi->zi_freq) {
5009 (void) printf("\tzi_freq=%lu\n",
5010 (ulong_t)zi->zi_freq);
5012 if (zi->zi_failfast) {
5013 (void) printf("\tzi_failfast=%lu\n",
5014 (ulong_t)zi->zi_failfast);
5016 if (zi->zi_func[0])
5017 (void) printf("\tzi_func=%s\n", zi->zi_func);
5018 if (zi->zi_iotype) {
5019 (void) printf("\tzi_iotype=%lu\n",
5020 (ulong_t)zi->zi_iotype);
5022 if (zi->zi_duration) {
5023 (void) printf("\tzi_duration=%ld\n",
5024 (long)zi->zi_duration);
5026 if (zi->zi_timer) {
5027 (void) printf("\tzi_timer=%llu\n",
5028 (u_longlong_t)zi->zi_timer);
5032 if (zc.zc_defer_destroy) {
5033 (void) printf(" zc_defer_destroy=%d\n",
5034 (int)zc.zc_defer_destroy);
5036 if (zc.zc_flags) {
5037 (void) printf(" zc_flags=0x%x\n",
5038 zc.zc_flags);
5040 if (zc.zc_action_handle) {
5041 (void) printf(" zc_action_handle=%llu\n",
5042 (u_longlong_t)zc.zc_action_handle);
5044 if (zc.zc_cleanup_fd >= 0)
5045 (void) printf(" zc_cleanup_fd=%d\n", zc.zc_cleanup_fd);
5046 if (zc.zc_sendobj) {
5047 (void) printf(" zc_sendobj=%llu\n",
5048 (u_longlong_t)zc.zc_sendobj);
5050 if (zc.zc_fromobj) {
5051 (void) printf(" zc_fromobj=%llu\n",
5052 (u_longlong_t)zc.zc_fromobj);
5054 if (zc.zc_createtxg) {
5055 (void) printf(" zc_createtxg=%llu\n",
5056 (u_longlong_t)zc.zc_createtxg);
5059 if (memcmp(&zc.zc_stat, &zero_zstat, sizeof (zc.zc_stat))) {
5060 zfs_stat_t *zs = &zc.zc_stat;
5061 (void) printf(" zc_stat:\n");
5062 if (zs->zs_gen) {
5063 (void) printf("\tzs_gen=%llu\n",
5064 (u_longlong_t)zs->zs_gen);
5066 if (zs->zs_mode) {
5067 (void) printf("\tzs_mode=%llu\n",
5068 (u_longlong_t)zs->zs_mode);
5070 if (zs->zs_links) {
5071 (void) printf("\tzs_links=%llu\n",
5072 (u_longlong_t)zs->zs_links);
5074 if (zs->zs_ctime[0]) {
5075 (void) printf("\tzs_ctime[0]=%llu\n",
5076 (u_longlong_t)zs->zs_ctime[0]);
5078 if (zs->zs_ctime[1]) {
5079 (void) printf("\tzs_ctime[1]=%llu\n",
5080 (u_longlong_t)zs->zs_ctime[1]);
5085 /* expound verbosely upon syscall arguments */
5086 /*ARGSUSED*/
5087 void
5088 expound(private_t *pri, long r0, int raw)
5090 const lwpstatus_t *Lsp = pri->lwpstat;
5091 int lp64 = (data_model == PR_MODEL_LP64);
5092 int what = Lsp->pr_what;
5093 int err = pri->Errno; /* don't display output parameters */
5094 /* for a failed system call */
5095 #ifndef _LP64
5096 /* We are a 32-bit truss; we can't grok a 64-bit process */
5097 if (lp64)
5098 return;
5099 #endif
5100 /* for reporting sleeping system calls */
5101 if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
5102 what = Lsp->pr_syscall;
5104 switch (what) {
5105 case SYS_gettimeofday:
5106 if (!err)
5107 show_timeofday(pri);
5108 break;
5109 case SYS_getitimer:
5110 if (!err && pri->sys_nargs > 1)
5111 show_itimerval(pri, (long)pri->sys_args[1],
5112 " value");
5113 break;
5114 case SYS_setitimer:
5115 if (pri->sys_nargs > 1)
5116 show_itimerval(pri, (long)pri->sys_args[1],
5117 " value");
5118 if (!err && pri->sys_nargs > 2)
5119 show_itimerval(pri, (long)pri->sys_args[2],
5120 "ovalue");
5121 break;
5122 case SYS_stime:
5123 show_stime(pri);
5124 break;
5125 case SYS_times:
5126 if (!err)
5127 show_times(pri);
5128 break;
5129 case SYS_utssys:
5130 if (err)
5131 break;
5132 #ifdef _LP64
5133 if (lp64)
5134 show_utssys(pri, r0);
5135 else
5136 show_utssys32(pri, r0);
5137 #else
5138 show_utssys(pri, r0);
5139 #endif
5140 break;
5141 case SYS_ioctl:
5142 if (pri->sys_nargs >= 3) /* each case must decide for itself */
5143 show_ioctl(pri, pri->sys_args[1],
5144 (long)pri->sys_args[2]);
5145 break;
5146 case SYS_fstatat:
5147 if (!err && pri->sys_nargs >= 3)
5148 show_stat(pri, (long)pri->sys_args[2]);
5149 break;
5150 case SYS_fstatat64:
5151 if (!err && pri->sys_nargs >= 3)
5152 show_stat64_32(pri, (long)pri->sys_args[2]);
5153 break;
5154 case SYS_stat:
5155 case SYS_fstat:
5156 case SYS_lstat:
5157 if (!err && pri->sys_nargs >= 2)
5158 show_stat(pri, (long)pri->sys_args[1]);
5159 break;
5160 case SYS_stat64:
5161 case SYS_fstat64:
5162 case SYS_lstat64:
5163 if (!err && pri->sys_nargs >= 2)
5164 show_stat64_32(pri, (long)pri->sys_args[1]);
5165 break;
5166 case SYS_statvfs:
5167 case SYS_fstatvfs:
5168 if (err)
5169 break;
5170 #ifdef _LP64
5171 if (!lp64) {
5172 show_statvfs32(pri);
5173 break;
5175 #endif
5176 show_statvfs(pri);
5177 break;
5178 case SYS_statvfs64:
5179 case SYS_fstatvfs64:
5180 if (err)
5181 break;
5182 show_statvfs64(pri);
5183 break;
5184 case SYS_statfs:
5185 case SYS_fstatfs:
5186 if (err)
5187 break;
5188 #ifdef _LP64
5189 if (lp64)
5190 show_statfs(pri);
5191 else
5192 show_statfs32(pri);
5193 #else
5194 show_statfs(pri);
5195 #endif
5196 break;
5197 case SYS_fcntl:
5198 show_fcntl(pri);
5199 break;
5200 case SYS_msgsys:
5201 show_msgsys(pri, r0); /* each case must decide for itself */
5202 break;
5203 case SYS_semsys:
5204 show_semsys(pri); /* each case must decide for itself */
5205 break;
5206 case SYS_shmsys:
5207 show_shmsys(pri); /* each case must decide for itself */
5208 break;
5209 case SYS_getdents:
5210 if (err || pri->sys_nargs <= 1 || r0 <= 0)
5211 break;
5212 #ifdef _LP64
5213 if (!lp64) {
5214 show_dents32(pri, (long)pri->sys_args[1], r0);
5215 break;
5217 /* FALLTHROUGH */
5218 #else
5219 show_dents32(pri, (long)pri->sys_args[1], r0);
5220 break;
5221 #endif
5222 case SYS_getdents64:
5223 if (err || pri->sys_nargs <= 1 || r0 <= 0)
5224 break;
5225 show_dents64(pri, (long)pri->sys_args[1], r0);
5226 break;
5227 case SYS_getmsg:
5228 show_gp_msg(pri, what);
5229 if (pri->sys_nargs > 3)
5230 show_hhex_int(pri, (long)pri->sys_args[3], "flags");
5231 break;
5232 case SYS_getpmsg:
5233 show_gp_msg(pri, what);
5234 if (pri->sys_nargs > 3)
5235 show_hhex_int(pri, (long)pri->sys_args[3], "band");
5236 if (pri->sys_nargs > 4)
5237 show_hhex_int(pri, (long)pri->sys_args[4], "flags");
5238 break;
5239 case SYS_putmsg:
5240 case SYS_putpmsg:
5241 show_gp_msg(pri, what);
5242 break;
5243 case SYS_pollsys:
5244 show_pollsys(pri);
5245 break;
5246 case SYS_setgroups:
5247 if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
5248 show_groups(pri, (long)pri->sys_args[1], r0);
5249 break;
5250 case SYS_getgroups:
5251 if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
5252 show_groups(pri, (long)pri->sys_args[1], r0);
5253 break;
5254 case SYS_sigprocmask:
5255 if (pri->sys_nargs > 1)
5256 show_sigset(pri, (long)pri->sys_args[1], " set");
5257 if (!err && pri->sys_nargs > 2)
5258 show_sigset(pri, (long)pri->sys_args[2], "oset");
5259 break;
5260 case SYS_sigsuspend:
5261 case SYS_sigtimedwait:
5262 if (pri->sys_nargs > 0)
5263 show_sigset(pri, (long)pri->sys_args[0], "sigmask");
5264 if (!err && pri->sys_nargs > 1)
5265 show_siginfo(pri, (long)pri->sys_args[1]);
5266 if (pri->sys_nargs > 2)
5267 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5268 break;
5269 case SYS_sigaltstack:
5270 if (pri->sys_nargs > 0)
5271 show_sigaltstack(pri, (long)pri->sys_args[0],
5272 "new");
5273 if (!err && pri->sys_nargs > 1)
5274 show_sigaltstack(pri, (long)pri->sys_args[1],
5275 "old");
5276 break;
5277 case SYS_sigaction:
5278 if (pri->sys_nargs > 1)
5279 show_sigaction(pri, (long)pri->sys_args[1],
5280 "new", NULL);
5281 if (!err && pri->sys_nargs > 2)
5282 show_sigaction(pri, (long)pri->sys_args[2],
5283 "old", r0);
5284 break;
5285 case SYS_signotify:
5286 if (pri->sys_nargs > 1)
5287 show_siginfo(pri, (long)pri->sys_args[1]);
5288 break;
5289 case SYS_sigresend:
5290 if (pri->sys_nargs > 1)
5291 show_siginfo(pri, (long)pri->sys_args[1]);
5292 if (pri->sys_nargs > 2)
5293 show_sigset(pri, (long)pri->sys_args[2], "sigmask");
5294 break;
5295 case SYS_sigpending:
5296 if (!err && pri->sys_nargs > 1)
5297 show_sigset(pri, (long)pri->sys_args[1], "sigmask");
5298 break;
5299 case SYS_waitid:
5300 if (!err && pri->sys_nargs > 2)
5301 show_siginfo(pri, (long)pri->sys_args[2]);
5302 break;
5303 case SYS_sigsendsys:
5304 if (pri->sys_nargs > 0)
5305 show_procset(pri, (long)pri->sys_args[0]);
5306 break;
5307 case SYS_priocntlsys:
5308 if (pri->sys_nargs > 1)
5309 show_procset(pri, (long)pri->sys_args[1]);
5310 break;
5311 case SYS_mincore:
5312 if (!err && pri->sys_nargs > 2)
5313 show_bool(pri, (long)pri->sys_args[2],
5314 (pri->sys_args[1] + pagesize - 1) / pagesize);
5315 break;
5316 case SYS_readv:
5317 case SYS_writev:
5318 if (pri->sys_nargs > 2) {
5319 int i = pri->sys_args[0]+1;
5320 int showbuf = FALSE;
5321 long nb = (what == SYS_readv)? r0 : 32*1024;
5323 if ((what == SYS_readv && !err &&
5324 prismember(&readfd, i)) ||
5325 (what == SYS_writev &&
5326 prismember(&writefd, i)))
5327 showbuf = TRUE;
5328 show_iovec(pri, (long)pri->sys_args[1],
5329 pri->sys_args[2], showbuf, nb);
5331 break;
5332 case SYS_getrlimit:
5333 if (err)
5334 break;
5335 /*FALLTHROUGH*/
5336 case SYS_setrlimit:
5337 if (pri->sys_nargs <= 1)
5338 break;
5339 #ifdef _LP64
5340 if (lp64)
5341 show_rlimit64(pri, (long)pri->sys_args[1]);
5342 else
5343 show_rlimit32(pri, (long)pri->sys_args[1]);
5344 #else
5345 show_rlimit32(pri, (long)pri->sys_args[1]);
5346 #endif
5347 break;
5348 case SYS_getrlimit64:
5349 if (err)
5350 break;
5351 /*FALLTHROUGH*/
5352 case SYS_setrlimit64:
5353 if (pri->sys_nargs <= 1)
5354 break;
5355 show_rlimit64(pri, (long)pri->sys_args[1]);
5356 break;
5357 case SYS_uname:
5358 if (!err && pri->sys_nargs > 0)
5359 show_nuname(pri, (long)pri->sys_args[0]);
5360 break;
5361 case SYS_adjtime:
5362 if (!err && pri->sys_nargs > 1)
5363 show_adjtime(pri, (long)pri->sys_args[0],
5364 (long)pri->sys_args[1]);
5365 break;
5366 case SYS_lwp_info:
5367 if (!err && pri->sys_nargs > 0)
5368 show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
5369 break;
5370 case SYS_lwp_wait:
5371 if (!err && pri->sys_nargs > 1)
5372 show_int(pri, (long)pri->sys_args[1], "lwpid");
5373 break;
5374 case SYS_lwp_mutex_wakeup:
5375 case SYS_lwp_mutex_unlock:
5376 case SYS_lwp_mutex_trylock:
5377 case SYS_lwp_mutex_register:
5378 if (pri->sys_nargs > 0)
5379 show_mutex(pri, (long)pri->sys_args[0]);
5380 break;
5381 case SYS_lwp_mutex_timedlock:
5382 if (pri->sys_nargs > 0)
5383 show_mutex(pri, (long)pri->sys_args[0]);
5384 if (pri->sys_nargs > 1)
5385 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5386 break;
5387 case SYS_lwp_cond_wait:
5388 if (pri->sys_nargs > 0)
5389 show_condvar(pri, (long)pri->sys_args[0]);
5390 if (pri->sys_nargs > 1)
5391 show_mutex(pri, (long)pri->sys_args[1]);
5392 if (pri->sys_nargs > 2)
5393 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5394 break;
5395 case SYS_lwp_cond_signal:
5396 case SYS_lwp_cond_broadcast:
5397 if (pri->sys_nargs > 0)
5398 show_condvar(pri, (long)pri->sys_args[0]);
5399 break;
5400 case SYS_lwp_sema_trywait:
5401 case SYS_lwp_sema_post:
5402 if (pri->sys_nargs > 0)
5403 show_sema(pri, (long)pri->sys_args[0]);
5404 break;
5405 case SYS_lwp_sema_timedwait:
5406 if (pri->sys_nargs > 0)
5407 show_sema(pri, (long)pri->sys_args[0]);
5408 if (pri->sys_nargs > 1)
5409 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5410 break;
5411 case SYS_lwp_rwlock_sys:
5412 if (pri->sys_nargs > 1)
5413 show_rwlock(pri, (long)pri->sys_args[1]);
5414 if (pri->sys_nargs > 2 &&
5415 (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
5416 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5417 break;
5418 case SYS_lwp_create:
5419 /* XXX print some values in ucontext ??? */
5420 if (!err && pri->sys_nargs > 2)
5421 show_int(pri, (long)pri->sys_args[2], "lwpid");
5422 break;
5423 case SYS_kaio:
5424 if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
5425 show_timeval(pri, (long)pri->sys_args[1], "timeout");
5426 break;
5427 case SYS_nanosleep:
5428 if (pri->sys_nargs > 0)
5429 show_timestruc(pri, (long)pri->sys_args[0], "tmout");
5430 if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
5431 show_timestruc(pri, (long)pri->sys_args[1], "resid");
5432 break;
5433 case SYS_privsys:
5434 switch (pri->sys_args[0]) {
5435 case PRIVSYS_SETPPRIV:
5436 case PRIVSYS_GETPPRIV:
5437 if (!err)
5438 show_privset(pri, (long)pri->sys_args[3],
5439 (size_t)pri->sys_args[4], "");
5441 break;
5442 case SYS_ucredsys:
5443 switch (pri->sys_args[0]) {
5444 case UCREDSYS_UCREDGET:
5445 case UCREDSYS_GETPEERUCRED:
5446 if (err == 0)
5447 show_ucred(pri, (long)pri->sys_args[2]);
5448 break;
5450 break;
5451 case SYS_bind:
5452 case SYS_connect:
5453 if (pri->sys_nargs > 2)
5454 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5455 0, (long)pri->sys_args[2]);
5456 break;
5457 case SYS_sendto:
5458 if (pri->sys_nargs > 5)
5459 show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
5460 pri->sys_args[5]);
5461 break;
5462 case SYS_accept:
5463 if (!err && pri->sys_nargs > 2)
5464 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5465 (long)pri->sys_args[2], 0);
5466 break;
5467 case SYS_getsockname:
5468 case SYS_getpeername:
5469 if (!err && pri->sys_nargs > 2)
5470 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5471 (long)pri->sys_args[2], 0);
5472 break;
5473 case SYS_cladm:
5474 if (!err && pri->sys_nargs > 2)
5475 show_cladm(pri, pri->sys_args[0], pri->sys_args[1],
5476 (long)pri->sys_args[2]);
5477 break;
5478 case SYS_recvfrom:
5479 if (!err && pri->sys_nargs > 5)
5480 show_sockaddr(pri, "from", (long)pri->sys_args[4],
5481 (long)pri->sys_args[5], 0);
5482 break;
5483 case SYS_recvmsg:
5484 if (err)
5485 break;
5486 /* FALLTHROUGH */
5487 case SYS_sendmsg:
5488 if (pri->sys_nargs <= 2)
5489 break;
5490 #ifdef _LP64
5491 if (lp64)
5492 show_msghdr(pri, pri->sys_args[1]);
5493 else
5494 show_msghdr32(pri, pri->sys_args[1]);
5495 #else
5496 show_msghdr(pri, pri->sys_args[1]);
5497 #endif
5498 break;
5499 case SYS_door:
5500 show_doors(pri);
5501 break;
5502 case SYS_sendfilev:
5503 if (pri->sys_nargs != 5)
5504 break;
5506 if (pri->sys_args[0] == SENDFILEV) {
5507 show_sendfilevec(pri, (int)pri->sys_args[1],
5508 (sendfilevec_t *)pri->sys_args[2],
5509 (int)pri->sys_args[3]);
5510 } else if (pri->sys_args[0] == SENDFILEV64) {
5511 show_sendfilevec64(pri, (int)pri->sys_args[1],
5512 (sendfilevec64_t *)pri->sys_args[2],
5513 (int)pri->sys_args[3]);
5515 break;
5516 case SYS_memcntl:
5517 show_memcntl(pri);
5518 break;
5519 case SYS_lwp_park:
5521 * subcode 0: lwp_park(timespec_t *, id_t)
5522 * subcode 4: lwp_set_park(timespec_t *, id_t)
5524 if (pri->sys_nargs > 1 &&
5525 (pri->sys_args[0] == 0 || pri->sys_args[0] == 4))
5526 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5527 /* subcode 2: lwp_unpark_all(id_t *, int) */
5528 if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
5529 show_ids(pri, (long)pri->sys_args[1],
5530 (int)pri->sys_args[2]);
5531 break;
5532 case SYS_ntp_gettime:
5533 if (!err)
5534 show_ntp_gettime(pri);
5535 break;
5536 case SYS_ntp_adjtime:
5537 if (!err)
5538 show_ntp_adjtime(pri);
5539 break;
5540 case SYS_rusagesys:
5541 if (!err)
5542 if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
5543 #ifdef _LP64
5544 if (!lp64)
5545 show_getrusage32(pri->sys_args[1]);
5546 else
5547 #endif
5548 show_getrusage(pri->sys_args[1]);
5550 break;
5551 case SYS_port:
5552 show_ports(pri);
5553 break;
5554 case SYS_zone:
5555 show_zones(pri);
5556 break;
5557 case SYS_rctlsys:
5558 show_rctls(pri);
5559 break;
5560 case SYS_utimesys:
5561 show_utimesys(pri);
5562 break;
5563 case SYS_sockconfig:
5564 show_sockconfig(pri);
5565 break;