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