2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#) Copyright (c) 1988, 1993 The Regents of the University of California. All rights reserved.
30 * @(#)kdump.c 8.1 (Berkeley) 6/6/93
31 * $FreeBSD: src/usr.bin/kdump/kdump.c,v 1.29 2006/05/20 14:27:22 netchild Exp $
34 #define _KERNEL_STRUCTURES
36 #include <sys/errno.h>
37 #include <sys/param.h>
40 #include <sys/ktrace.h>
41 #include <sys/ioctl.h>
42 #include <sys/ptrace.h>
52 #include "kdump_subr.h"
54 extern const char *ioctlname(u_long
);
56 static int dumpheader(struct ktr_header
*);
57 static int fread_tail(void *, int, int);
58 static void ktrcsw(struct ktr_csw
*);
59 static void ktrgenio(struct ktr_genio
*, int);
60 static void ktrnamei(char *, int);
61 static void ktrpsig(struct ktr_psig
*);
62 static void ktrsyscall(struct ktr_syscall
*);
63 static void ktrsysret(struct ktr_sysret
*);
64 static void ktruser(int, unsigned char *);
65 static void ktruser_malloc(int, unsigned char *);
66 static void ktruser_rtld(int, unsigned char *);
67 static void timevalfix(struct timeval
*);
68 static void timevalsub(struct timeval
*, struct timeval
*);
69 static void usage(void);
71 int timestamp
, decimal
, fancy
= 1, tail
, maxdata
= 64;
74 const char *tracefile
= DEF_TRACEFILE
;
75 struct ktr_header ktr_header
;
77 #define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
80 main(int argc
, char **argv
)
82 int ch
, col
, ktrlen
, size
;
85 int trpoints
= ALL_POINTS
;
88 setlocale(LC_CTYPE
, "");
90 while ((ch
= getopt(argc
,argv
,"acf:djlm:np:RTt:")) != -1)
102 timestamp
= 2; /* relative timestamp */
112 maxdata
= atoi(optarg
);
118 do_pid
= strtoul(optarg
, &cp
, 0);
120 errx(1,"invalid number %s", optarg
);
123 timestamp
= 2; /* relative timestamp */
129 trpoints
= getpoints(optarg
);
131 errx(1, "unknown trace point in %s", optarg
);
140 m
= (void *)malloc(size
= 1025);
142 errx(1, "%s", strerror(ENOMEM
));
143 if (!freopen(tracefile
, "r", stdin
))
144 err(1, "%s", tracefile
);
145 while (fread_tail(&ktr_header
, sizeof(struct ktr_header
), 1)) {
146 if (trpoints
& (1 << ktr_header
.ktr_type
) &&
147 (do_pid
== -1 || ktr_header
.ktr_pid
== do_pid
))
148 col
= dumpheader(&ktr_header
);
151 if ((ktrlen
= ktr_header
.ktr_len
) < 0)
152 errx(1, "bogus length 0x%x", ktrlen
);
154 m
= (void *)realloc(m
, ktrlen
+1);
156 errx(1, "%s", strerror(ENOMEM
));
159 if (ktrlen
&& fread_tail(m
, ktrlen
, 1) == 0)
160 errx(1, "data too short");
161 if ((trpoints
& (1<<ktr_header
.ktr_type
)) == 0)
165 switch (ktr_header
.ktr_type
) {
167 ktrsyscall((struct ktr_syscall
*)m
);
170 ktrsysret((struct ktr_sysret
*)m
);
176 ktrgenio((struct ktr_genio
*)m
, ktrlen
);
179 ktrpsig((struct ktr_psig
*)m
);
182 ktrcsw((struct ktr_csw
*)m
);
195 fread_tail(void *buf
, int size
, int num
)
199 while ((i
= fread(buf
, size
, num
, stdin
)) == 0 && tail
) {
207 dumpheader(struct ktr_header
*kth
)
209 static char unknown
[64];
210 static struct timeval prevtime
, temp
;
214 switch (kth
->ktr_type
) {
237 sprintf(unknown
, "UNKNOWN(%d)", kth
->ktr_type
);
241 if (kth
->ktr_tid
|| (kth
->ktr_flags
& KTRH_THREADED
) || fixedformat
)
242 col
= printf("%5d:%-4d", kth
->ktr_pid
, kth
->ktr_tid
);
244 col
= printf("%5d", kth
->ktr_pid
);
246 col
+= printf(" %2d", KTRH_CPUID_DECODE(kth
->ktr_flags
));
247 col
+= printf(" %-8.*s ", MAXCOMLEN
, kth
->ktr_comm
);
249 if (timestamp
== 2) {
250 temp
= kth
->ktr_time
;
251 timevalsub(&kth
->ktr_time
, &prevtime
);
254 col
+= printf("%ld.%06ld ",
255 kth
->ktr_time
.tv_sec
, kth
->ktr_time
.tv_usec
);
257 col
+= printf("%s ", type
);
261 #include <sys/syscall.h>
263 #include <sys/kern/syscalls.c>
265 int nsyscalls
= sizeof (syscallnames
) / sizeof (syscallnames
[0]);
267 static const char *ptrace_ops
[] = {
268 "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
269 "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
270 "PT_KILL", "PT_STEP", "PT_ATTACH", "PT_DETACH",
274 ktrsyscall(struct ktr_syscall
*ktr
)
276 int narg
= ktr
->ktr_narg
;
279 if (ktr
->ktr_code
>= nsyscalls
|| ktr
->ktr_code
< 0)
280 printf("[%d]", ktr
->ktr_code
);
282 printf("%s", syscallnames
[ktr
->ktr_code
]);
283 ip
= &ktr
->ktr_args
[0];
288 #define print_number(i,n,c) do { \
290 printf("%c%ld", c, (long)*i); \
292 printf("%c%#lx", c, (long)*i); \
298 if (ktr
->ktr_code
== SYS_ioctl
) {
300 print_number(ip
,narg
,c
);
301 if ((cp
= ioctlname(*ip
)) != NULL
)
305 printf(",%ld", (long)*ip
);
307 printf(",%#lx ", (long)*ip
);
312 } else if (ktr
->ktr_code
== SYS_access
) {
313 print_number(ip
,narg
,c
);
315 accessmodename ((int)*ip
);
318 } else if (ktr
->ktr_code
== SYS_open
||
319 ktr
->ktr_code
== SYS_mq_open
) {
322 print_number(ip
,narg
,c
);
326 flagsandmodename (flags
, mode
, decimal
);
329 } else if (ktr
->ktr_code
== SYS_wait4
) {
330 print_number(ip
,narg
,c
);
331 print_number(ip
,narg
,c
);
333 wait4optname ((int)*ip
);
336 } else if (ktr
->ktr_code
== SYS_chmod
||
337 ktr
->ktr_code
== SYS_fchmod
||
338 ktr
->ktr_code
== SYS_lchmod
) {
339 print_number(ip
,narg
,c
);
344 } else if (ktr
->ktr_code
== SYS_mknod
) {
345 print_number(ip
,narg
,c
);
350 } else if (ktr
->ktr_code
== SYS_getfsstat
) {
351 print_number(ip
,narg
,c
);
352 print_number(ip
,narg
,c
);
354 getfsstatflagsname ((int)*ip
);
357 } else if (ktr
->ktr_code
== SYS_mount
) {
358 print_number(ip
,narg
,c
);
359 print_number(ip
,narg
,c
);
361 mountflagsname ((int)*ip
);
364 } else if (ktr
->ktr_code
== SYS_unmount
) {
365 print_number(ip
,narg
,c
);
367 mountflagsname ((int)*ip
);
370 } else if (ktr
->ktr_code
== SYS_recvmsg
||
371 ktr
->ktr_code
== SYS_sendmsg
) {
372 print_number(ip
,narg
,c
);
373 print_number(ip
,narg
,c
);
375 sendrecvflagsname ((int)*ip
);
378 } else if (ktr
->ktr_code
== SYS_recvfrom
||
379 ktr
->ktr_code
== SYS_sendto
) {
380 print_number(ip
,narg
,c
);
381 print_number(ip
,narg
,c
);
382 print_number(ip
,narg
,c
);
384 sendrecvflagsname ((int)*ip
);
387 } else if (ktr
->ktr_code
== SYS_chflags
||
388 ktr
->ktr_code
== SYS_fchflags
) {
389 print_number(ip
,narg
,c
);
394 } else if (ktr
->ktr_code
== SYS_kill
) {
395 print_number(ip
,narg
,c
);
400 } else if (ktr
->ktr_code
== SYS_reboot
) {
402 rebootoptname((int)*ip
);
405 } else if (ktr
->ktr_code
== SYS_umask
) {
410 } else if (ktr
->ktr_code
== SYS_msync
) {
411 print_number(ip
,narg
,c
);
412 print_number(ip
,narg
,c
);
414 msyncflagsname((int)*ip
);
417 } else if (ktr
->ktr_code
== SYS_mmap
) {
418 print_number(ip
,narg
,c
);
419 print_number(ip
,narg
,c
);
421 mmapprotname ((int)*ip
);
425 mmapflagsname ((int)*ip
);
428 } else if (ktr
->ktr_code
== SYS_mprotect
) {
429 print_number(ip
,narg
,c
);
430 print_number(ip
,narg
,c
);
432 mmapprotname ((int)*ip
);
435 } else if (ktr
->ktr_code
== SYS_madvise
) {
436 print_number(ip
,narg
,c
);
437 print_number(ip
,narg
,c
);
439 madvisebehavname((int)*ip
);
442 } else if (ktr
->ktr_code
== SYS_setpriority
) {
448 print_number(ip
,narg
,c
);
449 print_number(ip
,narg
,c
);
450 } else if (ktr
->ktr_code
== SYS_fcntl
) {
453 print_number(ip
,narg
,c
);
457 fcntlcmdname(cmd
, arg
, decimal
);
460 } else if (ktr
->ktr_code
== SYS_socket
) {
462 sockdomainname((int)*ip
);
466 socktypename((int)*ip
);
470 } else if (ktr
->ktr_code
== SYS_setsockopt
||
471 ktr
->ktr_code
== SYS_getsockopt
) {
472 print_number(ip
,narg
,c
);
474 sockoptlevelname((int)*ip
, decimal
);
478 sockoptname((int)*ip
);
481 } else if (ktr
->ktr_code
== SYS_lseek
) {
482 print_number(ip
,narg
,c
);
483 /* Hidden 'pad' argument, not in lseek(2) */
484 print_number(ip
,narg
,c
);
485 print_number(ip
,narg
,c
);
487 whencename ((int)*ip
);
490 } else if (ktr
->ktr_code
== SYS_flock
) {
491 print_number(ip
,narg
,c
);
496 } else if (ktr
->ktr_code
== SYS_mkfifo
||
497 ktr
->ktr_code
== SYS_mkdir
) {
498 print_number(ip
,narg
,c
);
503 } else if (ktr
->ktr_code
== SYS_shutdown
) {
504 print_number(ip
,narg
,c
);
506 shutdownhowname((int)*ip
);
509 } else if (ktr
->ktr_code
== SYS_socketpair
) {
511 sockdomainname((int)*ip
);
515 socktypename((int)*ip
);
519 } else if (ktr
->ktr_code
== SYS_getrlimit
||
520 ktr
->ktr_code
== SYS_setrlimit
) {
522 rlimitname((int)*ip
);
526 } else if (ktr
->ktr_code
== SYS_quotactl
) {
527 print_number(ip
,narg
,c
);
528 quotactlname((int)*ip
);
532 } else if (ktr
->ktr_code
== SYS_rtprio
) {
534 rtprioname((int)*ip
);
538 } else if (ktr
->ktr_code
== SYS___semctl
) {
539 print_number(ip
,narg
,c
);
540 print_number(ip
,narg
,c
);
541 semctlname((int)*ip
);
544 } else if (ktr
->ktr_code
== SYS_semget
) {
545 print_number(ip
,narg
,c
);
546 print_number(ip
,narg
,c
);
547 semgetname((int)*ip
);
550 } else if (ktr
->ktr_code
== SYS_msgctl
) {
551 print_number(ip
,narg
,c
);
552 shmctlname((int)*ip
);
555 } else if (ktr
->ktr_code
== SYS_shmat
) {
556 print_number(ip
,narg
,c
);
557 print_number(ip
,narg
,c
);
561 } else if (ktr
->ktr_code
== SYS_shmctl
) {
562 print_number(ip
,narg
,c
);
563 shmctlname((int)*ip
);
566 } else if (ktr
->ktr_code
== SYS_minherit
) {
567 print_number(ip
,narg
,c
);
568 print_number(ip
,narg
,c
);
569 minheritname((int)*ip
);
572 } else if (ktr
->ktr_code
== SYS_rfork
) {
578 } else if (ktr
->ktr_code
== SYS_lio_listio
) {
580 lio_listioname((int)*ip
);
584 } else if (ktr
->ktr_code
== SYS_mlockall
) {
586 mlockallname((int)*ip
);
589 } else if (ktr
->ktr_code
== SYS_sched_setscheduler
) {
590 print_number(ip
,narg
,c
);
591 schedpolicyname((int)*ip
);
594 } else if (ktr
->ktr_code
== SYS_sched_get_priority_max
||
595 ktr
->ktr_code
== SYS_sched_get_priority_min
) {
597 schedpolicyname((int)*ip
);
600 } else if (ktr
->ktr_code
== SYS_sendfile
) {
601 print_number(ip
,narg
,c
);
602 print_number(ip
,narg
,c
);
603 print_number(ip
,narg
,c
);
604 print_number(ip
,narg
,c
);
605 print_number(ip
,narg
,c
);
606 print_number(ip
,narg
,c
);
607 sendfileflagsname((int)*ip
);
610 } else if (ktr
->ktr_code
== SYS_kldsym
) {
611 print_number(ip
,narg
,c
);
612 kldsymcmdname((int)*ip
);
615 } else if (ktr
->ktr_code
== SYS_sigprocmask
) {
617 sigprocmaskhowname((int)*ip
);
621 } else if (ktr
->ktr_code
== SYS___acl_get_file
||
622 ktr
->ktr_code
== SYS___acl_set_file
||
623 ktr
->ktr_code
== SYS___acl_get_fd
||
624 ktr
->ktr_code
== SYS___acl_set_fd
||
625 ktr
->ktr_code
== SYS___acl_delete_file
||
626 ktr
->ktr_code
== SYS___acl_delete_fd
||
627 ktr
->ktr_code
== SYS___acl_aclcheck_file
||
628 ktr
->ktr_code
== SYS___acl_aclcheck_fd
) {
629 print_number(ip
,narg
,c
);
630 acltypename((int)*ip
);
633 } else if (ktr
->ktr_code
== SYS_sigaction
) {
639 } else if (ktr
->ktr_code
== SYS_extattrctl
) {
640 print_number(ip
,narg
,c
);
641 extattrctlname((int)*ip
);
644 } else if (ktr
->ktr_code
== SYS_ptrace
) {
645 if (*ip
< (register_t
)(sizeof(ptrace_ops
) /
646 sizeof(ptrace_ops
[0])) && *ip
>= 0)
647 printf("(%s", ptrace_ops
[*ip
]);
649 else if (*ip
== PT_GETREGS
)
650 printf("(%s", "PT_GETREGS");
653 else if (*ip
== PT_SETREGS
)
654 printf("(%s", "PT_SETREGS");
657 else if (*ip
== PT_GETFPREGS
)
658 printf("(%s", "PT_GETFPREGS");
661 else if (*ip
== PT_SETFPREGS
)
662 printf("(%s", "PT_SETFPREGS");
665 else if (*ip
== PT_GETDBREGS
)
666 printf("(%s", "PT_GETDBREGS");
669 else if (*ip
== PT_SETDBREGS
)
670 printf("(%s", "PT_SETDBREGS");
673 printf("(%ld", (long)*ip
);
680 print_number(ip
,narg
,c
);
688 ktrsysret(struct ktr_sysret
*ktr
)
690 register_t ret
= ktr
->ktr_retval
;
691 int error
= ktr
->ktr_error
;
692 int code
= ktr
->ktr_code
;
694 if (code
>= nsyscalls
|| code
< 0)
695 printf("[%d] ", code
);
697 printf("%s ", syscallnames
[code
]);
701 printf("%ld", (long)ret
);
702 if (ret
< 0 || ret
> 9)
703 printf("/%#lx", (long)ret
);
706 printf("%ld", (long)ret
);
708 printf("%#lx", (long)ret
);
710 } else if (error
== ERESTART
)
712 else if (error
== EJUSTRETURN
)
713 printf("JUSTRETURN");
715 printf("-1 errno %d", ktr
->ktr_error
);
717 printf(" %s", strerror(ktr
->ktr_error
));
723 ktrnamei(char *cp
, int len
)
725 printf("\"%.*s\"\n", len
, cp
);
729 ktrgenio(struct ktr_genio
*ktr
, int len
)
731 int datalen
= len
- sizeof (struct ktr_genio
);
732 char *dp
= (char *)ktr
+ sizeof (struct ktr_genio
);
737 static int screenwidth
= 0;
739 if (screenwidth
== 0) {
742 if (fancy
&& ioctl(fileno(stderr
), TIOCGWINSZ
, &ws
) != -1 &&
744 screenwidth
= ws
.ws_col
;
748 printf("fd %d %s %d byte%s\n", ktr
->ktr_fd
,
749 ktr
->ktr_rw
== UIO_READ
? "read" : "wrote", datalen
,
750 datalen
== 1 ? "" : "s");
751 if (maxdata
&& datalen
> maxdata
)
755 for (;datalen
> 0; datalen
--, dp
++) {
756 vis(visbuf
, *dp
, VIS_CSTYLE
, *(dp
+1));
759 * Keep track of printables and
760 * space chars (like fold(1)).
772 width
= 8 - (col
&07);
777 if (col
+ width
> (screenwidth
-2)) {
791 const char *signames
[NSIG
] = {
792 "NULL", "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", /* 1 - 6 */
793 "EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", /* 7 - 12 */
794 "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", /* 13 - 18 */
795 "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", /* 19 - 24 */
796 "XFSZ", "VTALRM", "PROF", "WINCH", "29", "USR1", /* 25 - 30 */
797 "USR2", NULL
, /* 31 - 32 */
801 ktrpsig(struct ktr_psig
*psig
)
803 printf("SIG%s ", signames
[psig
->signo
]);
804 if (psig
->action
== SIG_DFL
)
807 printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
808 (u_long
)psig
->action
, psig
->mask
.__bits
[0], psig
->code
);
812 ktrcsw(struct ktr_csw
*cs
)
814 printf("%s %s\n", cs
->out
? "stop" : "resume",
815 cs
->user
? "user" : "kernel");
818 #define UTRACE_DLOPEN_START 1
819 #define UTRACE_DLOPEN_STOP 2
820 #define UTRACE_DLCLOSE_START 3
821 #define UTRACE_DLCLOSE_STOP 4
822 #define UTRACE_LOAD_OBJECT 5
823 #define UTRACE_UNLOAD_OBJECT 6
824 #define UTRACE_ADD_RUNDEP 7
825 #define UTRACE_PRELOAD_FINISHED 8
826 #define UTRACE_INIT_CALL 9
827 #define UTRACE_FINI_CALL 10
830 char sig
[4]; /* 'RTLD' */
836 char name
[MAXPATHLEN
];
840 ktruser_rtld(int len
, unsigned char *p
)
842 struct utrace_rtld
*ut
= (struct utrace_rtld
*)p
;
847 case UTRACE_DLOPEN_START
:
849 printf("dlopen(%s, ", ut
->name
);
850 switch (mode
& RTLD_MODEMASK
) {
858 printf("%#x", mode
& RTLD_MODEMASK
);
860 if (mode
& RTLD_GLOBAL
)
861 printf(" | RTLD_GLOBAL");
862 if (mode
& RTLD_TRACE
)
863 printf(" | RTLD_TRACE");
864 if (mode
& ~(RTLD_MODEMASK
| RTLD_GLOBAL
| RTLD_TRACE
))
865 printf(" | %#x", mode
&
866 ~(RTLD_MODEMASK
| RTLD_GLOBAL
| RTLD_TRACE
));
869 case UTRACE_DLOPEN_STOP
:
870 printf("%p = dlopen(%s) ref %d\n", ut
->handle
, ut
->name
,
873 case UTRACE_DLCLOSE_START
:
874 printf("dlclose(%p) (%s, %d)\n", ut
->handle
, ut
->name
,
877 case UTRACE_DLCLOSE_STOP
:
878 printf("dlclose(%p) finished\n", ut
->handle
);
880 case UTRACE_LOAD_OBJECT
:
881 printf("RTLD: loaded %p @ %p - %p (%s)\n", ut
->handle
,
882 ut
->mapbase
, (char *)ut
->mapbase
+ ut
->mapsize
- 1,
885 case UTRACE_UNLOAD_OBJECT
:
886 printf("RTLD: unloaded %p @ %p - %p (%s)\n", ut
->handle
,
887 ut
->mapbase
, (char *)ut
->mapbase
+ ut
->mapsize
- 1,
890 case UTRACE_ADD_RUNDEP
:
891 parent
= ut
->mapbase
;
892 printf("RTLD: %p now depends on %p (%s, %d)\n", parent
,
893 ut
->handle
, ut
->name
, ut
->refcnt
);
895 case UTRACE_PRELOAD_FINISHED
:
896 printf("RTLD: LD_PRELOAD finished\n");
898 case UTRACE_INIT_CALL
:
899 printf("RTLD: init %p for %p (%s)\n", ut
->mapbase
, ut
->handle
,
902 case UTRACE_FINI_CALL
:
903 printf("RTLD: fini %p for %p (%s)\n", ut
->mapbase
, ut
->handle
,
909 printf("RTLD: %d ", len
);
914 printf(" %02x", *p
++);
919 struct utrace_malloc
{
926 ktruser_malloc(int len __unused
, unsigned char *p
)
928 struct utrace_malloc
*ut
= (struct utrace_malloc
*)p
;
931 if (ut
->s
== 0 && ut
->r
== NULL
)
932 printf("malloc_init()\n");
934 printf("%p = malloc(%zu)\n", ut
->r
, ut
->s
);
937 printf("free(%p)\n", ut
->p
);
939 printf("%p = realloc(%p, %zu)\n", ut
->r
, ut
->p
, ut
->s
);
944 ktruser(int len
, unsigned char *p
)
947 if (len
>= 8 && bcmp(p
, "RTLD", 4) == 0) {
948 ktruser_rtld(len
, p
);
952 if (len
== sizeof(struct utrace_malloc
)) {
953 ktruser_malloc(len
, p
);
959 printf(" %02x", *p
++);
967 "usage: kdump [-dnlRT] [-f trfile] [-m maxdata] [-t [cnisuw]] [-p pid]\n");
972 timevalsub(struct timeval
*t1
, struct timeval
*t2
)
974 t1
->tv_sec
-= t2
->tv_sec
;
975 t1
->tv_usec
-= t2
->tv_usec
;
980 timevalfix(struct timeval
*t1
)
982 if (t1
->tv_usec
< 0) {
984 t1
->tv_usec
+= 1000000;
986 if (t1
->tv_usec
>= 1000000) {
988 t1
->tv_usec
-= 1000000;