Merge commit 'a058d1cc571af5fbcfe7f1d719df1abbfdb722f3' into merges
[unleashed.git] / usr / src / cmd / truss / expound.c
blob29de8b17d2b94b6d0bd6fe62bd2d55e3bf8f069b
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/synch.h>
80 #include <sys/synch32.h>
81 #include <sys/sysmacros.h>
82 #include <sys/sendfile.h>
83 #include <priv.h>
84 #include <ucred.h>
85 #include <sys/ucred.h>
86 #include <sys/port_impl.h>
87 #include <sys/zone.h>
88 #include <sys/priv_impl.h>
89 #include <sys/priv.h>
90 #include <sys/nvpair.h>
91 #include <libnvpair.h>
92 #include <sys/rctl_impl.h>
93 #include <sys/socketvar.h>
94 #include <sys/fs/zfs.h>
95 #include <sys/zfs_ioctl.h>
97 #include "ramdata.h"
98 #include "systable.h"
99 #include "proto.h"
101 void show_sigset(private_t *, long, const char *);
102 void show_ioctl(private_t *, int, long);
103 void show_zfs_ioc(private_t *, long);
105 static void
106 mk_ctime(char *str, size_t maxsize, time_t value)
108 (void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
109 localtime(&value));
112 void
113 prtime(private_t *pri, const char *name, time_t value)
115 char str[80];
117 mk_ctime(str, sizeof (str), value);
118 (void) printf("%s\t%s%s [ %lu ]\n",
119 pri->pname,
120 name,
121 str,
122 value);
125 void
126 prtimeval(private_t *pri, const char *name, struct timeval *value)
128 char str[80];
130 mk_ctime(str, sizeof (str), value->tv_sec);
131 (void) printf("%s\t%s%s [ %lu.%6.6lu ]\n",
132 pri->pname,
133 name,
134 str,
135 value->tv_sec,
136 value->tv_usec);
139 void
140 prtimestruc(private_t *pri, const char *name, timestruc_t *value)
142 char str[80];
144 mk_ctime(str, sizeof (str), value->tv_sec);
145 (void) printf("%s\t%s%s [ %lu.%9.9lu ]\n",
146 pri->pname,
147 name,
148 str,
149 value->tv_sec,
150 value->tv_nsec);
153 static void
154 show_utimens(private_t *pri, long offset)
156 struct {
157 timespec_t atime;
158 timespec_t mtime;
159 } utimbuf;
161 if (offset == 0)
162 return;
164 if (data_model == PR_MODEL_NATIVE) {
165 if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
166 != sizeof (utimbuf))
167 return;
168 } else {
169 struct {
170 timespec32_t atime;
171 timespec32_t mtime;
172 } utimbuf32;
174 if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
175 != sizeof (utimbuf32))
176 return;
178 TIMESPEC32_TO_TIMESPEC(&utimbuf.atime, &utimbuf32.atime);
179 TIMESPEC32_TO_TIMESPEC(&utimbuf.mtime, &utimbuf32.mtime);
182 /* print access and modification times */
183 if (utimbuf.atime.tv_nsec == UTIME_OMIT)
184 (void) printf("%s\tat = UTIME_OMIT\n", pri->pname);
185 else if (utimbuf.atime.tv_nsec == UTIME_NOW)
186 (void) printf("%s\tat = UTIME_NOW\n", pri->pname);
187 else
188 prtimestruc(pri, "at = ", &utimbuf.atime);
189 if (utimbuf.mtime.tv_nsec == UTIME_OMIT)
190 (void) printf("%s\tmt = UTIME_OMIT\n", pri->pname);
191 else if (utimbuf.mtime.tv_nsec == UTIME_NOW)
192 (void) printf("%s\tmt = UTIME_NOW\n", pri->pname);
193 else
194 prtimestruc(pri, "mt = ", &utimbuf.mtime);
197 void
198 show_timeofday(private_t *pri)
200 struct timeval tod;
201 long offset;
203 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
204 return;
206 if (data_model == PR_MODEL_NATIVE) {
207 if (Pread(Proc, &tod, sizeof (tod), offset)
208 != sizeof (tod))
209 return;
210 } else {
211 struct timeval32 tod32;
213 if (Pread(Proc, &tod32, sizeof (tod32), offset)
214 != sizeof (tod32))
215 return;
217 TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
220 prtimeval(pri, "time: ", &tod);
223 void
224 show_itimerval(private_t *pri, long offset, const char *name)
226 struct itimerval itimerval;
228 if (offset == 0)
229 return;
231 if (data_model == PR_MODEL_NATIVE) {
232 if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
233 != sizeof (itimerval))
234 return;
235 } else {
236 struct itimerval32 itimerval32;
238 if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
239 != sizeof (itimerval32))
240 return;
242 ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
245 (void) printf(
246 "%s\t%s: interval: %4ld.%6.6ld sec value: %4ld.%6.6ld sec\n",
247 pri->pname,
248 name,
249 itimerval.it_interval.tv_sec,
250 itimerval.it_interval.tv_usec,
251 itimerval.it_value.tv_sec,
252 itimerval.it_value.tv_usec);
255 void
256 show_timeval(private_t *pri, long offset, const char *name)
258 struct timeval timeval;
260 if (offset == 0)
261 return;
263 if (data_model == PR_MODEL_NATIVE) {
264 if (Pread(Proc, &timeval, sizeof (timeval), offset)
265 != sizeof (timeval))
266 return;
267 } else {
268 struct timeval32 timeval32;
270 if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
271 != sizeof (timeval32))
272 return;
274 TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
277 (void) printf(
278 "%s\t%s: %ld.%6.6ld sec\n",
279 pri->pname,
280 name,
281 timeval.tv_sec,
282 timeval.tv_usec);
285 void
286 show_timestruc(private_t *pri, long offset, const char *name)
288 timestruc_t timestruc;
290 if (offset == 0)
291 return;
293 if (data_model == PR_MODEL_NATIVE) {
294 if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
295 != sizeof (timestruc))
296 return;
297 } else {
298 timestruc32_t timestruc32;
300 if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
301 != sizeof (timestruc32))
302 return;
304 TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
307 (void) printf(
308 "%s\t%s: %ld.%9.9ld sec\n",
309 pri->pname,
310 name,
311 timestruc.tv_sec,
312 timestruc.tv_nsec);
315 void
316 show_stime(private_t *pri)
318 if (pri->sys_nargs >= 1) {
319 /* print new system time */
320 prtime(pri, "systime = ", (time_t)pri->sys_args[0]);
324 void
325 show_times(private_t *pri)
327 long hz = sysconf(_SC_CLK_TCK);
328 long offset;
329 struct tms tms;
331 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
332 return;
334 if (data_model == PR_MODEL_NATIVE) {
335 if (Pread(Proc, &tms, sizeof (tms), offset)
336 != sizeof (tms))
337 return;
338 } else {
339 struct tms32 tms32;
341 if (Pread(Proc, &tms32, sizeof (tms32), offset)
342 != sizeof (tms32))
343 return;
346 * This looks a bit odd (since the values are actually
347 * signed), but we need to suppress sign extension to
348 * preserve compatibility (we've always printed these
349 * numbers as unsigned quantities).
351 tms.tms_utime = (unsigned)tms32.tms_utime;
352 tms.tms_stime = (unsigned)tms32.tms_stime;
353 tms.tms_cutime = (unsigned)tms32.tms_cutime;
354 tms.tms_cstime = (unsigned)tms32.tms_cstime;
357 (void) printf(
358 "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
359 pri->pname,
360 tms.tms_utime,
361 tms.tms_stime,
362 tms.tms_cutime,
363 tms.tms_cstime,
364 hz);
367 /* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
368 void
369 show_ustat(private_t *pri, long offset)
371 struct ustat ubuf;
373 if (offset != 0 &&
374 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
375 (void) printf(
376 "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
377 pri->pname,
378 ubuf.f_tfree,
379 ubuf.f_tinode,
380 ubuf.f_fname,
381 ubuf.f_fpack);
385 #ifdef _LP64
386 void
387 show_ustat32(private_t *pri, long offset)
389 struct ustat32 ubuf;
391 if (offset != 0 &&
392 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
393 (void) printf(
394 "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
395 pri->pname,
396 ubuf.f_tfree,
397 ubuf.f_tinode,
398 ubuf.f_fname,
399 ubuf.f_fpack);
402 #endif /* _LP64 */
404 void
405 show_fusers(private_t *pri, long offset, long nproc)
407 f_user_t fubuf;
408 int serial = (nproc > 4);
410 if (offset == 0)
411 return;
413 /* enter region of lengthy output */
414 if (serial)
415 Eserialize();
417 while (nproc > 0 &&
418 Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
419 (void) printf("%s\tpid=%-5d uid=%-5u flags=%s\n",
420 pri->pname,
421 (int)fubuf.fu_pid,
422 fubuf.fu_uid,
423 fuflags(pri, fubuf.fu_flags));
424 nproc--;
425 offset += sizeof (fubuf);
428 /* exit region of lengthy output */
429 if (serial)
430 Xserialize();
433 void
434 show_utssys(private_t *pri, long r0)
436 if (pri->sys_nargs >= 3) {
437 switch (pri->sys_args[2]) {
438 case UTS_USTAT:
439 show_ustat(pri, (long)pri->sys_args[0]);
440 break;
441 case UTS_FUSERS:
442 show_fusers(pri, (long)pri->sys_args[3], r0);
443 break;
448 #ifdef _LP64
449 void
450 show_utssys32(private_t *pri, long r0)
452 if (pri->sys_nargs >= 3) {
453 switch (pri->sys_args[2]) {
454 case UTS_USTAT:
455 show_ustat32(pri, (long)pri->sys_args[0]);
456 break;
457 case UTS_FUSERS:
458 show_fusers(pri, (long)pri->sys_args[3], r0);
459 break;
463 #endif /* _LP64 */
465 #define ALL_LOCK_TYPES \
466 (USYNC_PROCESS | LOCK_ERRORCHECK | LOCK_RECURSIVE | \
467 LOCK_PRIO_INHERIT | LOCK_PRIO_PROTECT | LOCK_ROBUST | \
468 USYNC_PROCESS_ROBUST)
470 /* return cv and mutex types */
471 const char *
472 synch_type(private_t *pri, uint_t type)
474 char *str = pri->code_buf;
476 if (type & USYNC_PROCESS)
477 (void) strcpy(str, "USYNC_PROCESS");
478 else
479 (void) strcpy(str, "USYNC_THREAD");
481 if (type & LOCK_ERRORCHECK)
482 (void) strcat(str, "|LOCK_ERRORCHECK");
483 if (type & LOCK_RECURSIVE)
484 (void) strcat(str, "|LOCK_RECURSIVE");
485 if (type & LOCK_PRIO_INHERIT)
486 (void) strcat(str, "|LOCK_PRIO_INHERIT");
487 if (type & LOCK_PRIO_PROTECT)
488 (void) strcat(str, "|LOCK_PRIO_PROTECT");
489 if (type & LOCK_ROBUST)
490 (void) strcat(str, "|LOCK_ROBUST");
491 if (type & USYNC_PROCESS_ROBUST)
492 (void) strcat(str, "|USYNC_PROCESS_ROBUST");
494 if ((type &= ~ALL_LOCK_TYPES) != 0)
495 (void) sprintf(str + strlen(str), "|0x%.4X", type);
497 return ((const char *)str);
500 void
501 show_mutex(private_t *pri, long offset)
503 lwp_mutex_t mutex;
505 if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
506 (void) printf("%s\tmutex type: %s\n",
507 pri->pname,
508 synch_type(pri, mutex.mutex_type));
512 void
513 show_condvar(private_t *pri, long offset)
515 lwp_cond_t condvar;
517 if (Pread(Proc, &condvar, sizeof (condvar), offset)
518 == sizeof (condvar)) {
519 (void) printf("%s\tcondvar type: %s\n",
520 pri->pname,
521 synch_type(pri, condvar.cond_type));
525 void
526 show_sema(private_t *pri, long offset)
528 lwp_sema_t sema;
530 if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
531 (void) printf("%s\tsema type: %s count = %u\n",
532 pri->pname,
533 synch_type(pri, sema.sema_type),
534 sema.sema_count);
538 void
539 show_rwlock(private_t *pri, long offset)
541 lwp_rwlock_t rwlock;
543 if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
544 (void) printf("%s\trwlock type: %s readers = %d\n",
545 pri->pname,
546 synch_type(pri, rwlock.rwlock_type),
547 rwlock.rwlock_readers);
551 /* represent character as itself ('c') or octal (012) */
552 char *
553 show_char(char *buf, int c)
555 const char *fmt;
557 if (c >= ' ' && c < 0177)
558 fmt = "'%c'";
559 else
560 fmt = "%.3o";
562 (void) sprintf(buf, fmt, c&0xff);
563 return (buf);
566 void
567 show_termio(private_t *pri, long offset)
569 struct termio termio;
570 char cbuf[8];
571 int i;
573 if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
574 (void) printf(
575 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
576 pri->pname,
577 termio.c_iflag,
578 termio.c_oflag,
579 termio.c_cflag,
580 termio.c_lflag,
581 termio.c_line);
582 (void) printf("%s\t cc: ", pri->pname);
583 for (i = 0; i < NCC; i++)
584 (void) printf(" %s",
585 show_char(cbuf, (int)termio.c_cc[i]));
586 (void) fputc('\n', stdout);
590 void
591 show_termios(private_t *pri, long offset)
593 struct termios termios;
594 char cbuf[8];
595 int i;
597 if (Pread(Proc, &termios, sizeof (termios), offset)
598 == sizeof (termios)) {
599 (void) printf(
600 "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
601 pri->pname,
602 termios.c_iflag,
603 termios.c_oflag,
604 termios.c_cflag,
605 termios.c_lflag);
606 (void) printf("%s\t cc: ", pri->pname);
607 for (i = 0; i < NCCS; i++) {
608 if (i == NCC) /* show new chars on new line */
609 (void) printf("\n%s\t\t", pri->pname);
610 (void) printf(" %s",
611 show_char(cbuf, (int)termios.c_cc[i]));
613 (void) fputc('\n', stdout);
617 void
618 show_termiox(private_t *pri, long offset)
620 struct termiox termiox;
621 int i;
623 if (Pread(Proc, &termiox, sizeof (termiox), offset)
624 == sizeof (termiox)) {
625 (void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
626 pri->pname,
627 termiox.x_hflag,
628 termiox.x_cflag,
629 termiox.x_rflag[0]);
630 for (i = 1; i < NFF; i++)
631 (void) printf(",0%.3o", termiox.x_rflag[i]);
632 (void) printf(" sflag=0%.3o\n",
633 termiox.x_sflag);
637 void
638 show_sgttyb(private_t *pri, long offset)
640 struct sgttyb sgttyb;
642 if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
643 char erase[8];
644 char kill[8];
646 (void) printf(
647 "%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
648 pri->pname,
649 sgttyb.sg_ispeed&0xff,
650 sgttyb.sg_ospeed&0xff,
651 show_char(erase, sgttyb.sg_erase),
652 show_char(kill, sgttyb.sg_kill),
653 sgttyb.sg_flags);
657 void
658 show_ltchars(private_t *pri, long offset)
660 struct ltchars ltchars;
661 char *p;
662 char cbuf[8];
663 int i;
665 if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
666 == sizeof (ltchars)) {
667 (void) printf("%s\t cc: ", pri->pname);
668 for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
669 (void) printf(" %s", show_char(cbuf, (int)*p++));
670 (void) fputc('\n', stdout);
674 void
675 show_tchars(private_t *pri, long offset)
677 struct tchars tchars;
678 char *p;
679 char cbuf[8];
680 int i;
682 if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) {
683 (void) printf("%s\t cc: ", pri->pname);
684 for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++)
685 (void) printf(" %s", show_char(cbuf, (int)*p++));
686 (void) fputc('\n', stdout);
690 void
691 show_termcb(private_t *pri, long offset)
693 struct termcb termcb;
695 if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
696 (void) printf(
697 "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
698 pri->pname,
699 termcb.st_flgs&0xff,
700 termcb.st_termt&0xff,
701 termcb.st_crow&0xff,
702 termcb.st_ccol&0xff,
703 termcb.st_vrow&0xff,
704 termcb.st_lrow&0xff);
708 /* integer value pointed to by ioctl() arg */
709 void
710 show_strint(private_t *pri, int code, long offset)
712 int val;
714 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
715 const char *s = NULL;
717 switch (code) { /* interpret these symbolically */
718 case I_GRDOPT:
719 s = strrdopt(val);
720 break;
721 case I_GETSIG:
722 s = strevents(pri, val);
723 break;
724 case TIOCFLUSH:
725 s = tiocflush(pri, val);
726 break;
729 if (s == NULL)
730 (void) printf("%s\t0x%.8lX: %d\n",
731 pri->pname, offset, val);
732 else
733 (void) printf("%s\t0x%.8lX: %s\n",
734 pri->pname, offset, s);
738 void
739 show_strioctl(private_t *pri, long offset)
741 struct strioctl strioctl;
743 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
744 sizeof (strioctl)) {
745 (void) printf(
746 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
747 pri->pname,
748 ioctlname(pri, strioctl.ic_cmd),
749 strioctl.ic_timout,
750 strioctl.ic_len,
751 (long)strioctl.ic_dp);
753 if (pri->recur++ == 0) /* avoid indefinite recursion */
754 show_ioctl(pri, strioctl.ic_cmd,
755 (long)strioctl.ic_dp);
756 --pri->recur;
760 #ifdef _LP64
761 void
762 show_strioctl32(private_t *pri, long offset)
764 struct strioctl32 strioctl;
766 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
767 sizeof (strioctl)) {
768 (void) printf(
769 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
770 pri->pname,
771 ioctlname(pri, strioctl.ic_cmd),
772 strioctl.ic_timout,
773 strioctl.ic_len,
774 (long)strioctl.ic_dp);
776 if (pri->recur++ == 0) /* avoid indefinite recursion */
777 show_ioctl(pri, strioctl.ic_cmd,
778 (long)strioctl.ic_dp);
779 --pri->recur;
782 #endif /* _LP64 */
784 void
785 print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
787 (void) printf(
788 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
789 pri->pname,
790 name,
791 sp->maxlen,
792 sp->len,
793 (long)sp->buf);
795 * Should we show the buffer contents?
796 * Keyed to the '-r fds' and '-w fds' options?
798 if (sp->buf == NULL || sp->len <= 0)
799 (void) fputc('\n', stdout);
800 else {
801 int nb = (sp->len > 8)? 8 : sp->len;
802 char buffer[8];
803 char obuf[40];
805 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
806 (void) strcpy(obuf, ": \"");
807 showbytes(buffer, nb, obuf+3);
808 (void) strcat(obuf,
809 (nb == sp->len)?
810 (const char *)"\"" : (const char *)"\"..");
811 (void) fputs(obuf, stdout);
813 (void) fputc('\n', stdout);
814 if (dump && sp->len > 8)
815 showbuffer(pri, (long)sp->buf, (long)sp->len);
819 #ifdef _LP64
820 void
821 print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
823 (void) printf(
824 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
825 pri->pname,
826 name,
827 sp->maxlen,
828 sp->len,
829 (long)sp->buf);
831 * Should we show the buffer contents?
832 * Keyed to the '-r fds' and '-w fds' options?
834 if (sp->buf == (uintptr_t)NULL || sp->len <= 0)
835 (void) fputc('\n', stdout);
836 else {
837 int nb = (sp->len > 8)? 8 : sp->len;
838 char buffer[8];
839 char obuf[40];
841 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
842 (void) strcpy(obuf, ": \"");
843 showbytes(buffer, nb, obuf+3);
844 (void) strcat(obuf,
845 (nb == sp->len)?
846 (const char *)"\"" : (const char *)"\"..");
847 (void) fputs(obuf, stdout);
849 (void) fputc('\n', stdout);
850 if (dump && sp->len > 8)
851 showbuffer(pri, (long)sp->buf, (long)sp->len);
854 #endif /* _LP64 */
856 /* strpeek and strfdinsert flags word */
857 const char *
858 strflags(private_t *pri, int flags)
860 const char *s;
862 switch (flags) {
863 case 0:
864 s = "0";
865 break;
866 case RS_HIPRI:
867 s = "RS_HIPRI";
868 break;
869 default:
870 (void) sprintf(pri->code_buf, "0x%.4X", flags);
871 s = pri->code_buf;
874 return (s);
877 void
878 show_strpeek(private_t *pri, long offset)
880 struct strpeek strpeek;
882 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
883 == sizeof (strpeek)) {
885 print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
886 print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
888 (void) printf("%s\tflags=%s\n",
889 pri->pname,
890 strflags(pri, strpeek.flags));
894 #ifdef _LP64
895 void
896 show_strpeek32(private_t *pri, long offset)
898 struct strpeek32 strpeek;
900 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
901 == sizeof (strpeek)) {
903 print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
904 print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
906 (void) printf("%s\tflags=%s\n",
907 pri->pname,
908 strflags(pri, strpeek.flags));
911 #endif /* _LP64 */
913 void
914 show_strfdinsert(private_t *pri, long offset)
916 struct strfdinsert strfdinsert;
918 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
919 sizeof (strfdinsert)) {
921 print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
922 print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
924 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
925 pri->pname,
926 strflags(pri, strfdinsert.flags),
927 strfdinsert.fildes,
928 strfdinsert.offset);
932 #ifdef _LP64
933 void
934 show_strfdinsert32(private_t *pri, long offset)
936 struct strfdinsert32 strfdinsert;
938 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
939 sizeof (strfdinsert)) {
941 print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
942 print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
944 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
945 pri->pname,
946 strflags(pri, strfdinsert.flags),
947 strfdinsert.fildes,
948 strfdinsert.offset);
951 #endif /* _LP64 */
953 void
954 show_strrecvfd(private_t *pri, long offset)
956 struct strrecvfd strrecvfd;
958 if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
959 sizeof (strrecvfd)) {
960 (void) printf(
961 "%s\tfd=%-5d uid=%-5u gid=%u\n",
962 pri->pname,
963 strrecvfd.fd,
964 strrecvfd.uid,
965 strrecvfd.gid);
969 void
970 show_strlist(private_t *pri, long offset)
972 struct str_list strlist;
973 struct str_mlist list;
974 int count;
976 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
977 sizeof (strlist)) {
978 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
979 pri->pname,
980 strlist.sl_nmods,
981 (long)strlist.sl_modlist);
983 count = strlist.sl_nmods;
984 offset = (long)strlist.sl_modlist;
985 while (!interrupt && --count >= 0) {
986 if (Pread(Proc, &list, sizeof (list), offset) !=
987 sizeof (list))
988 break;
989 (void) printf("%s\t\t\"%.*s\"\n",
990 pri->pname,
991 (int)sizeof (list.l_name),
992 list.l_name);
993 offset += sizeof (struct str_mlist);
998 #ifdef _LP64
999 void
1000 show_strlist32(private_t *pri, long offset)
1002 struct str_list32 strlist;
1003 struct str_mlist list;
1004 int count;
1006 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1007 sizeof (strlist)) {
1008 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
1009 pri->pname,
1010 strlist.sl_nmods,
1011 (long)strlist.sl_modlist);
1013 count = strlist.sl_nmods;
1014 offset = (long)strlist.sl_modlist;
1015 while (!interrupt && --count >= 0) {
1016 if (Pread(Proc, &list, sizeof (list), offset) !=
1017 sizeof (list))
1018 break;
1019 (void) printf("%s\t\t\"%.*s\"\n",
1020 pri->pname,
1021 (int)sizeof (list.l_name),
1022 list.l_name);
1023 offset += sizeof (struct str_mlist);
1027 #endif /* _LP64 */
1029 void
1030 show_jwinsize(private_t *pri, long offset)
1032 struct jwinsize jwinsize;
1034 if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
1035 sizeof (jwinsize)) {
1036 (void) printf(
1037 "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1038 pri->pname,
1039 (unsigned)jwinsize.bytesx,
1040 (unsigned)jwinsize.bytesy,
1041 (unsigned)jwinsize.bitsx,
1042 (unsigned)jwinsize.bitsy);
1046 void
1047 show_winsize(private_t *pri, long offset)
1049 struct winsize winsize;
1051 if (Pread(Proc, &winsize, sizeof (winsize), offset)
1052 == sizeof (winsize)) {
1053 (void) printf(
1054 "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1055 pri->pname,
1056 winsize.ws_row,
1057 winsize.ws_col,
1058 winsize.ws_xpixel,
1059 winsize.ws_ypixel);
1063 struct audio_stuff {
1064 uint_t bit;
1065 const char *str;
1068 const struct audio_stuff audio_output_ports[] = {
1069 { AUDIO_SPEAKER, "SPEAKER" },
1070 { AUDIO_HEADPHONE, "HEADPHONE" },
1071 { AUDIO_LINE_OUT, "LINE_OUT" },
1072 { AUDIO_SPDIF_OUT, "SPDIF_OUT" },
1073 { AUDIO_AUX1_OUT, "AUX1_OUT" },
1074 { AUDIO_AUX2_OUT, "AUX2_OUT" },
1075 { 0, NULL }
1078 const struct audio_stuff audio_input_ports[] = {
1079 { AUDIO_MICROPHONE, "MICROPHONE" },
1080 { AUDIO_LINE_IN, "LINE_IN" },
1081 { AUDIO_CD, "CD" },
1082 { AUDIO_SPDIF_IN, "SPDIF_IN" },
1083 { AUDIO_AUX1_IN, "AUX1_IN" },
1084 { AUDIO_AUX2_IN, "AUX2_IN" },
1085 { AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
1086 { AUDIO_SUNVTS, "SUNVTS" },
1087 { 0, NULL }
1090 static const struct audio_stuff audio_hw_features[] = {
1091 { AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
1092 { AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
1093 { AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
1094 { AUDIO_HWFEATURE_PLAY, "PLAY" },
1095 { AUDIO_HWFEATURE_RECORD, "RECORD" },
1096 { 0, NULL }
1099 static const struct audio_stuff audio_sw_features[] = {
1100 { AUDIO_SWFEATURE_MIXER, "MIXER" },
1101 { 0, NULL }
1104 void
1105 show_audio_features(const private_t *pri,
1106 const struct audio_stuff *audio_porttab, uint_t features,
1107 const char *name)
1109 (void) printf("%s\t%s=", pri->pname, name);
1110 if (features == 0) {
1111 (void) printf("0\n");
1112 return;
1115 for (; audio_porttab->bit != 0; ++audio_porttab) {
1116 if (features & audio_porttab->bit) {
1117 (void) printf(audio_porttab->str);
1118 features &= ~audio_porttab->bit;
1119 if (features)
1120 (void) putchar('|');
1123 if (features)
1124 (void) printf("0x%x", features);
1125 (void) putchar('\n');
1128 void
1129 show_audio_ports(private_t *pri, const char *mode,
1130 const char *field, uint_t ports)
1132 const struct audio_stuff *audio_porttab;
1134 (void) printf("%s\t%s\t%s=", pri->pname, mode, field);
1135 if (ports == 0) {
1136 (void) printf("0\n");
1137 return;
1139 if (*mode == 'p')
1140 audio_porttab = audio_output_ports;
1141 else
1142 audio_porttab = audio_input_ports;
1143 for (; audio_porttab->bit != 0; ++audio_porttab) {
1144 if (ports & audio_porttab->bit) {
1145 (void) printf(audio_porttab->str);
1146 ports &= ~audio_porttab->bit;
1147 if (ports)
1148 (void) putchar('|');
1151 if (ports)
1152 (void) printf("0x%x", ports);
1153 (void) putchar('\n');
1156 void
1157 show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
1159 const char *s;
1162 * The following values describe the audio data encoding.
1165 (void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1166 pri->pname, mode,
1167 au_pr->sample_rate,
1168 au_pr->channels,
1169 au_pr->precision);
1171 s = NULL;
1172 switch (au_pr->encoding) {
1173 case AUDIO_ENCODING_NONE: s = "NONE"; break;
1174 case AUDIO_ENCODING_ULAW: s = "ULAW"; break;
1175 case AUDIO_ENCODING_ALAW: s = "ALAW"; break;
1176 case AUDIO_ENCODING_LINEAR: s = "LINEAR"; break;
1177 case AUDIO_ENCODING_DVI: s = "DVI"; break;
1178 case AUDIO_ENCODING_LINEAR8: s = "LINEAR8"; break;
1180 if (s)
1181 (void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
1182 else {
1183 (void) printf("%s\t%s\tencoding=%u\n",
1184 pri->pname, mode, au_pr->encoding);
1188 * The following values control audio device configuration
1191 (void) printf(
1192 "%s\t%s\tgain=%u buffer_size=%u\n",
1193 pri->pname, mode,
1194 au_pr->gain,
1195 au_pr->buffer_size);
1196 show_audio_ports(pri, mode, "port", au_pr->port);
1197 show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
1198 show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
1201 * The following values describe driver state
1204 (void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1205 pri->pname, mode,
1206 au_pr->samples,
1207 au_pr->eof,
1208 au_pr->pause,
1209 au_pr->error);
1210 (void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1211 pri->pname, mode,
1212 au_pr->waiting,
1213 au_pr->balance,
1214 au_pr->minordev);
1217 * The following values are read-only state flags
1219 (void) printf("%s\t%s\topen=%u active=%u\n",
1220 pri->pname, mode,
1221 au_pr->open,
1222 au_pr->active);
1225 void
1226 show_audio_info(private_t *pri, long offset)
1228 struct audio_info au;
1230 if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
1231 show_audio_prinfo(pri, "play", &au.play);
1232 show_audio_prinfo(pri, "record", &au.record);
1233 (void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1234 pri->pname, au.monitor_gain, au.output_muted);
1235 show_audio_features(pri, audio_hw_features, au.hw_features,
1236 "hw_features");
1237 show_audio_features(pri, audio_sw_features, au.sw_features,
1238 "sw_features");
1239 show_audio_features(pri, audio_sw_features,
1240 au.sw_features_enabled, "sw_features_enabled");
1244 void
1245 show_ioctl(private_t *pri, int code, long offset)
1247 int lp64 = (data_model == PR_MODEL_LP64);
1248 int err = pri->Errno; /* don't display output parameters */
1249 /* for a failed system call */
1250 #ifndef _LP64
1251 if (lp64)
1252 return;
1253 #endif
1254 if (offset == 0)
1255 return;
1257 switch (code) {
1258 case TCGETA:
1259 if (err)
1260 break;
1261 /*FALLTHROUGH*/
1262 case TCSETA:
1263 case TCSETAW:
1264 case TCSETAF:
1265 show_termio(pri, offset);
1266 break;
1267 case TCGETS:
1268 if (err)
1269 break;
1270 /*FALLTHROUGH*/
1271 case TCSETS:
1272 case TCSETSW:
1273 case TCSETSF:
1274 show_termios(pri, offset);
1275 break;
1276 case TCGETX:
1277 if (err)
1278 break;
1279 /*FALLTHROUGH*/
1280 case TCSETX:
1281 case TCSETXW:
1282 case TCSETXF:
1283 show_termiox(pri, offset);
1284 break;
1285 case TIOCGETP:
1286 if (err)
1287 break;
1288 /*FALLTHROUGH*/
1289 case TIOCSETN:
1290 case TIOCSETP:
1291 show_sgttyb(pri, offset);
1292 break;
1293 case TIOCGLTC:
1294 if (err)
1295 break;
1296 /*FALLTHROUGH*/
1297 case TIOCSLTC:
1298 show_ltchars(pri, offset);
1299 break;
1300 case TIOCGETC:
1301 if (err)
1302 break;
1303 /*FALLTHROUGH*/
1304 case TIOCSETC:
1305 show_tchars(pri, offset);
1306 break;
1307 case LDGETT:
1308 if (err)
1309 break;
1310 /*FALLTHROUGH*/
1311 case LDSETT:
1312 show_termcb(pri, offset);
1313 break;
1314 /* streams ioctl()s */
1315 #if 0
1316 /* these are displayed as strings in the arg list */
1317 /* by prt_ioa(). don't display them again here */
1318 case I_PUSH:
1319 case I_LOOK:
1320 case I_FIND:
1321 /* these are displayed as decimal in the arg list */
1322 /* by prt_ioa(). don't display them again here */
1323 case I_LINK:
1324 case I_UNLINK:
1325 case I_SENDFD:
1326 /* these are displayed symbolically in the arg list */
1327 /* by prt_ioa(). don't display them again here */
1328 case I_SRDOPT:
1329 case I_SETSIG:
1330 case I_FLUSH:
1331 break;
1332 /* this one just ignores the argument */
1333 case I_POP:
1334 break;
1335 #endif
1336 /* these return something in an int pointed to by arg */
1337 case I_NREAD:
1338 case I_GRDOPT:
1339 case I_GETSIG:
1340 case TIOCGSID:
1341 case TIOCGPGRP:
1342 case TIOCLGET:
1343 case FIONREAD:
1344 case FIORDCHK:
1345 if (err)
1346 break;
1347 /*FALLTHROUGH*/
1348 /* these pass something in an int pointed to by arg */
1349 case TIOCSPGRP:
1350 case TIOCFLUSH:
1351 case TIOCLBIS:
1352 case TIOCLBIC:
1353 case TIOCLSET:
1354 show_strint(pri, code, offset);
1355 break;
1356 /* these all point to structures */
1357 case I_STR:
1358 #ifdef _LP64
1359 if (lp64)
1360 show_strioctl(pri, offset);
1361 else
1362 show_strioctl32(pri, offset);
1363 #else
1364 show_strioctl(pri, offset);
1365 #endif
1366 break;
1367 case I_PEEK:
1368 #ifdef _LP64
1369 if (lp64)
1370 show_strpeek(pri, offset);
1371 else
1372 show_strpeek32(pri, offset);
1373 #else
1374 show_strpeek(pri, offset);
1375 #endif
1376 break;
1377 case I_FDINSERT:
1378 #ifdef _LP64
1379 if (lp64)
1380 show_strfdinsert(pri, offset);
1381 else
1382 show_strfdinsert32(pri, offset);
1383 #else
1384 show_strfdinsert(pri, offset);
1385 #endif
1386 break;
1387 case I_RECVFD:
1388 if (err)
1389 break;
1390 show_strrecvfd(pri, offset);
1391 break;
1392 case I_LIST:
1393 if (err)
1394 break;
1395 #ifdef _LP64
1396 if (lp64)
1397 show_strlist(pri, offset);
1398 else
1399 show_strlist32(pri, offset);
1400 #else
1401 show_strlist(pri, offset);
1402 #endif
1403 break;
1404 case JWINSIZE:
1405 if (err)
1406 break;
1407 show_jwinsize(pri, offset);
1408 break;
1409 case TIOCGWINSZ:
1410 if (err)
1411 break;
1412 /*FALLTHROUGH*/
1413 case TIOCSWINSZ:
1414 show_winsize(pri, offset);
1415 break;
1416 case AUDIO_GETINFO:
1417 case (int)AUDIO_SETINFO:
1418 show_audio_info(pri, offset);
1419 break;
1421 default:
1422 if ((code & ~0xff) == ZFS_IOC) {
1423 show_zfs_ioc(pri, offset);
1424 break;
1427 if (code & IOC_INOUT) {
1428 const char *str = ioctldatastruct(code);
1430 (void) printf("\t\t%s",
1431 (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1432 code & IOC_IN ? "write" : "read");
1433 if (str != NULL) {
1434 (void) printf(" (struct %s)\n", str);
1435 } else {
1436 (void) printf(" %d bytes\n",
1437 (code >> 16) & IOCPARM_MASK);
1443 void
1444 show_statvfs(private_t *pri)
1446 long offset;
1447 struct statvfs statvfs;
1448 char *cp;
1450 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1451 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1452 == sizeof (statvfs)) {
1453 (void) printf(
1454 "%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1455 pri->pname,
1456 statvfs.f_bsize,
1457 statvfs.f_frsize,
1458 (u_longlong_t)statvfs.f_blocks,
1459 (u_longlong_t)statvfs.f_bfree);
1460 (void) printf(
1461 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1462 pri->pname,
1463 (u_longlong_t)statvfs.f_bavail,
1464 (u_longlong_t)statvfs.f_files,
1465 (u_longlong_t)statvfs.f_ffree,
1466 (u_longlong_t)statvfs.f_favail);
1467 (void) printf(
1468 "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1469 pri->pname,
1470 statvfs.f_fsid,
1471 statvfs.f_basetype,
1472 (long)statvfs.f_namemax);
1473 (void) printf(
1474 "%s\tflag=%s\n",
1475 pri->pname,
1476 svfsflags(pri, (ulong_t)statvfs.f_flag));
1477 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1478 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1479 *(cp+1) != '\0')
1480 *cp = ' ';
1481 (void) printf("%s\tfstr=\"%.*s\"\n",
1482 pri->pname,
1483 (int)sizeof (statvfs.f_fstr),
1484 statvfs.f_fstr);
1488 #ifdef _LP64
1489 void
1490 show_statvfs32(private_t *pri)
1492 long offset;
1493 struct statvfs32 statvfs;
1494 char *cp;
1496 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1497 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1498 == sizeof (statvfs)) {
1499 (void) printf(
1500 "%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
1501 pri->pname,
1502 statvfs.f_bsize,
1503 statvfs.f_frsize,
1504 statvfs.f_blocks,
1505 statvfs.f_bfree);
1506 (void) printf(
1507 "%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
1508 pri->pname,
1509 statvfs.f_bavail,
1510 statvfs.f_files,
1511 statvfs.f_ffree,
1512 statvfs.f_favail);
1513 (void) printf(
1514 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1515 pri->pname,
1516 statvfs.f_fsid,
1517 statvfs.f_basetype,
1518 (int)statvfs.f_namemax);
1519 (void) printf(
1520 "%s\tflag=%s\n",
1521 pri->pname,
1522 svfsflags(pri, (ulong_t)statvfs.f_flag));
1523 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1524 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1525 *(cp+1) != '\0')
1526 *cp = ' ';
1527 (void) printf("%s\tfstr=\"%.*s\"\n",
1528 pri->pname,
1529 (int)sizeof (statvfs.f_fstr),
1530 statvfs.f_fstr);
1533 #endif /* _LP64 */
1535 void
1536 show_statvfs64(private_t *pri)
1538 long offset;
1539 struct statvfs64_32 statvfs;
1540 char *cp;
1542 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1543 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1544 == sizeof (statvfs)) {
1545 (void) printf(
1546 "%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
1547 pri->pname,
1548 statvfs.f_bsize,
1549 statvfs.f_frsize,
1550 (u_longlong_t)statvfs.f_blocks,
1551 (u_longlong_t)statvfs.f_bfree);
1552 (void) printf(
1553 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1554 pri->pname,
1555 (u_longlong_t)statvfs.f_bavail,
1556 (u_longlong_t)statvfs.f_files,
1557 (u_longlong_t)statvfs.f_ffree,
1558 (u_longlong_t)statvfs.f_favail);
1559 (void) printf(
1560 "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1561 pri->pname,
1562 statvfs.f_fsid,
1563 statvfs.f_basetype,
1564 (int)statvfs.f_namemax);
1565 (void) printf(
1566 "%s\tflag=%s\n",
1567 pri->pname,
1568 svfsflags(pri, (ulong_t)statvfs.f_flag));
1569 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1570 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1571 *(cp+1) != '\0')
1572 *cp = ' ';
1573 (void) printf("%s\tfstr=\"%.*s\"\n",
1574 pri->pname,
1575 (int)sizeof (statvfs.f_fstr),
1576 statvfs.f_fstr);
1580 void
1581 show_statfs(private_t *pri)
1583 long offset;
1584 struct statfs statfs;
1586 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
1587 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1588 (void) printf(
1589 "%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1590 pri->pname,
1591 statfs.f_fstyp,
1592 statfs.f_bsize,
1593 statfs.f_frsize,
1594 statfs.f_blocks,
1595 statfs.f_bfree,
1596 statfs.f_files,
1597 statfs.f_ffree);
1598 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1599 pri->pname,
1600 statfs.f_fname,
1601 statfs.f_fpack);
1605 #ifdef _LP64
1606 void
1607 show_statfs32(private_t *pri)
1609 long offset;
1610 struct statfs32 statfs;
1612 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
1613 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1614 (void) printf(
1615 "%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
1616 pri->pname,
1617 statfs.f_fstyp,
1618 statfs.f_bsize,
1619 statfs.f_frsize,
1620 statfs.f_blocks,
1621 statfs.f_bfree,
1622 statfs.f_files,
1623 statfs.f_ffree);
1624 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1625 pri->pname,
1626 statfs.f_fname,
1627 statfs.f_fpack);
1630 #endif /* _LP64 */
1632 void
1633 show_flock32(private_t *pri, long offset)
1635 struct flock32 flock;
1637 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1638 const char *str = NULL;
1640 (void) printf("%s\ttyp=", pri->pname);
1642 switch (flock.l_type) {
1643 case F_RDLCK:
1644 str = "F_RDLCK";
1645 break;
1646 case F_WRLCK:
1647 str = "F_WRLCK";
1648 break;
1649 case F_UNLCK:
1650 str = "F_UNLCK";
1651 break;
1653 if (str != NULL)
1654 (void) printf("%s", str);
1655 else
1656 (void) printf("%-7d", flock.l_type);
1658 str = whencearg(flock.l_whence);
1659 if (str != NULL)
1660 (void) printf(" whence=%s", str);
1661 else
1662 (void) printf(" whence=%-8u", flock.l_whence);
1664 (void) printf(
1665 " start=%-5d len=%-5d sys=%-2u pid=%d\n",
1666 flock.l_start,
1667 flock.l_len,
1668 flock.l_sysid,
1669 flock.l_pid);
1673 void
1674 show_flock64(private_t *pri, long offset)
1676 struct flock64 flock;
1678 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1679 const char *str = NULL;
1681 (void) printf("%s\ttyp=", pri->pname);
1683 switch (flock.l_type) {
1684 case F_RDLCK:
1685 str = "F_RDLCK";
1686 break;
1687 case F_WRLCK:
1688 str = "F_WRLCK";
1689 break;
1690 case F_UNLCK:
1691 str = "F_UNLCK";
1692 break;
1694 if (str != NULL)
1695 (void) printf("%s", str);
1696 else
1697 (void) printf("%-7d", flock.l_type);
1699 str = whencearg(flock.l_whence);
1700 if (str != NULL)
1701 (void) printf(" whence=%s", str);
1702 else
1703 (void) printf(" whence=%-8u", flock.l_whence);
1705 (void) printf(
1706 " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1707 (long long)flock.l_start,
1708 (long long)flock.l_len,
1709 flock.l_sysid,
1710 (int)flock.l_pid);
1714 void
1715 show_share(private_t *pri, long offset)
1717 struct fshare fshare;
1719 if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
1720 const char *str = NULL;
1721 int manddny = 0;
1723 (void) printf("%s\taccess=", pri->pname);
1725 switch (fshare.f_access) {
1726 case F_RDACC:
1727 str = "F_RDACC";
1728 break;
1729 case F_WRACC:
1730 str = "F_WRACC";
1731 break;
1732 case F_RWACC:
1733 str = "F_RWACC";
1734 break;
1736 if (str != NULL)
1737 (void) printf("%s", str);
1738 else
1739 (void) printf("%-7d", fshare.f_access);
1741 str = NULL;
1742 if (fshare.f_deny & F_MANDDNY) {
1743 fshare.f_deny &= ~F_MANDDNY;
1744 manddny = 1;
1746 switch (fshare.f_deny) {
1747 case F_NODNY:
1748 str = "F_NODNY";
1749 break;
1750 case F_RDDNY:
1751 str = "F_RDDNY";
1752 break;
1753 case F_WRDNY:
1754 str = "F_WRDNY";
1755 break;
1756 case F_RWDNY:
1757 str = "F_RWDNY";
1758 break;
1759 case F_COMPAT:
1760 str = "F_COMPAT";
1761 break;
1763 if (str != NULL) {
1764 if (manddny)
1765 (void) printf(" deny=F_MANDDNY|%s", str);
1766 else
1767 (void) printf(" deny=%s", str);
1768 } else {
1769 (void) printf(" deny=0x%x", manddny?
1770 fshare.f_deny | F_MANDDNY : fshare.f_deny);
1773 (void) printf(" id=%x\n", fshare.f_id);
1777 void
1778 show_ffg(private_t *pri)
1780 (void) putchar('\t');
1781 (void) putchar('\t');
1782 prt_ffg(pri, 0, pri->Rval1);
1783 (void) puts(pri->sys_string);
1786 /* print values in fcntl() pointed-to structure */
1787 void
1788 show_fcntl(private_t *pri)
1790 long offset;
1792 if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
1793 show_ffg(pri);
1794 return;
1797 if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == 0)
1798 return;
1800 switch (pri->sys_args[1]) {
1801 #ifdef _LP64
1802 case F_GETLK:
1803 case F_SETLK:
1804 case F_SETLKW:
1805 case F_FREESP:
1806 case F_ALLOCSP:
1807 case F_SETLK_NBMAND:
1808 case F_OFD_GETLK:
1809 case F_OFD_SETLK:
1810 case F_OFD_SETLKW:
1811 case F_FLOCK:
1812 case F_FLOCKW:
1813 if (data_model == PR_MODEL_LP64)
1814 show_flock64(pri, offset);
1815 else
1816 show_flock32(pri, offset);
1817 break;
1818 case 33: /* F_GETLK64 */
1819 case 34: /* F_SETLK64 */
1820 case 35: /* F_SETLKW64 */
1821 case 27: /* F_FREESP64 */
1822 case 28: /* F_ALLOCSP64 */
1823 case 44: /* F_SETLK64_NBMAND */
1824 case 50: /* F_OFD_GETLK64 */
1825 case 51: /* F_OFD_SETLK64 */
1826 case 52: /* F_OFD_SETLKW64 */
1827 case 55: /* F_FLOCK64 */
1828 case 56: /* F_FLOCKW64 */
1829 show_flock64(pri, offset);
1830 break;
1831 #else /* _LP64 */
1832 case F_GETLK:
1833 case F_SETLK:
1834 case F_SETLKW:
1835 case F_FREESP:
1836 case F_ALLOCSP:
1837 case F_SETLK_NBMAND:
1838 show_flock32(pri, offset);
1839 break;
1840 case F_GETLK64:
1841 case F_SETLK64:
1842 case F_SETLKW64:
1843 case F_FREESP64:
1844 case F_ALLOCSP64:
1845 case F_SETLK64_NBMAND:
1846 case F_OFD_GETLK64:
1847 case F_OFD_SETLK64:
1848 case F_OFD_SETLKW64:
1849 case F_FLOCK64:
1850 case F_FLOCKW64:
1851 show_flock64(pri, offset);
1852 break;
1853 #endif /* _LP64 */
1854 case F_SHARE:
1855 case F_UNSHARE:
1856 show_share(pri, offset);
1857 break;
1861 void
1862 show_strbuf(private_t *pri, long offset, const char *name, int dump)
1864 struct strbuf strbuf;
1866 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1867 print_strbuf(pri, &strbuf, name, dump);
1870 #ifdef _LP64
1871 void
1872 show_strbuf32(private_t *pri, long offset, const char *name, int dump)
1874 struct strbuf32 strbuf;
1876 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1877 print_strbuf32(pri, &strbuf, name, dump);
1879 #endif /* _LP64 */
1881 void
1882 show_gp_msg(private_t *pri, int what)
1884 long offset;
1885 int dump = FALSE;
1886 int fdp1 = pri->sys_args[0] + 1;
1888 switch (what) {
1889 case SYS_getmsg:
1890 case SYS_getpmsg:
1891 if (pri->Errno == 0 && prismember(&readfd, fdp1))
1892 dump = TRUE;
1893 break;
1894 case SYS_putmsg:
1895 case SYS_putpmsg:
1896 if (prismember(&writefd, fdp1))
1897 dump = TRUE;
1898 break;
1901 /* enter region of lengthy output */
1902 if (dump)
1903 Eserialize();
1905 #ifdef _LP64
1906 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0) {
1907 if (data_model == PR_MODEL_LP64)
1908 show_strbuf(pri, offset, "ctl", dump);
1909 else
1910 show_strbuf32(pri, offset, "ctl", dump);
1912 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0) {
1913 if (data_model == PR_MODEL_LP64)
1914 show_strbuf(pri, offset, "dat", dump);
1915 else
1916 show_strbuf32(pri, offset, "dat", dump);
1918 #else /* _LP64 */
1919 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0)
1920 show_strbuf(pri, offset, "ctl", dump);
1921 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0)
1922 show_strbuf(pri, offset, "dat", dump);
1923 #endif /* _LP64 */
1925 /* exit region of lengthy output */
1926 if (dump)
1927 Xserialize();
1930 void
1931 show_int(private_t *pri, long offset, const char *name)
1933 int value;
1935 if (offset != 0 &&
1936 Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1937 (void) printf("%s\t%s:\t%d\n",
1938 pri->pname,
1939 name,
1940 value);
1943 void
1944 show_hhex_int(private_t *pri, long offset, const char *name)
1946 int value;
1948 if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1949 (void) printf("%s\t%s:\t0x%.4X\n",
1950 pri->pname,
1951 name,
1952 value);
1955 #define ALL_POLL_FLAGS (POLLIN|POLLPRI|POLLOUT| \
1956 POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
1958 const char *
1959 pollevent(private_t *pri, int arg)
1961 char *str = pri->code_buf;
1963 if (arg == 0)
1964 return ("0");
1965 if (arg & ~ALL_POLL_FLAGS) {
1966 (void) sprintf(str, "0x%-5X", arg);
1967 return ((const char *)str);
1970 *str = '\0';
1971 if (arg & POLLIN)
1972 (void) strcat(str, "|POLLIN");
1973 if (arg & POLLPRI)
1974 (void) strcat(str, "|POLLPRI");
1975 if (arg & POLLOUT)
1976 (void) strcat(str, "|POLLOUT");
1977 if (arg & POLLRDNORM)
1978 (void) strcat(str, "|POLLRDNORM");
1979 if (arg & POLLRDBAND)
1980 (void) strcat(str, "|POLLRDBAND");
1981 if (arg & POLLWRBAND)
1982 (void) strcat(str, "|POLLWRBAND");
1983 if (arg & POLLERR)
1984 (void) strcat(str, "|POLLERR");
1985 if (arg & POLLHUP)
1986 (void) strcat(str, "|POLLHUP");
1987 if (arg & POLLNVAL)
1988 (void) strcat(str, "|POLLNVAL");
1990 return ((const char *)(str+1));
1993 static void
1994 show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
1997 * can't print both events and revents in same printf.
1998 * pollevent() returns a pointer to a TSD location.
2000 (void) printf("%s\tfd=%-2d ev=%s",
2001 pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
2002 (void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
2005 static void
2006 show_all_pollfds(private_t *pri, long offset, int nfds)
2008 struct pollfd pollfd[2];
2009 int skip = -1;
2011 for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
2012 if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
2013 sizeof (struct pollfd))
2014 continue;
2016 if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
2017 pollfd[0].events == pollfd[1].events &&
2018 pollfd[0].revents == pollfd[1].revents) {
2019 skip++;
2020 continue;
2023 if (skip > 0)
2024 (void) printf("%s\t...last pollfd structure"
2025 " repeated %d time%s...\n",
2026 pri->pname, skip, (skip == 1 ? "" : "s"));
2028 skip = 0;
2029 show_one_pollfd(pri, &pollfd[0]);
2030 pollfd[1] = pollfd[0];
2033 if (skip > 0)
2034 (void) printf(
2035 "%s\t...last pollfd structure repeated %d time%s...\n",
2036 pri->pname, skip, (skip == 1 ? "" : "s"));
2039 void
2040 show_pollsys(private_t *pri)
2042 long offset;
2043 int nfds;
2044 int serial = 0;
2046 if (pri->sys_nargs < 2)
2047 return;
2049 offset = pri->sys_args[0];
2050 nfds = pri->sys_args[1];
2052 /* enter region of lengthy output */
2053 if (offset != 0 && nfds > 32) {
2054 Eserialize();
2055 serial = 1;
2058 if (offset != 0 && nfds > 0)
2059 show_all_pollfds(pri, offset, nfds);
2061 if (pri->sys_nargs > 2)
2062 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
2064 if (pri->sys_nargs > 3)
2065 show_sigset(pri, (long)pri->sys_args[3], "sigmask");
2067 /* exit region of lengthy output */
2068 if (serial)
2069 Xserialize();
2072 static void
2073 show_perm64(private_t *pri, struct ipc_perm64 *ip)
2075 (void) printf("%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u z=%-5d "
2076 "m=0%.6o key=%d projid=%-5d\n",
2077 pri->pname,
2078 ip->ipcx_uid,
2079 ip->ipcx_gid,
2080 ip->ipcx_cuid,
2081 ip->ipcx_cgid,
2082 (int)ip->ipcx_zoneid,
2083 (unsigned int)ip->ipcx_mode,
2084 ip->ipcx_key,
2085 (int)ip->ipcx_projid);
2088 void
2089 show_perm(private_t *pri, struct ipc_perm *ip)
2091 (void) printf(
2092 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2093 pri->pname,
2094 ip->uid,
2095 ip->gid,
2096 ip->cuid,
2097 ip->cgid,
2098 (int)ip->mode,
2099 ip->seq,
2100 ip->key);
2103 #ifdef _LP64
2104 void
2105 show_perm32(private_t *pri, struct ipc_perm32 *ip)
2107 (void) printf(
2108 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
2109 pri->pname,
2110 ip->uid,
2111 ip->gid,
2112 ip->cuid,
2113 ip->cgid,
2114 ip->mode,
2115 ip->seq,
2116 ip->key);
2118 #endif /* _LP64 */
2120 static void
2121 show_msgctl64(private_t *pri, long offset)
2123 struct msqid_ds64 msgq;
2125 if (offset != 0 &&
2126 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2127 show_perm64(pri, &msgq.msgx_perm);
2129 (void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2130 "lspid=%-5d lrpid=%-5d\n", pri->pname,
2131 (unsigned long long)msgq.msgx_cbytes,
2132 (unsigned long long)msgq.msgx_qnum,
2133 (unsigned long long)msgq.msgx_qbytes,
2134 (int)msgq.msgx_lspid,
2135 (int)msgq.msgx_lrpid);
2137 prtime(pri, " st = ", (time_t)msgq.msgx_stime);
2138 prtime(pri, " rt = ", (time_t)msgq.msgx_rtime);
2139 prtime(pri, " ct = ", (time_t)msgq.msgx_ctime);
2143 void
2144 show_msgctl(private_t *pri, long offset)
2146 struct msqid_ds msgq;
2148 if (offset != 0 &&
2149 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2150 show_perm(pri, &msgq.msg_perm);
2152 (void) printf(
2153 "%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2154 pri->pname,
2155 msgq.msg_cbytes,
2156 msgq.msg_qnum,
2157 msgq.msg_qbytes,
2158 (int)msgq.msg_lspid,
2159 (int)msgq.msg_lrpid);
2161 prtime(pri, " st = ", msgq.msg_stime);
2162 prtime(pri, " rt = ", msgq.msg_rtime);
2163 prtime(pri, " ct = ", msgq.msg_ctime);
2167 #ifdef _LP64
2168 void
2169 show_msgctl32(private_t *pri, long offset)
2171 struct msqid_ds32 msgq;
2173 if (offset != 0 &&
2174 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2175 show_perm32(pri, &msgq.msg_perm);
2177 (void) printf(
2178 "%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2179 pri->pname,
2180 msgq.msg_cbytes,
2181 msgq.msg_qnum,
2182 msgq.msg_qbytes,
2183 msgq.msg_lspid,
2184 msgq.msg_lrpid);
2186 prtime(pri, " st = ", msgq.msg_stime);
2187 prtime(pri, " rt = ", msgq.msg_rtime);
2188 prtime(pri, " ct = ", msgq.msg_ctime);
2191 #endif /* _LP64 */
2193 void
2194 show_msgbuf(private_t *pri, long offset, long msgsz)
2196 struct msgbuf msgb;
2198 if (offset != 0 &&
2199 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2200 sizeof (msgb.mtype)) {
2201 /* enter region of lengthy output */
2202 if (msgsz > MYBUFSIZ / 4)
2203 Eserialize();
2205 (void) printf("%s\tmtype=%lu mtext[]=\n",
2206 pri->pname,
2207 msgb.mtype);
2208 showbuffer(pri,
2209 (long)(offset + sizeof (msgb.mtype)), msgsz);
2211 /* exit region of lengthy output */
2212 if (msgsz > MYBUFSIZ / 4)
2213 Xserialize();
2217 #ifdef _LP64
2218 void
2219 show_msgbuf32(private_t *pri, long offset, long msgsz)
2221 struct ipcmsgbuf32 msgb;
2223 if (offset != 0 &&
2224 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2225 sizeof (msgb.mtype)) {
2226 /* enter region of lengthy output */
2227 if (msgsz > MYBUFSIZ / 4)
2228 Eserialize();
2230 (void) printf("%s\tmtype=%u mtext[]=\n",
2231 pri->pname,
2232 msgb.mtype);
2233 showbuffer(pri,
2234 (long)(offset + sizeof (msgb.mtype)), msgsz);
2236 /* exit region of lengthy output */
2237 if (msgsz > MYBUFSIZ / 4)
2238 Xserialize();
2241 #endif /* _LP64 */
2243 #ifdef _LP64
2244 void
2245 show_msgsys(private_t *pri, long msgsz)
2247 switch (pri->sys_args[0]) {
2248 case 0: /* msgget() */
2249 break;
2250 case 1: /* msgctl() */
2251 if (pri->sys_nargs > 3) {
2252 switch (pri->sys_args[2]) {
2253 case IPC_STAT:
2254 if (pri->Errno)
2255 break;
2256 /*FALLTHROUGH*/
2257 case IPC_SET:
2258 if (data_model == PR_MODEL_LP64)
2259 show_msgctl(pri,
2260 (long)pri->sys_args[3]);
2261 else
2262 show_msgctl32(pri,
2263 (long)pri->sys_args[3]);
2264 break;
2265 case IPC_STAT64:
2266 if (pri->Errno)
2267 break;
2268 /*FALLTHROUGH*/
2269 case IPC_SET64:
2270 show_msgctl64(pri, (long)pri->sys_args[3]);
2271 break;
2274 break;
2275 case 2: /* msgrcv() */
2276 if (!pri->Errno && pri->sys_nargs > 2) {
2277 if (data_model == PR_MODEL_LP64)
2278 show_msgbuf(pri, pri->sys_args[2], msgsz);
2279 else
2280 show_msgbuf32(pri, pri->sys_args[2], msgsz);
2282 break;
2283 case 3: /* msgsnd() */
2284 if (pri->sys_nargs > 3) {
2285 if (data_model == PR_MODEL_LP64)
2286 show_msgbuf(pri, pri->sys_args[2],
2287 pri->sys_args[3]);
2288 else
2289 show_msgbuf32(pri, pri->sys_args[2],
2290 pri->sys_args[3]);
2292 break;
2293 case 4: /* msgids() */
2294 case 5: /* msgsnap() */
2295 default: /* unexpected subcode */
2296 break;
2299 #else /* _LP64 */
2300 void
2301 show_msgsys(private_t *pri, long msgsz)
2303 switch (pri->sys_args[0]) {
2304 case 0: /* msgget() */
2305 break;
2306 case 1: /* msgctl() */
2307 if (pri->sys_nargs > 3) {
2308 switch (pri->sys_args[2]) {
2309 case IPC_STAT:
2310 if (pri->Errno)
2311 break;
2312 /*FALLTHROUGH*/
2313 case IPC_SET:
2314 show_msgctl(pri, (long)pri->sys_args[3]);
2315 break;
2316 case IPC_STAT64:
2317 if (pri->Errno)
2318 break;
2319 /*FALLTHROUGH*/
2320 case IPC_SET64:
2321 show_msgctl64(pri, (long)pri->sys_args[3]);
2322 break;
2325 break;
2326 case 2: /* msgrcv() */
2327 if (!pri->Errno && pri->sys_nargs > 2)
2328 show_msgbuf(pri, pri->sys_args[2], msgsz);
2329 break;
2330 case 3: /* msgsnd() */
2331 if (pri->sys_nargs > 3)
2332 show_msgbuf(pri, pri->sys_args[2],
2333 pri->sys_args[3]);
2334 break;
2335 case 4: /* msgids() */
2336 case 5: /* msgsnap() */
2337 default: /* unexpected subcode */
2338 break;
2341 #endif /* _LP64 */
2343 static void
2344 show_semctl64(private_t *pri, long offset)
2346 struct semid_ds64 semds;
2348 if (offset != 0 &&
2349 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2350 show_perm64(pri, &semds.semx_perm);
2352 (void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
2354 prtime(pri, " ot = ", (time_t)semds.semx_otime);
2355 prtime(pri, " ct = ", (time_t)semds.semx_ctime);
2359 void
2360 show_semctl(private_t *pri, long offset)
2362 struct semid_ds semds;
2364 if (offset != 0 &&
2365 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2366 show_perm(pri, &semds.sem_perm);
2368 (void) printf("%s\tnsems=%u\n",
2369 pri->pname,
2370 semds.sem_nsems);
2372 prtime(pri, " ot = ", semds.sem_otime);
2373 prtime(pri, " ct = ", semds.sem_ctime);
2377 #ifdef _LP64
2378 void
2379 show_semctl32(private_t *pri, long offset)
2381 struct semid_ds32 semds;
2383 if (offset != 0 &&
2384 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2385 show_perm32(pri, &semds.sem_perm);
2387 (void) printf("%s\tnsems=%u\n",
2388 pri->pname,
2389 semds.sem_nsems);
2391 prtime(pri, " ot = ", semds.sem_otime);
2392 prtime(pri, " ct = ", semds.sem_ctime);
2395 #endif /* _LP64 */
2397 void
2398 show_semop(private_t *pri, long offset, long nsops, long timeout)
2400 struct sembuf sembuf;
2401 const char *str;
2403 if (offset == 0)
2404 return;
2406 if (nsops > 40) /* let's not be ridiculous */
2407 nsops = 40;
2409 for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
2410 if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
2411 sizeof (sembuf))
2412 break;
2414 (void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2415 pri->pname,
2416 sembuf.sem_num,
2417 sembuf.sem_op);
2419 if (sembuf.sem_flg == 0)
2420 (void) printf("0\n");
2421 else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
2422 (void) printf("%s\n", str);
2423 else
2424 (void) printf("0%.6o\n", sembuf.sem_flg);
2426 if (timeout)
2427 show_timestruc(pri, timeout, "timeout");
2430 void
2431 show_semsys(private_t *pri)
2433 switch (pri->sys_args[0]) {
2434 case 0: /* semctl() */
2435 if (pri->sys_nargs > 4) {
2436 switch (pri->sys_args[3]) {
2437 case IPC_STAT:
2438 if (pri->Errno)
2439 break;
2440 /*FALLTHROUGH*/
2441 case IPC_SET:
2442 #ifdef _LP64
2443 if (data_model == PR_MODEL_LP64)
2444 show_semctl(pri,
2445 (long)pri->sys_args[4]);
2446 else
2447 show_semctl32(pri,
2448 (long)pri->sys_args[4]);
2449 #else
2450 show_semctl(pri, (long)pri->sys_args[4]);
2451 #endif
2452 break;
2453 case IPC_STAT64:
2454 if (pri->Errno)
2455 break;
2456 /*FALLTHROUGH*/
2457 case IPC_SET64:
2458 show_semctl64(pri, (long)pri->sys_args[4]);
2459 break;
2462 break;
2463 case 1: /* semget() */
2464 break;
2465 case 2: /* semop() */
2466 if (pri->sys_nargs > 3)
2467 show_semop(pri, (long)pri->sys_args[2],
2468 pri->sys_args[3], 0);
2469 break;
2470 case 3: /* semids() */
2471 break;
2472 case 4: /* semtimedop() */
2473 if (pri->sys_nargs > 4)
2474 show_semop(pri, (long)pri->sys_args[2],
2475 pri->sys_args[3], pri->sys_args[4]);
2476 break;
2477 default: /* unexpected subcode */
2478 break;
2482 static void
2483 show_shmctl64(private_t *pri, long offset)
2485 struct shmid_ds64 shmds;
2487 if (offset != 0 &&
2488 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2489 show_perm64(pri, &shmds.shmx_perm);
2491 (void) printf(
2492 "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2493 pri->pname,
2494 (unsigned long long)shmds.shmx_segsz,
2495 (int)shmds.shmx_lpid,
2496 (int)shmds.shmx_cpid,
2497 (unsigned long long)shmds.shmx_nattch,
2498 (unsigned long long)shmds.shmx_cnattch);
2500 prtime(pri, " at = ", (time_t)shmds.shmx_atime);
2501 prtime(pri, " dt = ", (time_t)shmds.shmx_dtime);
2502 prtime(pri, " ct = ", (time_t)shmds.shmx_ctime);
2506 void
2507 show_shmctl(private_t *pri, long offset)
2509 struct shmid_ds shmds;
2511 if (offset != 0 &&
2512 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2513 show_perm(pri, &shmds.shm_perm);
2515 (void) printf(
2516 "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2517 pri->pname,
2518 (ulong_t)shmds.shm_segsz,
2519 (int)shmds.shm_lpid,
2520 (int)shmds.shm_cpid,
2521 shmds.shm_nattch,
2522 shmds.shm_cnattch);
2524 prtime(pri, " at = ", shmds.shm_atime);
2525 prtime(pri, " dt = ", shmds.shm_dtime);
2526 prtime(pri, " ct = ", shmds.shm_ctime);
2530 #ifdef _LP64
2531 void
2532 show_shmctl32(private_t *pri, long offset)
2534 struct shmid_ds32 shmds;
2536 if (offset != 0 &&
2537 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2538 show_perm32(pri, &shmds.shm_perm);
2540 (void) printf(
2541 "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2542 pri->pname,
2543 shmds.shm_segsz,
2544 shmds.shm_lpid,
2545 shmds.shm_cpid,
2546 shmds.shm_nattch,
2547 shmds.shm_cnattch);
2549 prtime(pri, " at = ", shmds.shm_atime);
2550 prtime(pri, " dt = ", shmds.shm_dtime);
2551 prtime(pri, " ct = ", shmds.shm_ctime);
2554 #endif /* _LP64 */
2556 void
2557 show_shmsys(private_t *pri)
2559 switch (pri->sys_args[0]) {
2560 case 0: /* shmat() */
2561 break;
2562 case 1: /* shmctl() */
2563 if (pri->sys_nargs > 3) {
2564 switch (pri->sys_args[2]) {
2565 case IPC_STAT:
2566 if (pri->Errno)
2567 break;
2568 /*FALLTHROUGH*/
2569 case IPC_SET:
2570 #ifdef _LP64
2571 if (data_model == PR_MODEL_LP64)
2572 show_shmctl(pri,
2573 (long)pri->sys_args[3]);
2574 else
2575 show_shmctl32(pri,
2576 (long)pri->sys_args[3]);
2577 #else
2578 show_shmctl(pri, (long)pri->sys_args[3]);
2579 #endif
2580 break;
2581 case IPC_STAT64:
2582 if (pri->Errno)
2583 break;
2584 /*FALLTHROUGH*/
2585 case IPC_SET64:
2586 show_shmctl64(pri, (long)pri->sys_args[3]);
2587 break;
2590 break;
2591 case 2: /* shmdt() */
2592 case 3: /* shmget() */
2593 case 4: /* shmids() */
2594 default: /* unexpected subcode */
2595 break;
2599 void
2600 show_groups(private_t *pri, long offset, long count)
2602 int groups[100];
2604 if (count > 100)
2605 count = 100;
2607 if (count > 0 && offset != 0 &&
2608 Pread(Proc, &groups[0], count*sizeof (int), offset) ==
2609 count*sizeof (int)) {
2610 int n;
2612 (void) printf("%s\t", pri->pname);
2613 for (n = 0; !interrupt && n < count; n++) {
2614 if (n != 0 && n%10 == 0)
2615 (void) printf("\n%s\t", pri->pname);
2616 (void) printf(" %5d", groups[n]);
2618 (void) fputc('\n', stdout);
2623 * This assumes that a sigset_t is simply an array of ints.
2625 char *
2626 sigset_string(private_t *pri, sigset_t *sp)
2628 char *s = pri->code_buf;
2629 int n = sizeof (*sp) / sizeof (int32_t);
2630 int32_t *lp = (int32_t *)sp;
2632 while (--n >= 0) {
2633 int32_t val = *lp++;
2635 if (val == 0)
2636 s += sprintf(s, " 0");
2637 else
2638 s += sprintf(s, " 0x%.8X", val);
2641 return (pri->code_buf);
2644 void
2645 show_sigset(private_t *pri, long offset, const char *name)
2647 sigset_t sigset;
2649 if (offset != 0 &&
2650 Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
2651 (void) printf("%s\t%s =%s\n",
2652 pri->pname, name, sigset_string(pri, &sigset));
2656 #ifdef _LP64
2657 void
2658 show_sigaltstack32(private_t *pri, long offset, const char *name)
2660 struct sigaltstack32 altstack;
2662 if (offset != 0 &&
2663 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2664 sizeof (altstack)) {
2665 (void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2666 pri->pname,
2667 name,
2668 altstack.ss_sp,
2669 altstack.ss_size,
2670 altstack.ss_flags);
2673 #endif /* _LP64 */
2675 void
2676 show_sigaltstack(private_t *pri, long offset, const char *name)
2678 struct sigaltstack altstack;
2680 #ifdef _LP64
2681 if (data_model != PR_MODEL_LP64) {
2682 show_sigaltstack32(pri, offset, name);
2683 return;
2685 #endif
2686 if (offset != 0 &&
2687 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2688 sizeof (altstack)) {
2689 (void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2690 pri->pname,
2691 name,
2692 (ulong_t)altstack.ss_sp,
2693 (ulong_t)altstack.ss_size,
2694 altstack.ss_flags);
2698 #ifdef _LP64
2699 void
2700 show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
2702 struct sigaction32 sigaction;
2704 if (offset != 0 &&
2705 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2706 sizeof (sigaction)) {
2707 /* This is stupid, we shouldn't have to do this */
2708 if (odisp != 0)
2709 sigaction.sa_handler = (caddr32_t)odisp;
2710 (void) printf(
2711 "%s %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2712 pri->pname,
2713 name,
2714 sigaction.sa_handler,
2715 sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
2716 sigaction.sa_flags);
2719 #endif /* _LP64 */
2721 void
2722 show_sigaction(private_t *pri, long offset, const char *name, long odisp)
2724 struct sigaction sigaction;
2726 #ifdef _LP64
2727 if (data_model != PR_MODEL_LP64) {
2728 show_sigaction32(pri, offset, name, odisp);
2729 return;
2731 #endif
2732 if (offset != 0 &&
2733 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2734 sizeof (sigaction)) {
2735 /* This is stupid, we shouldn't have to do this */
2736 if (odisp != 0)
2737 sigaction.sa_handler = (void (*)())odisp;
2738 (void) printf(
2739 "%s %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2740 pri->pname,
2741 name,
2742 (long)sigaction.sa_handler,
2743 sigset_string(pri, &sigaction.sa_mask),
2744 sigaction.sa_flags);
2748 #ifdef _LP64
2749 void
2750 print_siginfo32(private_t *pri, const siginfo32_t *sip)
2752 const char *code = NULL;
2754 (void) printf("%s siginfo: %s", pri->pname,
2755 signame(pri, sip->si_signo));
2757 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2758 (void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
2759 if (sip->si_code != 0)
2760 (void) printf(" code=%d", sip->si_code);
2761 (void) fputc('\n', stdout);
2762 return;
2765 switch (sip->si_signo) {
2766 default:
2767 (void) fputc('\n', stdout);
2768 return;
2769 case SIGILL:
2770 case SIGTRAP:
2771 case SIGFPE:
2772 case SIGSEGV:
2773 case SIGBUS:
2774 case SIGEMT:
2775 case SIGCLD:
2776 case SIGPOLL:
2777 case SIGXFSZ:
2778 break;
2781 switch (sip->si_signo) {
2782 case SIGILL:
2783 switch (sip->si_code) {
2784 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2785 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2786 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2787 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2788 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2789 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2790 case ILL_COPROC: code = "ILL_COPROC"; break;
2791 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2793 break;
2794 case SIGTRAP:
2795 switch (sip->si_code) {
2796 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2797 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2798 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2799 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2800 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2801 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2803 break;
2804 case SIGFPE:
2805 switch (sip->si_code) {
2806 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2807 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2808 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2809 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2810 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2811 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2812 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2813 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2814 #if defined(FPE_FLTDEN)
2815 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2816 #endif
2818 break;
2819 case SIGSEGV:
2820 switch (sip->si_code) {
2821 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2822 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2824 break;
2825 case SIGEMT:
2826 switch (sip->si_code) {
2827 #ifdef EMT_TAGOVF
2828 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2829 #endif
2830 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2832 break;
2833 case SIGBUS:
2834 switch (sip->si_code) {
2835 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2836 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2837 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2839 break;
2840 case SIGCLD:
2841 switch (sip->si_code) {
2842 case CLD_EXITED: code = "CLD_EXITED"; break;
2843 case CLD_KILLED: code = "CLD_KILLED"; break;
2844 case CLD_DUMPED: code = "CLD_DUMPED"; break;
2845 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
2846 case CLD_STOPPED: code = "CLD_STOPPED"; break;
2847 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
2849 break;
2850 case SIGPOLL:
2851 switch (sip->si_code) {
2852 case POLL_IN: code = "POLL_IN"; break;
2853 case POLL_OUT: code = "POLL_OUT"; break;
2854 case POLL_MSG: code = "POLL_MSG"; break;
2855 case POLL_ERR: code = "POLL_ERR"; break;
2856 case POLL_PRI: code = "POLL_PRI"; break;
2857 case POLL_HUP: code = "POLL_HUP"; break;
2859 break;
2862 if (code == NULL) {
2863 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2864 code = (const char *)pri->code_buf;
2867 switch (sip->si_signo) {
2868 case SIGILL:
2869 case SIGTRAP:
2870 case SIGFPE:
2871 case SIGSEGV:
2872 case SIGBUS:
2873 case SIGEMT:
2874 (void) printf(" %s addr=0x%.8X",
2875 code,
2876 sip->si_addr);
2877 break;
2878 case SIGCLD:
2879 (void) printf(" %s pid=%d status=0x%.4X",
2880 code,
2881 sip->si_pid,
2882 sip->si_status);
2883 break;
2884 case SIGPOLL:
2885 case SIGXFSZ:
2886 (void) printf(" %s fd=%d band=%d",
2887 code,
2888 sip->si_fd,
2889 sip->si_band);
2890 break;
2893 if (sip->si_errno != 0) {
2894 const char *ename = errname(sip->si_errno);
2896 (void) printf(" errno=%d", sip->si_errno);
2897 if (ename != NULL)
2898 (void) printf("(%s)", ename);
2901 (void) fputc('\n', stdout);
2903 #endif /* _LP64 */
2905 void
2906 print_siginfo(private_t *pri, const siginfo_t *sip)
2908 const char *code = NULL;
2910 (void) printf("%s siginfo: %s", pri->pname,
2911 signame(pri, sip->si_signo));
2913 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2914 (void) printf(" pid=%d uid=%u",
2915 (int)sip->si_pid,
2916 sip->si_uid);
2917 if (sip->si_code != 0)
2918 (void) printf(" code=%d", sip->si_code);
2919 (void) fputc('\n', stdout);
2920 return;
2923 switch (sip->si_signo) {
2924 default:
2925 (void) fputc('\n', stdout);
2926 return;
2927 case SIGILL:
2928 case SIGTRAP:
2929 case SIGFPE:
2930 case SIGSEGV:
2931 case SIGBUS:
2932 case SIGEMT:
2933 case SIGCLD:
2934 case SIGPOLL:
2935 case SIGXFSZ:
2936 break;
2939 switch (sip->si_signo) {
2940 case SIGILL:
2941 switch (sip->si_code) {
2942 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2943 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2944 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2945 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2946 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2947 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2948 case ILL_COPROC: code = "ILL_COPROC"; break;
2949 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2951 break;
2952 case SIGTRAP:
2953 switch (sip->si_code) {
2954 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2955 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2956 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2957 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2958 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2959 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2961 break;
2962 case SIGFPE:
2963 switch (sip->si_code) {
2964 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2965 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2966 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2967 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2968 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2969 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2970 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2971 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2972 #if defined(FPE_FLTDEN)
2973 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2974 #endif
2976 break;
2977 case SIGSEGV:
2978 switch (sip->si_code) {
2979 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2980 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2982 break;
2983 case SIGEMT:
2984 switch (sip->si_code) {
2985 #ifdef EMT_TAGOVF
2986 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2987 #endif
2988 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2990 break;
2991 case SIGBUS:
2992 switch (sip->si_code) {
2993 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2994 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2995 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2997 break;
2998 case SIGCLD:
2999 switch (sip->si_code) {
3000 case CLD_EXITED: code = "CLD_EXITED"; break;
3001 case CLD_KILLED: code = "CLD_KILLED"; break;
3002 case CLD_DUMPED: code = "CLD_DUMPED"; break;
3003 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
3004 case CLD_STOPPED: code = "CLD_STOPPED"; break;
3005 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
3007 break;
3008 case SIGPOLL:
3009 switch (sip->si_code) {
3010 case POLL_IN: code = "POLL_IN"; break;
3011 case POLL_OUT: code = "POLL_OUT"; break;
3012 case POLL_MSG: code = "POLL_MSG"; break;
3013 case POLL_ERR: code = "POLL_ERR"; break;
3014 case POLL_PRI: code = "POLL_PRI"; break;
3015 case POLL_HUP: code = "POLL_HUP"; break;
3017 break;
3020 if (code == NULL) {
3021 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
3022 code = (const char *)pri->code_buf;
3025 switch (sip->si_signo) {
3026 case SIGILL:
3027 case SIGTRAP:
3028 case SIGFPE:
3029 case SIGSEGV:
3030 case SIGBUS:
3031 case SIGEMT:
3032 (void) printf(" %s addr=0x%.8lX",
3033 code,
3034 (long)sip->si_addr);
3035 break;
3036 case SIGCLD:
3037 (void) printf(" %s pid=%d status=0x%.4X",
3038 code,
3039 (int)sip->si_pid,
3040 sip->si_status);
3041 break;
3042 case SIGPOLL:
3043 case SIGXFSZ:
3044 (void) printf(" %s fd=%d band=%ld",
3045 code,
3046 sip->si_fd,
3047 sip->si_band);
3048 break;
3051 if (sip->si_errno != 0) {
3052 const char *ename = errname(sip->si_errno);
3054 (void) printf(" errno=%d", sip->si_errno);
3055 if (ename != NULL)
3056 (void) printf("(%s)", ename);
3059 (void) fputc('\n', stdout);
3062 #ifdef _LP64
3063 void
3064 show_siginfo32(private_t *pri, long offset)
3066 struct siginfo32 siginfo;
3068 if (offset != 0 &&
3069 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3070 print_siginfo32(pri, &siginfo);
3072 #endif /* _LP64 */
3074 void
3075 show_siginfo(private_t *pri, long offset)
3077 struct siginfo siginfo;
3079 #ifdef _LP64
3080 if (data_model != PR_MODEL_LP64) {
3081 show_siginfo32(pri, offset);
3082 return;
3084 #endif
3085 if (offset != 0 &&
3086 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
3087 print_siginfo(pri, &siginfo);
3090 void
3091 show_bool(private_t *pri, long offset, int count)
3093 int serial = (count > MYBUFSIZ / 4);
3095 /* enter region of lengthy output */
3096 if (serial)
3097 Eserialize();
3099 while (count > 0) {
3100 char buf[32];
3101 int nb = (count < 32)? count : 32;
3102 int i;
3104 if (Pread(Proc, buf, (size_t)nb, offset) != nb)
3105 break;
3107 (void) printf("%s ", pri->pname);
3108 for (i = 0; i < nb; i++)
3109 (void) printf(" %d", buf[i]);
3110 (void) fputc('\n', stdout);
3112 count -= nb;
3113 offset += nb;
3116 /* exit region of lengthy output */
3117 if (serial)
3118 Xserialize();
3121 #ifdef _LP64
3122 void
3123 show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
3125 iovec32_t iovec[16];
3126 iovec32_t *ip;
3127 long nb;
3128 int serial = (count > MYBUFSIZ / 4 && showbuf);
3130 if (niov > 16) /* is this the real limit? */
3131 niov = 16;
3133 if (offset != 0 && niov > 0 &&
3134 Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
3135 == niov*sizeof (iovec32_t)) {
3136 /* enter region of lengthy output */
3137 if (serial)
3138 Eserialize();
3140 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3141 (void) printf("%s\tiov_base = 0x%.8X iov_len = %d\n",
3142 pri->pname,
3143 ip->iov_base,
3144 ip->iov_len);
3145 if ((nb = count) > 0) {
3146 if (nb > ip->iov_len)
3147 nb = ip->iov_len;
3148 if (nb > 0)
3149 count -= nb;
3151 if (showbuf && nb > 0)
3152 showbuffer(pri, (long)ip->iov_base, nb);
3155 /* exit region of lengthy output */
3156 if (serial)
3157 Xserialize();
3160 #endif /* _LP64 */
3162 void
3163 show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
3165 iovec_t iovec[16];
3166 iovec_t *ip;
3167 long nb;
3168 int serial = (count > MYBUFSIZ / 4 && showbuf);
3170 #ifdef _LP64
3171 if (data_model != PR_MODEL_LP64) {
3172 show_iovec32(pri, offset, niov, showbuf, count);
3173 return;
3175 #endif
3176 if (niov > 16) /* is this the real limit? */
3177 niov = 16;
3179 if (offset != 0 && niov > 0 &&
3180 Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
3181 == niov*sizeof (iovec_t)) {
3182 /* enter region of lengthy output */
3183 if (serial)
3184 Eserialize();
3186 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3187 (void) printf("%s\tiov_base = 0x%.8lX iov_len = %lu\n",
3188 pri->pname,
3189 (long)ip->iov_base,
3190 ip->iov_len);
3191 if ((nb = count) > 0) {
3192 if (nb > ip->iov_len)
3193 nb = ip->iov_len;
3194 if (nb > 0)
3195 count -= nb;
3197 if (showbuf && nb > 0)
3198 showbuffer(pri, (long)ip->iov_base, nb);
3201 /* exit region of lengthy output */
3202 if (serial)
3203 Xserialize();
3207 void
3208 show_dents32(private_t *pri, long offset, long count)
3210 long buf[MYBUFSIZ / sizeof (long)];
3211 struct dirent32 *dp;
3212 int serial = (count > 100);
3214 if (offset == 0)
3215 return;
3217 /* enter region of lengthy output */
3218 if (serial)
3219 Eserialize();
3221 while (count > 0 && !interrupt) {
3222 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3224 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3225 break;
3227 dp = (struct dirent32 *)&buf[0];
3228 if (nb < (int)(dp->d_name - (char *)dp))
3229 break;
3230 if ((unsigned)nb < dp->d_reclen) {
3231 /* getdents() error? */
3232 (void) printf(
3233 "%s ino=%-5u off=%-4d rlen=%-3d\n",
3234 pri->pname,
3235 dp->d_ino,
3236 dp->d_off,
3237 dp->d_reclen);
3238 break;
3241 while (!interrupt &&
3242 nb >= (int)(dp->d_name - (char *)dp) &&
3243 (unsigned)nb >= dp->d_reclen) {
3244 (void) printf(
3245 "%s ino=%-5u off=%-4d rlen=%-3d \"%.*s\"\n",
3246 pri->pname,
3247 dp->d_ino,
3248 dp->d_off,
3249 dp->d_reclen,
3250 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3251 dp->d_name);
3252 nb -= dp->d_reclen;
3253 count -= dp->d_reclen;
3254 offset += dp->d_reclen;
3255 /* LINTED improper alignment */
3256 dp = (struct dirent32 *)((char *)dp + dp->d_reclen);
3260 /* exit region of lengthy output */
3261 if (serial)
3262 Xserialize();
3265 void
3266 show_dents64(private_t *pri, long offset, long count)
3268 long long buf[MYBUFSIZ / sizeof (long long)];
3269 struct dirent64 *dp;
3270 int serial = (count > 100);
3272 if (offset == 0)
3273 return;
3275 /* enter region of lengthy output */
3276 if (serial)
3277 Eserialize();
3279 while (count > 0 && !interrupt) {
3280 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3282 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3283 break;
3285 dp = (struct dirent64 *)&buf[0];
3286 if (nb < (int)(dp->d_name - (char *)dp))
3287 break;
3288 if ((unsigned)nb < dp->d_reclen) {
3289 /* getdents() error? */
3290 (void) printf(
3291 "%s ino=%-5llu off=%-4lld rlen=%-3d\n",
3292 pri->pname,
3293 (long long)dp->d_ino,
3294 (long long)dp->d_off,
3295 dp->d_reclen);
3296 break;
3299 while (!interrupt &&
3300 nb >= (int)(dp->d_name - (char *)dp) &&
3301 (unsigned)nb >= dp->d_reclen) {
3302 (void) printf(
3303 "%s ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3304 pri->pname,
3305 (long long)dp->d_ino,
3306 (long long)dp->d_off,
3307 dp->d_reclen,
3308 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3309 dp->d_name);
3310 nb -= dp->d_reclen;
3311 count -= dp->d_reclen;
3312 offset += dp->d_reclen;
3313 /* LINTED improper alignment */
3314 dp = (struct dirent64 *)((char *)dp + dp->d_reclen);
3318 /* exit region of lengthy output */
3319 if (serial)
3320 Xserialize();
3323 void
3324 show_rlimit32(private_t *pri, long offset)
3326 struct rlimit32 rlimit;
3328 if (offset != 0 &&
3329 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3330 (void) printf("%s\t", pri->pname);
3331 switch (rlimit.rlim_cur) {
3332 case RLIM32_INFINITY:
3333 (void) fputs("cur = RLIM_INFINITY", stdout);
3334 break;
3335 case RLIM32_SAVED_MAX:
3336 (void) fputs("cur = RLIM_SAVED_MAX", stdout);
3337 break;
3338 case RLIM32_SAVED_CUR:
3339 (void) fputs("cur = RLIM_SAVED_CUR", stdout);
3340 break;
3341 default:
3342 (void) printf("cur = %lu", (long)rlimit.rlim_cur);
3343 break;
3345 switch (rlimit.rlim_max) {
3346 case RLIM32_INFINITY:
3347 (void) fputs(" max = RLIM_INFINITY\n", stdout);
3348 break;
3349 case RLIM32_SAVED_MAX:
3350 (void) fputs(" max = RLIM_SAVED_MAX\n", stdout);
3351 break;
3352 case RLIM32_SAVED_CUR:
3353 (void) fputs(" max = RLIM_SAVED_CUR\n", stdout);
3354 break;
3355 default:
3356 (void) printf(" max = %lu\n", (long)rlimit.rlim_max);
3357 break;
3362 void
3363 show_rlimit64(private_t *pri, long offset)
3365 struct rlimit64 rlimit;
3367 if (offset != 0 &&
3368 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3369 (void) printf("%s\t", pri->pname);
3370 switch (rlimit.rlim_cur) {
3371 case RLIM64_INFINITY:
3372 (void) fputs("cur = RLIM64_INFINITY", stdout);
3373 break;
3374 case RLIM64_SAVED_MAX:
3375 (void) fputs("cur = RLIM64_SAVED_MAX", stdout);
3376 break;
3377 case RLIM64_SAVED_CUR:
3378 (void) fputs("cur = RLIM64_SAVED_CUR", stdout);
3379 break;
3380 default:
3381 (void) printf("cur = %llu",
3382 (unsigned long long)rlimit.rlim_cur);
3383 break;
3385 switch (rlimit.rlim_max) {
3386 case RLIM64_INFINITY:
3387 (void) fputs(" max = RLIM64_INFINITY\n", stdout);
3388 break;
3389 case RLIM64_SAVED_MAX:
3390 (void) fputs(" max = RLIM64_SAVED_MAX\n", stdout);
3391 break;
3392 case RLIM64_SAVED_CUR:
3393 (void) fputs(" max = RLIM64_SAVED_CUR\n", stdout);
3394 break;
3395 default:
3396 (void) printf(" max = %llu\n",
3397 (unsigned long long)rlimit.rlim_max);
3398 break;
3403 void
3404 show_uname(private_t *pri, long offset)
3406 struct utsname ubuf;
3408 if (offset != 0 &&
3409 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3410 (void) printf(
3411 "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3412 pri->pname,
3413 ubuf.sysname,
3414 ubuf.nodename,
3415 ubuf.release,
3416 ubuf.version,
3417 ubuf.machine);
3421 void
3422 show_adjtime(private_t *pri, long off1, long off2)
3424 show_timeval(pri, off1, " delta");
3425 show_timeval(pri, off2, "olddelta");
3428 void
3429 show_sockaddr(private_t *pri,
3430 const char *str, long addroff, long lenoff, long len)
3433 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3434 * also large enough to store a sockaddr_in or a sockaddr_in6.
3436 long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3437 / sizeof (long)];
3438 struct sockaddr *sa = (struct sockaddr *)buf;
3439 struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3440 struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3441 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3442 char addrbuf[INET6_ADDRSTRLEN];
3444 if (lenoff != 0) {
3445 uint_t ilen;
3446 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3447 return;
3448 len = ilen;
3451 if (len >= sizeof (buf)) /* protect against ridiculous length */
3452 len = sizeof (buf) - 1;
3453 if (Pread(Proc, buf, len, addroff) != len)
3454 return;
3456 switch (sa->sa_family) {
3457 case AF_INET6:
3458 (void) printf("%s\tAF_INET6 %s = %s port = %u\n",
3459 pri->pname, str,
3460 inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3461 sizeof (addrbuf)),
3462 ntohs(sin6->sin6_port));
3463 (void) printf("%s\tscope id = %u source id = 0x%x\n"
3464 "%s\tflow class = 0x%02x flow label = 0x%05x\n",
3465 pri->pname, ntohl(sin6->sin6_scope_id),
3466 ntohl(sin6->__sin6_src_id),
3467 pri->pname,
3468 ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3469 ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3470 break;
3471 case AF_INET:
3472 (void) printf("%s\tAF_%s %s = %s port = %u\n",
3473 pri->pname, "INET",
3474 str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3475 sizeof (addrbuf)), ntohs(sin->sin_port));
3476 break;
3477 case AF_UNIX:
3478 len -= sizeof (soun->sun_family);
3479 if (len >= 0) {
3480 /* Null terminate */
3481 soun->sun_path[len] = '\0';
3482 (void) printf("%s\tAF_UNIX %s = %s\n", pri->pname,
3483 str, soun->sun_path);
3485 break;
3489 void
3490 show_msghdr(private_t *pri, long offset)
3492 const lwpstatus_t *Lsp = pri->lwpstat;
3493 int what = Lsp->pr_what;
3494 int err = pri->Errno;
3495 struct msghdr msg;
3496 int showbuf = FALSE;
3497 int i = pri->sys_args[0]+1;
3498 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3500 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3501 return;
3503 if (msg.msg_name != NULL && msg.msg_namelen != 0)
3504 show_sockaddr(pri, "msg_name",
3505 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3508 * Print the iovec if the syscall was successful and the fd is
3509 * part of the set being traced.
3511 if ((what == SYS_recvmsg && !err &&
3512 prismember(&readfd, i)) ||
3513 (what == SYS_sendmsg &&
3514 prismember(&writefd, i)))
3515 showbuf = TRUE;
3517 show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3521 #ifdef _LP64
3522 void
3523 show_msghdr32(private_t *pri, long offset)
3525 struct msghdr32 {
3526 caddr32_t msg_name;
3527 uint32_t msg_namelen;
3528 caddr32_t msg_iov;
3529 int32_t msg_iovlen;
3530 } msg;
3531 const lwpstatus_t *Lsp = pri->lwpstat;
3532 int what = Lsp->pr_what;
3533 int err = pri->Errno;
3534 int showbuf = FALSE;
3535 int i = pri->sys_args[0]+1;
3536 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3538 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3539 return;
3541 if (msg.msg_name != 0 && msg.msg_namelen != 0)
3542 show_sockaddr(pri, "msg_name",
3543 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3545 * Print the iovec if the syscall was successful and the fd is
3546 * part of the set being traced.
3548 if ((what == SYS_recvmsg && !err &&
3549 prismember(&readfd, i)) ||
3550 (what == SYS_sendmsg &&
3551 prismember(&writefd, i)))
3552 showbuf = TRUE;
3554 show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3557 #endif /* _LP64 */
3559 static void
3560 show_doorargs(private_t *pri, long offset)
3562 door_arg_t args;
3564 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3565 (void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3566 pri->pname,
3567 (ulong_t)args.data_ptr,
3568 (ulong_t)args.data_size);
3569 (void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3570 pri->pname,
3571 (ulong_t)args.desc_ptr,
3572 args.desc_num);
3573 (void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3574 pri->pname,
3575 (ulong_t)args.rbuf,
3576 (ulong_t)args.rsize);
3580 static void
3581 show_ucred_privsets(private_t *pri, ucred_t *uc)
3583 int i = 0;
3584 const priv_set_t *s;
3585 priv_ptype_t sn;
3586 char *str;
3588 while ((sn = priv_getsetbynum(i++)) != NULL) {
3589 s = ucred_getprivset(uc, sn);
3591 if (s == NULL)
3592 continue;
3594 (void) printf("%s\t%c: %s\n",
3595 pri->pname,
3596 *sn,
3597 str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3599 free(str);
3603 static void
3604 show_ucred(private_t *pri, long offset)
3606 ucred_t *uc = _ucred_alloc();
3607 size_t sz;
3609 if (uc == NULL)
3610 return;
3612 sz = Pread(Proc, uc, uc->uc_size, offset);
3615 * A new uc_size is read, it could be smaller than the previously
3616 * value. We accept short reads that fill the whole header.
3618 if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3619 (void) printf("%s\teuid=%u egid=%u\n",
3620 pri->pname,
3621 ucred_geteuid(uc),
3622 ucred_getegid(uc));
3623 (void) printf("%s\truid=%u rgid=%u\n",
3624 pri->pname,
3625 ucred_getruid(uc),
3626 ucred_getrgid(uc));
3627 (void) printf("%s\tpid=%d zoneid=%d\n",
3628 pri->pname,
3629 (int)ucred_getpid(uc),
3630 (int)ucred_getzoneid(uc));
3631 show_ucred_privsets(pri, uc);
3633 ucred_free(uc);
3636 static void
3637 show_privset(private_t *pri, long offset, size_t size, char *label)
3639 priv_set_t *tmp = priv_allocset();
3640 size_t sz;
3642 if (tmp == NULL)
3643 return;
3645 sz = Pread(Proc, tmp, size, offset);
3647 if (sz == size) {
3648 char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3649 if (str != NULL) {
3650 (void) printf("%s\t%s%s\n", pri->pname, label, str);
3651 free(str);
3654 priv_freeset(tmp);
3657 static void
3658 show_doorinfo(private_t *pri, long offset)
3660 door_info_t info;
3661 door_attr_t attr;
3663 if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3664 return;
3665 (void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3666 pri->pname,
3667 (int)info.di_target,
3668 info.di_proc,
3669 info.di_data);
3670 attr = info.di_attributes;
3671 (void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3672 (void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3675 static void
3676 show_doorparam(private_t *pri, long offset)
3678 ulong_t val;
3680 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3681 (void) printf("%s\tvalue=%lu\n",
3682 pri->pname,
3683 val);
3687 #ifdef _LP64
3689 static void
3690 show_doorargs32(private_t *pri, long offset)
3692 struct door_arg32 args;
3694 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3695 (void) printf("%s\tdata_ptr=%X data_size=%u\n",
3696 pri->pname,
3697 args.data_ptr,
3698 args.data_size);
3699 (void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3700 pri->pname,
3701 args.desc_ptr,
3702 args.desc_num);
3703 (void) printf("%s\trbuf=0x%X rsize=%u\n",
3704 pri->pname,
3705 args.rbuf,
3706 args.rsize);
3710 static void
3711 show_doorparam32(private_t *pri, long offset)
3713 uint_t val;
3715 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3716 (void) printf("%s\tvalue=%u\n",
3717 pri->pname,
3718 val);
3722 #endif /* _LP64 */
3724 static void
3725 show_doors(private_t *pri)
3727 switch (pri->sys_args[5]) {
3728 case DOOR_CALL:
3729 #ifdef _LP64
3730 if (data_model == PR_MODEL_LP64)
3731 show_doorargs(pri, (long)pri->sys_args[1]);
3732 else
3733 show_doorargs32(pri, (long)pri->sys_args[1]);
3734 #else
3735 show_doorargs(pri, (long)pri->sys_args[1]);
3736 #endif
3737 break;
3738 case DOOR_UCRED:
3739 if (!pri->Errno)
3740 show_ucred(pri, (long)pri->sys_args[0]);
3741 break;
3742 case DOOR_INFO:
3743 if (!pri->Errno)
3744 show_doorinfo(pri, (long)pri->sys_args[1]);
3745 break;
3746 case DOOR_GETPARAM:
3747 if (!pri->Errno) {
3748 #ifdef _LP64
3749 if (data_model == PR_MODEL_LP64)
3750 show_doorparam(pri, (long)pri->sys_args[2]);
3751 else
3752 show_doorparam32(pri, (long)pri->sys_args[2]);
3753 #else
3754 show_doorparam(pri, (long)pri->sys_args[2]);
3755 #endif
3757 break;
3761 static void
3762 show_portargs(private_t *pri, long offset)
3764 port_event_t args;
3766 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3767 (void) printf("%s\tevents=0x%x source=%u\n",
3768 pri->pname,
3769 args.portev_events,
3770 args.portev_source);
3771 (void) printf("%s\tobject=0x%p user=0x%p\n",
3772 pri->pname,
3773 (void *)args.portev_object,
3774 (void *)args.portev_user);
3779 #ifdef _LP64
3781 static void
3782 show_portargs32(private_t *pri, long offset)
3784 port_event32_t args;
3786 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3787 (void) printf("%s\tevents=0x%x source=%u\n",
3788 pri->pname,
3789 args.portev_events,
3790 args.portev_source);
3791 (void) printf("%s\tobject=0x%x user=0x%x\n",
3792 pri->pname,
3793 args.portev_object,
3794 args.portev_user);
3798 #endif /* _LP64 */
3800 static void
3801 show_ports(private_t *pri)
3803 switch (pri->sys_args[0]) {
3804 case PORT_GET:
3805 #ifdef _LP64
3806 if (data_model == PR_MODEL_LP64)
3807 show_portargs(pri, (long)pri->sys_args[2]);
3808 else
3809 show_portargs32(pri, (long)pri->sys_args[2]);
3810 #else
3811 show_portargs(pri, (long)pri->sys_args[2]);
3812 #endif
3813 break;
3817 #define MAX_SNDFL_PRD 16
3819 #ifdef _LP64
3821 static void
3822 show_ksendfilevec32(private_t *pri, int fd,
3823 ksendfilevec32_t *sndvec, int sfvcnt)
3825 ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3826 size_t cpy_rqst;
3828 Eserialize();
3829 while (sfvcnt > 0) {
3830 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3831 sfvcnt -= cpy_rqst;
3832 cpy_rqst *= sizeof (snd[0]);
3834 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3835 break;
3837 snd_ptr = &snd[0];
3839 while (cpy_rqst) {
3840 (void) printf(
3841 "sfv_fd=%d\tsfv_flag=0x%x\t"
3842 "sfv_off=%d\tsfv_len=%u\n",
3843 snd_ptr->sfv_fd,
3844 snd_ptr->sfv_flag,
3845 snd_ptr->sfv_off,
3846 snd_ptr->sfv_len);
3848 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3849 prismember(&writefd, fd)) {
3850 showbuffer(pri,
3851 (long)snd_ptr->sfv_off & 0xffffffff,
3852 (long)snd_ptr->sfv_len);
3855 cpy_rqst -= sizeof (snd[0]);
3856 snd_ptr++;
3859 sndvec += MAX_SNDFL_PRD;
3861 Xserialize();
3864 static void
3865 show_ksendfilevec64(private_t *pri, int fd,
3866 ksendfilevec64_t *sndvec, int sfvcnt)
3868 ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3869 size_t cpy_rqst;
3871 Eserialize();
3872 while (sfvcnt > 0) {
3873 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3874 sfvcnt -= cpy_rqst;
3875 cpy_rqst *= sizeof (snd[0]);
3877 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3878 break;
3880 snd_ptr = &snd[0];
3882 while (cpy_rqst) {
3883 (void) printf(
3884 "sfv_fd=%d\tsfv_flag=0x%x\t"
3885 "sfv_off=%ld\tsfv_len=%u\n",
3886 snd_ptr->sfv_fd,
3887 snd_ptr->sfv_flag,
3888 snd_ptr->sfv_off,
3889 snd_ptr->sfv_len);
3891 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3892 prismember(&writefd, fd)) {
3893 showbuffer(pri,
3894 (long)snd_ptr->sfv_off & 0xffffffff,
3895 (long)snd_ptr->sfv_len);
3898 cpy_rqst -= sizeof (snd[0]);
3899 snd_ptr++;
3902 sndvec += MAX_SNDFL_PRD;
3904 Xserialize();
3907 #endif /* _LP64 */
3909 /*ARGSUSED*/
3910 static void
3911 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3913 sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3914 size_t cpy_rqst;
3916 #ifdef _LP64
3917 if (data_model != PR_MODEL_LP64) {
3918 show_ksendfilevec32(pri, fd,
3919 (ksendfilevec32_t *)sndvec, sfvcnt);
3920 return;
3922 #endif
3923 Eserialize();
3924 while (sfvcnt > 0) {
3925 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3926 sfvcnt -= cpy_rqst;
3927 cpy_rqst *= sizeof (snd[0]);
3929 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3930 break;
3932 snd_ptr = &snd[0];
3934 while (cpy_rqst) {
3935 (void) printf(
3936 "sfv_fd=%d\tsfv_flag=0x%x\t"
3937 "sfv_off=%ld\tsfv_len=%lu\n",
3938 snd_ptr->sfv_fd,
3939 snd_ptr->sfv_flag,
3940 snd_ptr->sfv_off,
3941 (ulong_t)snd_ptr->sfv_len);
3943 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3944 prismember(&writefd, fd)) {
3945 showbuffer(pri, (long)snd_ptr->sfv_off,
3946 (long)snd_ptr->sfv_len);
3949 cpy_rqst -= sizeof (snd[0]);
3950 snd_ptr++;
3953 sndvec += MAX_SNDFL_PRD;
3955 Xserialize();
3958 /*ARGSUSED*/
3959 static void
3960 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
3962 sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3963 size_t cpy_rqst;
3965 #ifdef _LP64
3966 if (data_model != PR_MODEL_LP64) {
3967 show_ksendfilevec64(pri, fd,
3968 (ksendfilevec64_t *)sndvec, sfvcnt);
3969 return;
3971 #endif
3973 Eserialize();
3974 while (sfvcnt > 0) {
3975 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3976 sfvcnt -= cpy_rqst;
3977 cpy_rqst *= sizeof (snd[0]);
3979 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3980 break;
3982 snd_ptr = &snd[0];
3984 while (cpy_rqst) {
3985 (void) printf(
3986 #ifdef _LP64
3987 "sfv_fd=%d\tsfv_flag=0x%x\t"
3988 "sfv_off=%ld\tsfv_len=%lu\n",
3989 #else
3990 "sfv_fd=%d\tsfv_flag=0x%x\t"
3991 "sfv_off=%lld\tsfv_len=%lu\n",
3992 #endif
3993 snd_ptr->sfv_fd,
3994 snd_ptr->sfv_flag,
3995 snd_ptr->sfv_off,
3996 (ulong_t)snd_ptr->sfv_len);
3998 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3999 prismember(&writefd, fd)) {
4000 showbuffer(pri, (long)snd_ptr->sfv_off,
4001 (long)snd_ptr->sfv_len);
4004 cpy_rqst -= sizeof (snd[0]);
4005 snd_ptr++;
4008 sndvec += MAX_SNDFL_PRD;
4010 Xserialize();
4013 static void
4014 show_memcntl_mha(private_t *pri, long offset)
4016 struct memcntl_mha mha;
4017 const char *s = NULL;
4019 if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
4020 switch (mha.mha_cmd) {
4021 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
4022 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
4023 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
4025 if (s)
4026 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4027 " mha_pagesize=%lu\n",
4028 pri->pname, s, mha.mha_flags,
4029 (ulong_t)mha.mha_pagesize);
4030 else
4031 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4032 " mha_pagesize=%lu\n",
4033 pri->pname, mha.mha_cmd, mha.mha_flags,
4034 (ulong_t)mha.mha_pagesize);
4038 #ifdef _LP64
4040 static void
4041 show_memcntl_mha32(private_t *pri, long offset)
4043 struct memcntl_mha32 mha32;
4044 const char *s = NULL;
4046 if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
4047 sizeof (mha32)) {
4048 switch (mha32.mha_cmd) {
4049 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
4050 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
4051 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
4053 if (s)
4054 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
4055 " mha_pagesize=%u\n",
4056 pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
4057 else
4058 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
4059 " mha_pagesize=%u\n",
4060 pri->pname, mha32.mha_cmd, mha32.mha_flags,
4061 mha32.mha_pagesize);
4065 #endif /* _LP64 */
4067 static void
4068 show_memcntl(private_t *pri)
4071 if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
4072 return;
4073 #ifdef _LP64
4074 if (data_model == PR_MODEL_LP64)
4075 show_memcntl_mha(pri, (long)pri->sys_args[3]);
4076 else
4077 show_memcntl_mha32(pri, (long)pri->sys_args[3]);
4078 #else
4079 show_memcntl_mha(pri, (long)pri->sys_args[3]);
4080 #endif
4083 void
4084 show_ids(private_t *pri, long offset, int count)
4086 id_t buf[MYBUFSIZ / sizeof (id_t)];
4087 id_t *idp;
4088 int serial = (count > MYBUFSIZ / 48);
4090 if (offset == 0)
4091 return;
4093 /* enter region of lengthy output */
4094 if (serial)
4095 Eserialize();
4097 while (count > 0 && !interrupt) {
4098 ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
4099 count * sizeof (id_t) : MYBUFSIZ;
4101 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
4102 nb < sizeof (id_t))
4103 break;
4105 idp = buf;
4106 while (!interrupt && nb >= sizeof (id_t)) {
4107 (void) printf("%s\t%8d\n", pri->pname, (int)*idp);
4108 offset += sizeof (id_t);
4109 nb -= sizeof (id_t);
4110 idp++;
4111 count--;
4115 /* exit region of lengthy output */
4116 if (serial)
4117 Xserialize();
4120 void
4121 show_ntp_gettime(private_t *pri)
4123 struct ntptimeval ntv;
4124 long offset;
4126 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
4127 return;
4129 if (data_model == PR_MODEL_NATIVE) {
4130 if (Pread(Proc, &ntv, sizeof (ntv), offset)
4131 != sizeof (ntv))
4132 return;
4133 } else {
4134 struct ntptimeval32 ntv32;
4136 if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
4137 != sizeof (ntv32))
4138 return;
4140 TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
4141 ntv.maxerror = ntv32.maxerror;
4142 ntv.esterror = ntv32.esterror;
4145 (void) printf("\ttime: %ld.%6.6ld sec\n",
4146 ntv.time.tv_sec, ntv.time.tv_usec);
4147 (void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
4148 (void) printf("\testerror: %11d usec\n", ntv.esterror);
4151 static char *
4152 get_timex_modes(private_t *pri, uint32_t val)
4154 char *str = pri->code_buf;
4155 size_t used = 0;
4157 *str = '\0';
4158 if (val & MOD_OFFSET)
4159 used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
4160 if (val & MOD_FREQUENCY)
4161 used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
4162 if (val & MOD_MAXERROR)
4163 used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
4164 if (val & MOD_ESTERROR)
4165 used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
4166 if (val & MOD_STATUS)
4167 used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
4168 if (val & MOD_TIMECONST)
4169 used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
4170 if (val & MOD_CLKB)
4171 used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
4172 if (val & MOD_CLKA)
4173 used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
4175 if (used == 0 || used >= sizeof (pri->code_buf))
4176 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4178 return (str + 1);
4181 static char *
4182 get_timex_status(private_t *pri, int32_t val)
4184 char *str = pri->code_buf;
4185 size_t used = 0;
4187 *str = '\0';
4188 if (val & STA_PLL)
4189 used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
4190 if (val & STA_PPSFREQ)
4191 used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
4192 if (val & STA_PPSTIME)
4193 used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
4194 if (val & STA_FLL)
4195 used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
4197 if (val & STA_INS)
4198 used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
4199 if (val & STA_DEL)
4200 used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
4201 if (val & STA_UNSYNC)
4202 used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
4203 if (val & STA_FREQHOLD)
4204 used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
4206 if (val & STA_PPSSIGNAL)
4207 used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
4208 if (val & STA_PPSJITTER)
4209 used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
4210 if (val & STA_PPSWANDER)
4211 used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
4212 if (val & STA_PPSERROR)
4213 used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
4215 if (val & STA_CLOCKERR)
4216 used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
4218 if (used == 0 || used >= sizeof (pri->code_buf))
4219 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
4221 return (str + 1);
4224 void
4225 show_ntp_adjtime(private_t *pri)
4227 struct timex timex;
4228 long offset;
4230 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
4231 return;
4233 if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4234 return;
4236 (void) printf("\tmodes: %s\n", get_timex_modes(pri, timex.modes));
4237 (void) printf("\toffset: %11d usec\n", timex.offset);
4238 (void) printf("\tfreq: %11d scaled ppm\n", timex.freq);
4239 (void) printf("\tmaxerror: %11d usec\n", timex.maxerror);
4240 (void) printf("\testerror: %11d usec\n", timex.esterror);
4241 (void) printf("\tstatus: %s\n", get_timex_status(pri, timex.status));
4242 (void) printf("\tconstant: %11d\n", timex.constant);
4243 (void) printf("\tprecision: %11d usec\n", timex.precision);
4244 (void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4245 (void) printf("\tppsfreq: %11d scaled ppm\n", timex.ppsfreq);
4246 (void) printf("\tjitter: %11d usec\n", timex.jitter);
4247 (void) printf("\tshift: %11d sec\n", timex.shift);
4248 (void) printf("\tstabil: %11d scaled ppm\n", timex.stabil);
4249 (void) printf("\tjitcnt: %11d\n", timex.jitcnt);
4250 (void) printf("\tcalcnt: %11d\n", timex.calcnt);
4251 (void) printf("\terrcnt: %11d\n", timex.errcnt);
4252 (void) printf("\tstbcnt: %11d\n", timex.stbcnt);
4255 void
4256 show_getrusage(long offset)
4258 struct rusage r;
4259 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4260 return;
4261 (void) printf("\t user time: %ld.%6.6ld sec\n",
4262 r.ru_utime.tv_sec,
4263 r.ru_utime.tv_usec);
4264 (void) printf("\t system time: %ld.%6.6ld sec\n",
4265 r.ru_stime.tv_sec,
4266 r.ru_stime.tv_usec);
4267 (void) printf("\t max rss: <unimpl> %ld\n",
4268 r.ru_maxrss);
4269 (void) printf("\t shared data: <unimpl> %ld\n",
4270 r.ru_ixrss);
4271 (void) printf("\t unshared data: <unimpl> %ld\n",
4272 r.ru_idrss);
4273 (void) printf("\t unshared stack: <unimpl> %ld\n",
4274 r.ru_isrss);
4275 (void) printf("\t minor faults: %ld\n",
4276 r.ru_minflt);
4277 (void) printf("\t major faults: %ld\n",
4278 r.ru_majflt);
4279 (void) printf("\t # of swaps: %ld\n",
4280 r.ru_nswap);
4281 (void) printf("\t blocked inputs: %ld\n",
4282 r.ru_inblock);
4283 (void) printf("\t blocked outputs: %ld\n",
4284 r.ru_oublock);
4285 (void) printf("\t msgs sent: %ld\n",
4286 r.ru_msgsnd);
4287 (void) printf("\t msgs rcv'd: %ld\n",
4288 r.ru_msgrcv);
4289 (void) printf("\t signals rcv'd: %ld\n",
4290 r.ru_nsignals);
4291 (void) printf("\tvol cntxt swtchs: %ld\n",
4292 r.ru_nvcsw);
4293 (void) printf("\tinv cntxt swtchs: %ld\n",
4294 r.ru_nivcsw);
4297 #ifdef _LP64
4298 void
4299 show_getrusage32(long offset)
4301 struct rusage32 r;
4302 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4303 return;
4304 (void) printf("\t user time: %d.%6.6d sec\n",
4305 r.ru_utime.tv_sec,
4306 r.ru_utime.tv_usec);
4307 (void) printf("\t system time: %d.%6.6d sec\n",
4308 r.ru_stime.tv_sec,
4309 r.ru_stime.tv_usec);
4310 (void) printf("\t max rss: <unimpl> %d\n",
4311 r.ru_maxrss);
4312 (void) printf("\t shared data: <unimpl> %d\n",
4313 r.ru_ixrss);
4314 (void) printf("\t unshared data: <unimpl> %d\n",
4315 r.ru_idrss);
4316 (void) printf("\t unshared stack: <unimpl> %d\n",
4317 r.ru_isrss);
4318 (void) printf("\t minor faults: %d\n",
4319 r.ru_minflt);
4320 (void) printf("\t major faults: %d\n",
4321 r.ru_majflt);
4322 (void) printf("\t # of swaps: %d\n",
4323 r.ru_nswap);
4324 (void) printf("\t blocked inputs: %d\n",
4325 r.ru_inblock);
4326 (void) printf("\t blocked outputs: %d\n",
4327 r.ru_oublock);
4328 (void) printf("\t msgs sent: %d\n",
4329 r.ru_msgsnd);
4330 (void) printf("\t msgs rcv'd: %d\n",
4331 r.ru_msgrcv);
4332 (void) printf("\t signals rcv'd: %d\n",
4333 r.ru_nsignals);
4334 (void) printf("\tvol cntxt swtchs: %d\n",
4335 r.ru_nvcsw);
4336 (void) printf("\tinv cntxt swtchs: %d\n",
4337 r.ru_nivcsw);
4339 #endif
4342 * Utility function to print a packed nvlist by unpacking
4343 * and calling the libnvpair pretty printer. Frees all
4344 * allocated memory internally.
4346 static void
4347 show_packed_nvlist(private_t *pri, uintptr_t offset, size_t size)
4349 nvlist_t *nvl = NULL;
4350 size_t readsize;
4351 char *buf;
4353 if ((offset == 0) || (size == 0)) {
4354 return;
4357 buf = my_malloc(size, "nvlist decode buffer");
4358 readsize = Pread(Proc, buf, size, offset);
4359 if (readsize != size) {
4360 (void) printf("%s\t<?>", pri->pname);
4361 } else {
4362 int result;
4364 result = nvlist_unpack(buf, size, &nvl, 0);
4365 if (result == 0) {
4366 dump_nvlist(nvl, 8);
4367 nvlist_free(nvl);
4368 } else {
4369 (void) printf("%s\tunpack of nvlist"
4370 " failed: %d\n", pri->pname, result);
4373 free(buf);
4376 static void
4377 show_zone_create_args(private_t *pri, long offset)
4379 zone_def args;
4380 char zone_name[ZONENAME_MAX];
4381 char zone_root[MAXPATHLEN];
4382 char *zone_zfs = NULL;
4384 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4386 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4387 (uintptr_t)args.zone_name) == -1)
4388 (void) strcpy(zone_name, "<?>");
4390 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4391 (uintptr_t)args.zone_root) == -1)
4392 (void) strcpy(zone_root, "<?>");
4394 if (args.zfsbufsz > 0) {
4395 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4396 if (zone_zfs != NULL) {
4397 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4398 (uintptr_t)args.zfsbuf) == -1)
4399 (void) strcpy(zone_zfs, "<?>");
4401 } else {
4402 zone_zfs = "";
4405 (void) printf("%s\t zone_name: %s\n", pri->pname,
4406 zone_name);
4407 (void) printf("%s\t zone_root: %s\n", pri->pname,
4408 zone_root);
4410 show_privset(pri, (uintptr_t)args.zone_privs,
4411 args.zone_privssz, " zone_privs: ");
4413 (void) printf("%s\t rctlbuf: 0x%p\n", pri->pname,
4414 (void *)args.rctlbuf);
4415 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4416 (ulong_t)args.rctlbufsz);
4418 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4419 args.rctlbufsz);
4421 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4423 (void) printf("%s\textended_error: 0x%p\n", pri->pname,
4424 (void *)args.extended_error);
4426 if (args.zfsbufsz > 0)
4427 free(zone_zfs);
4432 #ifdef _LP64
4434 static void
4435 show_zone_create_args32(private_t *pri, long offset)
4437 zone_def32 args;
4438 char zone_name[ZONENAME_MAX];
4439 char zone_root[MAXPATHLEN];
4440 char *zone_zfs = NULL;
4442 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4444 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4445 (uintptr_t)args.zone_name) == -1)
4446 (void) strcpy(zone_name, "<?>");
4448 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4449 (uintptr_t)args.zone_root) == -1)
4450 (void) strcpy(zone_root, "<?>");
4452 if (args.zfsbufsz > 0) {
4453 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4454 if (zone_zfs != NULL) {
4455 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4456 (uintptr_t)args.zfsbuf) == -1)
4457 (void) strcpy(zone_zfs, "<?>");
4459 } else {
4460 zone_zfs = "";
4463 (void) printf("%s\t zone_name: %s\n", pri->pname,
4464 zone_name);
4465 (void) printf("%s\t zone_root: %s\n", pri->pname,
4466 zone_root);
4468 show_privset(pri, (uintptr_t)args.zone_privs,
4469 args.zone_privssz, " zone_privs: ");
4471 (void) printf("%s\t rctlbuf: 0x%x\n", pri->pname,
4472 (caddr32_t)args.rctlbuf);
4473 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4474 (ulong_t)args.rctlbufsz);
4476 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4477 args.rctlbufsz);
4479 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4481 (void) printf("%s\textended_error: 0x%x\n", pri->pname,
4482 (caddr32_t)args.extended_error);
4484 if (args.zfsbufsz > 0)
4485 free(zone_zfs);
4489 #endif
4491 static void
4492 show_zones(private_t *pri)
4494 switch (pri->sys_args[0]) {
4495 case ZONE_CREATE:
4496 #ifdef _LP64
4497 if (data_model == PR_MODEL_LP64)
4498 show_zone_create_args(pri, (long)pri->sys_args[1]);
4499 else
4500 show_zone_create_args32(pri, (long)pri->sys_args[1]);
4501 #else
4502 show_zone_create_args(pri, (long)pri->sys_args[1]);
4503 #endif
4504 break;
4508 static void
4509 show_rctlblk(private_t *pri, long _rctlblk)
4511 rctlblk_t *blk;
4512 int size = rctlblk_size();
4513 size_t readsize;
4514 const char *s;
4516 blk = my_malloc(size, "rctlblk decode buffer");
4517 readsize = Pread(Proc, blk, size, _rctlblk);
4518 if (readsize != size) {
4519 (void) printf("%s\t\t<?>", pri->pname);
4520 } else {
4521 (void) printf("%s\t\t Privilege: 0x%x\n",
4522 pri->pname,
4523 rctlblk_get_privilege(blk));
4524 (void) printf("%s\t\t Value: %lld\n",
4525 pri->pname,
4526 rctlblk_get_value(blk));
4527 (void) printf("%s\t\tEnforced Value: %lld\n",
4528 pri->pname,
4529 rctlblk_get_enforced_value(blk));
4532 int sig, act;
4533 act = rctlblk_get_local_action(blk, &sig);
4535 s = rctl_local_action(pri, act);
4536 if (s == NULL) {
4537 (void) printf("%s\t\t Local action: 0x%x\n",
4538 pri->pname, act);
4539 } else {
4540 (void) printf("%s\t\t Local action: %s\n",
4541 pri->pname, s);
4544 if (act & RCTL_LOCAL_SIGNAL) {
4545 (void) printf("%s\t\t "
4546 "For signal %s\n",
4547 pri->pname, signame(pri, sig));
4551 s = rctl_local_flags(pri, rctlblk_get_local_flags(blk));
4552 if (s == NULL) {
4553 (void) printf("%s\t\t Local flags: 0x%x\n",
4554 pri->pname, rctlblk_get_local_flags(blk));
4555 } else {
4556 (void) printf("%s\t\t Local flags: %s\n",
4557 pri->pname, s);
4560 #ifdef _LP64
4561 (void) printf("%s\t\t Recipient PID: %d\n",
4562 pri->pname,
4563 rctlblk_get_recipient_pid(blk));
4564 #else
4565 (void) printf("%s\t\t Recipient PID: %ld\n",
4566 pri->pname,
4567 rctlblk_get_recipient_pid(blk));
4568 #endif
4569 (void) printf("%s\t\t Firing Time: %lld\n",
4570 pri->pname,
4571 rctlblk_get_firing_time(blk));
4573 free(blk);
4576 static void
4577 show_rctls(private_t *pri)
4579 int entry;
4581 switch (pri->sys_args[0]) {
4582 case 0: /* getrctl */
4583 case 1: /* setrctl */
4585 * If these offsets look a little odd, remember that they're
4586 * into the _raw_ system call
4588 (void) printf("%s\tOld rctlblk: 0x%lx\n", pri->pname,
4589 pri->sys_args[2]);
4590 if (pri->sys_args[2] != 0) {
4591 show_rctlblk(pri, pri->sys_args[2]);
4593 (void) printf("%s\tNew rctlblk: 0x%lx\n", pri->pname,
4594 pri->sys_args[3]);
4595 if (pri->sys_args[3] != 0) {
4596 show_rctlblk(pri, pri->sys_args[3]);
4598 break;
4599 case 4: /* setprojrctl */
4600 for (entry = 0; entry < pri->sys_args[4]; entry++) {
4601 (void) printf("%s\tNew rctlblk[%d]: 0x%lx\n",
4602 pri->pname, entry,
4603 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4604 if (RCTLBLK_INC(pri->sys_args[3], entry) != NULL) {
4605 show_rctlblk(pri,
4606 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4612 void
4613 show_utimesys(private_t *pri)
4615 switch (pri->sys_args[0]) {
4616 case 0: /* futimens() */
4617 if (pri->sys_nargs > 2)
4618 show_utimens(pri, (long)pri->sys_args[2]);
4619 break;
4620 case 1: /* utimensat */
4621 if (pri->sys_nargs > 3)
4622 show_utimens(pri, (long)pri->sys_args[3]);
4623 break;
4624 default: /* unexpected subcode */
4625 break;
4629 #ifdef _LP64
4630 static void
4631 show_sockconfig_filter_prop32(private_t *pri, long addr)
4633 struct sockconfig_filter_props32 props;
4634 const char *s = NULL;
4635 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4636 sof_socktuple32_t *tup;
4637 size_t sz;
4638 int i;
4640 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4641 if (Pread_string(Proc, buf, sizeof (buf),
4642 (uintptr_t)props.sfp_modname) == -1)
4643 (void) strcpy(buf, "<?>");
4644 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4645 (void) printf("%s\tattach semantics: %s", pri->pname,
4646 props.sfp_autoattach ? "automatic" : "progammatic");
4647 if (props.sfp_autoattach) {
4648 buf[0] = '\0';
4649 switch (props.sfp_hint) {
4650 case SOF_HINT_TOP: s = "top"; break;
4651 case SOF_HINT_BOTTOM: s = "bottom"; break;
4652 case SOF_HINT_BEFORE:
4653 case SOF_HINT_AFTER:
4654 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4655 "before" : "after";
4656 if (Pread_string(Proc, buf, sizeof (buf),
4657 (uintptr_t)props.sfp_hintarg) == -1)
4658 (void) strcpy(buf, "<?>");
4660 if (s != NULL) {
4661 (void) printf(", placement: %s %s", s, buf);
4664 (void) printf("\n");
4665 (void) printf("%s\tsocket tuples:\n", pri->pname);
4666 if (props.sfp_socktuple_cnt == 0) {
4667 (void) printf("\t\t<empty>\n");
4668 return;
4670 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4671 tup = my_malloc(sz, "socket tuple buffer");
4672 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4673 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4674 (void) printf(
4675 "\t\tfamily: %d, type: %d, proto: %d\n",
4676 tup[i].sofst_family, tup[i].sofst_type,
4677 tup[i].sofst_protocol);
4681 #endif /* _LP64 */
4682 static void
4683 show_sockconfig_filter_prop(private_t *pri, long addr)
4685 struct sockconfig_filter_props props;
4686 const char *s = NULL;
4687 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4688 sof_socktuple_t *tup;
4689 size_t sz;
4690 int i;
4692 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4693 if (Pread_string(Proc, buf, sizeof (buf),
4694 (uintptr_t)props.sfp_modname) == -1)
4695 (void) strcpy(buf, "<?>");
4696 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4697 (void) printf("%s\tattach semantics: %s", pri->pname,
4698 props.sfp_autoattach ? "automatic" : "progammatic");
4699 if (props.sfp_autoattach) {
4700 buf[0] = '\0';
4701 switch (props.sfp_hint) {
4702 case SOF_HINT_TOP: s = "top"; break;
4703 case SOF_HINT_BOTTOM: s = "bottom"; break;
4704 case SOF_HINT_BEFORE:
4705 case SOF_HINT_AFTER:
4706 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4707 "before" : "after";
4708 if (Pread_string(Proc, buf, sizeof (buf),
4709 (uintptr_t)props.sfp_hintarg) == -1)
4710 (void) strcpy(buf, "<?>");
4712 if (s != NULL) {
4713 (void) printf(", placement: %s", s);
4716 (void) printf("\n");
4717 (void) printf("%s\tsocket tuples:\n", pri->pname);
4718 if (props.sfp_socktuple_cnt == 0) {
4719 (void) printf("\t\t<empty>\n");
4720 return;
4722 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4723 tup = my_malloc(sz, "socket tuple buffer");
4724 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4725 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4726 (void) printf(
4727 "\t\tfamily: %d, type: %d, proto: %d\n",
4728 tup[i].sofst_family, tup[i].sofst_type,
4729 tup[i].sofst_protocol);
4734 void
4735 show_sockconfig(private_t *pri)
4737 switch (pri->sys_args[0]) {
4738 case SOCKCONFIG_ADD_FILTER:
4739 #ifdef _LP64
4740 if (data_model == PR_MODEL_LP64)
4741 show_sockconfig_filter_prop(pri,
4742 (long)pri->sys_args[2]);
4743 else
4744 show_sockconfig_filter_prop32(pri,
4745 (long)pri->sys_args[2]);
4746 #else
4747 show_sockconfig_filter_prop(pri, (long)pri->sys_args[2]);
4748 #endif
4749 break;
4750 default:
4751 break;
4755 void
4756 show_zfs_ioc(private_t *pri, long addr)
4758 static const zfs_share_t zero_share = {0};
4759 static const dmu_objset_stats_t zero_objstats = {0};
4760 static const struct drr_begin zero_drrbegin = {0};
4761 static const zinject_record_t zero_injectrec = {0};
4762 static const zfs_stat_t zero_zstat = {0};
4763 zfs_cmd_t zc;
4765 if (Pread(Proc, &zc, sizeof (zc), addr) != sizeof (zc)) {
4766 (void) printf(" zfs_ioctl read failed\n");
4767 return;
4770 if (zc.zc_name[0])
4771 (void) printf(" zc_name=%s\n", zc.zc_name);
4772 if (zc.zc_value[0])
4773 (void) printf(" zc_value=%s\n", zc.zc_value);
4774 if (zc.zc_string[0])
4775 (void) printf(" zc_string=%s\n", zc.zc_string);
4776 if (zc.zc_guid != 0) {
4777 (void) printf(" zc_guid=%llu\n",
4778 (u_longlong_t)zc.zc_guid);
4780 if (zc.zc_nvlist_conf_size) {
4781 (void) printf(" nvlist_conf:\n");
4782 show_packed_nvlist(pri, zc.zc_nvlist_conf,
4783 zc.zc_nvlist_conf_size);
4785 if (zc.zc_nvlist_src_size) {
4786 (void) printf(" nvlist_src:\n");
4787 show_packed_nvlist(pri, zc.zc_nvlist_src,
4788 zc.zc_nvlist_src_size);
4790 if (zc.zc_nvlist_dst_size) {
4791 (void) printf(" nvlist_dst:\n");
4792 show_packed_nvlist(pri, zc.zc_nvlist_dst,
4793 zc.zc_nvlist_dst_size);
4795 if (zc.zc_cookie != 0) {
4796 (void) printf(" zc_cookie=%llu\n",
4797 (u_longlong_t)zc.zc_cookie);
4799 if (zc.zc_objset_type != 0) {
4800 (void) printf(" zc_objset_type=%llu\n",
4801 (u_longlong_t)zc.zc_objset_type);
4803 if (zc.zc_perm_action != 0) {
4804 (void) printf(" zc_perm_action=%llu\n",
4805 (u_longlong_t)zc.zc_perm_action);
4807 if (zc.zc_history != 0) {
4808 (void) printf(" zc_history=%llu\n",
4809 (u_longlong_t)zc.zc_history);
4811 if (zc.zc_obj != 0) {
4812 (void) printf(" zc_obj=%llu\n",
4813 (u_longlong_t)zc.zc_obj);
4815 if (zc.zc_iflags != 0) {
4816 (void) printf(" zc_obj=0x%llx\n",
4817 (u_longlong_t)zc.zc_iflags);
4820 if (memcmp(&zc.zc_share, &zero_share, sizeof (zc.zc_share))) {
4821 zfs_share_t *z = &zc.zc_share;
4822 (void) printf(" zc_share:\n");
4823 if (z->z_exportdata) {
4824 (void) printf("\tz_exportdata=0x%llx\n",
4825 (u_longlong_t)z->z_exportdata);
4827 if (z->z_sharedata) {
4828 (void) printf("\tz_sharedata=0x%llx\n",
4829 (u_longlong_t)z->z_sharedata);
4831 if (z->z_sharetype) {
4832 (void) printf("\tz_sharetype=%llu\n",
4833 (u_longlong_t)z->z_sharetype);
4835 if (z->z_sharemax) {
4836 (void) printf("\tz_sharemax=%llu\n",
4837 (u_longlong_t)z->z_sharemax);
4841 if (memcmp(&zc.zc_objset_stats, &zero_objstats,
4842 sizeof (zc.zc_objset_stats))) {
4843 dmu_objset_stats_t *dds = &zc.zc_objset_stats;
4844 (void) printf(" zc_objset_stats:\n");
4845 if (dds->dds_num_clones) {
4846 (void) printf("\tdds_num_clones=%llu\n",
4847 (u_longlong_t)dds->dds_num_clones);
4849 if (dds->dds_creation_txg) {
4850 (void) printf("\tdds_creation_txg=%llu\n",
4851 (u_longlong_t)dds->dds_creation_txg);
4853 if (dds->dds_guid) {
4854 (void) printf("\tdds_guid=%llu\n",
4855 (u_longlong_t)dds->dds_guid);
4857 if (dds->dds_type)
4858 (void) printf("\tdds_type=%u\n", dds->dds_type);
4859 if (dds->dds_is_snapshot) {
4860 (void) printf("\tdds_is_snapshot=%u\n",
4861 dds->dds_is_snapshot);
4863 if (dds->dds_inconsistent) {
4864 (void) printf("\tdds_inconsitent=%u\n",
4865 dds->dds_inconsistent);
4867 if (dds->dds_origin[0]) {
4868 (void) printf("\tdds_origin=%s\n", dds->dds_origin);
4872 if (memcmp(&zc.zc_begin_record, &zero_drrbegin,
4873 sizeof (zc.zc_begin_record))) {
4874 struct drr_begin *drr = &zc.zc_begin_record.drr_u.drr_begin;
4875 (void) printf(" zc_begin_record:\n");
4876 if (drr->drr_magic) {
4877 (void) printf("\tdrr_magic=%llu\n",
4878 (u_longlong_t)drr->drr_magic);
4880 if (drr->drr_versioninfo) {
4881 (void) printf("\tdrr_versioninfo=%llu\n",
4882 (u_longlong_t)drr->drr_versioninfo);
4884 if (drr->drr_creation_time) {
4885 (void) printf("\tdrr_creation_time=%llu\n",
4886 (u_longlong_t)drr->drr_creation_time);
4888 if (drr->drr_type)
4889 (void) printf("\tdrr_type=%u\n", drr->drr_type);
4890 if (drr->drr_flags)
4891 (void) printf("\tdrr_flags=0x%x\n", drr->drr_flags);
4892 if (drr->drr_toguid) {
4893 (void) printf("\tdrr_toguid=%llu\n",
4894 (u_longlong_t)drr->drr_toguid);
4896 if (drr->drr_fromguid) {
4897 (void) printf("\tdrr_fromguid=%llu\n",
4898 (u_longlong_t)drr->drr_fromguid);
4900 if (drr->drr_toname[0]) {
4901 (void) printf("\tdrr_toname=%s\n", drr->drr_toname);
4905 if (memcmp(&zc.zc_inject_record, &zero_injectrec,
4906 sizeof (zc.zc_inject_record))) {
4907 zinject_record_t *zi = &zc.zc_inject_record;
4908 (void) printf(" zc_inject_record:\n");
4909 if (zi->zi_objset) {
4910 (void) printf("\tzi_objset=%llu\n",
4911 (u_longlong_t)zi->zi_objset);
4913 if (zi->zi_object) {
4914 (void) printf("\tzi_object=%llu\n",
4915 (u_longlong_t)zi->zi_object);
4917 if (zi->zi_start) {
4918 (void) printf("\tzi_start=%llu\n",
4919 (u_longlong_t)zi->zi_start);
4921 if (zi->zi_end) {
4922 (void) printf("\tzi_end=%llu\n",
4923 (u_longlong_t)zi->zi_end);
4925 if (zi->zi_guid) {
4926 (void) printf("\tzi_guid=%llu\n",
4927 (u_longlong_t)zi->zi_guid);
4929 if (zi->zi_level) {
4930 (void) printf("\tzi_level=%lu\n",
4931 (ulong_t)zi->zi_level);
4933 if (zi->zi_error) {
4934 (void) printf("\tzi_error=%lu\n",
4935 (ulong_t)zi->zi_error);
4937 if (zi->zi_type) {
4938 (void) printf("\tzi_type=%llu\n",
4939 (u_longlong_t)zi->zi_type);
4941 if (zi->zi_freq) {
4942 (void) printf("\tzi_freq=%lu\n",
4943 (ulong_t)zi->zi_freq);
4945 if (zi->zi_failfast) {
4946 (void) printf("\tzi_failfast=%lu\n",
4947 (ulong_t)zi->zi_failfast);
4949 if (zi->zi_func[0])
4950 (void) printf("\tzi_func=%s\n", zi->zi_func);
4951 if (zi->zi_iotype) {
4952 (void) printf("\tzi_iotype=%lu\n",
4953 (ulong_t)zi->zi_iotype);
4955 if (zi->zi_duration) {
4956 (void) printf("\tzi_duration=%ld\n",
4957 (long)zi->zi_duration);
4959 if (zi->zi_timer) {
4960 (void) printf("\tzi_timer=%llu\n",
4961 (u_longlong_t)zi->zi_timer);
4965 if (zc.zc_defer_destroy) {
4966 (void) printf(" zc_defer_destroy=%d\n",
4967 (int)zc.zc_defer_destroy);
4969 if (zc.zc_flags) {
4970 (void) printf(" zc_flags=0x%x\n",
4971 zc.zc_flags);
4973 if (zc.zc_action_handle) {
4974 (void) printf(" zc_action_handle=%llu\n",
4975 (u_longlong_t)zc.zc_action_handle);
4977 if (zc.zc_cleanup_fd >= 0)
4978 (void) printf(" zc_cleanup_fd=%d\n", zc.zc_cleanup_fd);
4979 if (zc.zc_sendobj) {
4980 (void) printf(" zc_sendobj=%llu\n",
4981 (u_longlong_t)zc.zc_sendobj);
4983 if (zc.zc_fromobj) {
4984 (void) printf(" zc_fromobj=%llu\n",
4985 (u_longlong_t)zc.zc_fromobj);
4987 if (zc.zc_createtxg) {
4988 (void) printf(" zc_createtxg=%llu\n",
4989 (u_longlong_t)zc.zc_createtxg);
4992 if (memcmp(&zc.zc_stat, &zero_zstat, sizeof (zc.zc_stat))) {
4993 zfs_stat_t *zs = &zc.zc_stat;
4994 (void) printf(" zc_stat:\n");
4995 if (zs->zs_gen) {
4996 (void) printf("\tzs_gen=%llu\n",
4997 (u_longlong_t)zs->zs_gen);
4999 if (zs->zs_mode) {
5000 (void) printf("\tzs_mode=%llu\n",
5001 (u_longlong_t)zs->zs_mode);
5003 if (zs->zs_links) {
5004 (void) printf("\tzs_links=%llu\n",
5005 (u_longlong_t)zs->zs_links);
5007 if (zs->zs_ctime[0]) {
5008 (void) printf("\tzs_ctime[0]=%llu\n",
5009 (u_longlong_t)zs->zs_ctime[0]);
5011 if (zs->zs_ctime[1]) {
5012 (void) printf("\tzs_ctime[1]=%llu\n",
5013 (u_longlong_t)zs->zs_ctime[1]);
5018 /* expound verbosely upon syscall arguments */
5019 /*ARGSUSED*/
5020 void
5021 expound(private_t *pri, long r0, int raw)
5023 const lwpstatus_t *Lsp = pri->lwpstat;
5024 int lp64 = (data_model == PR_MODEL_LP64);
5025 int what = Lsp->pr_what;
5026 int err = pri->Errno; /* don't display output parameters */
5027 /* for a failed system call */
5028 #ifndef _LP64
5029 /* We are a 32-bit truss; we can't grok a 64-bit process */
5030 if (lp64)
5031 return;
5032 #endif
5033 /* for reporting sleeping system calls */
5034 if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
5035 what = Lsp->pr_syscall;
5037 switch (what) {
5038 case SYS_gettimeofday:
5039 if (!err)
5040 show_timeofday(pri);
5041 break;
5042 case SYS_getitimer:
5043 if (!err && pri->sys_nargs > 1)
5044 show_itimerval(pri, (long)pri->sys_args[1],
5045 " value");
5046 break;
5047 case SYS_setitimer:
5048 if (pri->sys_nargs > 1)
5049 show_itimerval(pri, (long)pri->sys_args[1],
5050 " value");
5051 if (!err && pri->sys_nargs > 2)
5052 show_itimerval(pri, (long)pri->sys_args[2],
5053 "ovalue");
5054 break;
5055 case SYS_stime:
5056 show_stime(pri);
5057 break;
5058 case SYS_times:
5059 if (!err)
5060 show_times(pri);
5061 break;
5062 case SYS_utssys:
5063 if (err)
5064 break;
5065 #ifdef _LP64
5066 if (lp64)
5067 show_utssys(pri, r0);
5068 else
5069 show_utssys32(pri, r0);
5070 #else
5071 show_utssys(pri, r0);
5072 #endif
5073 break;
5074 case SYS_ioctl:
5075 if (pri->sys_nargs >= 3) /* each case must decide for itself */
5076 show_ioctl(pri, pri->sys_args[1],
5077 (long)pri->sys_args[2]);
5078 break;
5079 case SYS_fstatat:
5080 if (!err && pri->sys_nargs >= 3)
5081 show_stat(pri, (long)pri->sys_args[2]);
5082 break;
5083 case SYS_fstatat64:
5084 if (!err && pri->sys_nargs >= 3)
5085 show_stat64_32(pri, (long)pri->sys_args[2]);
5086 break;
5087 case SYS_stat:
5088 case SYS_fstat:
5089 case SYS_lstat:
5090 if (!err && pri->sys_nargs >= 2)
5091 show_stat(pri, (long)pri->sys_args[1]);
5092 break;
5093 case SYS_stat64:
5094 case SYS_fstat64:
5095 case SYS_lstat64:
5096 if (!err && pri->sys_nargs >= 2)
5097 show_stat64_32(pri, (long)pri->sys_args[1]);
5098 break;
5099 case SYS_statvfs:
5100 case SYS_fstatvfs:
5101 if (err)
5102 break;
5103 #ifdef _LP64
5104 if (!lp64) {
5105 show_statvfs32(pri);
5106 break;
5108 #endif
5109 show_statvfs(pri);
5110 break;
5111 case SYS_statvfs64:
5112 case SYS_fstatvfs64:
5113 if (err)
5114 break;
5115 show_statvfs64(pri);
5116 break;
5117 case SYS_statfs:
5118 case SYS_fstatfs:
5119 if (err)
5120 break;
5121 #ifdef _LP64
5122 if (lp64)
5123 show_statfs(pri);
5124 else
5125 show_statfs32(pri);
5126 #else
5127 show_statfs(pri);
5128 #endif
5129 break;
5130 case SYS_fcntl:
5131 show_fcntl(pri);
5132 break;
5133 case SYS_msgsys:
5134 show_msgsys(pri, r0); /* each case must decide for itself */
5135 break;
5136 case SYS_semsys:
5137 show_semsys(pri); /* each case must decide for itself */
5138 break;
5139 case SYS_shmsys:
5140 show_shmsys(pri); /* each case must decide for itself */
5141 break;
5142 case SYS_getdents:
5143 if (err || pri->sys_nargs <= 1 || r0 <= 0)
5144 break;
5145 #ifdef _LP64
5146 if (!lp64) {
5147 show_dents32(pri, (long)pri->sys_args[1], r0);
5148 break;
5150 /* FALLTHROUGH */
5151 #else
5152 show_dents32(pri, (long)pri->sys_args[1], r0);
5153 break;
5154 #endif
5155 case SYS_getdents64:
5156 if (err || pri->sys_nargs <= 1 || r0 <= 0)
5157 break;
5158 show_dents64(pri, (long)pri->sys_args[1], r0);
5159 break;
5160 case SYS_getmsg:
5161 show_gp_msg(pri, what);
5162 if (pri->sys_nargs > 3)
5163 show_hhex_int(pri, (long)pri->sys_args[3], "flags");
5164 break;
5165 case SYS_getpmsg:
5166 show_gp_msg(pri, what);
5167 if (pri->sys_nargs > 3)
5168 show_hhex_int(pri, (long)pri->sys_args[3], "band");
5169 if (pri->sys_nargs > 4)
5170 show_hhex_int(pri, (long)pri->sys_args[4], "flags");
5171 break;
5172 case SYS_putmsg:
5173 case SYS_putpmsg:
5174 show_gp_msg(pri, what);
5175 break;
5176 case SYS_pollsys:
5177 show_pollsys(pri);
5178 break;
5179 case SYS_setgroups:
5180 if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
5181 show_groups(pri, (long)pri->sys_args[1], r0);
5182 break;
5183 case SYS_getgroups:
5184 if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
5185 show_groups(pri, (long)pri->sys_args[1], r0);
5186 break;
5187 case SYS_sigprocmask:
5188 if (pri->sys_nargs > 1)
5189 show_sigset(pri, (long)pri->sys_args[1], " set");
5190 if (!err && pri->sys_nargs > 2)
5191 show_sigset(pri, (long)pri->sys_args[2], "oset");
5192 break;
5193 case SYS_sigsuspend:
5194 case SYS_sigtimedwait:
5195 if (pri->sys_nargs > 0)
5196 show_sigset(pri, (long)pri->sys_args[0], "sigmask");
5197 if (!err && pri->sys_nargs > 1)
5198 show_siginfo(pri, (long)pri->sys_args[1]);
5199 if (pri->sys_nargs > 2)
5200 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5201 break;
5202 case SYS_sigaltstack:
5203 if (pri->sys_nargs > 0)
5204 show_sigaltstack(pri, (long)pri->sys_args[0],
5205 "new");
5206 if (!err && pri->sys_nargs > 1)
5207 show_sigaltstack(pri, (long)pri->sys_args[1],
5208 "old");
5209 break;
5210 case SYS_sigaction:
5211 if (pri->sys_nargs > 1)
5212 show_sigaction(pri, (long)pri->sys_args[1],
5213 "new", 0);
5214 if (!err && pri->sys_nargs > 2)
5215 show_sigaction(pri, (long)pri->sys_args[2],
5216 "old", r0);
5217 break;
5218 case SYS_signotify:
5219 if (pri->sys_nargs > 1)
5220 show_siginfo(pri, (long)pri->sys_args[1]);
5221 break;
5222 case SYS_sigresend:
5223 if (pri->sys_nargs > 1)
5224 show_siginfo(pri, (long)pri->sys_args[1]);
5225 if (pri->sys_nargs > 2)
5226 show_sigset(pri, (long)pri->sys_args[2], "sigmask");
5227 break;
5228 case SYS_sigpending:
5229 if (!err && pri->sys_nargs > 1)
5230 show_sigset(pri, (long)pri->sys_args[1], "sigmask");
5231 break;
5232 case SYS_waitid:
5233 if (!err && pri->sys_nargs > 2)
5234 show_siginfo(pri, (long)pri->sys_args[2]);
5235 break;
5236 case SYS_sigsendsys:
5237 if (pri->sys_nargs > 0)
5238 show_procset(pri, (long)pri->sys_args[0]);
5239 break;
5240 case SYS_priocntlsys:
5241 if (pri->sys_nargs > 1)
5242 show_procset(pri, (long)pri->sys_args[1]);
5243 break;
5244 case SYS_mincore:
5245 if (!err && pri->sys_nargs > 2)
5246 show_bool(pri, (long)pri->sys_args[2],
5247 (pri->sys_args[1] + pagesize - 1) / pagesize);
5248 break;
5249 case SYS_readv:
5250 case SYS_writev:
5251 if (pri->sys_nargs > 2) {
5252 int i = pri->sys_args[0]+1;
5253 int showbuf = FALSE;
5254 long nb = (what == SYS_readv)? r0 : 32*1024;
5256 if ((what == SYS_readv && !err &&
5257 prismember(&readfd, i)) ||
5258 (what == SYS_writev &&
5259 prismember(&writefd, i)))
5260 showbuf = TRUE;
5261 show_iovec(pri, (long)pri->sys_args[1],
5262 pri->sys_args[2], showbuf, nb);
5264 break;
5265 case SYS_getrlimit:
5266 if (err)
5267 break;
5268 /*FALLTHROUGH*/
5269 case SYS_setrlimit:
5270 if (pri->sys_nargs <= 1)
5271 break;
5272 #ifdef _LP64
5273 if (lp64)
5274 show_rlimit64(pri, (long)pri->sys_args[1]);
5275 else
5276 show_rlimit32(pri, (long)pri->sys_args[1]);
5277 #else
5278 show_rlimit32(pri, (long)pri->sys_args[1]);
5279 #endif
5280 break;
5281 case SYS_getrlimit64:
5282 if (err)
5283 break;
5284 /*FALLTHROUGH*/
5285 case SYS_setrlimit64:
5286 if (pri->sys_nargs <= 1)
5287 break;
5288 show_rlimit64(pri, (long)pri->sys_args[1]);
5289 break;
5290 case SYS_uname:
5291 if (!err && pri->sys_nargs > 0)
5292 show_uname(pri, (long)pri->sys_args[0]);
5293 break;
5294 case SYS_adjtime:
5295 if (!err && pri->sys_nargs > 1)
5296 show_adjtime(pri, (long)pri->sys_args[0],
5297 (long)pri->sys_args[1]);
5298 break;
5299 case SYS_lwp_info:
5300 if (!err && pri->sys_nargs > 0)
5301 show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
5302 break;
5303 case SYS_lwp_wait:
5304 if (!err && pri->sys_nargs > 1)
5305 show_int(pri, (long)pri->sys_args[1], "lwpid");
5306 break;
5307 case SYS_lwp_mutex_wakeup:
5308 case SYS_lwp_mutex_unlock:
5309 case SYS_lwp_mutex_trylock:
5310 case SYS_lwp_mutex_register:
5311 if (pri->sys_nargs > 0)
5312 show_mutex(pri, (long)pri->sys_args[0]);
5313 break;
5314 case SYS_lwp_mutex_timedlock:
5315 if (pri->sys_nargs > 0)
5316 show_mutex(pri, (long)pri->sys_args[0]);
5317 if (pri->sys_nargs > 1)
5318 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5319 break;
5320 case SYS_lwp_cond_wait:
5321 if (pri->sys_nargs > 0)
5322 show_condvar(pri, (long)pri->sys_args[0]);
5323 if (pri->sys_nargs > 1)
5324 show_mutex(pri, (long)pri->sys_args[1]);
5325 if (pri->sys_nargs > 2)
5326 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5327 break;
5328 case SYS_lwp_cond_signal:
5329 case SYS_lwp_cond_broadcast:
5330 if (pri->sys_nargs > 0)
5331 show_condvar(pri, (long)pri->sys_args[0]);
5332 break;
5333 case SYS_lwp_sema_trywait:
5334 case SYS_lwp_sema_post:
5335 if (pri->sys_nargs > 0)
5336 show_sema(pri, (long)pri->sys_args[0]);
5337 break;
5338 case SYS_lwp_sema_timedwait:
5339 if (pri->sys_nargs > 0)
5340 show_sema(pri, (long)pri->sys_args[0]);
5341 if (pri->sys_nargs > 1)
5342 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5343 break;
5344 case SYS_lwp_rwlock_sys:
5345 if (pri->sys_nargs > 1)
5346 show_rwlock(pri, (long)pri->sys_args[1]);
5347 if (pri->sys_nargs > 2 &&
5348 (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
5349 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5350 break;
5351 case SYS_lwp_create:
5352 /* XXX print some values in ucontext ??? */
5353 if (!err && pri->sys_nargs > 2)
5354 show_int(pri, (long)pri->sys_args[2], "lwpid");
5355 break;
5356 case SYS_kaio:
5357 if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
5358 show_timeval(pri, (long)pri->sys_args[1], "timeout");
5359 break;
5360 case SYS_nanosleep:
5361 if (pri->sys_nargs > 0)
5362 show_timestruc(pri, (long)pri->sys_args[0], "tmout");
5363 if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
5364 show_timestruc(pri, (long)pri->sys_args[1], "resid");
5365 break;
5366 case SYS_privsys:
5367 switch (pri->sys_args[0]) {
5368 case PRIVSYS_SETPPRIV:
5369 case PRIVSYS_GETPPRIV:
5370 if (!err)
5371 show_privset(pri, (long)pri->sys_args[3],
5372 (size_t)pri->sys_args[4], "");
5374 break;
5375 case SYS_ucredsys:
5376 switch (pri->sys_args[0]) {
5377 case UCREDSYS_UCREDGET:
5378 case UCREDSYS_GETPEERUCRED:
5379 if (err == 0)
5380 show_ucred(pri, (long)pri->sys_args[2]);
5381 break;
5383 break;
5384 case SYS_bind:
5385 case SYS_connect:
5386 if (pri->sys_nargs > 2)
5387 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5388 0, (long)pri->sys_args[2]);
5389 break;
5390 case SYS_sendto:
5391 if (pri->sys_nargs > 5)
5392 show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
5393 pri->sys_args[5]);
5394 break;
5395 case SYS_accept:
5396 if (!err && pri->sys_nargs > 2)
5397 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5398 (long)pri->sys_args[2], 0);
5399 break;
5400 case SYS_getsockname:
5401 case SYS_getpeername:
5402 if (!err && pri->sys_nargs > 2)
5403 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5404 (long)pri->sys_args[2], 0);
5405 break;
5406 case SYS_recvfrom:
5407 if (!err && pri->sys_nargs > 5)
5408 show_sockaddr(pri, "from", (long)pri->sys_args[4],
5409 (long)pri->sys_args[5], 0);
5410 break;
5411 case SYS_recvmsg:
5412 if (err)
5413 break;
5414 /* FALLTHROUGH */
5415 case SYS_sendmsg:
5416 if (pri->sys_nargs <= 2)
5417 break;
5418 #ifdef _LP64
5419 if (lp64)
5420 show_msghdr(pri, pri->sys_args[1]);
5421 else
5422 show_msghdr32(pri, pri->sys_args[1]);
5423 #else
5424 show_msghdr(pri, pri->sys_args[1]);
5425 #endif
5426 break;
5427 case SYS_door:
5428 show_doors(pri);
5429 break;
5430 case SYS_sendfilev:
5431 if (pri->sys_nargs != 5)
5432 break;
5434 if (pri->sys_args[0] == SENDFILEV) {
5435 show_sendfilevec(pri, (int)pri->sys_args[1],
5436 (sendfilevec_t *)pri->sys_args[2],
5437 (int)pri->sys_args[3]);
5438 } else if (pri->sys_args[0] == SENDFILEV64) {
5439 show_sendfilevec64(pri, (int)pri->sys_args[1],
5440 (sendfilevec64_t *)pri->sys_args[2],
5441 (int)pri->sys_args[3]);
5443 break;
5444 case SYS_memcntl:
5445 show_memcntl(pri);
5446 break;
5447 case SYS_lwp_park:
5449 * subcode 0: lwp_park(timespec_t *, id_t)
5450 * subcode 4: lwp_set_park(timespec_t *, id_t)
5452 if (pri->sys_nargs > 1 &&
5453 (pri->sys_args[0] == 0 || pri->sys_args[0] == 4))
5454 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5455 /* subcode 2: lwp_unpark_all(id_t *, int) */
5456 if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
5457 show_ids(pri, (long)pri->sys_args[1],
5458 (int)pri->sys_args[2]);
5459 break;
5460 case SYS_ntp_gettime:
5461 if (!err)
5462 show_ntp_gettime(pri);
5463 break;
5464 case SYS_ntp_adjtime:
5465 if (!err)
5466 show_ntp_adjtime(pri);
5467 break;
5468 case SYS_rusagesys:
5469 if (!err)
5470 if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
5471 #ifdef _LP64
5472 if (!lp64)
5473 show_getrusage32(pri->sys_args[1]);
5474 else
5475 #endif
5476 show_getrusage(pri->sys_args[1]);
5478 break;
5479 case SYS_port:
5480 show_ports(pri);
5481 break;
5482 case SYS_zone:
5483 show_zones(pri);
5484 break;
5485 case SYS_rctlsys:
5486 show_rctls(pri);
5487 break;
5488 case SYS_utimesys:
5489 show_utimesys(pri);
5490 break;
5491 case SYS_sockconfig:
5492 show_sockconfig(pri);
5493 break;