| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dump.c,v 1.42 2012/07/17 14:39:08 njoly Exp $ */ | | 1 | /* $NetBSD: dump.c,v 1.43 2018/06/03 13:41:30 kamil Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1988, 1993 | | 4 | * Copyright (c) 1988, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | __COPYRIGHT("@(#) Copyright (c) 1988, 1993\ | | 34 | __COPYRIGHT("@(#) Copyright (c) 1988, 1993\ |
35 | The Regents of the University of California. All rights reserved."); | | 35 | The Regents of the University of California. All rights reserved."); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95"; | | 40 | static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95"; |
41 | #endif | | 41 | #endif |
42 | __RCSID("$NetBSD: dump.c,v 1.42 2012/07/17 14:39:08 njoly Exp $"); | | 42 | __RCSID("$NetBSD: dump.c,v 1.43 2018/06/03 13:41:30 kamil Exp $"); |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #define _KERNEL | | 46 | #define _KERNEL |
47 | #include <sys/errno.h> | | 47 | #include <sys/errno.h> |
48 | #undef _KERNEL | | 48 | #undef _KERNEL |
49 | #include <sys/ioctl.h> | | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | | 50 | #include <sys/time.h> |
51 | #include <sys/uio.h> | | 51 | #include <sys/uio.h> |
52 | #include <sys/ktrace.h> | | 52 | #include <sys/ktrace.h> |
53 | #include <sys/ptrace.h> | | 53 | #include <sys/ptrace.h> |
54 | #include <sys/queue.h> | | 54 | #include <sys/queue.h> |
55 | | | 55 | |
| @@ -102,31 +102,31 @@ void ktrcsw(struct ktr_entry *); | | | @@ -102,31 +102,31 @@ void ktrcsw(struct ktr_entry *); |
102 | void ktremul(struct ktr_entry *); | | 102 | void ktremul(struct ktr_entry *); |
103 | void ktrgenio(struct ktr_entry *); | | 103 | void ktrgenio(struct ktr_entry *); |
104 | void ktrnamei(struct ktr_entry *); | | 104 | void ktrnamei(struct ktr_entry *); |
105 | void ktrpsig(struct ktr_entry *); | | 105 | void ktrpsig(struct ktr_entry *); |
106 | void ktrsyscall(struct ktr_entry *); | | 106 | void ktrsyscall(struct ktr_entry *); |
107 | void ktrsysret(struct ktr_entry *); | | 107 | void ktrsysret(struct ktr_entry *); |
108 | void nameiargprint(const char *, struct ktr_header *, register_t **, int *); | | 108 | void nameiargprint(const char *, struct ktr_header *, register_t **, int *); |
109 | void nameiprint(struct ktr_header *); | | 109 | void nameiprint(struct ktr_header *); |
110 | void newline(void); | | 110 | void newline(void); |
111 | void putpendq(struct ktr_entry *); | | 111 | void putpendq(struct ktr_entry *); |
112 | void syscallnameprint(int); | | 112 | void syscallnameprint(int); |
113 | void syscallprint(struct ktr_header *); | | 113 | void syscallprint(struct ktr_header *); |
114 | void sysretprint(struct ktr_header *); | | 114 | void sysretprint(struct ktr_header *); |
115 | int wprintf(const char *, ...) __printflike(1, 2); | | 115 | int xwprintf(const char *, ...) __printflike(1, 2); |
116 | void *xrealloc(void *, size_t *, size_t); | | 116 | void *xrealloc(void *, size_t *, size_t); |
117 | | | 117 | |
118 | int | | 118 | int |
119 | wprintf(const char *fmt, ...) | | 119 | xwprintf(const char *fmt, ...) |
120 | { | | 120 | { |
121 | va_list ap; | | 121 | va_list ap; |
122 | int w; | | 122 | int w; |
123 | | | 123 | |
124 | va_start(ap, fmt); | | 124 | va_start(ap, fmt); |
125 | w = vprintf(fmt, ap); | | 125 | w = vprintf(fmt, ap); |
126 | if (w == -1) | | 126 | if (w == -1) |
127 | warn("vprintf"); | | 127 | warn("vprintf"); |
128 | else | | 128 | else |
129 | width += w; | | 129 | width += w; |
130 | va_end(ap); | | 130 | va_end(ap); |
131 | return (w); | | 131 | return (w); |
132 | } | | 132 | } |
| @@ -136,27 +136,27 @@ newline(void) | | | @@ -136,27 +136,27 @@ newline(void) |
136 | { | | 136 | { |
137 | | | 137 | |
138 | if (width > 0) { | | 138 | if (width > 0) { |
139 | printf("\n"); | | 139 | printf("\n"); |
140 | width = 0; | | 140 | width = 0; |
141 | } | | 141 | } |
142 | } | | 142 | } |
143 | | | 143 | |
144 | void | | 144 | void |
145 | indent(int col) | | 145 | indent(int col) |
146 | { | | 146 | { |
147 | | | 147 | |
148 | while (width < col) | | 148 | while (width < col) |
149 | if (wprintf(" ") < 0) | | 149 | if (xwprintf(" ") < 0) |
150 | break; | | 150 | break; |
151 | } | | 151 | } |
152 | | | 152 | |
153 | void * | | 153 | void * |
154 | xrealloc(void *p, size_t *siz, size_t req) | | 154 | xrealloc(void *p, size_t *siz, size_t req) |
155 | { | | 155 | { |
156 | | | 156 | |
157 | if (*siz < req) { | | 157 | if (*siz < req) { |
158 | if (*siz == 0) | | 158 | if (*siz == 0) |
159 | *siz = 1; | | 159 | *siz = 1; |
160 | while (*siz < req) | | 160 | while (*siz < req) |
161 | *siz <<= 1; | | 161 | *siz <<= 1; |
162 | p = realloc(p, *siz); | | 162 | p = realloc(p, *siz); |
| @@ -340,30 +340,30 @@ fread_tail(void *buf, int size, int num, | | | @@ -340,30 +340,30 @@ fread_tail(void *buf, int size, int num, |
340 | } | | 340 | } |
341 | | | 341 | |
342 | void | | 342 | void |
343 | dumpheader(struct ktr_header *kth) | | 343 | dumpheader(struct ktr_header *kth) |
344 | { | | 344 | { |
345 | union timeholder { | | 345 | union timeholder { |
346 | struct timeval tv; | | 346 | struct timeval tv; |
347 | struct timespec ts; | | 347 | struct timespec ts; |
348 | }; | | 348 | }; |
349 | static union timeholder prevtime; | | 349 | static union timeholder prevtime; |
350 | union timeholder temp; | | 350 | union timeholder temp; |
351 | | | 351 | |
352 | temp.tv.tv_sec = temp.tv.tv_usec = 0; | | 352 | temp.tv.tv_sec = temp.tv.tv_usec = 0; |
353 | wprintf("%6d ", kth->ktr_pid); | | 353 | xwprintf("%6d ", kth->ktr_pid); |
354 | if (kth->ktr_version > KTRFAC_VERSION(KTRFACv0)) | | 354 | if (kth->ktr_version > KTRFAC_VERSION(KTRFACv0)) |
355 | wprintf("%6d ", kth->ktr_lid); | | 355 | xwprintf("%6d ", kth->ktr_lid); |
356 | wprintf("%-8.*s ", MAXCOMLEN, kth->ktr_comm); | | 356 | xwprintf("%-8.*s ", MAXCOMLEN, kth->ktr_comm); |
357 | if (timestamp) { | | 357 | if (timestamp) { |
358 | if (timestamp == 2) { | | 358 | if (timestamp == 2) { |
359 | switch (kth->ktr_version) { | | 359 | switch (kth->ktr_version) { |
360 | case KTRFAC_VERSION(KTRFACv0): | | 360 | case KTRFAC_VERSION(KTRFACv0): |
361 | if (prevtime.tv.tv_sec == 0) | | 361 | if (prevtime.tv.tv_sec == 0) |
362 | temp.tv.tv_sec = temp.tv.tv_usec = 0; | | 362 | temp.tv.tv_sec = temp.tv.tv_usec = 0; |
363 | else | | 363 | else |
364 | timersub(&kth->ktr_otv, | | 364 | timersub(&kth->ktr_otv, |
365 | &prevtime.tv, &temp.tv); | | 365 | &prevtime.tv, &temp.tv); |
366 | prevtime.tv.tv_sec = kth->ktr_otv.tv_sec; | | 366 | prevtime.tv.tv_sec = kth->ktr_otv.tv_sec; |
367 | prevtime.tv.tv_usec = kth->ktr_otv.tv_usec; | | 367 | prevtime.tv.tv_usec = kth->ktr_otv.tv_usec; |
368 | break; | | 368 | break; |
369 | | | 369 | |
| @@ -394,115 +394,115 @@ dumpheader(struct ktr_header *kth) | | | @@ -394,115 +394,115 @@ dumpheader(struct ktr_header *kth) |
394 | temp.tv.tv_usec = kth->ktr_otv.tv_usec; | | 394 | temp.tv.tv_usec = kth->ktr_otv.tv_usec; |
395 | break; | | 395 | break; |
396 | case KTRFAC_VERSION(KTRFACv1): | | 396 | case KTRFAC_VERSION(KTRFACv1): |
397 | temp.ts.tv_sec = kth->ktr_ots.tv_sec; | | 397 | temp.ts.tv_sec = kth->ktr_ots.tv_sec; |
398 | temp.ts.tv_nsec = kth->ktr_ots.tv_nsec; | | 398 | temp.ts.tv_nsec = kth->ktr_ots.tv_nsec; |
399 | break; | | 399 | break; |
400 | case KTRFAC_VERSION(KTRFACv2): | | 400 | case KTRFAC_VERSION(KTRFACv2): |
401 | temp.ts.tv_sec = kth->ktr_ts.tv_sec; | | 401 | temp.ts.tv_sec = kth->ktr_ts.tv_sec; |
402 | temp.ts.tv_nsec = kth->ktr_ts.tv_nsec; | | 402 | temp.ts.tv_nsec = kth->ktr_ts.tv_nsec; |
403 | break; | | 403 | break; |
404 | } | | 404 | } |
405 | } | | 405 | } |
406 | if (kth->ktr_version == KTRFAC_VERSION(KTRFACv0)) | | 406 | if (kth->ktr_version == KTRFAC_VERSION(KTRFACv0)) |
407 | wprintf("%lld.%06ld ", | | 407 | xwprintf("%lld.%06ld ", |
408 | (long long)temp.tv.tv_sec, (long)temp.tv.tv_usec); | | 408 | (long long)temp.tv.tv_sec, (long)temp.tv.tv_usec); |
409 | else | | 409 | else |
410 | wprintf("%lld.%09ld ", | | 410 | xwprintf("%lld.%09ld ", |
411 | (long long)temp.ts.tv_sec, (long)temp.ts.tv_nsec); | | 411 | (long long)temp.ts.tv_sec, (long)temp.ts.tv_nsec); |
412 | } | | 412 | } |
413 | } | | 413 | } |
414 | | | 414 | |
415 | void | | 415 | void |
416 | ioctldecode(u_long cmd) | | 416 | ioctldecode(u_long cmd) |
417 | { | | 417 | { |
418 | char dirbuf[4], *dir = dirbuf; | | 418 | char dirbuf[4], *dir = dirbuf; |
419 | | | 419 | |
420 | if (cmd & IOC_OUT) | | 420 | if (cmd & IOC_OUT) |
421 | *dir++ = 'W'; | | 421 | *dir++ = 'W'; |
422 | if (cmd & IOC_IN) | | 422 | if (cmd & IOC_IN) |
423 | *dir++ = 'R'; | | 423 | *dir++ = 'R'; |
424 | *dir = '\0'; | | 424 | *dir = '\0'; |
425 | | | 425 | |
426 | wprintf(decimal ? ", _IO%s('%c',%ld" : ", _IO%s('%c',%#lx", | | 426 | xwprintf(decimal ? ", _IO%s('%c',%ld" : ", _IO%s('%c',%#lx", |
427 | dirbuf, (int) ((cmd >> 8) & 0xff), cmd & 0xff); | | 427 | dirbuf, (int) ((cmd >> 8) & 0xff), cmd & 0xff); |
428 | if ((cmd & IOC_VOID) == 0) | | 428 | if ((cmd & IOC_VOID) == 0) |
429 | wprintf(decimal ? ",%ld)" : ",%#lx)", | | 429 | xwprintf(decimal ? ",%ld)" : ",%#lx)", |
430 | (cmd >> 16) & 0xff); | | 430 | (cmd >> 16) & 0xff); |
431 | else | | 431 | else |
432 | wprintf(")"); | | 432 | xwprintf(")"); |
433 | } | | 433 | } |
434 | | | 434 | |
435 | void | | 435 | void |
436 | nameiargprint(const char *prefix, struct ktr_header *kth, | | 436 | nameiargprint(const char *prefix, struct ktr_header *kth, |
437 | register_t **ap, int *argsize) | | 437 | register_t **ap, int *argsize) |
438 | { | | 438 | { |
439 | struct ktr_entry *kte; | | 439 | struct ktr_entry *kte; |
440 | | | 440 | |
441 | if (*argsize == 0) | | 441 | if (*argsize == 0) |
442 | errx(EXIT_FAILURE, "argument expected"); | | 442 | errx(EXIT_FAILURE, "argument expected"); |
443 | /* | | 443 | /* |
444 | * XXX: binary emulation mode. | | 444 | * XXX: binary emulation mode. |
445 | */ | | 445 | */ |
446 | kte = getpendq(kth, KTR_NAMEI, NULL); | | 446 | kte = getpendq(kth, KTR_NAMEI, NULL); |
447 | if (kte == NULL) | | 447 | if (kte == NULL) |
448 | argprint(prefix, ap, argsize); | | 448 | argprint(prefix, ap, argsize); |
449 | else { | | 449 | else { |
450 | wprintf("%s", prefix); | | 450 | xwprintf("%s", prefix); |
451 | nameiprint(&kte->kte_kth); | | 451 | nameiprint(&kte->kte_kth); |
452 | free(kte); | | 452 | free(kte); |
453 | (*ap)++; | | 453 | (*ap)++; |
454 | *argsize -= sizeof(register_t); | | 454 | *argsize -= sizeof(register_t); |
455 | } | | 455 | } |
456 | } | | 456 | } |
457 | | | 457 | |
458 | void | | 458 | void |
459 | syscallnameprint(int code) | | 459 | syscallnameprint(int code) |
460 | { | | 460 | { |
461 | | | 461 | |
462 | if (code >= cur_emul->nsysnames || code < 0) | | 462 | if (code >= cur_emul->nsysnames || code < 0) |
463 | wprintf("[%d]", code); | | 463 | xwprintf("[%d]", code); |
464 | else | | 464 | else |
465 | wprintf("%s", cur_emul->sysnames[code]); | | 465 | xwprintf("%s", cur_emul->sysnames[code]); |
466 | } | | 466 | } |
467 | | | 467 | |
468 | void | | 468 | void |
469 | argprint(const char *prefix, register_t **ap, int *argsize) | | 469 | argprint(const char *prefix, register_t **ap, int *argsize) |
470 | { | | 470 | { |
471 | | | 471 | |
472 | if (decimal) | | 472 | if (decimal) |
473 | wprintf("%s%ld", prefix, (long)**ap); | | 473 | xwprintf("%s%ld", prefix, (long)**ap); |
474 | else | | 474 | else |
475 | wprintf("%s%#lx", prefix, (long)**ap); | | 475 | xwprintf("%s%#lx", prefix, (long)**ap); |
476 | (*ap)++; | | 476 | (*ap)++; |
477 | *argsize -= sizeof(register_t); | | 477 | *argsize -= sizeof(register_t); |
478 | } | | 478 | } |
479 | | | 479 | |
480 | void | | 480 | void |
481 | syscallprint(struct ktr_header *kth) | | 481 | syscallprint(struct ktr_header *kth) |
482 | { | | 482 | { |
483 | struct ktr_syscall *ktr = (struct ktr_syscall *)(kth + 1); | | 483 | struct ktr_syscall *ktr = (struct ktr_syscall *)(kth + 1); |
484 | register_t *ap; | | 484 | register_t *ap; |
485 | const char *s; | | 485 | const char *s; |
486 | int argsize; | | 486 | int argsize; |
487 | | | 487 | |
488 | syscallnameprint(ktr->ktr_code); | | 488 | syscallnameprint(ktr->ktr_code); |
489 | | | 489 | |
490 | /* | | 490 | /* |
491 | * Arguments processing. | | 491 | * Arguments processing. |
492 | */ | | 492 | */ |
493 | argsize = ktr->ktr_argsize; | | 493 | argsize = ktr->ktr_argsize; |
494 | if (argsize == 0) { | | 494 | if (argsize == 0) { |
495 | wprintf("("); | | 495 | xwprintf("("); |
496 | goto noargument; | | 496 | goto noargument; |
497 | } | | 497 | } |
498 | | | 498 | |
499 | ap = (register_t *)(ktr + 1); | | 499 | ap = (register_t *)(ktr + 1); |
500 | if (!fancy) | | 500 | if (!fancy) |
501 | goto print_first; | | 501 | goto print_first; |
502 | | | 502 | |
503 | switch (ktr->ktr_code) { | | 503 | switch (ktr->ktr_code) { |
504 | /* | | 504 | /* |
505 | * All these have a path as the first param. | | 505 | * All these have a path as the first param. |
506 | * The order is same as syscalls.master. | | 506 | * The order is same as syscalls.master. |
507 | */ | | 507 | */ |
508 | case SYS_open: | | 508 | case SYS_open: |
| @@ -548,63 +548,63 @@ syscallprint(struct ktr_header *kth) | | | @@ -548,63 +548,63 @@ syscallprint(struct ktr_header *kth) |
548 | /* | | 548 | /* |
549 | * 2nd argument is also pathname. | | 549 | * 2nd argument is also pathname. |
550 | */ | | 550 | */ |
551 | switch (ktr->ktr_code) { | | 551 | switch (ktr->ktr_code) { |
552 | case SYS_link: | | 552 | case SYS_link: |
553 | case SYS_rename: | | 553 | case SYS_rename: |
554 | case SYS___posix_rename: | | 554 | case SYS___posix_rename: |
555 | nameiargprint(", ", kth, &ap, &argsize); | | 555 | nameiargprint(", ", kth, &ap, &argsize); |
556 | break; | | 556 | break; |
557 | } | | 557 | } |
558 | break; | | 558 | break; |
559 | | | 559 | |
560 | case SYS_compat_16___sigaction14 : | | 560 | case SYS_compat_16___sigaction14 : |
561 | wprintf("(%s", signals[(int)*ap].name); | | 561 | xwprintf("(%s", signals[(int)*ap].name); |
562 | ap++; | | 562 | ap++; |
563 | argsize -= sizeof(register_t); | | 563 | argsize -= sizeof(register_t); |
564 | break; | | 564 | break; |
565 | | | 565 | |
566 | case SYS_ioctl : | | 566 | case SYS_ioctl : |
567 | argprint("(", &ap, &argsize); | | 567 | argprint("(", &ap, &argsize); |
568 | if ((s = ioctlname(*ap)) != NULL) | | 568 | if ((s = ioctlname(*ap)) != NULL) |
569 | wprintf(", %s", s); | | 569 | xwprintf(", %s", s); |
570 | else | | 570 | else |
571 | ioctldecode(*ap); | | 571 | ioctldecode(*ap); |
572 | ap++; | | 572 | ap++; |
573 | argsize -= sizeof(register_t); | | 573 | argsize -= sizeof(register_t); |
574 | break; | | 574 | break; |
575 | | | 575 | |
576 | case SYS_ptrace : | | 576 | case SYS_ptrace : |
577 | if ((long)*ap >= 0 && | | 577 | if ((long)*ap >= 0 && |
578 | *ap < (register_t)(sizeof(ptrace_ops) / sizeof(ptrace_ops[0]))) | | 578 | *ap < (register_t)(sizeof(ptrace_ops) / sizeof(ptrace_ops[0]))) |
579 | wprintf("(%s", ptrace_ops[*ap]); | | 579 | xwprintf("(%s", ptrace_ops[*ap]); |
580 | else | | 580 | else |
581 | wprintf("(%ld", (long)*ap); | | 581 | xwprintf("(%ld", (long)*ap); |
582 | ap++; | | 582 | ap++; |
583 | argsize -= sizeof(register_t); | | 583 | argsize -= sizeof(register_t); |
584 | break; | | 584 | break; |
585 | | | 585 | |
586 | default: | | 586 | default: |
587 | print_first: | | 587 | print_first: |
588 | argprint("(", &ap, &argsize); | | 588 | argprint("(", &ap, &argsize); |
589 | break; | | 589 | break; |
590 | } | | 590 | } |
591 | | | 591 | |
592 | /* Print rest of argument. */ | | 592 | /* Print rest of argument. */ |
593 | while (argsize > 0) | | 593 | while (argsize > 0) |
594 | argprint(", ", &ap, &argsize); | | 594 | argprint(", ", &ap, &argsize); |
595 | | | 595 | |
596 | noargument: | | 596 | noargument: |
597 | wprintf(")"); | | 597 | xwprintf(")"); |
598 | } | | 598 | } |
599 | | | 599 | |
600 | void | | 600 | void |
601 | ktrsyscall(struct ktr_entry *kte) | | 601 | ktrsyscall(struct ktr_entry *kte) |
602 | { | | 602 | { |
603 | struct ktr_header *kth = &kte->kte_kth; | | 603 | struct ktr_header *kth = &kte->kte_kth; |
604 | struct ktr_syscall *ktr = (struct ktr_syscall *)(kth + 1); | | 604 | struct ktr_syscall *ktr = (struct ktr_syscall *)(kth + 1); |
605 | | | 605 | |
606 | switch (ktr->ktr_code) { | | 606 | switch (ktr->ktr_code) { |
607 | case SYS_exit: | | 607 | case SYS_exit: |
608 | dumpheader(kth); | | 608 | dumpheader(kth); |
609 | syscallprint(kth); | | 609 | syscallprint(kth); |
610 | break; | | 610 | break; |
| @@ -615,44 +615,44 @@ ktrsyscall(struct ktr_entry *kte) | | | @@ -615,44 +615,44 @@ ktrsyscall(struct ktr_entry *kte) |
615 | | | 615 | |
616 | free(kte); | | 616 | free(kte); |
617 | } | | 617 | } |
618 | | | 618 | |
619 | void | | 619 | void |
620 | sysretprint(struct ktr_header *kth) | | 620 | sysretprint(struct ktr_header *kth) |
621 | { | | 621 | { |
622 | struct ktr_sysret *ktr = (struct ktr_sysret *)(kth + 1); | | 622 | struct ktr_sysret *ktr = (struct ktr_sysret *)(kth + 1); |
623 | register_t ret = ktr->ktr_retval; | | 623 | register_t ret = ktr->ktr_retval; |
624 | int error = ktr->ktr_error; | | 624 | int error = ktr->ktr_error; |
625 | | | 625 | |
626 | indent(50); | | 626 | indent(50); |
627 | if (error == EJUSTRETURN) | | 627 | if (error == EJUSTRETURN) |
628 | wprintf(" JUSTRETURN"); | | 628 | xwprintf(" JUSTRETURN"); |
629 | else if (error == ERESTART) | | 629 | else if (error == ERESTART) |
630 | wprintf(" RESTART"); | | 630 | xwprintf(" RESTART"); |
631 | else if (error) { | | 631 | else if (error) { |
632 | wprintf(" Err#%d", error); | | 632 | xwprintf(" Err#%d", error); |
633 | if (error < MAXERRNOS && error >= -2) | | 633 | if (error < MAXERRNOS && error >= -2) |
634 | wprintf(" %s", errnos[error].name); | | 634 | xwprintf(" %s", errnos[error].name); |
635 | } else | | 635 | } else |
636 | switch (ktr->ktr_code) { | | 636 | switch (ktr->ktr_code) { |
637 | case SYS_mremap: | | 637 | case SYS_mremap: |
638 | case SYS_mmap: | | 638 | case SYS_mmap: |
639 | wprintf(" = %p", (void *)(intptr_t)ret); | | 639 | xwprintf(" = %p", (void *)(intptr_t)ret); |
640 | break; | | 640 | break; |
641 | default: | | 641 | default: |
642 | wprintf(" = %ld", (long)ret); | | 642 | xwprintf(" = %ld", (long)ret); |
643 | if (kth->ktr_len > (int)offsetof(struct ktr_sysret, | | 643 | if (kth->ktr_len > (int)offsetof(struct ktr_sysret, |
644 | ktr_retval_1) && ktr->ktr_retval_1 != 0) | | 644 | ktr_retval_1) && ktr->ktr_retval_1 != 0) |
645 | wprintf(", %ld", (long)ktr->ktr_retval_1); | | 645 | xwprintf(", %ld", (long)ktr->ktr_retval_1); |
646 | break; | | 646 | break; |
647 | } | | 647 | } |
648 | } | | 648 | } |
649 | | | 649 | |
650 | void | | 650 | void |
651 | ktrsysret(struct ktr_entry *kte) | | 651 | ktrsysret(struct ktr_entry *kte) |
652 | { | | 652 | { |
653 | struct ktr_header *kth = &kte->kte_kth; | | 653 | struct ktr_header *kth = &kte->kte_kth; |
654 | struct ktr_sysret *ktr = (struct ktr_sysret *)(kth + 1); | | 654 | struct ktr_sysret *ktr = (struct ktr_sysret *)(kth + 1); |
655 | struct ktr_entry *emul; | | 655 | struct ktr_entry *emul; |
656 | struct ktr_entry *genio; | | 656 | struct ktr_entry *genio; |
657 | struct ktr_entry *syscall_ent; | | 657 | struct ktr_entry *syscall_ent; |
658 | | | 658 | |
| @@ -684,52 +684,52 @@ ktrsysret(struct ktr_entry *kte) | | | @@ -684,52 +684,52 @@ ktrsysret(struct ktr_entry *kte) |
684 | if (emul != NULL) { | | 684 | if (emul != NULL) { |
685 | newline(); | | 685 | newline(); |
686 | ktremul(emul); | | 686 | ktremul(emul); |
687 | } | | 687 | } |
688 | | | 688 | |
689 | flushpendq(kte); | | 689 | flushpendq(kte); |
690 | free(kte); | | 690 | free(kte); |
691 | } | | 691 | } |
692 | | | 692 | |
693 | void | | 693 | void |
694 | nameiprint(struct ktr_header *kth) | | 694 | nameiprint(struct ktr_header *kth) |
695 | { | | 695 | { |
696 | | | 696 | |
697 | wprintf("\"%.*s\"", kth->ktr_len, (char *)(kth + 1)); | | 697 | xwprintf("\"%.*s\"", kth->ktr_len, (char *)(kth + 1)); |
698 | } | | 698 | } |
699 | | | 699 | |
700 | #ifdef notused | | 700 | #ifdef notused |
701 | void | | 701 | void |
702 | ktrnamei(struct ktr_entry *kte) | | 702 | ktrnamei(struct ktr_entry *kte) |
703 | { | | 703 | { |
704 | struct ktr_header *kth = &kte->kte_kth; | | 704 | struct ktr_header *kth = &kte->kte_kth; |
705 | | | 705 | |
706 | dumpheader(kth); | | 706 | dumpheader(kth); |
707 | wprintf("namei("); | | 707 | xwprintf("namei("); |
708 | nameiprint(kth); | | 708 | nameiprint(kth); |
709 | wprintf(")"); | | 709 | xwprintf(")"); |
710 | | | 710 | |
711 | free(kte); | | 711 | free(kte); |
712 | } | | 712 | } |
713 | #endif | | 713 | #endif |
714 | | | 714 | |
715 | void | | 715 | void |
716 | ktremul(struct ktr_entry *kte) | | 716 | ktremul(struct ktr_entry *kte) |
717 | { | | 717 | { |
718 | struct ktr_header *kth = &kte->kte_kth; | | 718 | struct ktr_header *kth = &kte->kte_kth; |
719 | char *emul = (char *)(kth + 1); | | 719 | char *emul = (char *)(kth + 1); |
720 | | | 720 | |
721 | dumpheader(kth); | | 721 | dumpheader(kth); |
722 | wprintf("emul(%s)", emul); | | 722 | xwprintf("emul(%s)", emul); |
723 | setemul(emul, kth->ktr_pid, 1); | | 723 | setemul(emul, kth->ktr_pid, 1); |
724 | | | 724 | |
725 | free(kte); | | 725 | free(kte); |
726 | } | | 726 | } |
727 | | | 727 | |
728 | void | | 728 | void |
729 | genioprint(struct ktr_header *kth) | | 729 | genioprint(struct ktr_header *kth) |
730 | { | | 730 | { |
731 | struct ktr_genio *ktr = (struct ktr_genio *)(kth + 1); | | 731 | struct ktr_genio *ktr = (struct ktr_genio *)(kth + 1); |
732 | static int screenwidth = 0; | | 732 | static int screenwidth = 0; |
733 | int datalen = kth->ktr_len - sizeof(struct ktr_genio); | | 733 | int datalen = kth->ktr_len - sizeof(struct ktr_genio); |
734 | /* | | 734 | /* |
735 | * Need to be unsigned type so that positive value is passed | | 735 | * Need to be unsigned type so that positive value is passed |
| @@ -742,76 +742,76 @@ genioprint(struct ktr_header *kth) | | | @@ -742,76 +742,76 @@ genioprint(struct ktr_header *kth) |
742 | if (screenwidth == 0) { | | 742 | if (screenwidth == 0) { |
743 | struct winsize ws; | | 743 | struct winsize ws; |
744 | | | 744 | |
745 | if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 && | | 745 | if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 && |
746 | ws.ws_col > 8) | | 746 | ws.ws_col > 8) |
747 | screenwidth = ws.ws_col; | | 747 | screenwidth = ws.ws_col; |
748 | else | | 748 | else |
749 | screenwidth = 80; | | 749 | screenwidth = 80; |
750 | } | | 750 | } |
751 | | | 751 | |
752 | if (maxdata && datalen > maxdata) | | 752 | if (maxdata && datalen > maxdata) |
753 | datalen = maxdata; | | 753 | datalen = maxdata; |
754 | newline(); | | 754 | newline(); |
755 | wprintf(" \""); | | 755 | xwprintf(" \""); |
756 | for (; datalen > 0; datalen--, dp++) { | | 756 | for (; datalen > 0; datalen--, dp++) { |
757 | (void) vis(visbuf, *dp, VIS_NL|VIS_TAB|VIS_CSTYLE, | | 757 | (void) vis(visbuf, *dp, VIS_NL|VIS_TAB|VIS_CSTYLE, |
758 | /* We put NUL at the end of buffer when reading */ | | 758 | /* We put NUL at the end of buffer when reading */ |
759 | *(dp + 1)); | | 759 | *(dp + 1)); |
760 | visbuf[4] = '\0'; | | 760 | visbuf[4] = '\0'; |
761 | w = strlen(visbuf); | | 761 | w = strlen(visbuf); |
762 | if (width + w + 2 >= screenwidth) | | 762 | if (width + w + 2 >= screenwidth) |
763 | break; | | 763 | break; |
764 | wprintf("%s", visbuf); | | 764 | xwprintf("%s", visbuf); |
765 | if (width + 2 >= screenwidth) | | 765 | if (width + 2 >= screenwidth) |
766 | break; | | 766 | break; |
767 | } | | 767 | } |
768 | wprintf("\""); | | 768 | xwprintf("\""); |
769 | } | | 769 | } |
770 | | | 770 | |
771 | #ifdef notused | | 771 | #ifdef notused |
772 | void | | 772 | void |
773 | ktrgenio(struct ktr_entry *kte) | | 773 | ktrgenio(struct ktr_entry *kte) |
774 | { | | 774 | { |
775 | struct ktr_header *kth = &kte->kte_kth; | | 775 | struct ktr_header *kth = &kte->kte_kth; |
776 | struct ktr_genio *ktr = (struct ktr_genio *)(kth + 1); | | 776 | struct ktr_genio *ktr = (struct ktr_genio *)(kth + 1); |
777 | | | 777 | |
778 | dumpheader(kth); | | 778 | dumpheader(kth); |
779 | wprintf("genio fd %d %s", | | 779 | xwprintf("genio fd %d %s", |
780 | ktr->ktr_fd, ktr->ktr_rw ? "write" : "read"); | | 780 | ktr->ktr_fd, ktr->ktr_rw ? "write" : "read"); |
781 | genioprint(kth); | | 781 | genioprint(kth); |
782 | | | 782 | |
783 | free(kte); | | 783 | free(kte); |
784 | } | | 784 | } |
785 | #endif | | 785 | #endif |
786 | | | 786 | |
787 | void | | 787 | void |
788 | ktrpsig(struct ktr_entry *kte) | | 788 | ktrpsig(struct ktr_entry *kte) |
789 | { | | 789 | { |
790 | struct ktr_header *kth = &kte->kte_kth; | | 790 | struct ktr_header *kth = &kte->kte_kth; |
791 | struct ktr_psig *psig = (struct ktr_psig *)(kth + 1); | | 791 | struct ktr_psig *psig = (struct ktr_psig *)(kth + 1); |
792 | | | 792 | |
793 | dumpheader(kth); | | 793 | dumpheader(kth); |
794 | wprintf("SIG%s ", sys_signame[psig->signo]); | | 794 | xwprintf("SIG%s ", sys_signame[psig->signo]); |
795 | if (psig->action == SIG_DFL) | | 795 | if (psig->action == SIG_DFL) |
796 | wprintf("SIG_DFL"); | | 796 | xwprintf("SIG_DFL"); |
797 | else { | | 797 | else { |
798 | wprintf("caught handler=0x%lx mask=0x%lx code=0x%x", | | 798 | xwprintf("caught handler=0x%lx mask=0x%lx code=0x%x", |
799 | (u_long)psig->action, (unsigned long)psig->mask.__bits[0], | | 799 | (u_long)psig->action, (unsigned long)psig->mask.__bits[0], |
800 | psig->code); | | 800 | psig->code); |
801 | } | | 801 | } |
802 | | | 802 | |
803 | free(kte); | | 803 | free(kte); |
804 | } | | 804 | } |
805 | | | 805 | |
806 | void | | 806 | void |
807 | ktrcsw(struct ktr_entry *kte) | | 807 | ktrcsw(struct ktr_entry *kte) |
808 | { | | 808 | { |
809 | struct ktr_header *kth = &kte->kte_kth; | | 809 | struct ktr_header *kth = &kte->kte_kth; |
810 | struct ktr_csw *cs = (struct ktr_csw *)(kth + 1); | | 810 | struct ktr_csw *cs = (struct ktr_csw *)(kth + 1); |
811 | | | 811 | |
812 | dumpheader(kth); | | 812 | dumpheader(kth); |
813 | wprintf("%s %s", cs->out ? "stop" : "resume", | | 813 | xwprintf("%s %s", cs->out ? "stop" : "resume", |
814 | cs->user ? "user" : "kernel"); | | 814 | cs->user ? "user" : "kernel"); |
815 | | | 815 | |
816 | free(kte); | | 816 | free(kte); |
817 | } | | 817 | } |