Move /var/svc/log to /var/log/svc
[unleashed/lotheac.git] / usr / src / cmd / truss / expound.c
blobf12fcb4c243e07521029ebd1bea77aa474259823
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_vrow&0xff,
702 termcb.st_lrow&0xff);
706 /* integer value pointed to by ioctl() arg */
707 void
708 show_strint(private_t *pri, int code, long offset)
710 int val;
712 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
713 const char *s = NULL;
715 switch (code) { /* interpret these symbolically */
716 case I_GRDOPT:
717 s = strrdopt(val);
718 break;
719 case I_GETSIG:
720 s = strevents(pri, val);
721 break;
722 case TIOCFLUSH:
723 s = tiocflush(pri, val);
724 break;
727 if (s == NULL)
728 (void) printf("%s\t0x%.8lX: %d\n",
729 pri->pname, offset, val);
730 else
731 (void) printf("%s\t0x%.8lX: %s\n",
732 pri->pname, offset, s);
736 void
737 show_strioctl(private_t *pri, long offset)
739 struct strioctl strioctl;
741 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
742 sizeof (strioctl)) {
743 (void) printf(
744 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
745 pri->pname,
746 ioctlname(pri, strioctl.ic_cmd),
747 strioctl.ic_timout,
748 strioctl.ic_len,
749 (long)strioctl.ic_dp);
751 if (pri->recur++ == 0) /* avoid indefinite recursion */
752 show_ioctl(pri, strioctl.ic_cmd,
753 (long)strioctl.ic_dp);
754 --pri->recur;
758 #ifdef _LP64
759 void
760 show_strioctl32(private_t *pri, long offset)
762 struct strioctl32 strioctl;
764 if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
765 sizeof (strioctl)) {
766 (void) printf(
767 "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
768 pri->pname,
769 ioctlname(pri, strioctl.ic_cmd),
770 strioctl.ic_timout,
771 strioctl.ic_len,
772 (long)strioctl.ic_dp);
774 if (pri->recur++ == 0) /* avoid indefinite recursion */
775 show_ioctl(pri, strioctl.ic_cmd,
776 (long)strioctl.ic_dp);
777 --pri->recur;
780 #endif /* _LP64 */
782 void
783 print_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
785 (void) printf(
786 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
787 pri->pname,
788 name,
789 sp->maxlen,
790 sp->len,
791 (long)sp->buf);
793 * Should we show the buffer contents?
794 * Keyed to the '-r fds' and '-w fds' options?
796 if (sp->buf == NULL || sp->len <= 0)
797 (void) fputc('\n', stdout);
798 else {
799 int nb = (sp->len > 8)? 8 : sp->len;
800 char buffer[8];
801 char obuf[40];
803 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
804 (void) strcpy(obuf, ": \"");
805 showbytes(buffer, nb, obuf+3);
806 (void) strcat(obuf,
807 (nb == sp->len)?
808 (const char *)"\"" : (const char *)"\"..");
809 (void) fputs(obuf, stdout);
811 (void) fputc('\n', stdout);
812 if (dump && sp->len > 8)
813 showbuffer(pri, (long)sp->buf, (long)sp->len);
817 #ifdef _LP64
818 void
819 print_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
821 (void) printf(
822 "%s\t%s: maxlen=%-4d len=%-4d buf=0x%.8lX",
823 pri->pname,
824 name,
825 sp->maxlen,
826 sp->len,
827 (long)sp->buf);
829 * Should we show the buffer contents?
830 * Keyed to the '-r fds' and '-w fds' options?
832 if (sp->buf == (uintptr_t)NULL || sp->len <= 0)
833 (void) fputc('\n', stdout);
834 else {
835 int nb = (sp->len > 8)? 8 : sp->len;
836 char buffer[8];
837 char obuf[40];
839 if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
840 (void) strcpy(obuf, ": \"");
841 showbytes(buffer, nb, obuf+3);
842 (void) strcat(obuf,
843 (nb == sp->len)?
844 (const char *)"\"" : (const char *)"\"..");
845 (void) fputs(obuf, stdout);
847 (void) fputc('\n', stdout);
848 if (dump && sp->len > 8)
849 showbuffer(pri, (long)sp->buf, (long)sp->len);
852 #endif /* _LP64 */
854 /* strpeek and strfdinsert flags word */
855 const char *
856 strflags(private_t *pri, int flags)
858 const char *s;
860 switch (flags) {
861 case 0:
862 s = "0";
863 break;
864 case RS_HIPRI:
865 s = "RS_HIPRI";
866 break;
867 default:
868 (void) sprintf(pri->code_buf, "0x%.4X", flags);
869 s = pri->code_buf;
872 return (s);
875 void
876 show_strpeek(private_t *pri, long offset)
878 struct strpeek strpeek;
880 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
881 == sizeof (strpeek)) {
883 print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
884 print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
886 (void) printf("%s\tflags=%s\n",
887 pri->pname,
888 strflags(pri, strpeek.flags));
892 #ifdef _LP64
893 void
894 show_strpeek32(private_t *pri, long offset)
896 struct strpeek32 strpeek;
898 if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
899 == sizeof (strpeek)) {
901 print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
902 print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
904 (void) printf("%s\tflags=%s\n",
905 pri->pname,
906 strflags(pri, strpeek.flags));
909 #endif /* _LP64 */
911 void
912 show_strfdinsert(private_t *pri, long offset)
914 struct strfdinsert strfdinsert;
916 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
917 sizeof (strfdinsert)) {
919 print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
920 print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
922 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
923 pri->pname,
924 strflags(pri, strfdinsert.flags),
925 strfdinsert.fildes,
926 strfdinsert.offset);
930 #ifdef _LP64
931 void
932 show_strfdinsert32(private_t *pri, long offset)
934 struct strfdinsert32 strfdinsert;
936 if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
937 sizeof (strfdinsert)) {
939 print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
940 print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
942 (void) printf("%s\tflags=%s fildes=%d offset=%d\n",
943 pri->pname,
944 strflags(pri, strfdinsert.flags),
945 strfdinsert.fildes,
946 strfdinsert.offset);
949 #endif /* _LP64 */
951 void
952 show_strrecvfd(private_t *pri, long offset)
954 struct strrecvfd strrecvfd;
956 if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
957 sizeof (strrecvfd)) {
958 (void) printf(
959 "%s\tfd=%-5d uid=%-5u gid=%u\n",
960 pri->pname,
961 strrecvfd.fd,
962 strrecvfd.uid,
963 strrecvfd.gid);
967 void
968 show_strlist(private_t *pri, long offset)
970 struct str_list strlist;
971 struct str_mlist list;
972 int count;
974 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
975 sizeof (strlist)) {
976 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
977 pri->pname,
978 strlist.sl_nmods,
979 (long)strlist.sl_modlist);
981 count = strlist.sl_nmods;
982 offset = (long)strlist.sl_modlist;
983 while (!interrupt && --count >= 0) {
984 if (Pread(Proc, &list, sizeof (list), offset) !=
985 sizeof (list))
986 break;
987 (void) printf("%s\t\t\"%.*s\"\n",
988 pri->pname,
989 (int)sizeof (list.l_name),
990 list.l_name);
991 offset += sizeof (struct str_mlist);
996 #ifdef _LP64
997 void
998 show_strlist32(private_t *pri, long offset)
1000 struct str_list32 strlist;
1001 struct str_mlist list;
1002 int count;
1004 if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
1005 sizeof (strlist)) {
1006 (void) printf("%s\tnmods=%d modlist=0x%.8lX\n",
1007 pri->pname,
1008 strlist.sl_nmods,
1009 (long)strlist.sl_modlist);
1011 count = strlist.sl_nmods;
1012 offset = (long)strlist.sl_modlist;
1013 while (!interrupt && --count >= 0) {
1014 if (Pread(Proc, &list, sizeof (list), offset) !=
1015 sizeof (list))
1016 break;
1017 (void) printf("%s\t\t\"%.*s\"\n",
1018 pri->pname,
1019 (int)sizeof (list.l_name),
1020 list.l_name);
1021 offset += sizeof (struct str_mlist);
1025 #endif /* _LP64 */
1027 void
1028 show_jwinsize(private_t *pri, long offset)
1030 struct jwinsize jwinsize;
1032 if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
1033 sizeof (jwinsize)) {
1034 (void) printf(
1035 "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1036 pri->pname,
1037 (unsigned)jwinsize.bytesx,
1038 (unsigned)jwinsize.bytesy,
1039 (unsigned)jwinsize.bitsx,
1040 (unsigned)jwinsize.bitsy);
1044 void
1045 show_winsize(private_t *pri, long offset)
1047 struct winsize winsize;
1049 if (Pread(Proc, &winsize, sizeof (winsize), offset)
1050 == sizeof (winsize)) {
1051 (void) printf(
1052 "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1053 pri->pname,
1054 winsize.ws_row,
1055 winsize.ws_col,
1056 winsize.ws_xpixel,
1057 winsize.ws_ypixel);
1061 struct audio_stuff {
1062 uint_t bit;
1063 const char *str;
1066 const struct audio_stuff audio_output_ports[] = {
1067 { AUDIO_SPEAKER, "SPEAKER" },
1068 { AUDIO_HEADPHONE, "HEADPHONE" },
1069 { AUDIO_LINE_OUT, "LINE_OUT" },
1070 { AUDIO_SPDIF_OUT, "SPDIF_OUT" },
1071 { AUDIO_AUX1_OUT, "AUX1_OUT" },
1072 { AUDIO_AUX2_OUT, "AUX2_OUT" },
1073 { 0, NULL }
1076 const struct audio_stuff audio_input_ports[] = {
1077 { AUDIO_MICROPHONE, "MICROPHONE" },
1078 { AUDIO_LINE_IN, "LINE_IN" },
1079 { AUDIO_CD, "CD" },
1080 { AUDIO_SPDIF_IN, "SPDIF_IN" },
1081 { AUDIO_AUX1_IN, "AUX1_IN" },
1082 { AUDIO_AUX2_IN, "AUX2_IN" },
1083 { AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
1084 { AUDIO_SUNVTS, "SUNVTS" },
1085 { 0, NULL }
1088 static const struct audio_stuff audio_hw_features[] = {
1089 { AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
1090 { AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
1091 { AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
1092 { AUDIO_HWFEATURE_PLAY, "PLAY" },
1093 { AUDIO_HWFEATURE_RECORD, "RECORD" },
1094 { 0, NULL }
1097 static const struct audio_stuff audio_sw_features[] = {
1098 { AUDIO_SWFEATURE_MIXER, "MIXER" },
1099 { 0, NULL }
1102 void
1103 show_audio_features(const private_t *pri,
1104 const struct audio_stuff *audio_porttab, uint_t features,
1105 const char *name)
1107 (void) printf("%s\t%s=", pri->pname, name);
1108 if (features == 0) {
1109 (void) printf("0\n");
1110 return;
1113 for (; audio_porttab->bit != 0; ++audio_porttab) {
1114 if (features & audio_porttab->bit) {
1115 (void) printf(audio_porttab->str);
1116 features &= ~audio_porttab->bit;
1117 if (features)
1118 (void) putchar('|');
1121 if (features)
1122 (void) printf("0x%x", features);
1123 (void) putchar('\n');
1126 void
1127 show_audio_ports(private_t *pri, const char *mode,
1128 const char *field, uint_t ports)
1130 const struct audio_stuff *audio_porttab;
1132 (void) printf("%s\t%s\t%s=", pri->pname, mode, field);
1133 if (ports == 0) {
1134 (void) printf("0\n");
1135 return;
1137 if (*mode == 'p')
1138 audio_porttab = audio_output_ports;
1139 else
1140 audio_porttab = audio_input_ports;
1141 for (; audio_porttab->bit != 0; ++audio_porttab) {
1142 if (ports & audio_porttab->bit) {
1143 (void) printf(audio_porttab->str);
1144 ports &= ~audio_porttab->bit;
1145 if (ports)
1146 (void) putchar('|');
1149 if (ports)
1150 (void) printf("0x%x", ports);
1151 (void) putchar('\n');
1154 void
1155 show_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
1157 const char *s;
1160 * The following values describe the audio data encoding.
1163 (void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1164 pri->pname, mode,
1165 au_pr->sample_rate,
1166 au_pr->channels,
1167 au_pr->precision);
1169 s = NULL;
1170 switch (au_pr->encoding) {
1171 case AUDIO_ENCODING_NONE: s = "NONE"; break;
1172 case AUDIO_ENCODING_ULAW: s = "ULAW"; break;
1173 case AUDIO_ENCODING_ALAW: s = "ALAW"; break;
1174 case AUDIO_ENCODING_LINEAR: s = "LINEAR"; break;
1175 case AUDIO_ENCODING_DVI: s = "DVI"; break;
1176 case AUDIO_ENCODING_LINEAR8: s = "LINEAR8"; break;
1178 if (s)
1179 (void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
1180 else {
1181 (void) printf("%s\t%s\tencoding=%u\n",
1182 pri->pname, mode, au_pr->encoding);
1186 * The following values control audio device configuration
1189 (void) printf(
1190 "%s\t%s\tgain=%u buffer_size=%u\n",
1191 pri->pname, mode,
1192 au_pr->gain,
1193 au_pr->buffer_size);
1194 show_audio_ports(pri, mode, "port", au_pr->port);
1195 show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
1196 show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
1199 * The following values describe driver state
1202 (void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1203 pri->pname, mode,
1204 au_pr->samples,
1205 au_pr->eof,
1206 au_pr->pause,
1207 au_pr->error);
1208 (void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1209 pri->pname, mode,
1210 au_pr->waiting,
1211 au_pr->balance,
1212 au_pr->minordev);
1215 * The following values are read-only state flags
1217 (void) printf("%s\t%s\topen=%u active=%u\n",
1218 pri->pname, mode,
1219 au_pr->open,
1220 au_pr->active);
1223 void
1224 show_audio_info(private_t *pri, long offset)
1226 struct audio_info au;
1228 if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
1229 show_audio_prinfo(pri, "play", &au.play);
1230 show_audio_prinfo(pri, "record", &au.record);
1231 (void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1232 pri->pname, au.monitor_gain, au.output_muted);
1233 show_audio_features(pri, audio_hw_features, au.hw_features,
1234 "hw_features");
1235 show_audio_features(pri, audio_sw_features, au.sw_features,
1236 "sw_features");
1237 show_audio_features(pri, audio_sw_features,
1238 au.sw_features_enabled, "sw_features_enabled");
1242 void
1243 show_ioctl(private_t *pri, int code, long offset)
1245 int lp64 = (data_model == PR_MODEL_LP64);
1246 int err = pri->Errno; /* don't display output parameters */
1247 /* for a failed system call */
1248 #ifndef _LP64
1249 if (lp64)
1250 return;
1251 #endif
1252 if (offset == 0)
1253 return;
1255 switch (code) {
1256 case TCGETA:
1257 if (err)
1258 break;
1259 /*FALLTHROUGH*/
1260 case TCSETA:
1261 case TCSETAW:
1262 case TCSETAF:
1263 show_termio(pri, offset);
1264 break;
1265 case TCGETS:
1266 if (err)
1267 break;
1268 /*FALLTHROUGH*/
1269 case TCSETS:
1270 case TCSETSW:
1271 case TCSETSF:
1272 show_termios(pri, offset);
1273 break;
1274 case TCGETX:
1275 if (err)
1276 break;
1277 /*FALLTHROUGH*/
1278 case TCSETX:
1279 case TCSETXW:
1280 case TCSETXF:
1281 show_termiox(pri, offset);
1282 break;
1283 case TIOCGETP:
1284 if (err)
1285 break;
1286 /*FALLTHROUGH*/
1287 case TIOCSETN:
1288 case TIOCSETP:
1289 show_sgttyb(pri, offset);
1290 break;
1291 case TIOCGLTC:
1292 if (err)
1293 break;
1294 /*FALLTHROUGH*/
1295 case TIOCSLTC:
1296 show_ltchars(pri, offset);
1297 break;
1298 case TIOCGETC:
1299 if (err)
1300 break;
1301 /*FALLTHROUGH*/
1302 case TIOCSETC:
1303 show_tchars(pri, offset);
1304 break;
1305 case LDGETT:
1306 if (err)
1307 break;
1308 /*FALLTHROUGH*/
1309 case LDSETT:
1310 show_termcb(pri, offset);
1311 break;
1312 /* streams ioctl()s */
1313 #if 0
1314 /* these are displayed as strings in the arg list */
1315 /* by prt_ioa(). don't display them again here */
1316 case I_PUSH:
1317 case I_LOOK:
1318 case I_FIND:
1319 /* these are displayed as decimal in the arg list */
1320 /* by prt_ioa(). don't display them again here */
1321 case I_LINK:
1322 case I_UNLINK:
1323 case I_SENDFD:
1324 /* these are displayed symbolically in the arg list */
1325 /* by prt_ioa(). don't display them again here */
1326 case I_SRDOPT:
1327 case I_SETSIG:
1328 case I_FLUSH:
1329 break;
1330 /* this one just ignores the argument */
1331 case I_POP:
1332 break;
1333 #endif
1334 /* these return something in an int pointed to by arg */
1335 case I_NREAD:
1336 case I_GRDOPT:
1337 case I_GETSIG:
1338 case TIOCGSID:
1339 case TIOCGPGRP:
1340 case TIOCLGET:
1341 case FIONREAD:
1342 case FIORDCHK:
1343 if (err)
1344 break;
1345 /*FALLTHROUGH*/
1346 /* these pass something in an int pointed to by arg */
1347 case TIOCSPGRP:
1348 case TIOCFLUSH:
1349 case TIOCLBIS:
1350 case TIOCLBIC:
1351 case TIOCLSET:
1352 show_strint(pri, code, offset);
1353 break;
1354 /* these all point to structures */
1355 case I_STR:
1356 #ifdef _LP64
1357 if (lp64)
1358 show_strioctl(pri, offset);
1359 else
1360 show_strioctl32(pri, offset);
1361 #else
1362 show_strioctl(pri, offset);
1363 #endif
1364 break;
1365 case I_PEEK:
1366 #ifdef _LP64
1367 if (lp64)
1368 show_strpeek(pri, offset);
1369 else
1370 show_strpeek32(pri, offset);
1371 #else
1372 show_strpeek(pri, offset);
1373 #endif
1374 break;
1375 case I_FDINSERT:
1376 #ifdef _LP64
1377 if (lp64)
1378 show_strfdinsert(pri, offset);
1379 else
1380 show_strfdinsert32(pri, offset);
1381 #else
1382 show_strfdinsert(pri, offset);
1383 #endif
1384 break;
1385 case I_RECVFD:
1386 if (err)
1387 break;
1388 show_strrecvfd(pri, offset);
1389 break;
1390 case I_LIST:
1391 if (err)
1392 break;
1393 #ifdef _LP64
1394 if (lp64)
1395 show_strlist(pri, offset);
1396 else
1397 show_strlist32(pri, offset);
1398 #else
1399 show_strlist(pri, offset);
1400 #endif
1401 break;
1402 case JWINSIZE:
1403 if (err)
1404 break;
1405 show_jwinsize(pri, offset);
1406 break;
1407 case TIOCGWINSZ:
1408 if (err)
1409 break;
1410 /*FALLTHROUGH*/
1411 case TIOCSWINSZ:
1412 show_winsize(pri, offset);
1413 break;
1414 case AUDIO_GETINFO:
1415 case (int)AUDIO_SETINFO:
1416 show_audio_info(pri, offset);
1417 break;
1419 default:
1420 if ((code & ~0xff) == ZFS_IOC) {
1421 show_zfs_ioc(pri, offset);
1422 break;
1425 if (code & IOC_INOUT) {
1426 const char *str = ioctldatastruct(code);
1428 (void) printf("\t\t%s",
1429 (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1430 code & IOC_IN ? "write" : "read");
1431 if (str != NULL) {
1432 (void) printf(" (struct %s)\n", str);
1433 } else {
1434 (void) printf(" %d bytes\n",
1435 (code >> 16) & IOCPARM_MASK);
1441 void
1442 show_statvfs(private_t *pri)
1444 long offset;
1445 struct statvfs statvfs;
1446 char *cp;
1448 if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
1449 Pread(Proc, &statvfs, sizeof (statvfs), offset)
1450 == sizeof (statvfs)) {
1451 (void) printf(
1452 "%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1453 pri->pname,
1454 statvfs.f_bsize,
1455 statvfs.f_frsize,
1456 (u_longlong_t)statvfs.f_blocks,
1457 (u_longlong_t)statvfs.f_bfree);
1458 (void) printf(
1459 "%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1460 pri->pname,
1461 (u_longlong_t)statvfs.f_bavail,
1462 (u_longlong_t)statvfs.f_files,
1463 (u_longlong_t)statvfs.f_ffree,
1464 (u_longlong_t)statvfs.f_favail);
1465 (void) printf(
1466 "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1467 pri->pname,
1468 statvfs.f_fsid,
1469 statvfs.f_basetype,
1470 (long)statvfs.f_namemax);
1471 (void) printf(
1472 "%s\tflag=%s\n",
1473 pri->pname,
1474 svfsflags(pri, (ulong_t)statvfs.f_flag));
1475 cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
1476 if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
1477 *(cp+1) != '\0')
1478 *cp = ' ';
1479 (void) printf("%s\tfstr=\"%.*s\"\n",
1480 pri->pname,
1481 (int)sizeof (statvfs.f_fstr),
1482 statvfs.f_fstr);
1486 void
1487 show_statfs(private_t *pri)
1489 long offset;
1490 struct statfs statfs;
1492 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
1493 Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
1494 (void) printf(
1495 "%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1496 pri->pname,
1497 statfs.f_fstyp,
1498 statfs.f_bsize,
1499 statfs.f_frsize,
1500 statfs.f_blocks,
1501 statfs.f_bfree,
1502 statfs.f_files,
1503 statfs.f_ffree);
1504 (void) printf("%s\t fname=%.6s fpack=%.6s\n",
1505 pri->pname,
1506 statfs.f_fname,
1507 statfs.f_fpack);
1511 void
1512 show_flock32(private_t *pri, long offset)
1514 struct flock32 flock;
1516 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1517 const char *str = NULL;
1519 (void) printf("%s\ttyp=", pri->pname);
1521 switch (flock.l_type) {
1522 case F_RDLCK:
1523 str = "F_RDLCK";
1524 break;
1525 case F_WRLCK:
1526 str = "F_WRLCK";
1527 break;
1528 case F_UNLCK:
1529 str = "F_UNLCK";
1530 break;
1532 if (str != NULL)
1533 (void) printf("%s", str);
1534 else
1535 (void) printf("%-7d", flock.l_type);
1537 str = whencearg(flock.l_whence);
1538 if (str != NULL)
1539 (void) printf(" whence=%s", str);
1540 else
1541 (void) printf(" whence=%-8u", flock.l_whence);
1543 (void) printf(
1544 " start=%-5d len=%-5d sys=%-2u pid=%d\n",
1545 flock.l_start,
1546 flock.l_len,
1547 flock.l_sysid,
1548 flock.l_pid);
1552 void
1553 show_flock64(private_t *pri, long offset)
1555 struct flock64 flock;
1557 if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
1558 const char *str = NULL;
1560 (void) printf("%s\ttyp=", pri->pname);
1562 switch (flock.l_type) {
1563 case F_RDLCK:
1564 str = "F_RDLCK";
1565 break;
1566 case F_WRLCK:
1567 str = "F_WRLCK";
1568 break;
1569 case F_UNLCK:
1570 str = "F_UNLCK";
1571 break;
1573 if (str != NULL)
1574 (void) printf("%s", str);
1575 else
1576 (void) printf("%-7d", flock.l_type);
1578 str = whencearg(flock.l_whence);
1579 if (str != NULL)
1580 (void) printf(" whence=%s", str);
1581 else
1582 (void) printf(" whence=%-8u", flock.l_whence);
1584 (void) printf(
1585 " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1586 (long long)flock.l_start,
1587 (long long)flock.l_len,
1588 flock.l_sysid,
1589 (int)flock.l_pid);
1593 void
1594 show_share(private_t *pri, long offset)
1596 struct fshare fshare;
1598 if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
1599 const char *str = NULL;
1600 int manddny = 0;
1602 (void) printf("%s\taccess=", pri->pname);
1604 switch (fshare.f_access) {
1605 case F_RDACC:
1606 str = "F_RDACC";
1607 break;
1608 case F_WRACC:
1609 str = "F_WRACC";
1610 break;
1611 case F_RWACC:
1612 str = "F_RWACC";
1613 break;
1615 if (str != NULL)
1616 (void) printf("%s", str);
1617 else
1618 (void) printf("%-7d", fshare.f_access);
1620 str = NULL;
1621 if (fshare.f_deny & F_MANDDNY) {
1622 fshare.f_deny &= ~F_MANDDNY;
1623 manddny = 1;
1625 switch (fshare.f_deny) {
1626 case F_NODNY:
1627 str = "F_NODNY";
1628 break;
1629 case F_RDDNY:
1630 str = "F_RDDNY";
1631 break;
1632 case F_WRDNY:
1633 str = "F_WRDNY";
1634 break;
1635 case F_RWDNY:
1636 str = "F_RWDNY";
1637 break;
1638 case F_COMPAT:
1639 str = "F_COMPAT";
1640 break;
1642 if (str != NULL) {
1643 if (manddny)
1644 (void) printf(" deny=F_MANDDNY|%s", str);
1645 else
1646 (void) printf(" deny=%s", str);
1647 } else {
1648 (void) printf(" deny=0x%x", manddny?
1649 fshare.f_deny | F_MANDDNY : fshare.f_deny);
1652 (void) printf(" id=%x\n", fshare.f_id);
1656 void
1657 show_ffg(private_t *pri)
1659 (void) putchar('\t');
1660 (void) putchar('\t');
1661 prt_ffg(pri, 0, pri->Rval1);
1662 (void) puts(pri->sys_string);
1665 /* print values in fcntl() pointed-to structure */
1666 void
1667 show_fcntl(private_t *pri)
1669 long offset;
1671 if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
1672 show_ffg(pri);
1673 return;
1676 if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == 0)
1677 return;
1679 switch (pri->sys_args[1]) {
1680 #ifdef _LP64
1681 case F_GETLK:
1682 case F_SETLK:
1683 case F_SETLKW:
1684 case F_FREESP:
1685 case F_ALLOCSP:
1686 case F_SETLK_NBMAND:
1687 case F_OFD_GETLK:
1688 case F_OFD_SETLK:
1689 case F_OFD_SETLKW:
1690 case F_FLOCK:
1691 case F_FLOCKW:
1692 if (data_model == PR_MODEL_LP64)
1693 show_flock64(pri, offset);
1694 else
1695 show_flock32(pri, offset);
1696 break;
1697 case 33: /* F_GETLK64 */
1698 case 34: /* F_SETLK64 */
1699 case 35: /* F_SETLKW64 */
1700 case 27: /* F_FREESP64 */
1701 case 28: /* F_ALLOCSP64 */
1702 case 44: /* F_SETLK64_NBMAND */
1703 case 50: /* F_OFD_GETLK64 */
1704 case 51: /* F_OFD_SETLK64 */
1705 case 52: /* F_OFD_SETLKW64 */
1706 case 55: /* F_FLOCK64 */
1707 case 56: /* F_FLOCKW64 */
1708 show_flock64(pri, offset);
1709 break;
1710 #else /* _LP64 */
1711 case F_GETLK64:
1712 case F_SETLK64:
1713 case F_SETLKW64:
1714 case F_FREESP64:
1715 case F_ALLOCSP64:
1716 case F_SETLK64_NBMAND:
1717 case F_OFD_GETLK64:
1718 case F_OFD_SETLK64:
1719 case F_OFD_SETLKW64:
1720 case F_FLOCK64:
1721 case F_FLOCKW64:
1722 show_flock64(pri, offset);
1723 break;
1724 #endif /* _LP64 */
1725 case F_SHARE:
1726 case F_UNSHARE:
1727 show_share(pri, offset);
1728 break;
1732 void
1733 show_strbuf(private_t *pri, long offset, const char *name, int dump)
1735 struct strbuf strbuf;
1737 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1738 print_strbuf(pri, &strbuf, name, dump);
1741 #ifdef _LP64
1742 void
1743 show_strbuf32(private_t *pri, long offset, const char *name, int dump)
1745 struct strbuf32 strbuf;
1747 if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
1748 print_strbuf32(pri, &strbuf, name, dump);
1750 #endif /* _LP64 */
1752 void
1753 show_gp_msg(private_t *pri, int what)
1755 long offset;
1756 int dump = FALSE;
1757 int fdp1 = pri->sys_args[0] + 1;
1759 switch (what) {
1760 case SYS_getmsg:
1761 case SYS_getpmsg:
1762 if (pri->Errno == 0 && prismember(&readfd, fdp1))
1763 dump = TRUE;
1764 break;
1765 case SYS_putmsg:
1766 case SYS_putpmsg:
1767 if (prismember(&writefd, fdp1))
1768 dump = TRUE;
1769 break;
1772 /* enter region of lengthy output */
1773 if (dump)
1774 Eserialize();
1776 #ifdef _LP64
1777 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0) {
1778 if (data_model == PR_MODEL_LP64)
1779 show_strbuf(pri, offset, "ctl", dump);
1780 else
1781 show_strbuf32(pri, offset, "ctl", dump);
1783 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0) {
1784 if (data_model == PR_MODEL_LP64)
1785 show_strbuf(pri, offset, "dat", dump);
1786 else
1787 show_strbuf32(pri, offset, "dat", dump);
1789 #else /* _LP64 */
1790 if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0)
1791 show_strbuf(pri, offset, "ctl", dump);
1792 if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0)
1793 show_strbuf(pri, offset, "dat", dump);
1794 #endif /* _LP64 */
1796 /* exit region of lengthy output */
1797 if (dump)
1798 Xserialize();
1801 void
1802 show_int(private_t *pri, long offset, const char *name)
1804 int value;
1806 if (offset != 0 &&
1807 Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1808 (void) printf("%s\t%s:\t%d\n",
1809 pri->pname,
1810 name,
1811 value);
1814 void
1815 show_hhex_int(private_t *pri, long offset, const char *name)
1817 int value;
1819 if (Pread(Proc, &value, sizeof (value), offset) == sizeof (value))
1820 (void) printf("%s\t%s:\t0x%.4X\n",
1821 pri->pname,
1822 name,
1823 value);
1826 #define ALL_POLL_FLAGS (POLLIN|POLLPRI|POLLOUT| \
1827 POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
1829 const char *
1830 pollevent(private_t *pri, int arg)
1832 char *str = pri->code_buf;
1834 if (arg == 0)
1835 return ("0");
1836 if (arg & ~ALL_POLL_FLAGS) {
1837 (void) sprintf(str, "0x%-5X", arg);
1838 return ((const char *)str);
1841 *str = '\0';
1842 if (arg & POLLIN)
1843 (void) strcat(str, "|POLLIN");
1844 if (arg & POLLPRI)
1845 (void) strcat(str, "|POLLPRI");
1846 if (arg & POLLOUT)
1847 (void) strcat(str, "|POLLOUT");
1848 if (arg & POLLRDNORM)
1849 (void) strcat(str, "|POLLRDNORM");
1850 if (arg & POLLRDBAND)
1851 (void) strcat(str, "|POLLRDBAND");
1852 if (arg & POLLWRBAND)
1853 (void) strcat(str, "|POLLWRBAND");
1854 if (arg & POLLERR)
1855 (void) strcat(str, "|POLLERR");
1856 if (arg & POLLHUP)
1857 (void) strcat(str, "|POLLHUP");
1858 if (arg & POLLNVAL)
1859 (void) strcat(str, "|POLLNVAL");
1861 return ((const char *)(str+1));
1864 static void
1865 show_one_pollfd(private_t *pri, struct pollfd *ppollfd)
1868 * can't print both events and revents in same printf.
1869 * pollevent() returns a pointer to a TSD location.
1871 (void) printf("%s\tfd=%-2d ev=%s",
1872 pri->pname, ppollfd->fd, pollevent(pri, ppollfd->events));
1873 (void) printf(" rev=%s\n", pollevent(pri, ppollfd->revents));
1876 static void
1877 show_all_pollfds(private_t *pri, long offset, int nfds)
1879 struct pollfd pollfd[2];
1880 int skip = -1;
1882 for (; nfds && !interrupt; nfds--, offset += sizeof (struct pollfd)) {
1883 if (Pread(Proc, &pollfd[0], sizeof (struct pollfd), offset) !=
1884 sizeof (struct pollfd))
1885 continue;
1887 if (skip >= 0 && pollfd[0].fd == pollfd[1].fd &&
1888 pollfd[0].events == pollfd[1].events &&
1889 pollfd[0].revents == pollfd[1].revents) {
1890 skip++;
1891 continue;
1894 if (skip > 0)
1895 (void) printf("%s\t...last pollfd structure"
1896 " repeated %d time%s...\n",
1897 pri->pname, skip, (skip == 1 ? "" : "s"));
1899 skip = 0;
1900 show_one_pollfd(pri, &pollfd[0]);
1901 pollfd[1] = pollfd[0];
1904 if (skip > 0)
1905 (void) printf(
1906 "%s\t...last pollfd structure repeated %d time%s...\n",
1907 pri->pname, skip, (skip == 1 ? "" : "s"));
1910 void
1911 show_pollsys(private_t *pri)
1913 long offset;
1914 int nfds;
1915 int serial = 0;
1917 if (pri->sys_nargs < 2)
1918 return;
1920 offset = pri->sys_args[0];
1921 nfds = pri->sys_args[1];
1923 /* enter region of lengthy output */
1924 if (offset != 0 && nfds > 32) {
1925 Eserialize();
1926 serial = 1;
1929 if (offset != 0 && nfds > 0)
1930 show_all_pollfds(pri, offset, nfds);
1932 if (pri->sys_nargs > 2)
1933 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
1935 if (pri->sys_nargs > 3)
1936 show_sigset(pri, (long)pri->sys_args[3], "sigmask");
1938 /* exit region of lengthy output */
1939 if (serial)
1940 Xserialize();
1943 static void
1944 show_perm64(private_t *pri, struct ipc_perm64 *ip)
1946 (void) printf("%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u z=%-5d "
1947 "m=0%.6o key=%d projid=%-5d\n",
1948 pri->pname,
1949 ip->ipcx_uid,
1950 ip->ipcx_gid,
1951 ip->ipcx_cuid,
1952 ip->ipcx_cgid,
1953 (int)ip->ipcx_zoneid,
1954 (unsigned int)ip->ipcx_mode,
1955 ip->ipcx_key,
1956 (int)ip->ipcx_projid);
1959 void
1960 show_perm(private_t *pri, struct ipc_perm *ip)
1962 (void) printf(
1963 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
1964 pri->pname,
1965 ip->uid,
1966 ip->gid,
1967 ip->cuid,
1968 ip->cgid,
1969 (int)ip->mode,
1970 ip->seq,
1971 ip->key);
1974 #ifdef _LP64
1975 void
1976 show_perm32(private_t *pri, struct ipc_perm32 *ip)
1978 (void) printf(
1979 "%s\tu=%-5u g=%-5u cu=%-5u cg=%-5u m=0%.6o seq=%u key=%d\n",
1980 pri->pname,
1981 ip->uid,
1982 ip->gid,
1983 ip->cuid,
1984 ip->cgid,
1985 ip->mode,
1986 ip->seq,
1987 ip->key);
1989 #endif /* _LP64 */
1991 static void
1992 show_msgctl64(private_t *pri, long offset)
1994 struct msqid_ds64 msgq;
1996 if (offset != 0 &&
1997 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
1998 show_perm64(pri, &msgq.msgx_perm);
2000 (void) printf("%s\tbytes=%-5llu msgs=%-5llu maxby=%-5llu "
2001 "lspid=%-5d lrpid=%-5d\n", pri->pname,
2002 (unsigned long long)msgq.msgx_cbytes,
2003 (unsigned long long)msgq.msgx_qnum,
2004 (unsigned long long)msgq.msgx_qbytes,
2005 (int)msgq.msgx_lspid,
2006 (int)msgq.msgx_lrpid);
2008 prtime(pri, " st = ", (time_t)msgq.msgx_stime);
2009 prtime(pri, " rt = ", (time_t)msgq.msgx_rtime);
2010 prtime(pri, " ct = ", (time_t)msgq.msgx_ctime);
2014 void
2015 show_msgctl(private_t *pri, long offset)
2017 struct msqid_ds msgq;
2019 if (offset != 0 &&
2020 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2021 show_perm(pri, &msgq.msg_perm);
2023 (void) printf(
2024 "%s\tbytes=%-5lu msgs=%-5lu maxby=%-5lu lspid=%-5u lrpid=%-5u\n",
2025 pri->pname,
2026 msgq.msg_cbytes,
2027 msgq.msg_qnum,
2028 msgq.msg_qbytes,
2029 (int)msgq.msg_lspid,
2030 (int)msgq.msg_lrpid);
2032 prtime(pri, " st = ", msgq.msg_stime);
2033 prtime(pri, " rt = ", msgq.msg_rtime);
2034 prtime(pri, " ct = ", msgq.msg_ctime);
2038 #ifdef _LP64
2039 void
2040 show_msgctl32(private_t *pri, long offset)
2042 struct msqid_ds32 msgq;
2044 if (offset != 0 &&
2045 Pread(Proc, &msgq, sizeof (msgq), offset) == sizeof (msgq)) {
2046 show_perm32(pri, &msgq.msg_perm);
2048 (void) printf(
2049 "%s\tbytes=%-5u msgs=%-5u maxby=%-5u lspid=%-5u lrpid=%-5u\n",
2050 pri->pname,
2051 msgq.msg_cbytes,
2052 msgq.msg_qnum,
2053 msgq.msg_qbytes,
2054 msgq.msg_lspid,
2055 msgq.msg_lrpid);
2057 prtime(pri, " st = ", msgq.msg_stime);
2058 prtime(pri, " rt = ", msgq.msg_rtime);
2059 prtime(pri, " ct = ", msgq.msg_ctime);
2062 #endif /* _LP64 */
2064 void
2065 show_msgbuf(private_t *pri, long offset, long msgsz)
2067 struct msgbuf msgb;
2069 if (offset != 0 &&
2070 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2071 sizeof (msgb.mtype)) {
2072 /* enter region of lengthy output */
2073 if (msgsz > MYBUFSIZ / 4)
2074 Eserialize();
2076 (void) printf("%s\tmtype=%lu mtext[]=\n",
2077 pri->pname,
2078 msgb.mtype);
2079 showbuffer(pri,
2080 (long)(offset + sizeof (msgb.mtype)), msgsz);
2082 /* exit region of lengthy output */
2083 if (msgsz > MYBUFSIZ / 4)
2084 Xserialize();
2088 #ifdef _LP64
2089 void
2090 show_msgbuf32(private_t *pri, long offset, long msgsz)
2092 struct ipcmsgbuf32 msgb;
2094 if (offset != 0 &&
2095 Pread(Proc, &msgb, sizeof (msgb.mtype), offset) ==
2096 sizeof (msgb.mtype)) {
2097 /* enter region of lengthy output */
2098 if (msgsz > MYBUFSIZ / 4)
2099 Eserialize();
2101 (void) printf("%s\tmtype=%u mtext[]=\n",
2102 pri->pname,
2103 msgb.mtype);
2104 showbuffer(pri,
2105 (long)(offset + sizeof (msgb.mtype)), msgsz);
2107 /* exit region of lengthy output */
2108 if (msgsz > MYBUFSIZ / 4)
2109 Xserialize();
2112 #endif /* _LP64 */
2114 #ifdef _LP64
2115 void
2116 show_msgsys(private_t *pri, long msgsz)
2118 switch (pri->sys_args[0]) {
2119 case 0: /* msgget() */
2120 break;
2121 case 1: /* msgctl() */
2122 if (pri->sys_nargs > 3) {
2123 switch (pri->sys_args[2]) {
2124 case IPC_STAT:
2125 if (pri->Errno)
2126 break;
2127 /*FALLTHROUGH*/
2128 case IPC_SET:
2129 if (data_model == PR_MODEL_LP64)
2130 show_msgctl(pri,
2131 (long)pri->sys_args[3]);
2132 else
2133 show_msgctl32(pri,
2134 (long)pri->sys_args[3]);
2135 break;
2136 case IPC_STAT64:
2137 if (pri->Errno)
2138 break;
2139 /*FALLTHROUGH*/
2140 case IPC_SET64:
2141 show_msgctl64(pri, (long)pri->sys_args[3]);
2142 break;
2145 break;
2146 case 2: /* msgrcv() */
2147 if (!pri->Errno && pri->sys_nargs > 2) {
2148 if (data_model == PR_MODEL_LP64)
2149 show_msgbuf(pri, pri->sys_args[2], msgsz);
2150 else
2151 show_msgbuf32(pri, pri->sys_args[2], msgsz);
2153 break;
2154 case 3: /* msgsnd() */
2155 if (pri->sys_nargs > 3) {
2156 if (data_model == PR_MODEL_LP64)
2157 show_msgbuf(pri, pri->sys_args[2],
2158 pri->sys_args[3]);
2159 else
2160 show_msgbuf32(pri, pri->sys_args[2],
2161 pri->sys_args[3]);
2163 break;
2164 case 4: /* msgids() */
2165 case 5: /* msgsnap() */
2166 default: /* unexpected subcode */
2167 break;
2170 #else /* _LP64 */
2171 void
2172 show_msgsys(private_t *pri, long msgsz)
2174 switch (pri->sys_args[0]) {
2175 case 0: /* msgget() */
2176 break;
2177 case 1: /* msgctl() */
2178 if (pri->sys_nargs > 3) {
2179 switch (pri->sys_args[2]) {
2180 case IPC_STAT:
2181 if (pri->Errno)
2182 break;
2183 /*FALLTHROUGH*/
2184 case IPC_SET:
2185 show_msgctl(pri, (long)pri->sys_args[3]);
2186 break;
2187 case IPC_STAT64:
2188 if (pri->Errno)
2189 break;
2190 /*FALLTHROUGH*/
2191 case IPC_SET64:
2192 show_msgctl64(pri, (long)pri->sys_args[3]);
2193 break;
2196 break;
2197 case 2: /* msgrcv() */
2198 if (!pri->Errno && pri->sys_nargs > 2)
2199 show_msgbuf(pri, pri->sys_args[2], msgsz);
2200 break;
2201 case 3: /* msgsnd() */
2202 if (pri->sys_nargs > 3)
2203 show_msgbuf(pri, pri->sys_args[2],
2204 pri->sys_args[3]);
2205 break;
2206 case 4: /* msgids() */
2207 case 5: /* msgsnap() */
2208 default: /* unexpected subcode */
2209 break;
2212 #endif /* _LP64 */
2214 static void
2215 show_semctl64(private_t *pri, long offset)
2217 struct semid_ds64 semds;
2219 if (offset != 0 &&
2220 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2221 show_perm64(pri, &semds.semx_perm);
2223 (void) printf("%s\tnsems=%u\n", pri->pname, semds.semx_nsems);
2225 prtime(pri, " ot = ", (time_t)semds.semx_otime);
2226 prtime(pri, " ct = ", (time_t)semds.semx_ctime);
2230 void
2231 show_semctl(private_t *pri, long offset)
2233 struct semid_ds semds;
2235 if (offset != 0 &&
2236 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2237 show_perm(pri, &semds.sem_perm);
2239 (void) printf("%s\tnsems=%u\n",
2240 pri->pname,
2241 semds.sem_nsems);
2243 prtime(pri, " ot = ", semds.sem_otime);
2244 prtime(pri, " ct = ", semds.sem_ctime);
2248 #ifdef _LP64
2249 void
2250 show_semctl32(private_t *pri, long offset)
2252 struct semid_ds32 semds;
2254 if (offset != 0 &&
2255 Pread(Proc, &semds, sizeof (semds), offset) == sizeof (semds)) {
2256 show_perm32(pri, &semds.sem_perm);
2258 (void) printf("%s\tnsems=%u\n",
2259 pri->pname,
2260 semds.sem_nsems);
2262 prtime(pri, " ot = ", semds.sem_otime);
2263 prtime(pri, " ct = ", semds.sem_ctime);
2266 #endif /* _LP64 */
2268 void
2269 show_semop(private_t *pri, long offset, long nsops, long timeout)
2271 struct sembuf sembuf;
2272 const char *str;
2274 if (offset == 0)
2275 return;
2277 if (nsops > 40) /* let's not be ridiculous */
2278 nsops = 40;
2280 for (; nsops > 0 && !interrupt; --nsops, offset += sizeof (sembuf)) {
2281 if (Pread(Proc, &sembuf, sizeof (sembuf), offset) !=
2282 sizeof (sembuf))
2283 break;
2285 (void) printf("%s\tsemnum=%-5u semop=%-5d semflg=",
2286 pri->pname,
2287 sembuf.sem_num,
2288 sembuf.sem_op);
2290 if (sembuf.sem_flg == 0)
2291 (void) printf("0\n");
2292 else if ((str = semflags(pri, sembuf.sem_flg)) != NULL)
2293 (void) printf("%s\n", str);
2294 else
2295 (void) printf("0%.6o\n", sembuf.sem_flg);
2297 if (timeout)
2298 show_timestruc(pri, timeout, "timeout");
2301 void
2302 show_semsys(private_t *pri)
2304 switch (pri->sys_args[0]) {
2305 case 0: /* semctl() */
2306 if (pri->sys_nargs > 4) {
2307 switch (pri->sys_args[3]) {
2308 case IPC_STAT:
2309 if (pri->Errno)
2310 break;
2311 /*FALLTHROUGH*/
2312 case IPC_SET:
2313 #ifdef _LP64
2314 if (data_model == PR_MODEL_LP64)
2315 show_semctl(pri,
2316 (long)pri->sys_args[4]);
2317 else
2318 show_semctl32(pri,
2319 (long)pri->sys_args[4]);
2320 #else
2321 show_semctl(pri, (long)pri->sys_args[4]);
2322 #endif
2323 break;
2324 case IPC_STAT64:
2325 if (pri->Errno)
2326 break;
2327 /*FALLTHROUGH*/
2328 case IPC_SET64:
2329 show_semctl64(pri, (long)pri->sys_args[4]);
2330 break;
2333 break;
2334 case 1: /* semget() */
2335 break;
2336 case 2: /* semop() */
2337 if (pri->sys_nargs > 3)
2338 show_semop(pri, (long)pri->sys_args[2],
2339 pri->sys_args[3], 0);
2340 break;
2341 case 3: /* semids() */
2342 break;
2343 case 4: /* semtimedop() */
2344 if (pri->sys_nargs > 4)
2345 show_semop(pri, (long)pri->sys_args[2],
2346 pri->sys_args[3], pri->sys_args[4]);
2347 break;
2348 default: /* unexpected subcode */
2349 break;
2353 static void
2354 show_shmctl64(private_t *pri, long offset)
2356 struct shmid_ds64 shmds;
2358 if (offset != 0 &&
2359 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2360 show_perm64(pri, &shmds.shmx_perm);
2362 (void) printf(
2363 "%s\tsize=%-6llu lpid=%-5d cpid=%-5d na=%-5llu cna=%llu\n",
2364 pri->pname,
2365 (unsigned long long)shmds.shmx_segsz,
2366 (int)shmds.shmx_lpid,
2367 (int)shmds.shmx_cpid,
2368 (unsigned long long)shmds.shmx_nattch,
2369 (unsigned long long)shmds.shmx_cnattch);
2371 prtime(pri, " at = ", (time_t)shmds.shmx_atime);
2372 prtime(pri, " dt = ", (time_t)shmds.shmx_dtime);
2373 prtime(pri, " ct = ", (time_t)shmds.shmx_ctime);
2377 void
2378 show_shmctl(private_t *pri, long offset)
2380 struct shmid_ds shmds;
2382 if (offset != 0 &&
2383 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2384 show_perm(pri, &shmds.shm_perm);
2386 (void) printf(
2387 "%s\tsize=%-6lu lpid=%-5u cpid=%-5u na=%-5lu cna=%lu\n",
2388 pri->pname,
2389 (ulong_t)shmds.shm_segsz,
2390 (int)shmds.shm_lpid,
2391 (int)shmds.shm_cpid,
2392 shmds.shm_nattch,
2393 shmds.shm_cnattch);
2395 prtime(pri, " at = ", shmds.shm_atime);
2396 prtime(pri, " dt = ", shmds.shm_dtime);
2397 prtime(pri, " ct = ", shmds.shm_ctime);
2401 #ifdef _LP64
2402 void
2403 show_shmctl32(private_t *pri, long offset)
2405 struct shmid_ds32 shmds;
2407 if (offset != 0 &&
2408 Pread(Proc, &shmds, sizeof (shmds), offset) == sizeof (shmds)) {
2409 show_perm32(pri, &shmds.shm_perm);
2411 (void) printf(
2412 "%s\tsize=%-6u lpid=%-5u cpid=%-5u na=%-5u cna=%u\n",
2413 pri->pname,
2414 shmds.shm_segsz,
2415 shmds.shm_lpid,
2416 shmds.shm_cpid,
2417 shmds.shm_nattch,
2418 shmds.shm_cnattch);
2420 prtime(pri, " at = ", shmds.shm_atime);
2421 prtime(pri, " dt = ", shmds.shm_dtime);
2422 prtime(pri, " ct = ", shmds.shm_ctime);
2425 #endif /* _LP64 */
2427 void
2428 show_shmsys(private_t *pri)
2430 switch (pri->sys_args[0]) {
2431 case 0: /* shmat() */
2432 break;
2433 case 1: /* shmctl() */
2434 if (pri->sys_nargs > 3) {
2435 switch (pri->sys_args[2]) {
2436 case IPC_STAT:
2437 if (pri->Errno)
2438 break;
2439 /*FALLTHROUGH*/
2440 case IPC_SET:
2441 #ifdef _LP64
2442 if (data_model == PR_MODEL_LP64)
2443 show_shmctl(pri,
2444 (long)pri->sys_args[3]);
2445 else
2446 show_shmctl32(pri,
2447 (long)pri->sys_args[3]);
2448 #else
2449 show_shmctl(pri, (long)pri->sys_args[3]);
2450 #endif
2451 break;
2452 case IPC_STAT64:
2453 if (pri->Errno)
2454 break;
2455 /*FALLTHROUGH*/
2456 case IPC_SET64:
2457 show_shmctl64(pri, (long)pri->sys_args[3]);
2458 break;
2461 break;
2462 case 2: /* shmdt() */
2463 case 3: /* shmget() */
2464 case 4: /* shmids() */
2465 default: /* unexpected subcode */
2466 break;
2470 void
2471 show_groups(private_t *pri, long offset, long count)
2473 int groups[100];
2475 if (count > 100)
2476 count = 100;
2478 if (count > 0 && offset != 0 &&
2479 Pread(Proc, &groups[0], count*sizeof (int), offset) ==
2480 count*sizeof (int)) {
2481 int n;
2483 (void) printf("%s\t", pri->pname);
2484 for (n = 0; !interrupt && n < count; n++) {
2485 if (n != 0 && n%10 == 0)
2486 (void) printf("\n%s\t", pri->pname);
2487 (void) printf(" %5d", groups[n]);
2489 (void) fputc('\n', stdout);
2494 * This assumes that a sigset_t is simply an array of ints.
2496 char *
2497 sigset_string(private_t *pri, sigset_t *sp)
2499 char *s = pri->code_buf;
2500 int n = sizeof (*sp) / sizeof (int32_t);
2501 int32_t *lp = (int32_t *)sp;
2503 while (--n >= 0) {
2504 int32_t val = *lp++;
2506 if (val == 0)
2507 s += sprintf(s, " 0");
2508 else
2509 s += sprintf(s, " 0x%.8X", val);
2512 return (pri->code_buf);
2515 void
2516 show_sigset(private_t *pri, long offset, const char *name)
2518 sigset_t sigset;
2520 if (offset != 0 &&
2521 Pread(Proc, &sigset, sizeof (sigset), offset) == sizeof (sigset)) {
2522 (void) printf("%s\t%s =%s\n",
2523 pri->pname, name, sigset_string(pri, &sigset));
2527 #ifdef _LP64
2528 void
2529 show_sigaltstack32(private_t *pri, long offset, const char *name)
2531 struct sigaltstack32 altstack;
2533 if (offset != 0 &&
2534 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2535 sizeof (altstack)) {
2536 (void) printf("%s\t%s: sp=0x%.8X size=%u flags=0x%.4X\n",
2537 pri->pname,
2538 name,
2539 altstack.ss_sp,
2540 altstack.ss_size,
2541 altstack.ss_flags);
2544 #endif /* _LP64 */
2546 void
2547 show_sigaltstack(private_t *pri, long offset, const char *name)
2549 struct sigaltstack altstack;
2551 #ifdef _LP64
2552 if (data_model != PR_MODEL_LP64) {
2553 show_sigaltstack32(pri, offset, name);
2554 return;
2556 #endif
2557 if (offset != 0 &&
2558 Pread(Proc, &altstack, sizeof (altstack), offset) ==
2559 sizeof (altstack)) {
2560 (void) printf("%s\t%s: sp=0x%.8lX size=%lu flags=0x%.4X\n",
2561 pri->pname,
2562 name,
2563 (ulong_t)altstack.ss_sp,
2564 (ulong_t)altstack.ss_size,
2565 altstack.ss_flags);
2569 #ifdef _LP64
2570 void
2571 show_sigaction32(private_t *pri, long offset, const char *name, long odisp)
2573 struct sigaction32 sigaction;
2575 if (offset != 0 &&
2576 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2577 sizeof (sigaction)) {
2578 /* This is stupid, we shouldn't have to do this */
2579 if (odisp != 0)
2580 sigaction.sa_handler = (caddr32_t)odisp;
2581 (void) printf(
2582 "%s %s: hand = 0x%.8X mask =%s flags = 0x%.4X\n",
2583 pri->pname,
2584 name,
2585 sigaction.sa_handler,
2586 sigset_string(pri, (sigset_t *)&sigaction.sa_mask),
2587 sigaction.sa_flags);
2590 #endif /* _LP64 */
2592 void
2593 show_sigaction(private_t *pri, long offset, const char *name, long odisp)
2595 struct sigaction sigaction;
2597 #ifdef _LP64
2598 if (data_model != PR_MODEL_LP64) {
2599 show_sigaction32(pri, offset, name, odisp);
2600 return;
2602 #endif
2603 if (offset != 0 &&
2604 Pread(Proc, &sigaction, sizeof (sigaction), offset) ==
2605 sizeof (sigaction)) {
2606 /* This is stupid, we shouldn't have to do this */
2607 if (odisp != 0)
2608 sigaction.sa_handler = (void (*)())odisp;
2609 (void) printf(
2610 "%s %s: hand = 0x%.8lX mask =%s flags = 0x%.4X\n",
2611 pri->pname,
2612 name,
2613 (long)sigaction.sa_handler,
2614 sigset_string(pri, &sigaction.sa_mask),
2615 sigaction.sa_flags);
2619 #ifdef _LP64
2620 void
2621 print_siginfo32(private_t *pri, const siginfo32_t *sip)
2623 const char *code = NULL;
2625 (void) printf("%s siginfo: %s", pri->pname,
2626 signame(pri, sip->si_signo));
2628 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2629 (void) printf(" pid=%d uid=%d", sip->si_pid, sip->si_uid);
2630 if (sip->si_code != 0)
2631 (void) printf(" code=%d", sip->si_code);
2632 (void) fputc('\n', stdout);
2633 return;
2636 switch (sip->si_signo) {
2637 default:
2638 (void) fputc('\n', stdout);
2639 return;
2640 case SIGILL:
2641 case SIGTRAP:
2642 case SIGFPE:
2643 case SIGSEGV:
2644 case SIGBUS:
2645 case SIGEMT:
2646 case SIGCLD:
2647 case SIGPOLL:
2648 case SIGXFSZ:
2649 break;
2652 switch (sip->si_signo) {
2653 case SIGILL:
2654 switch (sip->si_code) {
2655 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2656 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2657 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2658 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2659 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2660 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2661 case ILL_COPROC: code = "ILL_COPROC"; break;
2662 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2664 break;
2665 case SIGTRAP:
2666 switch (sip->si_code) {
2667 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2668 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2669 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2670 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2671 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2672 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2674 break;
2675 case SIGFPE:
2676 switch (sip->si_code) {
2677 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2678 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2679 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2680 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2681 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2682 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2683 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2684 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2685 #if defined(FPE_FLTDEN)
2686 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2687 #endif
2689 break;
2690 case SIGSEGV:
2691 switch (sip->si_code) {
2692 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2693 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2695 break;
2696 case SIGEMT:
2697 switch (sip->si_code) {
2698 #ifdef EMT_TAGOVF
2699 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2700 #endif
2701 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2703 break;
2704 case SIGBUS:
2705 switch (sip->si_code) {
2706 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2707 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2708 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2710 break;
2711 case SIGCLD:
2712 switch (sip->si_code) {
2713 case CLD_EXITED: code = "CLD_EXITED"; break;
2714 case CLD_KILLED: code = "CLD_KILLED"; break;
2715 case CLD_DUMPED: code = "CLD_DUMPED"; break;
2716 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
2717 case CLD_STOPPED: code = "CLD_STOPPED"; break;
2718 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
2720 break;
2721 case SIGPOLL:
2722 switch (sip->si_code) {
2723 case POLL_IN: code = "POLL_IN"; break;
2724 case POLL_OUT: code = "POLL_OUT"; break;
2725 case POLL_MSG: code = "POLL_MSG"; break;
2726 case POLL_ERR: code = "POLL_ERR"; break;
2727 case POLL_PRI: code = "POLL_PRI"; break;
2728 case POLL_HUP: code = "POLL_HUP"; break;
2730 break;
2733 if (code == NULL) {
2734 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2735 code = (const char *)pri->code_buf;
2738 switch (sip->si_signo) {
2739 case SIGILL:
2740 case SIGTRAP:
2741 case SIGFPE:
2742 case SIGSEGV:
2743 case SIGBUS:
2744 case SIGEMT:
2745 (void) printf(" %s addr=0x%.8X",
2746 code,
2747 sip->si_addr);
2748 break;
2749 case SIGCLD:
2750 (void) printf(" %s pid=%d status=0x%.4X",
2751 code,
2752 sip->si_pid,
2753 sip->si_status);
2754 break;
2755 case SIGPOLL:
2756 case SIGXFSZ:
2757 (void) printf(" %s fd=%d band=%d",
2758 code,
2759 sip->si_fd,
2760 sip->si_band);
2761 break;
2764 if (sip->si_errno != 0) {
2765 const char *ename = errname(sip->si_errno);
2767 (void) printf(" errno=%d", sip->si_errno);
2768 if (ename != NULL)
2769 (void) printf("(%s)", ename);
2772 (void) fputc('\n', stdout);
2774 #endif /* _LP64 */
2776 void
2777 print_siginfo(private_t *pri, const siginfo_t *sip)
2779 const char *code = NULL;
2781 (void) printf("%s siginfo: %s", pri->pname,
2782 signame(pri, sip->si_signo));
2784 if (sip->si_signo != 0 && SI_FROMUSER(sip) && sip->si_pid != 0) {
2785 (void) printf(" pid=%d uid=%u",
2786 (int)sip->si_pid,
2787 sip->si_uid);
2788 if (sip->si_code != 0)
2789 (void) printf(" code=%d", sip->si_code);
2790 (void) fputc('\n', stdout);
2791 return;
2794 switch (sip->si_signo) {
2795 default:
2796 (void) fputc('\n', stdout);
2797 return;
2798 case SIGILL:
2799 case SIGTRAP:
2800 case SIGFPE:
2801 case SIGSEGV:
2802 case SIGBUS:
2803 case SIGEMT:
2804 case SIGCLD:
2805 case SIGPOLL:
2806 case SIGXFSZ:
2807 break;
2810 switch (sip->si_signo) {
2811 case SIGILL:
2812 switch (sip->si_code) {
2813 case ILL_ILLOPC: code = "ILL_ILLOPC"; break;
2814 case ILL_ILLOPN: code = "ILL_ILLOPN"; break;
2815 case ILL_ILLADR: code = "ILL_ILLADR"; break;
2816 case ILL_ILLTRP: code = "ILL_ILLTRP"; break;
2817 case ILL_PRVOPC: code = "ILL_PRVOPC"; break;
2818 case ILL_PRVREG: code = "ILL_PRVREG"; break;
2819 case ILL_COPROC: code = "ILL_COPROC"; break;
2820 case ILL_BADSTK: code = "ILL_BADSTK"; break;
2822 break;
2823 case SIGTRAP:
2824 switch (sip->si_code) {
2825 case TRAP_BRKPT: code = "TRAP_BRKPT"; break;
2826 case TRAP_TRACE: code = "TRAP_TRACE"; break;
2827 case TRAP_RWATCH: code = "TRAP_RWATCH"; break;
2828 case TRAP_WWATCH: code = "TRAP_WWATCH"; break;
2829 case TRAP_XWATCH: code = "TRAP_XWATCH"; break;
2830 case TRAP_DTRACE: code = "TRAP_DTRACE"; break;
2832 break;
2833 case SIGFPE:
2834 switch (sip->si_code) {
2835 case FPE_INTDIV: code = "FPE_INTDIV"; break;
2836 case FPE_INTOVF: code = "FPE_INTOVF"; break;
2837 case FPE_FLTDIV: code = "FPE_FLTDIV"; break;
2838 case FPE_FLTOVF: code = "FPE_FLTOVF"; break;
2839 case FPE_FLTUND: code = "FPE_FLTUND"; break;
2840 case FPE_FLTRES: code = "FPE_FLTRES"; break;
2841 case FPE_FLTINV: code = "FPE_FLTINV"; break;
2842 case FPE_FLTSUB: code = "FPE_FLTSUB"; break;
2843 #if defined(FPE_FLTDEN)
2844 case FPE_FLTDEN: code = "FPE_FLTDEN"; break;
2845 #endif
2847 break;
2848 case SIGSEGV:
2849 switch (sip->si_code) {
2850 case SEGV_MAPERR: code = "SEGV_MAPERR"; break;
2851 case SEGV_ACCERR: code = "SEGV_ACCERR"; break;
2853 break;
2854 case SIGEMT:
2855 switch (sip->si_code) {
2856 #ifdef EMT_TAGOVF
2857 case EMT_TAGOVF: code = "EMT_TAGOVF"; break;
2858 #endif
2859 case EMT_CPCOVF: code = "EMT_CPCOVF"; break;
2861 break;
2862 case SIGBUS:
2863 switch (sip->si_code) {
2864 case BUS_ADRALN: code = "BUS_ADRALN"; break;
2865 case BUS_ADRERR: code = "BUS_ADRERR"; break;
2866 case BUS_OBJERR: code = "BUS_OBJERR"; break;
2868 break;
2869 case SIGCLD:
2870 switch (sip->si_code) {
2871 case CLD_EXITED: code = "CLD_EXITED"; break;
2872 case CLD_KILLED: code = "CLD_KILLED"; break;
2873 case CLD_DUMPED: code = "CLD_DUMPED"; break;
2874 case CLD_TRAPPED: code = "CLD_TRAPPED"; break;
2875 case CLD_STOPPED: code = "CLD_STOPPED"; break;
2876 case CLD_CONTINUED: code = "CLD_CONTINUED"; break;
2878 break;
2879 case SIGPOLL:
2880 switch (sip->si_code) {
2881 case POLL_IN: code = "POLL_IN"; break;
2882 case POLL_OUT: code = "POLL_OUT"; break;
2883 case POLL_MSG: code = "POLL_MSG"; break;
2884 case POLL_ERR: code = "POLL_ERR"; break;
2885 case POLL_PRI: code = "POLL_PRI"; break;
2886 case POLL_HUP: code = "POLL_HUP"; break;
2888 break;
2891 if (code == NULL) {
2892 (void) sprintf(pri->code_buf, "code=%d", sip->si_code);
2893 code = (const char *)pri->code_buf;
2896 switch (sip->si_signo) {
2897 case SIGILL:
2898 case SIGTRAP:
2899 case SIGFPE:
2900 case SIGSEGV:
2901 case SIGBUS:
2902 case SIGEMT:
2903 (void) printf(" %s addr=0x%.8lX",
2904 code,
2905 (long)sip->si_addr);
2906 break;
2907 case SIGCLD:
2908 (void) printf(" %s pid=%d status=0x%.4X",
2909 code,
2910 (int)sip->si_pid,
2911 sip->si_status);
2912 break;
2913 case SIGPOLL:
2914 case SIGXFSZ:
2915 (void) printf(" %s fd=%d band=%ld",
2916 code,
2917 sip->si_fd,
2918 sip->si_band);
2919 break;
2922 if (sip->si_errno != 0) {
2923 const char *ename = errname(sip->si_errno);
2925 (void) printf(" errno=%d", sip->si_errno);
2926 if (ename != NULL)
2927 (void) printf("(%s)", ename);
2930 (void) fputc('\n', stdout);
2933 #ifdef _LP64
2934 void
2935 show_siginfo32(private_t *pri, long offset)
2937 struct siginfo32 siginfo;
2939 if (offset != 0 &&
2940 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
2941 print_siginfo32(pri, &siginfo);
2943 #endif /* _LP64 */
2945 void
2946 show_siginfo(private_t *pri, long offset)
2948 struct siginfo siginfo;
2950 #ifdef _LP64
2951 if (data_model != PR_MODEL_LP64) {
2952 show_siginfo32(pri, offset);
2953 return;
2955 #endif
2956 if (offset != 0 &&
2957 Pread(Proc, &siginfo, sizeof (siginfo), offset) == sizeof (siginfo))
2958 print_siginfo(pri, &siginfo);
2961 void
2962 show_bool(private_t *pri, long offset, int count)
2964 int serial = (count > MYBUFSIZ / 4);
2966 /* enter region of lengthy output */
2967 if (serial)
2968 Eserialize();
2970 while (count > 0) {
2971 char buf[32];
2972 int nb = (count < 32)? count : 32;
2973 int i;
2975 if (Pread(Proc, buf, (size_t)nb, offset) != nb)
2976 break;
2978 (void) printf("%s ", pri->pname);
2979 for (i = 0; i < nb; i++)
2980 (void) printf(" %d", buf[i]);
2981 (void) fputc('\n', stdout);
2983 count -= nb;
2984 offset += nb;
2987 /* exit region of lengthy output */
2988 if (serial)
2989 Xserialize();
2992 #ifdef _LP64
2993 void
2994 show_iovec32(private_t *pri, long offset, int niov, int showbuf, long count)
2996 iovec32_t iovec[16];
2997 iovec32_t *ip;
2998 long nb;
2999 int serial = (count > MYBUFSIZ / 4 && showbuf);
3001 if (niov > 16) /* is this the real limit? */
3002 niov = 16;
3004 if (offset != 0 && niov > 0 &&
3005 Pread(Proc, &iovec[0], niov*sizeof (iovec32_t), offset)
3006 == niov*sizeof (iovec32_t)) {
3007 /* enter region of lengthy output */
3008 if (serial)
3009 Eserialize();
3011 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3012 (void) printf("%s\tiov_base = 0x%.8X iov_len = %d\n",
3013 pri->pname,
3014 ip->iov_base,
3015 ip->iov_len);
3016 if ((nb = count) > 0) {
3017 if (nb > ip->iov_len)
3018 nb = ip->iov_len;
3019 if (nb > 0)
3020 count -= nb;
3022 if (showbuf && nb > 0)
3023 showbuffer(pri, (long)ip->iov_base, nb);
3026 /* exit region of lengthy output */
3027 if (serial)
3028 Xserialize();
3031 #endif /* _LP64 */
3033 void
3034 show_iovec(private_t *pri, long offset, long niov, int showbuf, long count)
3036 iovec_t iovec[16];
3037 iovec_t *ip;
3038 long nb;
3039 int serial = (count > MYBUFSIZ / 4 && showbuf);
3041 #ifdef _LP64
3042 if (data_model != PR_MODEL_LP64) {
3043 show_iovec32(pri, offset, niov, showbuf, count);
3044 return;
3046 #endif
3047 if (niov > 16) /* is this the real limit? */
3048 niov = 16;
3050 if (offset != 0 && niov > 0 &&
3051 Pread(Proc, &iovec[0], niov*sizeof (iovec_t), offset)
3052 == niov*sizeof (iovec_t)) {
3053 /* enter region of lengthy output */
3054 if (serial)
3055 Eserialize();
3057 for (ip = &iovec[0]; niov-- && !interrupt; ip++) {
3058 (void) printf("%s\tiov_base = 0x%.8lX iov_len = %lu\n",
3059 pri->pname,
3060 (long)ip->iov_base,
3061 ip->iov_len);
3062 if ((nb = count) > 0) {
3063 if (nb > ip->iov_len)
3064 nb = ip->iov_len;
3065 if (nb > 0)
3066 count -= nb;
3068 if (showbuf && nb > 0)
3069 showbuffer(pri, (long)ip->iov_base, nb);
3072 /* exit region of lengthy output */
3073 if (serial)
3074 Xserialize();
3078 void
3079 show_dents(private_t *pri, long offset, long count)
3081 long long buf[MYBUFSIZ / sizeof (long long)];
3082 struct dirent *dp;
3083 int serial = (count > 100);
3085 if (offset == 0)
3086 return;
3088 /* enter region of lengthy output */
3089 if (serial)
3090 Eserialize();
3092 while (count > 0 && !interrupt) {
3093 int nb = count < MYBUFSIZ? (int)count : MYBUFSIZ;
3095 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) <= 0)
3096 break;
3098 dp = (struct dirent *)&buf[0];
3099 if (nb < (int)(dp->d_name - (char *)dp))
3100 break;
3101 if ((unsigned)nb < dp->d_reclen) {
3102 /* getdents() error? */
3103 (void) printf(
3104 "%s ino=%-5llu off=%-4lld rlen=%-3d\n",
3105 pri->pname,
3106 (long long)dp->d_ino,
3107 (long long)dp->d_off,
3108 dp->d_reclen);
3109 break;
3112 while (!interrupt &&
3113 nb >= (int)(dp->d_name - (char *)dp) &&
3114 (unsigned)nb >= dp->d_reclen) {
3115 (void) printf(
3116 "%s ino=%-5llu off=%-4lld rlen=%-3d \"%.*s\"\n",
3117 pri->pname,
3118 (long long)dp->d_ino,
3119 (long long)dp->d_off,
3120 dp->d_reclen,
3121 dp->d_reclen - (int)(dp->d_name - (char *)dp),
3122 dp->d_name);
3123 nb -= dp->d_reclen;
3124 count -= dp->d_reclen;
3125 offset += dp->d_reclen;
3126 /* LINTED improper alignment */
3127 dp = (struct dirent *)((char *)dp + dp->d_reclen);
3131 /* exit region of lengthy output */
3132 if (serial)
3133 Xserialize();
3136 void
3137 show_rlimit(private_t *pri, long offset)
3139 struct rlimit rlimit;
3141 if (offset != 0 &&
3142 Pread(Proc, &rlimit, sizeof (rlimit), offset) == sizeof (rlimit)) {
3143 (void) printf("%s\t", pri->pname);
3144 switch (rlimit.rlim_cur) {
3145 case RLIM_INFINITY:
3146 (void) fputs("cur = RLIM_INFINITY", stdout);
3147 break;
3148 case RLIM_SAVED_MAX:
3149 (void) fputs("cur = RLIM_SAVED_MAX", stdout);
3150 break;
3151 case RLIM_SAVED_CUR:
3152 (void) fputs("cur = RLIM_SAVED_CUR", stdout);
3153 break;
3154 default:
3155 (void) printf("cur = %llu",
3156 (unsigned long long)rlimit.rlim_cur);
3157 break;
3159 switch (rlimit.rlim_max) {
3160 case RLIM_INFINITY:
3161 (void) fputs(" max = RLIM_INFINITY\n", stdout);
3162 break;
3163 case RLIM_SAVED_MAX:
3164 (void) fputs(" max = RLIM_SAVED_MAX\n", stdout);
3165 break;
3166 case RLIM_SAVED_CUR:
3167 (void) fputs(" max = RLIM_SAVED_CUR\n", stdout);
3168 break;
3169 default:
3170 (void) printf(" max = %llu\n",
3171 (unsigned long long)rlimit.rlim_max);
3172 break;
3177 void
3178 show_uname(private_t *pri, long offset)
3180 struct utsname ubuf;
3182 if (offset != 0 &&
3183 Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3184 (void) printf(
3185 "%s\tsys=%s nod=%s rel=%s ver=%s mch=%s\n",
3186 pri->pname,
3187 ubuf.sysname,
3188 ubuf.nodename,
3189 ubuf.release,
3190 ubuf.version,
3191 ubuf.machine);
3195 void
3196 show_adjtime(private_t *pri, long off1, long off2)
3198 show_timeval(pri, off1, " delta");
3199 show_timeval(pri, off2, "olddelta");
3202 void
3203 show_sockaddr(private_t *pri,
3204 const char *str, long addroff, long lenoff, long len)
3207 * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3208 * also large enough to store a sockaddr_in or a sockaddr_in6.
3210 long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3211 / sizeof (long)];
3212 struct sockaddr *sa = (struct sockaddr *)buf;
3213 struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3214 struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3215 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3216 char addrbuf[INET6_ADDRSTRLEN];
3218 if (lenoff != 0) {
3219 uint_t ilen;
3220 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3221 return;
3222 len = ilen;
3225 if (len >= sizeof (buf)) /* protect against ridiculous length */
3226 len = sizeof (buf) - 1;
3227 if (Pread(Proc, buf, len, addroff) != len)
3228 return;
3230 switch (sa->sa_family) {
3231 case AF_INET6:
3232 (void) printf("%s\tAF_INET6 %s = %s port = %u\n",
3233 pri->pname, str,
3234 inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3235 sizeof (addrbuf)),
3236 ntohs(sin6->sin6_port));
3237 (void) printf("%s\tscope id = %u source id = 0x%x\n"
3238 "%s\tflow class = 0x%02x flow label = 0x%05x\n",
3239 pri->pname, ntohl(sin6->sin6_scope_id),
3240 ntohl(sin6->__sin6_src_id),
3241 pri->pname,
3242 ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3243 ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3244 break;
3245 case AF_INET:
3246 (void) printf("%s\tAF_%s %s = %s port = %u\n",
3247 pri->pname, "INET",
3248 str, inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
3249 sizeof (addrbuf)), ntohs(sin->sin_port));
3250 break;
3251 case AF_UNIX:
3252 len -= sizeof (soun->sun_family);
3253 if (len >= 0) {
3254 /* Null terminate */
3255 soun->sun_path[len] = '\0';
3256 (void) printf("%s\tAF_UNIX %s = %s\n", pri->pname,
3257 str, soun->sun_path);
3259 break;
3263 void
3264 show_msghdr(private_t *pri, long offset)
3266 const lwpstatus_t *Lsp = pri->lwpstat;
3267 int what = Lsp->pr_what;
3268 int err = pri->Errno;
3269 struct msghdr msg;
3270 int showbuf = FALSE;
3271 int i = pri->sys_args[0]+1;
3272 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3274 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3275 return;
3277 if (msg.msg_name != NULL && msg.msg_namelen != 0)
3278 show_sockaddr(pri, "msg_name",
3279 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3282 * Print the iovec if the syscall was successful and the fd is
3283 * part of the set being traced.
3285 if ((what == SYS_recvmsg && !err &&
3286 prismember(&readfd, i)) ||
3287 (what == SYS_sendmsg &&
3288 prismember(&writefd, i)))
3289 showbuf = TRUE;
3291 show_iovec(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3295 #ifdef _LP64
3296 void
3297 show_msghdr32(private_t *pri, long offset)
3299 struct msghdr32 {
3300 caddr32_t msg_name;
3301 uint32_t msg_namelen;
3302 caddr32_t msg_iov;
3303 int32_t msg_iovlen;
3304 } msg;
3305 const lwpstatus_t *Lsp = pri->lwpstat;
3306 int what = Lsp->pr_what;
3307 int err = pri->Errno;
3308 int showbuf = FALSE;
3309 int i = pri->sys_args[0]+1;
3310 long nb = (what == SYS_recvmsg)? pri->Rval1 : 32*1024;
3312 if (Pread(Proc, &msg, sizeof (msg), offset) != sizeof (msg))
3313 return;
3315 if (msg.msg_name != 0 && msg.msg_namelen != 0)
3316 show_sockaddr(pri, "msg_name",
3317 (long)msg.msg_name, 0, (long)msg.msg_namelen);
3319 * Print the iovec if the syscall was successful and the fd is
3320 * part of the set being traced.
3322 if ((what == SYS_recvmsg && !err &&
3323 prismember(&readfd, i)) ||
3324 (what == SYS_sendmsg &&
3325 prismember(&writefd, i)))
3326 showbuf = TRUE;
3328 show_iovec32(pri, (long)msg.msg_iov, msg.msg_iovlen, showbuf, nb);
3331 #endif /* _LP64 */
3333 static void
3334 show_doorargs(private_t *pri, long offset)
3336 door_arg_t args;
3338 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3339 (void) printf("%s\tdata_ptr=0x%lX data_size=%lu\n",
3340 pri->pname,
3341 (ulong_t)args.data_ptr,
3342 (ulong_t)args.data_size);
3343 (void) printf("%s\tdesc_ptr=0x%lX desc_num=%u\n",
3344 pri->pname,
3345 (ulong_t)args.desc_ptr,
3346 args.desc_num);
3347 (void) printf("%s\trbuf=0x%lX rsize=%lu\n",
3348 pri->pname,
3349 (ulong_t)args.rbuf,
3350 (ulong_t)args.rsize);
3354 static void
3355 show_ucred_privsets(private_t *pri, ucred_t *uc)
3357 int i = 0;
3358 const priv_set_t *s;
3359 priv_ptype_t sn;
3360 char *str;
3362 while ((sn = priv_getsetbynum(i++)) != NULL) {
3363 s = ucred_getprivset(uc, sn);
3365 if (s == NULL)
3366 continue;
3368 (void) printf("%s\t%c: %s\n",
3369 pri->pname,
3370 *sn,
3371 str = priv_set_to_str(s, ',', PRIV_STR_SHORT));
3373 free(str);
3377 static void
3378 show_ucred(private_t *pri, long offset)
3380 ucred_t *uc = _ucred_alloc();
3381 size_t sz;
3383 if (uc == NULL)
3384 return;
3386 sz = Pread(Proc, uc, uc->uc_size, offset);
3389 * A new uc_size is read, it could be smaller than the previously
3390 * value. We accept short reads that fill the whole header.
3392 if (sz >= sizeof (ucred_t) && sz >= uc->uc_size) {
3393 (void) printf("%s\teuid=%u egid=%u\n",
3394 pri->pname,
3395 ucred_geteuid(uc),
3396 ucred_getegid(uc));
3397 (void) printf("%s\truid=%u rgid=%u\n",
3398 pri->pname,
3399 ucred_getruid(uc),
3400 ucred_getrgid(uc));
3401 (void) printf("%s\tpid=%d zoneid=%d\n",
3402 pri->pname,
3403 (int)ucred_getpid(uc),
3404 (int)ucred_getzoneid(uc));
3405 show_ucred_privsets(pri, uc);
3407 ucred_free(uc);
3410 static void
3411 show_privset(private_t *pri, long offset, size_t size, char *label)
3413 priv_set_t *tmp = priv_allocset();
3414 size_t sz;
3416 if (tmp == NULL)
3417 return;
3419 sz = Pread(Proc, tmp, size, offset);
3421 if (sz == size) {
3422 char *str = priv_set_to_str(tmp, ',', PRIV_STR_SHORT);
3423 if (str != NULL) {
3424 (void) printf("%s\t%s%s\n", pri->pname, label, str);
3425 free(str);
3428 priv_freeset(tmp);
3431 static void
3432 show_doorinfo(private_t *pri, long offset)
3434 door_info_t info;
3435 door_attr_t attr;
3437 if (Pread(Proc, &info, sizeof (info), offset) != sizeof (info))
3438 return;
3439 (void) printf("%s\ttarget=%d proc=0x%llX data=0x%llX\n",
3440 pri->pname,
3441 (int)info.di_target,
3442 info.di_proc,
3443 info.di_data);
3444 attr = info.di_attributes;
3445 (void) printf("%s\tattributes=%s\n", pri->pname, door_flags(pri, attr));
3446 (void) printf("%s\tuniquifier=%llu\n", pri->pname, info.di_uniquifier);
3449 static void
3450 show_doorparam(private_t *pri, long offset)
3452 ulong_t val;
3454 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3455 (void) printf("%s\tvalue=%lu\n",
3456 pri->pname,
3457 val);
3461 #ifdef _LP64
3463 static void
3464 show_doorargs32(private_t *pri, long offset)
3466 struct door_arg32 args;
3468 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3469 (void) printf("%s\tdata_ptr=%X data_size=%u\n",
3470 pri->pname,
3471 args.data_ptr,
3472 args.data_size);
3473 (void) printf("%s\tdesc_ptr=0x%X desc_num=%u\n",
3474 pri->pname,
3475 args.desc_ptr,
3476 args.desc_num);
3477 (void) printf("%s\trbuf=0x%X rsize=%u\n",
3478 pri->pname,
3479 args.rbuf,
3480 args.rsize);
3484 static void
3485 show_doorparam32(private_t *pri, long offset)
3487 uint_t val;
3489 if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
3490 (void) printf("%s\tvalue=%u\n",
3491 pri->pname,
3492 val);
3496 #endif /* _LP64 */
3498 static void
3499 show_doors(private_t *pri)
3501 switch (pri->sys_args[5]) {
3502 case DOOR_CALL:
3503 #ifdef _LP64
3504 if (data_model == PR_MODEL_LP64)
3505 show_doorargs(pri, (long)pri->sys_args[1]);
3506 else
3507 show_doorargs32(pri, (long)pri->sys_args[1]);
3508 #else
3509 show_doorargs(pri, (long)pri->sys_args[1]);
3510 #endif
3511 break;
3512 case DOOR_UCRED:
3513 if (!pri->Errno)
3514 show_ucred(pri, (long)pri->sys_args[0]);
3515 break;
3516 case DOOR_INFO:
3517 if (!pri->Errno)
3518 show_doorinfo(pri, (long)pri->sys_args[1]);
3519 break;
3520 case DOOR_GETPARAM:
3521 if (!pri->Errno) {
3522 #ifdef _LP64
3523 if (data_model == PR_MODEL_LP64)
3524 show_doorparam(pri, (long)pri->sys_args[2]);
3525 else
3526 show_doorparam32(pri, (long)pri->sys_args[2]);
3527 #else
3528 show_doorparam(pri, (long)pri->sys_args[2]);
3529 #endif
3531 break;
3535 static void
3536 show_portargs(private_t *pri, long offset)
3538 port_event_t args;
3540 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3541 (void) printf("%s\tevents=0x%x source=%u\n",
3542 pri->pname,
3543 args.portev_events,
3544 args.portev_source);
3545 (void) printf("%s\tobject=0x%p user=0x%p\n",
3546 pri->pname,
3547 (void *)args.portev_object,
3548 (void *)args.portev_user);
3553 #ifdef _LP64
3555 static void
3556 show_portargs32(private_t *pri, long offset)
3558 port_event32_t args;
3560 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
3561 (void) printf("%s\tevents=0x%x source=%u\n",
3562 pri->pname,
3563 args.portev_events,
3564 args.portev_source);
3565 (void) printf("%s\tobject=0x%x user=0x%x\n",
3566 pri->pname,
3567 args.portev_object,
3568 args.portev_user);
3572 #endif /* _LP64 */
3574 static void
3575 show_ports(private_t *pri)
3577 switch (pri->sys_args[0]) {
3578 case PORT_GET:
3579 #ifdef _LP64
3580 if (data_model == PR_MODEL_LP64)
3581 show_portargs(pri, (long)pri->sys_args[2]);
3582 else
3583 show_portargs32(pri, (long)pri->sys_args[2]);
3584 #else
3585 show_portargs(pri, (long)pri->sys_args[2]);
3586 #endif
3587 break;
3591 #define MAX_SNDFL_PRD 16
3593 #ifdef _LP64
3595 static void
3596 show_ksendfilevec32(private_t *pri, int fd,
3597 ksendfilevec32_t *sndvec, int sfvcnt)
3599 ksendfilevec32_t *snd_ptr, snd[MAX_SNDFL_PRD];
3600 size_t cpy_rqst;
3602 Eserialize();
3603 while (sfvcnt > 0) {
3604 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3605 sfvcnt -= cpy_rqst;
3606 cpy_rqst *= sizeof (snd[0]);
3608 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3609 break;
3611 snd_ptr = &snd[0];
3613 while (cpy_rqst) {
3614 (void) printf(
3615 "sfv_fd=%d\tsfv_flag=0x%x\t"
3616 "sfv_off=%d\tsfv_len=%u\n",
3617 snd_ptr->sfv_fd,
3618 snd_ptr->sfv_flag,
3619 snd_ptr->sfv_off,
3620 snd_ptr->sfv_len);
3622 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3623 prismember(&writefd, fd)) {
3624 showbuffer(pri,
3625 (long)snd_ptr->sfv_off & 0xffffffff,
3626 (long)snd_ptr->sfv_len);
3629 cpy_rqst -= sizeof (snd[0]);
3630 snd_ptr++;
3633 sndvec += MAX_SNDFL_PRD;
3635 Xserialize();
3638 static void
3639 show_ksendfilevec64(private_t *pri, int fd,
3640 ksendfilevec64_t *sndvec, int sfvcnt)
3642 ksendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3643 size_t cpy_rqst;
3645 Eserialize();
3646 while (sfvcnt > 0) {
3647 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3648 sfvcnt -= cpy_rqst;
3649 cpy_rqst *= sizeof (snd[0]);
3651 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3652 break;
3654 snd_ptr = &snd[0];
3656 while (cpy_rqst) {
3657 (void) printf(
3658 "sfv_fd=%d\tsfv_flag=0x%x\t"
3659 "sfv_off=%ld\tsfv_len=%u\n",
3660 snd_ptr->sfv_fd,
3661 snd_ptr->sfv_flag,
3662 snd_ptr->sfv_off,
3663 snd_ptr->sfv_len);
3665 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3666 prismember(&writefd, fd)) {
3667 showbuffer(pri,
3668 (long)snd_ptr->sfv_off & 0xffffffff,
3669 (long)snd_ptr->sfv_len);
3672 cpy_rqst -= sizeof (snd[0]);
3673 snd_ptr++;
3676 sndvec += MAX_SNDFL_PRD;
3678 Xserialize();
3681 #endif /* _LP64 */
3683 /*ARGSUSED*/
3684 static void
3685 show_sendfilevec(private_t *pri, int fd, sendfilevec_t *sndvec, int sfvcnt)
3687 sendfilevec_t *snd_ptr, snd[MAX_SNDFL_PRD];
3688 size_t cpy_rqst;
3690 #ifdef _LP64
3691 if (data_model != PR_MODEL_LP64) {
3692 show_ksendfilevec32(pri, fd,
3693 (ksendfilevec32_t *)sndvec, sfvcnt);
3694 return;
3696 #endif
3697 Eserialize();
3698 while (sfvcnt > 0) {
3699 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3700 sfvcnt -= cpy_rqst;
3701 cpy_rqst *= sizeof (snd[0]);
3703 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3704 break;
3706 snd_ptr = &snd[0];
3708 while (cpy_rqst) {
3709 (void) printf(
3710 "sfv_fd=%d\tsfv_flag=0x%x\t"
3711 "sfv_off=%ld\tsfv_len=%lu\n",
3712 snd_ptr->sfv_fd,
3713 snd_ptr->sfv_flag,
3714 snd_ptr->sfv_off,
3715 (ulong_t)snd_ptr->sfv_len);
3717 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3718 prismember(&writefd, fd)) {
3719 showbuffer(pri, (long)snd_ptr->sfv_off,
3720 (long)snd_ptr->sfv_len);
3723 cpy_rqst -= sizeof (snd[0]);
3724 snd_ptr++;
3727 sndvec += MAX_SNDFL_PRD;
3729 Xserialize();
3732 /*ARGSUSED*/
3733 static void
3734 show_sendfilevec64(private_t *pri, int fd, sendfilevec64_t *sndvec, int sfvcnt)
3736 sendfilevec64_t *snd_ptr, snd[MAX_SNDFL_PRD];
3737 size_t cpy_rqst;
3739 #ifdef _LP64
3740 if (data_model != PR_MODEL_LP64) {
3741 show_ksendfilevec64(pri, fd,
3742 (ksendfilevec64_t *)sndvec, sfvcnt);
3743 return;
3745 #endif
3747 Eserialize();
3748 while (sfvcnt > 0) {
3749 cpy_rqst = MIN(sfvcnt, MAX_SNDFL_PRD);
3750 sfvcnt -= cpy_rqst;
3751 cpy_rqst *= sizeof (snd[0]);
3753 if (Pread(Proc, snd, cpy_rqst, (uintptr_t)sndvec) != cpy_rqst)
3754 break;
3756 snd_ptr = &snd[0];
3758 while (cpy_rqst) {
3759 (void) printf(
3760 #ifdef _LP64
3761 "sfv_fd=%d\tsfv_flag=0x%x\t"
3762 "sfv_off=%ld\tsfv_len=%lu\n",
3763 #else
3764 "sfv_fd=%d\tsfv_flag=0x%x\t"
3765 "sfv_off=%lld\tsfv_len=%lu\n",
3766 #endif
3767 snd_ptr->sfv_fd,
3768 snd_ptr->sfv_flag,
3769 snd_ptr->sfv_off,
3770 (ulong_t)snd_ptr->sfv_len);
3772 if (snd_ptr->sfv_fd == SFV_FD_SELF &&
3773 prismember(&writefd, fd)) {
3774 showbuffer(pri, (long)snd_ptr->sfv_off,
3775 (long)snd_ptr->sfv_len);
3778 cpy_rqst -= sizeof (snd[0]);
3779 snd_ptr++;
3782 sndvec += MAX_SNDFL_PRD;
3784 Xserialize();
3787 static void
3788 show_memcntl_mha(private_t *pri, long offset)
3790 struct memcntl_mha mha;
3791 const char *s = NULL;
3793 if (Pread(Proc, &mha, sizeof (mha), offset) == sizeof (mha)) {
3794 switch (mha.mha_cmd) {
3795 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
3796 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
3797 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
3799 if (s)
3800 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
3801 " mha_pagesize=%lu\n",
3802 pri->pname, s, mha.mha_flags,
3803 (ulong_t)mha.mha_pagesize);
3804 else
3805 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
3806 " mha_pagesize=%lu\n",
3807 pri->pname, mha.mha_cmd, mha.mha_flags,
3808 (ulong_t)mha.mha_pagesize);
3812 #ifdef _LP64
3814 static void
3815 show_memcntl_mha32(private_t *pri, long offset)
3817 struct memcntl_mha32 mha32;
3818 const char *s = NULL;
3820 if (Pread(Proc, &mha32, sizeof (mha32), offset) ==
3821 sizeof (mha32)) {
3822 switch (mha32.mha_cmd) {
3823 case MHA_MAPSIZE_VA: s = "MHA_MAPSIZE_VA"; break;
3824 case MHA_MAPSIZE_BSSBRK: s = "MHA_MAPSIZE_BSSBRK"; break;
3825 case MHA_MAPSIZE_STACK: s = "MHA_MAPSIZE_STACK"; break;
3827 if (s)
3828 (void) printf("%s\tmha_cmd=%s mha_flags=0x%x"
3829 " mha_pagesize=%u\n",
3830 pri->pname, s, mha32.mha_flags, mha32.mha_pagesize);
3831 else
3832 (void) printf("%s\tmha_cmd=0x%.8x mha_flags=0x%x"
3833 " mha_pagesize=%u\n",
3834 pri->pname, mha32.mha_cmd, mha32.mha_flags,
3835 mha32.mha_pagesize);
3839 #endif /* _LP64 */
3841 static void
3842 show_memcntl(private_t *pri)
3845 if ((int)pri->sys_args[2] != MC_HAT_ADVISE)
3846 return;
3847 #ifdef _LP64
3848 if (data_model == PR_MODEL_LP64)
3849 show_memcntl_mha(pri, (long)pri->sys_args[3]);
3850 else
3851 show_memcntl_mha32(pri, (long)pri->sys_args[3]);
3852 #else
3853 show_memcntl_mha(pri, (long)pri->sys_args[3]);
3854 #endif
3857 void
3858 show_ids(private_t *pri, long offset, int count)
3860 id_t buf[MYBUFSIZ / sizeof (id_t)];
3861 id_t *idp;
3862 int serial = (count > MYBUFSIZ / 48);
3864 if (offset == 0)
3865 return;
3867 /* enter region of lengthy output */
3868 if (serial)
3869 Eserialize();
3871 while (count > 0 && !interrupt) {
3872 ssize_t nb = (count * sizeof (id_t) < MYBUFSIZ)?
3873 count * sizeof (id_t) : MYBUFSIZ;
3875 if ((nb = Pread(Proc, &buf[0], (size_t)nb, offset)) < 0 ||
3876 nb < sizeof (id_t))
3877 break;
3879 idp = buf;
3880 while (!interrupt && nb >= sizeof (id_t)) {
3881 (void) printf("%s\t%8d\n", pri->pname, (int)*idp);
3882 offset += sizeof (id_t);
3883 nb -= sizeof (id_t);
3884 idp++;
3885 count--;
3889 /* exit region of lengthy output */
3890 if (serial)
3891 Xserialize();
3894 void
3895 show_ntp_gettime(private_t *pri)
3897 struct ntptimeval ntv;
3898 long offset;
3900 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
3901 return;
3903 if (data_model == PR_MODEL_NATIVE) {
3904 if (Pread(Proc, &ntv, sizeof (ntv), offset)
3905 != sizeof (ntv))
3906 return;
3907 } else {
3908 struct ntptimeval32 ntv32;
3910 if (Pread(Proc, &ntv32, sizeof (ntv32), offset)
3911 != sizeof (ntv32))
3912 return;
3914 TIMEVAL32_TO_TIMEVAL(&ntv.time, &ntv32.time);
3915 ntv.maxerror = ntv32.maxerror;
3916 ntv.esterror = ntv32.esterror;
3919 (void) printf("\ttime: %ld.%6.6ld sec\n",
3920 ntv.time.tv_sec, ntv.time.tv_usec);
3921 (void) printf("\tmaxerror: %11d usec\n", ntv.maxerror);
3922 (void) printf("\testerror: %11d usec\n", ntv.esterror);
3925 static char *
3926 get_timex_modes(private_t *pri, uint32_t val)
3928 char *str = pri->code_buf;
3929 size_t used = 0;
3931 *str = '\0';
3932 if (val & MOD_OFFSET)
3933 used = strlcat(str, "|MOD_OFFSET", sizeof (pri->code_buf));
3934 if (val & MOD_FREQUENCY)
3935 used = strlcat(str, "|MOD_FREQUENCY", sizeof (pri->code_buf));
3936 if (val & MOD_MAXERROR)
3937 used = strlcat(str, "|MOD_MAXERROR", sizeof (pri->code_buf));
3938 if (val & MOD_ESTERROR)
3939 used = strlcat(str, "|MOD_ESTERROR", sizeof (pri->code_buf));
3940 if (val & MOD_STATUS)
3941 used = strlcat(str, "|MOD_STATUS", sizeof (pri->code_buf));
3942 if (val & MOD_TIMECONST)
3943 used = strlcat(str, "|MOD_TIMECONST", sizeof (pri->code_buf));
3944 if (val & MOD_CLKB)
3945 used = strlcat(str, "|MOD_CLKB", sizeof (pri->code_buf));
3946 if (val & MOD_CLKA)
3947 used = strlcat(str, "|MOD_CLKA", sizeof (pri->code_buf));
3949 if (used == 0 || used >= sizeof (pri->code_buf))
3950 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
3952 return (str + 1);
3955 static char *
3956 get_timex_status(private_t *pri, int32_t val)
3958 char *str = pri->code_buf;
3959 size_t used = 0;
3961 *str = '\0';
3962 if (val & STA_PLL)
3963 used = strlcat(str, "|STA_PLL", sizeof (pri->code_buf));
3964 if (val & STA_PPSFREQ)
3965 used = strlcat(str, "|STA_PPSFREQ", sizeof (pri->code_buf));
3966 if (val & STA_PPSTIME)
3967 used = strlcat(str, "|STA_PPSTIME", sizeof (pri->code_buf));
3968 if (val & STA_FLL)
3969 used = strlcat(str, "|STA_FLL", sizeof (pri->code_buf));
3971 if (val & STA_INS)
3972 used = strlcat(str, "|STA_INS", sizeof (pri->code_buf));
3973 if (val & STA_DEL)
3974 used = strlcat(str, "|STA_DEL", sizeof (pri->code_buf));
3975 if (val & STA_UNSYNC)
3976 used = strlcat(str, "|STA_UNSYNC", sizeof (pri->code_buf));
3977 if (val & STA_FREQHOLD)
3978 used = strlcat(str, "|STA_FREQHOLD", sizeof (pri->code_buf));
3980 if (val & STA_PPSSIGNAL)
3981 used = strlcat(str, "|STA_PPSSIGNAL", sizeof (pri->code_buf));
3982 if (val & STA_PPSJITTER)
3983 used = strlcat(str, "|STA_PPSJITTER", sizeof (pri->code_buf));
3984 if (val & STA_PPSWANDER)
3985 used = strlcat(str, "|STA_PPSWANDER", sizeof (pri->code_buf));
3986 if (val & STA_PPSERROR)
3987 used = strlcat(str, "|STA_PPSERROR", sizeof (pri->code_buf));
3989 if (val & STA_CLOCKERR)
3990 used = strlcat(str, "|STA_CLOCKERR", sizeof (pri->code_buf));
3992 if (used == 0 || used >= sizeof (pri->code_buf))
3993 (void) snprintf(str, sizeof (pri->code_buf), " 0x%.4x", val);
3995 return (str + 1);
3998 void
3999 show_ntp_adjtime(private_t *pri)
4001 struct timex timex;
4002 long offset;
4004 if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
4005 return;
4007 if (Pread(Proc, &timex, sizeof (timex), offset) != sizeof (timex))
4008 return;
4010 (void) printf("\tmodes: %s\n", get_timex_modes(pri, timex.modes));
4011 (void) printf("\toffset: %11d usec\n", timex.offset);
4012 (void) printf("\tfreq: %11d scaled ppm\n", timex.freq);
4013 (void) printf("\tmaxerror: %11d usec\n", timex.maxerror);
4014 (void) printf("\testerror: %11d usec\n", timex.esterror);
4015 (void) printf("\tstatus: %s\n", get_timex_status(pri, timex.status));
4016 (void) printf("\tconstant: %11d\n", timex.constant);
4017 (void) printf("\tprecision: %11d usec\n", timex.precision);
4018 (void) printf("\ttolerance: %11d scaled ppm\n", timex.tolerance);
4019 (void) printf("\tppsfreq: %11d scaled ppm\n", timex.ppsfreq);
4020 (void) printf("\tjitter: %11d usec\n", timex.jitter);
4021 (void) printf("\tshift: %11d sec\n", timex.shift);
4022 (void) printf("\tstabil: %11d scaled ppm\n", timex.stabil);
4023 (void) printf("\tjitcnt: %11d\n", timex.jitcnt);
4024 (void) printf("\tcalcnt: %11d\n", timex.calcnt);
4025 (void) printf("\terrcnt: %11d\n", timex.errcnt);
4026 (void) printf("\tstbcnt: %11d\n", timex.stbcnt);
4029 void
4030 show_getrusage(long offset)
4032 struct rusage r;
4033 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4034 return;
4035 (void) printf("\t user time: %ld.%6.6ld sec\n",
4036 r.ru_utime.tv_sec,
4037 r.ru_utime.tv_usec);
4038 (void) printf("\t system time: %ld.%6.6ld sec\n",
4039 r.ru_stime.tv_sec,
4040 r.ru_stime.tv_usec);
4041 (void) printf("\t max rss: <unimpl> %ld\n",
4042 r.ru_maxrss);
4043 (void) printf("\t shared data: <unimpl> %ld\n",
4044 r.ru_ixrss);
4045 (void) printf("\t unshared data: <unimpl> %ld\n",
4046 r.ru_idrss);
4047 (void) printf("\t unshared stack: <unimpl> %ld\n",
4048 r.ru_isrss);
4049 (void) printf("\t minor faults: %ld\n",
4050 r.ru_minflt);
4051 (void) printf("\t major faults: %ld\n",
4052 r.ru_majflt);
4053 (void) printf("\t # of swaps: %ld\n",
4054 r.ru_nswap);
4055 (void) printf("\t blocked inputs: %ld\n",
4056 r.ru_inblock);
4057 (void) printf("\t blocked outputs: %ld\n",
4058 r.ru_oublock);
4059 (void) printf("\t msgs sent: %ld\n",
4060 r.ru_msgsnd);
4061 (void) printf("\t msgs rcv'd: %ld\n",
4062 r.ru_msgrcv);
4063 (void) printf("\t signals rcv'd: %ld\n",
4064 r.ru_nsignals);
4065 (void) printf("\tvol cntxt swtchs: %ld\n",
4066 r.ru_nvcsw);
4067 (void) printf("\tinv cntxt swtchs: %ld\n",
4068 r.ru_nivcsw);
4071 #ifdef _LP64
4072 void
4073 show_getrusage32(long offset)
4075 struct rusage32 r;
4076 if (Pread(Proc, &r, sizeof (r), offset) != sizeof (r))
4077 return;
4078 (void) printf("\t user time: %d.%6.6d sec\n",
4079 r.ru_utime.tv_sec,
4080 r.ru_utime.tv_usec);
4081 (void) printf("\t system time: %d.%6.6d sec\n",
4082 r.ru_stime.tv_sec,
4083 r.ru_stime.tv_usec);
4084 (void) printf("\t max rss: <unimpl> %d\n",
4085 r.ru_maxrss);
4086 (void) printf("\t shared data: <unimpl> %d\n",
4087 r.ru_ixrss);
4088 (void) printf("\t unshared data: <unimpl> %d\n",
4089 r.ru_idrss);
4090 (void) printf("\t unshared stack: <unimpl> %d\n",
4091 r.ru_isrss);
4092 (void) printf("\t minor faults: %d\n",
4093 r.ru_minflt);
4094 (void) printf("\t major faults: %d\n",
4095 r.ru_majflt);
4096 (void) printf("\t # of swaps: %d\n",
4097 r.ru_nswap);
4098 (void) printf("\t blocked inputs: %d\n",
4099 r.ru_inblock);
4100 (void) printf("\t blocked outputs: %d\n",
4101 r.ru_oublock);
4102 (void) printf("\t msgs sent: %d\n",
4103 r.ru_msgsnd);
4104 (void) printf("\t msgs rcv'd: %d\n",
4105 r.ru_msgrcv);
4106 (void) printf("\t signals rcv'd: %d\n",
4107 r.ru_nsignals);
4108 (void) printf("\tvol cntxt swtchs: %d\n",
4109 r.ru_nvcsw);
4110 (void) printf("\tinv cntxt swtchs: %d\n",
4111 r.ru_nivcsw);
4113 #endif
4116 * Utility function to print a packed nvlist by unpacking
4117 * and calling the libnvpair pretty printer. Frees all
4118 * allocated memory internally.
4120 static void
4121 show_packed_nvlist(private_t *pri, uintptr_t offset, size_t size)
4123 nvlist_t *nvl = NULL;
4124 size_t readsize;
4125 char *buf;
4127 if ((offset == 0) || (size == 0)) {
4128 return;
4131 buf = my_malloc(size, "nvlist decode buffer");
4132 readsize = Pread(Proc, buf, size, offset);
4133 if (readsize != size) {
4134 (void) printf("%s\t<?>", pri->pname);
4135 } else {
4136 int result;
4138 result = nvlist_unpack(buf, size, &nvl, 0);
4139 if (result == 0) {
4140 dump_nvlist(nvl, 8);
4141 nvlist_free(nvl);
4142 } else {
4143 (void) printf("%s\tunpack of nvlist"
4144 " failed: %d\n", pri->pname, result);
4147 free(buf);
4150 static void
4151 show_zone_create_args(private_t *pri, long offset)
4153 zone_def args;
4154 char zone_name[ZONENAME_MAX];
4155 char zone_root[MAXPATHLEN];
4156 char *zone_zfs = NULL;
4158 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4160 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4161 (uintptr_t)args.zone_name) == -1)
4162 (void) strcpy(zone_name, "<?>");
4164 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4165 (uintptr_t)args.zone_root) == -1)
4166 (void) strcpy(zone_root, "<?>");
4168 if (args.zfsbufsz > 0) {
4169 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4170 if (zone_zfs != NULL) {
4171 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4172 (uintptr_t)args.zfsbuf) == -1)
4173 (void) strcpy(zone_zfs, "<?>");
4175 } else {
4176 zone_zfs = "";
4179 (void) printf("%s\t zone_name: %s\n", pri->pname,
4180 zone_name);
4181 (void) printf("%s\t zone_root: %s\n", pri->pname,
4182 zone_root);
4184 show_privset(pri, (uintptr_t)args.zone_privs,
4185 args.zone_privssz, " zone_privs: ");
4187 (void) printf("%s\t rctlbuf: 0x%p\n", pri->pname,
4188 (void *)args.rctlbuf);
4189 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4190 (ulong_t)args.rctlbufsz);
4192 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4193 args.rctlbufsz);
4195 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4197 (void) printf("%s\textended_error: 0x%p\n", pri->pname,
4198 (void *)args.extended_error);
4200 if (args.zfsbufsz > 0)
4201 free(zone_zfs);
4206 #ifdef _LP64
4208 static void
4209 show_zone_create_args32(private_t *pri, long offset)
4211 zone_def32 args;
4212 char zone_name[ZONENAME_MAX];
4213 char zone_root[MAXPATHLEN];
4214 char *zone_zfs = NULL;
4216 if (Pread(Proc, &args, sizeof (args), offset) == sizeof (args)) {
4218 if (Pread_string(Proc, zone_name, sizeof (zone_name),
4219 (uintptr_t)args.zone_name) == -1)
4220 (void) strcpy(zone_name, "<?>");
4222 if (Pread_string(Proc, zone_root, sizeof (zone_root),
4223 (uintptr_t)args.zone_root) == -1)
4224 (void) strcpy(zone_root, "<?>");
4226 if (args.zfsbufsz > 0) {
4227 zone_zfs = malloc(MIN(4, args.zfsbufsz));
4228 if (zone_zfs != NULL) {
4229 if (Pread(Proc, zone_zfs, args.zfsbufsz,
4230 (uintptr_t)args.zfsbuf) == -1)
4231 (void) strcpy(zone_zfs, "<?>");
4233 } else {
4234 zone_zfs = "";
4237 (void) printf("%s\t zone_name: %s\n", pri->pname,
4238 zone_name);
4239 (void) printf("%s\t zone_root: %s\n", pri->pname,
4240 zone_root);
4242 show_privset(pri, (uintptr_t)args.zone_privs,
4243 args.zone_privssz, " zone_privs: ");
4245 (void) printf("%s\t rctlbuf: 0x%x\n", pri->pname,
4246 (caddr32_t)args.rctlbuf);
4247 (void) printf("%s\t rctlbufsz: %lu\n", pri->pname,
4248 (ulong_t)args.rctlbufsz);
4250 show_packed_nvlist(pri, (uintptr_t)args.rctlbuf,
4251 args.rctlbufsz);
4253 (void) printf("%s\t zfs: %s\n", pri->pname, zone_zfs);
4255 (void) printf("%s\textended_error: 0x%x\n", pri->pname,
4256 (caddr32_t)args.extended_error);
4258 if (args.zfsbufsz > 0)
4259 free(zone_zfs);
4263 #endif
4265 static void
4266 show_zones(private_t *pri)
4268 switch (pri->sys_args[0]) {
4269 case ZONE_CREATE:
4270 #ifdef _LP64
4271 if (data_model == PR_MODEL_LP64)
4272 show_zone_create_args(pri, (long)pri->sys_args[1]);
4273 else
4274 show_zone_create_args32(pri, (long)pri->sys_args[1]);
4275 #else
4276 show_zone_create_args(pri, (long)pri->sys_args[1]);
4277 #endif
4278 break;
4282 static void
4283 show_rctlblk(private_t *pri, long _rctlblk)
4285 rctlblk_t *blk;
4286 int size = rctlblk_size();
4287 size_t readsize;
4288 const char *s;
4290 blk = my_malloc(size, "rctlblk decode buffer");
4291 readsize = Pread(Proc, blk, size, _rctlblk);
4292 if (readsize != size) {
4293 (void) printf("%s\t\t<?>", pri->pname);
4294 } else {
4295 (void) printf("%s\t\t Privilege: 0x%x\n",
4296 pri->pname,
4297 rctlblk_get_privilege(blk));
4298 (void) printf("%s\t\t Value: %lld\n",
4299 pri->pname,
4300 rctlblk_get_value(blk));
4301 (void) printf("%s\t\tEnforced Value: %lld\n",
4302 pri->pname,
4303 rctlblk_get_enforced_value(blk));
4306 int sig, act;
4307 act = rctlblk_get_local_action(blk, &sig);
4309 s = rctl_local_action(pri, act);
4310 if (s == NULL) {
4311 (void) printf("%s\t\t Local action: 0x%x\n",
4312 pri->pname, act);
4313 } else {
4314 (void) printf("%s\t\t Local action: %s\n",
4315 pri->pname, s);
4318 if (act & RCTL_LOCAL_SIGNAL) {
4319 (void) printf("%s\t\t "
4320 "For signal %s\n",
4321 pri->pname, signame(pri, sig));
4325 s = rctl_local_flags(pri, rctlblk_get_local_flags(blk));
4326 if (s == NULL) {
4327 (void) printf("%s\t\t Local flags: 0x%x\n",
4328 pri->pname, rctlblk_get_local_flags(blk));
4329 } else {
4330 (void) printf("%s\t\t Local flags: %s\n",
4331 pri->pname, s);
4334 #ifdef _LP64
4335 (void) printf("%s\t\t Recipient PID: %d\n",
4336 pri->pname,
4337 rctlblk_get_recipient_pid(blk));
4338 #else
4339 (void) printf("%s\t\t Recipient PID: %ld\n",
4340 pri->pname,
4341 rctlblk_get_recipient_pid(blk));
4342 #endif
4343 (void) printf("%s\t\t Firing Time: %lld\n",
4344 pri->pname,
4345 rctlblk_get_firing_time(blk));
4347 free(blk);
4350 static void
4351 show_rctls(private_t *pri)
4353 int entry;
4355 switch (pri->sys_args[0]) {
4356 case 0: /* getrctl */
4357 case 1: /* setrctl */
4359 * If these offsets look a little odd, remember that they're
4360 * into the _raw_ system call
4362 (void) printf("%s\tOld rctlblk: 0x%lx\n", pri->pname,
4363 pri->sys_args[2]);
4364 if (pri->sys_args[2] != 0) {
4365 show_rctlblk(pri, pri->sys_args[2]);
4367 (void) printf("%s\tNew rctlblk: 0x%lx\n", pri->pname,
4368 pri->sys_args[3]);
4369 if (pri->sys_args[3] != 0) {
4370 show_rctlblk(pri, pri->sys_args[3]);
4372 break;
4373 case 4: /* setprojrctl */
4374 for (entry = 0; entry < pri->sys_args[4]; entry++) {
4375 (void) printf("%s\tNew rctlblk[%d]: 0x%lx\n",
4376 pri->pname, entry,
4377 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4378 if (RCTLBLK_INC(pri->sys_args[3], entry) != NULL) {
4379 show_rctlblk(pri,
4380 (long)RCTLBLK_INC(pri->sys_args[3], entry));
4386 void
4387 show_utimesys(private_t *pri)
4389 switch (pri->sys_args[0]) {
4390 case 0: /* futimens() */
4391 if (pri->sys_nargs > 2)
4392 show_utimens(pri, (long)pri->sys_args[2]);
4393 break;
4394 case 1: /* utimensat */
4395 if (pri->sys_nargs > 3)
4396 show_utimens(pri, (long)pri->sys_args[3]);
4397 break;
4398 default: /* unexpected subcode */
4399 break;
4403 #ifdef _LP64
4404 static void
4405 show_sockconfig_filter_prop32(private_t *pri, long addr)
4407 struct sockconfig_filter_props32 props;
4408 const char *s = NULL;
4409 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4410 sof_socktuple32_t *tup;
4411 size_t sz;
4412 int i;
4414 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4415 if (Pread_string(Proc, buf, sizeof (buf),
4416 (uintptr_t)props.sfp_modname) == -1)
4417 (void) strcpy(buf, "<?>");
4418 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4419 (void) printf("%s\tattach semantics: %s", pri->pname,
4420 props.sfp_autoattach ? "automatic" : "progammatic");
4421 if (props.sfp_autoattach) {
4422 buf[0] = '\0';
4423 switch (props.sfp_hint) {
4424 case SOF_HINT_TOP: s = "top"; break;
4425 case SOF_HINT_BOTTOM: s = "bottom"; break;
4426 case SOF_HINT_BEFORE:
4427 case SOF_HINT_AFTER:
4428 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4429 "before" : "after";
4430 if (Pread_string(Proc, buf, sizeof (buf),
4431 (uintptr_t)props.sfp_hintarg) == -1)
4432 (void) strcpy(buf, "<?>");
4434 if (s != NULL) {
4435 (void) printf(", placement: %s %s", s, buf);
4438 (void) printf("\n");
4439 (void) printf("%s\tsocket tuples:\n", pri->pname);
4440 if (props.sfp_socktuple_cnt == 0) {
4441 (void) printf("\t\t<empty>\n");
4442 return;
4444 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4445 tup = my_malloc(sz, "socket tuple buffer");
4446 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4447 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4448 (void) printf(
4449 "\t\tfamily: %d, type: %d, proto: %d\n",
4450 tup[i].sofst_family, tup[i].sofst_type,
4451 tup[i].sofst_protocol);
4455 #endif /* _LP64 */
4456 static void
4457 show_sockconfig_filter_prop(private_t *pri, long addr)
4459 struct sockconfig_filter_props props;
4460 const char *s = NULL;
4461 char buf[MAX(FILNAME_MAX, MODMAXNAMELEN)];
4462 sof_socktuple_t *tup;
4463 size_t sz;
4464 int i;
4466 if (Pread(Proc, &props, sizeof (props), addr) == sizeof (props)) {
4467 if (Pread_string(Proc, buf, sizeof (buf),
4468 (uintptr_t)props.sfp_modname) == -1)
4469 (void) strcpy(buf, "<?>");
4470 (void) printf("%s\tmodule name: %s\n", pri->pname, buf);
4471 (void) printf("%s\tattach semantics: %s", pri->pname,
4472 props.sfp_autoattach ? "automatic" : "progammatic");
4473 if (props.sfp_autoattach) {
4474 buf[0] = '\0';
4475 switch (props.sfp_hint) {
4476 case SOF_HINT_TOP: s = "top"; break;
4477 case SOF_HINT_BOTTOM: s = "bottom"; break;
4478 case SOF_HINT_BEFORE:
4479 case SOF_HINT_AFTER:
4480 s = (props.sfp_hint == SOF_HINT_BEFORE) ?
4481 "before" : "after";
4482 if (Pread_string(Proc, buf, sizeof (buf),
4483 (uintptr_t)props.sfp_hintarg) == -1)
4484 (void) strcpy(buf, "<?>");
4486 if (s != NULL) {
4487 (void) printf(", placement: %s", s);
4490 (void) printf("\n");
4491 (void) printf("%s\tsocket tuples:\n", pri->pname);
4492 if (props.sfp_socktuple_cnt == 0) {
4493 (void) printf("\t\t<empty>\n");
4494 return;
4496 sz = props.sfp_socktuple_cnt * sizeof (*tup);
4497 tup = my_malloc(sz, "socket tuple buffer");
4498 if (Pread(Proc, tup, sz, (uintptr_t)props.sfp_socktuple) == sz)
4499 for (i = 0; i < props.sfp_socktuple_cnt; i++) {
4500 (void) printf(
4501 "\t\tfamily: %d, type: %d, proto: %d\n",
4502 tup[i].sofst_family, tup[i].sofst_type,
4503 tup[i].sofst_protocol);
4508 void
4509 show_sockconfig(private_t *pri)
4511 switch (pri->sys_args[0]) {
4512 case SOCKCONFIG_ADD_FILTER:
4513 #ifdef _LP64
4514 if (data_model == PR_MODEL_LP64)
4515 show_sockconfig_filter_prop(pri,
4516 (long)pri->sys_args[2]);
4517 else
4518 show_sockconfig_filter_prop32(pri,
4519 (long)pri->sys_args[2]);
4520 #else
4521 show_sockconfig_filter_prop(pri, (long)pri->sys_args[2]);
4522 #endif
4523 break;
4524 default:
4525 break;
4529 void
4530 show_zfs_ioc(private_t *pri, long addr)
4532 static const zfs_share_t zero_share = {0};
4533 static const dmu_objset_stats_t zero_objstats = {0};
4534 static const struct drr_begin zero_drrbegin = {0};
4535 static const zinject_record_t zero_injectrec = {0};
4536 static const zfs_stat_t zero_zstat = {0};
4537 zfs_cmd_t zc;
4539 if (Pread(Proc, &zc, sizeof (zc), addr) != sizeof (zc)) {
4540 (void) printf(" zfs_ioctl read failed\n");
4541 return;
4544 if (zc.zc_name[0])
4545 (void) printf(" zc_name=%s\n", zc.zc_name);
4546 if (zc.zc_value[0])
4547 (void) printf(" zc_value=%s\n", zc.zc_value);
4548 if (zc.zc_string[0])
4549 (void) printf(" zc_string=%s\n", zc.zc_string);
4550 if (zc.zc_guid != 0) {
4551 (void) printf(" zc_guid=%llu\n",
4552 (u_longlong_t)zc.zc_guid);
4554 if (zc.zc_nvlist_conf_size) {
4555 (void) printf(" nvlist_conf:\n");
4556 show_packed_nvlist(pri, zc.zc_nvlist_conf,
4557 zc.zc_nvlist_conf_size);
4559 if (zc.zc_nvlist_src_size) {
4560 (void) printf(" nvlist_src:\n");
4561 show_packed_nvlist(pri, zc.zc_nvlist_src,
4562 zc.zc_nvlist_src_size);
4564 if (zc.zc_nvlist_dst_size) {
4565 (void) printf(" nvlist_dst:\n");
4566 show_packed_nvlist(pri, zc.zc_nvlist_dst,
4567 zc.zc_nvlist_dst_size);
4569 if (zc.zc_cookie != 0) {
4570 (void) printf(" zc_cookie=%llu\n",
4571 (u_longlong_t)zc.zc_cookie);
4573 if (zc.zc_objset_type != 0) {
4574 (void) printf(" zc_objset_type=%llu\n",
4575 (u_longlong_t)zc.zc_objset_type);
4577 if (zc.zc_perm_action != 0) {
4578 (void) printf(" zc_perm_action=%llu\n",
4579 (u_longlong_t)zc.zc_perm_action);
4581 if (zc.zc_history != 0) {
4582 (void) printf(" zc_history=%llu\n",
4583 (u_longlong_t)zc.zc_history);
4585 if (zc.zc_obj != 0) {
4586 (void) printf(" zc_obj=%llu\n",
4587 (u_longlong_t)zc.zc_obj);
4589 if (zc.zc_iflags != 0) {
4590 (void) printf(" zc_obj=0x%llx\n",
4591 (u_longlong_t)zc.zc_iflags);
4594 if (memcmp(&zc.zc_share, &zero_share, sizeof (zc.zc_share))) {
4595 zfs_share_t *z = &zc.zc_share;
4596 (void) printf(" zc_share:\n");
4597 if (z->z_exportdata) {
4598 (void) printf("\tz_exportdata=0x%llx\n",
4599 (u_longlong_t)z->z_exportdata);
4601 if (z->z_sharedata) {
4602 (void) printf("\tz_sharedata=0x%llx\n",
4603 (u_longlong_t)z->z_sharedata);
4605 if (z->z_sharetype) {
4606 (void) printf("\tz_sharetype=%llu\n",
4607 (u_longlong_t)z->z_sharetype);
4609 if (z->z_sharemax) {
4610 (void) printf("\tz_sharemax=%llu\n",
4611 (u_longlong_t)z->z_sharemax);
4615 if (memcmp(&zc.zc_objset_stats, &zero_objstats,
4616 sizeof (zc.zc_objset_stats))) {
4617 dmu_objset_stats_t *dds = &zc.zc_objset_stats;
4618 (void) printf(" zc_objset_stats:\n");
4619 if (dds->dds_num_clones) {
4620 (void) printf("\tdds_num_clones=%llu\n",
4621 (u_longlong_t)dds->dds_num_clones);
4623 if (dds->dds_creation_txg) {
4624 (void) printf("\tdds_creation_txg=%llu\n",
4625 (u_longlong_t)dds->dds_creation_txg);
4627 if (dds->dds_guid) {
4628 (void) printf("\tdds_guid=%llu\n",
4629 (u_longlong_t)dds->dds_guid);
4631 if (dds->dds_type)
4632 (void) printf("\tdds_type=%u\n", dds->dds_type);
4633 if (dds->dds_is_snapshot) {
4634 (void) printf("\tdds_is_snapshot=%u\n",
4635 dds->dds_is_snapshot);
4637 if (dds->dds_inconsistent) {
4638 (void) printf("\tdds_inconsitent=%u\n",
4639 dds->dds_inconsistent);
4641 if (dds->dds_origin[0]) {
4642 (void) printf("\tdds_origin=%s\n", dds->dds_origin);
4646 if (memcmp(&zc.zc_begin_record, &zero_drrbegin,
4647 sizeof (zc.zc_begin_record))) {
4648 struct drr_begin *drr = &zc.zc_begin_record.drr_u.drr_begin;
4649 (void) printf(" zc_begin_record:\n");
4650 if (drr->drr_magic) {
4651 (void) printf("\tdrr_magic=%llu\n",
4652 (u_longlong_t)drr->drr_magic);
4654 if (drr->drr_versioninfo) {
4655 (void) printf("\tdrr_versioninfo=%llu\n",
4656 (u_longlong_t)drr->drr_versioninfo);
4658 if (drr->drr_creation_time) {
4659 (void) printf("\tdrr_creation_time=%llu\n",
4660 (u_longlong_t)drr->drr_creation_time);
4662 if (drr->drr_type)
4663 (void) printf("\tdrr_type=%u\n", drr->drr_type);
4664 if (drr->drr_flags)
4665 (void) printf("\tdrr_flags=0x%x\n", drr->drr_flags);
4666 if (drr->drr_toguid) {
4667 (void) printf("\tdrr_toguid=%llu\n",
4668 (u_longlong_t)drr->drr_toguid);
4670 if (drr->drr_fromguid) {
4671 (void) printf("\tdrr_fromguid=%llu\n",
4672 (u_longlong_t)drr->drr_fromguid);
4674 if (drr->drr_toname[0]) {
4675 (void) printf("\tdrr_toname=%s\n", drr->drr_toname);
4679 if (memcmp(&zc.zc_inject_record, &zero_injectrec,
4680 sizeof (zc.zc_inject_record))) {
4681 zinject_record_t *zi = &zc.zc_inject_record;
4682 (void) printf(" zc_inject_record:\n");
4683 if (zi->zi_objset) {
4684 (void) printf("\tzi_objset=%llu\n",
4685 (u_longlong_t)zi->zi_objset);
4687 if (zi->zi_object) {
4688 (void) printf("\tzi_object=%llu\n",
4689 (u_longlong_t)zi->zi_object);
4691 if (zi->zi_start) {
4692 (void) printf("\tzi_start=%llu\n",
4693 (u_longlong_t)zi->zi_start);
4695 if (zi->zi_end) {
4696 (void) printf("\tzi_end=%llu\n",
4697 (u_longlong_t)zi->zi_end);
4699 if (zi->zi_guid) {
4700 (void) printf("\tzi_guid=%llu\n",
4701 (u_longlong_t)zi->zi_guid);
4703 if (zi->zi_level) {
4704 (void) printf("\tzi_level=%lu\n",
4705 (ulong_t)zi->zi_level);
4707 if (zi->zi_error) {
4708 (void) printf("\tzi_error=%lu\n",
4709 (ulong_t)zi->zi_error);
4711 if (zi->zi_type) {
4712 (void) printf("\tzi_type=%llu\n",
4713 (u_longlong_t)zi->zi_type);
4715 if (zi->zi_freq) {
4716 (void) printf("\tzi_freq=%lu\n",
4717 (ulong_t)zi->zi_freq);
4719 if (zi->zi_failfast) {
4720 (void) printf("\tzi_failfast=%lu\n",
4721 (ulong_t)zi->zi_failfast);
4723 if (zi->zi_func[0])
4724 (void) printf("\tzi_func=%s\n", zi->zi_func);
4725 if (zi->zi_iotype) {
4726 (void) printf("\tzi_iotype=%lu\n",
4727 (ulong_t)zi->zi_iotype);
4729 if (zi->zi_duration) {
4730 (void) printf("\tzi_duration=%ld\n",
4731 (long)zi->zi_duration);
4733 if (zi->zi_timer) {
4734 (void) printf("\tzi_timer=%llu\n",
4735 (u_longlong_t)zi->zi_timer);
4739 if (zc.zc_defer_destroy) {
4740 (void) printf(" zc_defer_destroy=%d\n",
4741 (int)zc.zc_defer_destroy);
4743 if (zc.zc_flags) {
4744 (void) printf(" zc_flags=0x%x\n",
4745 zc.zc_flags);
4747 if (zc.zc_action_handle) {
4748 (void) printf(" zc_action_handle=%llu\n",
4749 (u_longlong_t)zc.zc_action_handle);
4751 if (zc.zc_cleanup_fd >= 0)
4752 (void) printf(" zc_cleanup_fd=%d\n", zc.zc_cleanup_fd);
4753 if (zc.zc_sendobj) {
4754 (void) printf(" zc_sendobj=%llu\n",
4755 (u_longlong_t)zc.zc_sendobj);
4757 if (zc.zc_fromobj) {
4758 (void) printf(" zc_fromobj=%llu\n",
4759 (u_longlong_t)zc.zc_fromobj);
4761 if (zc.zc_createtxg) {
4762 (void) printf(" zc_createtxg=%llu\n",
4763 (u_longlong_t)zc.zc_createtxg);
4766 if (memcmp(&zc.zc_stat, &zero_zstat, sizeof (zc.zc_stat))) {
4767 zfs_stat_t *zs = &zc.zc_stat;
4768 (void) printf(" zc_stat:\n");
4769 if (zs->zs_gen) {
4770 (void) printf("\tzs_gen=%llu\n",
4771 (u_longlong_t)zs->zs_gen);
4773 if (zs->zs_mode) {
4774 (void) printf("\tzs_mode=%llu\n",
4775 (u_longlong_t)zs->zs_mode);
4777 if (zs->zs_links) {
4778 (void) printf("\tzs_links=%llu\n",
4779 (u_longlong_t)zs->zs_links);
4781 if (zs->zs_ctime[0]) {
4782 (void) printf("\tzs_ctime[0]=%llu\n",
4783 (u_longlong_t)zs->zs_ctime[0]);
4785 if (zs->zs_ctime[1]) {
4786 (void) printf("\tzs_ctime[1]=%llu\n",
4787 (u_longlong_t)zs->zs_ctime[1]);
4792 /* expound verbosely upon syscall arguments */
4793 /*ARGSUSED*/
4794 void
4795 expound(private_t *pri, long r0, int raw)
4797 const lwpstatus_t *Lsp = pri->lwpstat;
4798 int lp64 = (data_model == PR_MODEL_LP64);
4799 int what = Lsp->pr_what;
4800 int err = pri->Errno; /* don't display output parameters */
4801 /* for a failed system call */
4802 #ifndef _LP64
4803 /* We are a 32-bit truss; we can't grok a 64-bit process */
4804 if (lp64)
4805 return;
4806 #endif
4807 /* for reporting sleeping system calls */
4808 if (what == 0 && (Lsp->pr_flags & (PR_ASLEEP|PR_VFORKP)))
4809 what = Lsp->pr_syscall;
4811 switch (what) {
4812 case SYS_gettimeofday:
4813 if (!err)
4814 show_timeofday(pri);
4815 break;
4816 case SYS_getitimer:
4817 if (!err && pri->sys_nargs > 1)
4818 show_itimerval(pri, (long)pri->sys_args[1],
4819 " value");
4820 break;
4821 case SYS_setitimer:
4822 if (pri->sys_nargs > 1)
4823 show_itimerval(pri, (long)pri->sys_args[1],
4824 " value");
4825 if (!err && pri->sys_nargs > 2)
4826 show_itimerval(pri, (long)pri->sys_args[2],
4827 "ovalue");
4828 break;
4829 case SYS_stime:
4830 show_stime(pri);
4831 break;
4832 case SYS_times:
4833 if (!err)
4834 show_times(pri);
4835 break;
4836 case SYS_utssys:
4837 if (err)
4838 break;
4839 #ifdef _LP64
4840 if (lp64)
4841 show_utssys(pri, r0);
4842 else
4843 show_utssys32(pri, r0);
4844 #else
4845 show_utssys(pri, r0);
4846 #endif
4847 break;
4848 case SYS_ioctl:
4849 if (pri->sys_nargs >= 3) /* each case must decide for itself */
4850 show_ioctl(pri, pri->sys_args[1],
4851 (long)pri->sys_args[2]);
4852 break;
4853 case SYS_fstatat:
4854 if (!err && pri->sys_nargs >= 3)
4855 show_stat(pri, (long)pri->sys_args[2]);
4856 break;
4857 case SYS_stat:
4858 case SYS_fstat:
4859 case SYS_lstat:
4860 if (!err && pri->sys_nargs >= 2)
4861 show_stat(pri, (long)pri->sys_args[1]);
4862 break;
4863 case SYS_statvfs:
4864 case SYS_fstatvfs:
4865 if (err)
4866 break;
4867 show_statvfs(pri);
4868 break;
4869 case SYS_statfs:
4870 case SYS_fstatfs:
4871 if (err)
4872 break;
4873 show_statfs(pri);
4874 break;
4875 case SYS_fcntl:
4876 show_fcntl(pri);
4877 break;
4878 case SYS_msgsys:
4879 show_msgsys(pri, r0); /* each case must decide for itself */
4880 break;
4881 case SYS_semsys:
4882 show_semsys(pri); /* each case must decide for itself */
4883 break;
4884 case SYS_shmsys:
4885 show_shmsys(pri); /* each case must decide for itself */
4886 break;
4887 case SYS_getdents:
4888 if (err || pri->sys_nargs <= 1 || r0 <= 0)
4889 break;
4890 show_dents(pri, (long)pri->sys_args[1], r0);
4891 break;
4892 case SYS_getmsg:
4893 show_gp_msg(pri, what);
4894 if (pri->sys_nargs > 3)
4895 show_hhex_int(pri, (long)pri->sys_args[3], "flags");
4896 break;
4897 case SYS_getpmsg:
4898 show_gp_msg(pri, what);
4899 if (pri->sys_nargs > 3)
4900 show_hhex_int(pri, (long)pri->sys_args[3], "band");
4901 if (pri->sys_nargs > 4)
4902 show_hhex_int(pri, (long)pri->sys_args[4], "flags");
4903 break;
4904 case SYS_putmsg:
4905 case SYS_putpmsg:
4906 show_gp_msg(pri, what);
4907 break;
4908 case SYS_pollsys:
4909 show_pollsys(pri);
4910 break;
4911 case SYS_setgroups:
4912 if (pri->sys_nargs > 1 && (r0 = pri->sys_args[0]) > 0)
4913 show_groups(pri, (long)pri->sys_args[1], r0);
4914 break;
4915 case SYS_getgroups:
4916 if (!err && pri->sys_nargs > 1 && pri->sys_args[0] > 0)
4917 show_groups(pri, (long)pri->sys_args[1], r0);
4918 break;
4919 case SYS_sigprocmask:
4920 if (pri->sys_nargs > 1)
4921 show_sigset(pri, (long)pri->sys_args[1], " set");
4922 if (!err && pri->sys_nargs > 2)
4923 show_sigset(pri, (long)pri->sys_args[2], "oset");
4924 break;
4925 case SYS_sigsuspend:
4926 case SYS_sigtimedwait:
4927 if (pri->sys_nargs > 0)
4928 show_sigset(pri, (long)pri->sys_args[0], "sigmask");
4929 if (!err && pri->sys_nargs > 1)
4930 show_siginfo(pri, (long)pri->sys_args[1]);
4931 if (pri->sys_nargs > 2)
4932 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
4933 break;
4934 case SYS_sigaltstack:
4935 if (pri->sys_nargs > 0)
4936 show_sigaltstack(pri, (long)pri->sys_args[0],
4937 "new");
4938 if (!err && pri->sys_nargs > 1)
4939 show_sigaltstack(pri, (long)pri->sys_args[1],
4940 "old");
4941 break;
4942 case SYS_sigaction:
4943 if (pri->sys_nargs > 1)
4944 show_sigaction(pri, (long)pri->sys_args[1],
4945 "new", 0);
4946 if (!err && pri->sys_nargs > 2)
4947 show_sigaction(pri, (long)pri->sys_args[2],
4948 "old", r0);
4949 break;
4950 case SYS_signotify:
4951 if (pri->sys_nargs > 1)
4952 show_siginfo(pri, (long)pri->sys_args[1]);
4953 break;
4954 case SYS_sigresend:
4955 if (pri->sys_nargs > 1)
4956 show_siginfo(pri, (long)pri->sys_args[1]);
4957 if (pri->sys_nargs > 2)
4958 show_sigset(pri, (long)pri->sys_args[2], "sigmask");
4959 break;
4960 case SYS_sigpending:
4961 if (!err && pri->sys_nargs > 1)
4962 show_sigset(pri, (long)pri->sys_args[1], "sigmask");
4963 break;
4964 case SYS_waitid:
4965 if (!err && pri->sys_nargs > 2)
4966 show_siginfo(pri, (long)pri->sys_args[2]);
4967 break;
4968 case SYS_sigsendsys:
4969 if (pri->sys_nargs > 0)
4970 show_procset(pri, (long)pri->sys_args[0]);
4971 break;
4972 case SYS_priocntlsys:
4973 if (pri->sys_nargs > 1)
4974 show_procset(pri, (long)pri->sys_args[1]);
4975 break;
4976 case SYS_mincore:
4977 if (!err && pri->sys_nargs > 2)
4978 show_bool(pri, (long)pri->sys_args[2],
4979 (pri->sys_args[1] + pagesize - 1) / pagesize);
4980 break;
4981 case SYS_readv:
4982 case SYS_writev:
4983 if (pri->sys_nargs > 2) {
4984 int i = pri->sys_args[0]+1;
4985 int showbuf = FALSE;
4986 long nb = (what == SYS_readv)? r0 : 32*1024;
4988 if ((what == SYS_readv && !err &&
4989 prismember(&readfd, i)) ||
4990 (what == SYS_writev &&
4991 prismember(&writefd, i)))
4992 showbuf = TRUE;
4993 show_iovec(pri, (long)pri->sys_args[1],
4994 pri->sys_args[2], showbuf, nb);
4996 break;
4997 case SYS_getrlimit:
4998 if (err)
4999 break;
5000 /*FALLTHROUGH*/
5001 case SYS_setrlimit:
5002 if (pri->sys_nargs <= 1)
5003 break;
5004 show_rlimit(pri, (long)pri->sys_args[1]);
5005 case SYS_uname:
5006 if (!err && pri->sys_nargs > 0)
5007 show_uname(pri, (long)pri->sys_args[0]);
5008 break;
5009 case SYS_adjtime:
5010 if (!err && pri->sys_nargs > 1)
5011 show_adjtime(pri, (long)pri->sys_args[0],
5012 (long)pri->sys_args[1]);
5013 break;
5014 case SYS_lwp_info:
5015 if (!err && pri->sys_nargs > 0)
5016 show_timestruc(pri, (long)pri->sys_args[0], "cpu time");
5017 break;
5018 case SYS_lwp_wait:
5019 if (!err && pri->sys_nargs > 1)
5020 show_int(pri, (long)pri->sys_args[1], "lwpid");
5021 break;
5022 case SYS_lwp_mutex_wakeup:
5023 case SYS_lwp_mutex_unlock:
5024 case SYS_lwp_mutex_trylock:
5025 case SYS_lwp_mutex_register:
5026 if (pri->sys_nargs > 0)
5027 show_mutex(pri, (long)pri->sys_args[0]);
5028 break;
5029 case SYS_lwp_mutex_timedlock:
5030 if (pri->sys_nargs > 0)
5031 show_mutex(pri, (long)pri->sys_args[0]);
5032 if (pri->sys_nargs > 1)
5033 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5034 break;
5035 case SYS_lwp_cond_wait:
5036 if (pri->sys_nargs > 0)
5037 show_condvar(pri, (long)pri->sys_args[0]);
5038 if (pri->sys_nargs > 1)
5039 show_mutex(pri, (long)pri->sys_args[1]);
5040 if (pri->sys_nargs > 2)
5041 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5042 break;
5043 case SYS_lwp_cond_signal:
5044 case SYS_lwp_cond_broadcast:
5045 if (pri->sys_nargs > 0)
5046 show_condvar(pri, (long)pri->sys_args[0]);
5047 break;
5048 case SYS_lwp_sema_trywait:
5049 case SYS_lwp_sema_post:
5050 if (pri->sys_nargs > 0)
5051 show_sema(pri, (long)pri->sys_args[0]);
5052 break;
5053 case SYS_lwp_sema_timedwait:
5054 if (pri->sys_nargs > 0)
5055 show_sema(pri, (long)pri->sys_args[0]);
5056 if (pri->sys_nargs > 1)
5057 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5058 break;
5059 case SYS_lwp_rwlock_sys:
5060 if (pri->sys_nargs > 1)
5061 show_rwlock(pri, (long)pri->sys_args[1]);
5062 if (pri->sys_nargs > 2 &&
5063 (pri->sys_args[0] == 0 || pri->sys_args[0] == 1))
5064 show_timestruc(pri, (long)pri->sys_args[2], "timeout");
5065 break;
5066 case SYS_lwp_create:
5067 /* XXX print some values in ucontext ??? */
5068 if (!err && pri->sys_nargs > 2)
5069 show_int(pri, (long)pri->sys_args[2], "lwpid");
5070 break;
5071 case SYS_kaio:
5072 if (pri->sys_args[0] == AIOWAIT && !err && pri->sys_nargs > 1)
5073 show_timeval(pri, (long)pri->sys_args[1], "timeout");
5074 break;
5075 case SYS_nanosleep:
5076 if (pri->sys_nargs > 0)
5077 show_timestruc(pri, (long)pri->sys_args[0], "tmout");
5078 if (pri->sys_nargs > 1 && (err == 0 || err == EINTR))
5079 show_timestruc(pri, (long)pri->sys_args[1], "resid");
5080 break;
5081 case SYS_privsys:
5082 switch (pri->sys_args[0]) {
5083 case PRIVSYS_SETPPRIV:
5084 case PRIVSYS_GETPPRIV:
5085 if (!err)
5086 show_privset(pri, (long)pri->sys_args[3],
5087 (size_t)pri->sys_args[4], "");
5089 break;
5090 case SYS_ucredsys:
5091 switch (pri->sys_args[0]) {
5092 case UCREDSYS_UCREDGET:
5093 case UCREDSYS_GETPEERUCRED:
5094 if (err == 0)
5095 show_ucred(pri, (long)pri->sys_args[2]);
5096 break;
5098 break;
5099 case SYS_bind:
5100 case SYS_connect:
5101 if (pri->sys_nargs > 2)
5102 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5103 0, (long)pri->sys_args[2]);
5104 break;
5105 case SYS_sendto:
5106 if (pri->sys_nargs > 5)
5107 show_sockaddr(pri, "to", (long)pri->sys_args[4], 0,
5108 pri->sys_args[5]);
5109 break;
5110 case SYS_accept:
5111 if (!err && pri->sys_nargs > 2)
5112 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5113 (long)pri->sys_args[2], 0);
5114 break;
5115 case SYS_getsockname:
5116 case SYS_getpeername:
5117 if (!err && pri->sys_nargs > 2)
5118 show_sockaddr(pri, "name", (long)pri->sys_args[1],
5119 (long)pri->sys_args[2], 0);
5120 break;
5121 case SYS_recvfrom:
5122 if (!err && pri->sys_nargs > 5)
5123 show_sockaddr(pri, "from", (long)pri->sys_args[4],
5124 (long)pri->sys_args[5], 0);
5125 break;
5126 case SYS_recvmsg:
5127 if (err)
5128 break;
5129 /* FALLTHROUGH */
5130 case SYS_sendmsg:
5131 if (pri->sys_nargs <= 2)
5132 break;
5133 #ifdef _LP64
5134 if (lp64)
5135 show_msghdr(pri, pri->sys_args[1]);
5136 else
5137 show_msghdr32(pri, pri->sys_args[1]);
5138 #else
5139 show_msghdr(pri, pri->sys_args[1]);
5140 #endif
5141 break;
5142 case SYS_door:
5143 show_doors(pri);
5144 break;
5145 case SYS_sendfilev:
5146 if (pri->sys_nargs != 5)
5147 break;
5149 if (pri->sys_args[0] == SENDFILEV) {
5150 show_sendfilevec(pri, (int)pri->sys_args[1],
5151 (sendfilevec_t *)pri->sys_args[2],
5152 (int)pri->sys_args[3]);
5153 } else if (pri->sys_args[0] == SENDFILEV64) {
5154 show_sendfilevec64(pri, (int)pri->sys_args[1],
5155 (sendfilevec64_t *)pri->sys_args[2],
5156 (int)pri->sys_args[3]);
5158 break;
5159 case SYS_memcntl:
5160 show_memcntl(pri);
5161 break;
5162 case SYS_lwp_park:
5164 * subcode 0: lwp_park(timespec_t *, id_t)
5165 * subcode 4: lwp_set_park(timespec_t *, id_t)
5167 if (pri->sys_nargs > 1 &&
5168 (pri->sys_args[0] == 0 || pri->sys_args[0] == 4))
5169 show_timestruc(pri, (long)pri->sys_args[1], "timeout");
5170 /* subcode 2: lwp_unpark_all(id_t *, int) */
5171 if (pri->sys_nargs > 2 && pri->sys_args[0] == 2)
5172 show_ids(pri, (long)pri->sys_args[1],
5173 (int)pri->sys_args[2]);
5174 break;
5175 case SYS_ntp_gettime:
5176 if (!err)
5177 show_ntp_gettime(pri);
5178 break;
5179 case SYS_ntp_adjtime:
5180 if (!err)
5181 show_ntp_adjtime(pri);
5182 break;
5183 case SYS_rusagesys:
5184 if (!err)
5185 if (pri->sys_args[0] == _RUSAGESYS_GETRUSAGE) {
5186 #ifdef _LP64
5187 if (!lp64)
5188 show_getrusage32(pri->sys_args[1]);
5189 else
5190 #endif
5191 show_getrusage(pri->sys_args[1]);
5193 break;
5194 case SYS_port:
5195 show_ports(pri);
5196 break;
5197 case SYS_zone:
5198 show_zones(pri);
5199 break;
5200 case SYS_rctlsys:
5201 show_rctls(pri);
5202 break;
5203 case SYS_utimesys:
5204 show_utimesys(pri);
5205 break;
5206 case SYS_sockconfig:
5207 show_sockconfig(pri);
5208 break;