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. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 static const char copyright[] =
36 "@(#) Copyright (c) 1988, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
42 static char sccsid[] = "@(#)kdump.c 8.1 (Berkeley) 6/6/93";
45 #include <sys/cdefs.h>
46 __FBSDID("$FreeBSD$");
50 #include <sys/errno.h>
52 #include <sys/param.h>
53 #include <sys/errno.h>
58 #include <sys/ktrace.h>
59 #include <sys/ioctl.h>
60 #include <sys/socket.h>
70 #include "kdump_subr.h"
72 int fread_tail(void *, int, int);
73 void dumpheader(struct ktr_header *);
74 void ktrsyscall(struct ktr_syscall *);
75 void ktrsysret(struct ktr_sysret *);
76 void ktrnamei(char *, int);
77 void hexdump(char *, int, int);
78 void visdump(char *, int, int);
79 void ktrgenio(struct ktr_genio *, int);
80 void ktrpsig(struct ktr_psig *);
81 void ktrcsw(struct ktr_csw *);
82 void ktruser(int, unsigned char *);
84 const char *ioctlname(u_long);
86 int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata;
87 const char *tracefile = DEF_TRACEFILE;
88 struct ktr_header ktr_header;
90 #define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
93 main(int argc, char *argv[])
97 int trpoints = ALL_POINTS;
101 (void) setlocale(LC_CTYPE, "");
103 while ((ch = getopt(argc,argv,"f:dElm:np:HRsTt:")) != -1)
115 maxdata = atoi(optarg);
127 timestamp = 3; /* elapsed timestamp */
133 timestamp = 2; /* relative timestamp */
139 trpoints = getpoints(optarg);
141 errx(1, "unknown trace point in %s", optarg);
150 m = (void *)malloc(size = 1025);
152 errx(1, "%s", strerror(ENOMEM));
153 if (!freopen(tracefile, "r", stdin))
154 err(1, "%s", tracefile);
156 while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
157 if (ktr_header.ktr_type & KTR_DROP) {
158 ktr_header.ktr_type &= ~KTR_DROP;
159 if (!drop_logged && threads) {
160 (void)printf("%6d %6d %-8.*s Events dropped.\n",
161 ktr_header.ktr_pid, ktr_header.ktr_tid >
162 0 ? ktr_header.ktr_tid : 0, MAXCOMLEN,
163 ktr_header.ktr_comm);
165 } else if (!drop_logged) {
166 (void)printf("%6d %-8.*s Events dropped.\n",
167 ktr_header.ktr_pid, MAXCOMLEN,
168 ktr_header.ktr_comm);
172 if (trpoints & (1<<ktr_header.ktr_type))
173 if (pid == 0 || ktr_header.ktr_pid == pid)
174 dumpheader(&ktr_header);
175 if ((ktrlen = ktr_header.ktr_len) < 0)
176 errx(1, "bogus length 0x%x", ktrlen);
178 m = (void *)realloc(m, ktrlen+1);
180 errx(1, "%s", strerror(ENOMEM));
183 if (ktrlen && fread_tail(m, ktrlen, 1) == 0)
184 errx(1, "data too short");
185 if (pid && ktr_header.ktr_pid != pid)
187 if ((trpoints & (1<<ktr_header.ktr_type)) == 0)
190 switch (ktr_header.ktr_type) {
192 ktrsyscall((struct ktr_syscall *)m);
195 ktrsysret((struct ktr_sysret *)m);
201 ktrgenio((struct ktr_genio *)m, ktrlen);
204 ktrpsig((struct ktr_psig *)m);
207 ktrcsw((struct ktr_csw *)m);
217 (void)fflush(stdout);
223 fread_tail(void *buf, int size, int num)
227 while ((i = fread(buf, size, num, stdin)) == 0 && tail) {
235 dumpheader(struct ktr_header *kth)
237 static char unknown[64];
238 static struct timeval prevtime, temp;
241 switch (kth->ktr_type) {
264 (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type);
269 * The ktr_tid field was previously the ktr_buffer field, which held
270 * the kernel pointer value for the buffer associated with data
271 * following the record header. It now holds a threadid, but only
272 * for trace files after the change. Older trace files still contain
273 * kernel pointers. Detect this and suppress the results by printing
274 * negative tid's as 0.
277 (void)printf("%6d %6d %-8.*s ", kth->ktr_pid, kth->ktr_tid >
278 0 ? kth->ktr_tid : 0, MAXCOMLEN, kth->ktr_comm);
280 (void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN,
283 if (timestamp == 3) {
284 if (prevtime.tv_sec == 0)
285 prevtime = kth->ktr_time;
286 timevalsub(&kth->ktr_time, &prevtime);
288 if (timestamp == 2) {
289 temp = kth->ktr_time;
290 timevalsub(&kth->ktr_time, &prevtime);
293 (void)printf("%ld.%06ld ",
294 kth->ktr_time.tv_sec, kth->ktr_time.tv_usec);
296 (void)printf("%s ", type);
299 #include <sys/syscall.h>
301 #include <sys/kern/syscalls.c>
303 int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]);
306 ktrsyscall(struct ktr_syscall *ktr)
308 int narg = ktr->ktr_narg;
311 if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)
312 (void)printf("[%d]", ktr->ktr_code);
314 (void)printf("%s", syscallnames[ktr->ktr_code]);
315 ip = &ktr->ktr_args[0];
320 #define print_number(i,n,c) do { \
322 (void)printf("%c%ld", c, (long)*i); \
324 (void)printf("%c%#lx", c, (long)*i); \
330 if (ktr->ktr_code == SYS_ioctl) {
332 print_number(ip,narg,c);
333 if ((cp = ioctlname(*ip)) != NULL)
334 (void)printf(",%s", cp);
337 (void)printf(",%ld", (long)*ip);
339 (void)printf(",%#lx ", (long)*ip);
344 } else if (ktr->ktr_code == SYS_ptrace) {
346 ptraceopname ((int)*ip);
350 } else if (ktr->ktr_code == SYS_access ||
351 ktr->ktr_code == SYS_eaccess) {
352 print_number(ip,narg,c);
354 accessmodename ((int)*ip);
357 } else if (ktr->ktr_code == SYS_open) {
360 print_number(ip,narg,c);
364 flagsandmodename (flags, mode, decimal);
367 } else if (ktr->ktr_code == SYS_wait4) {
368 print_number(ip,narg,c);
369 print_number(ip,narg,c);
371 wait4optname ((int)*ip);
374 } else if (ktr->ktr_code == SYS_chmod ||
375 ktr->ktr_code == SYS_fchmod ||
376 ktr->ktr_code == SYS_lchmod) {
377 print_number(ip,narg,c);
382 } else if (ktr->ktr_code == SYS_mknod) {
383 print_number(ip,narg,c);
388 } else if (ktr->ktr_code == SYS_getfsstat) {
389 print_number(ip,narg,c);
390 print_number(ip,narg,c);
392 getfsstatflagsname ((int)*ip);
395 } else if (ktr->ktr_code == SYS_mount) {
396 print_number(ip,narg,c);
397 print_number(ip,narg,c);
399 mountflagsname ((int)*ip);
402 } else if (ktr->ktr_code == SYS_unmount) {
403 print_number(ip,narg,c);
405 mountflagsname ((int)*ip);
408 } else if (ktr->ktr_code == SYS_recvmsg ||
409 ktr->ktr_code == SYS_sendmsg) {
410 print_number(ip,narg,c);
411 print_number(ip,narg,c);
413 sendrecvflagsname ((int)*ip);
416 } else if (ktr->ktr_code == SYS_recvfrom ||
417 ktr->ktr_code == SYS_sendto) {
418 print_number(ip,narg,c);
419 print_number(ip,narg,c);
420 print_number(ip,narg,c);
422 sendrecvflagsname ((int)*ip);
425 } else if (ktr->ktr_code == SYS_chflags ||
426 ktr->ktr_code == SYS_fchflags ||
427 ktr->ktr_code == SYS_lchflags) {
428 print_number(ip,narg,c);
433 } else if (ktr->ktr_code == SYS_kill) {
434 print_number(ip,narg,c);
439 } else if (ktr->ktr_code == SYS_reboot) {
441 rebootoptname((int)*ip);
444 } else if (ktr->ktr_code == SYS_umask) {
449 } else if (ktr->ktr_code == SYS_msync) {
450 print_number(ip,narg,c);
451 print_number(ip,narg,c);
453 msyncflagsname((int)*ip);
456 #ifdef SYS_freebsd6_mmap
457 } else if (ktr->ktr_code == SYS_freebsd6_mmap) {
458 print_number(ip,narg,c);
459 print_number(ip,narg,c);
461 mmapprotname ((int)*ip);
465 mmapflagsname ((int)*ip);
469 } else if (ktr->ktr_code == SYS_mmap) {
470 print_number(ip,narg,c);
471 print_number(ip,narg,c);
473 mmapprotname ((int)*ip);
477 mmapflagsname ((int)*ip);
480 } else if (ktr->ktr_code == SYS_mprotect) {
481 print_number(ip,narg,c);
482 print_number(ip,narg,c);
484 mmapprotname ((int)*ip);
487 } else if (ktr->ktr_code == SYS_madvise) {
488 print_number(ip,narg,c);
489 print_number(ip,narg,c);
491 madvisebehavname((int)*ip);
494 } else if (ktr->ktr_code == SYS_setpriority) {
495 print_number(ip,narg,c);
496 print_number(ip,narg,c);
501 } else if (ktr->ktr_code == SYS_fcntl) {
504 print_number(ip,narg,c);
508 fcntlcmdname(cmd, arg, decimal);
511 } else if (ktr->ktr_code == SYS_socket) {
515 sockdomainname(sockdomain);
519 socktypename((int)*ip);
522 if (sockdomain == PF_INET ||
523 sockdomain == PF_INET6) {
525 sockipprotoname((int)*ip);
530 } else if (ktr->ktr_code == SYS_setsockopt ||
531 ktr->ktr_code == SYS_getsockopt) {
532 print_number(ip,narg,c);
534 sockoptlevelname((int)*ip, decimal);
538 sockoptname((int)*ip);
541 #ifdef SYS_freebsd6_lseek
542 } else if (ktr->ktr_code == SYS_freebsd6_lseek) {
543 print_number(ip,narg,c);
544 /* Hidden 'pad' argument, not in lseek(2) */
545 print_number(ip,narg,c);
546 print_number(ip,narg,c);
548 whencename ((int)*ip);
552 } else if (ktr->ktr_code == SYS_lseek) {
553 print_number(ip,narg,c);
554 /* Hidden 'pad' argument, not in lseek(2) */
555 print_number(ip,narg,c);
557 whencename ((int)*ip);
561 } else if (ktr->ktr_code == SYS_flock) {
562 print_number(ip,narg,c);
567 } else if (ktr->ktr_code == SYS_mkfifo ||
568 ktr->ktr_code == SYS_mkdir) {
569 print_number(ip,narg,c);
574 } else if (ktr->ktr_code == SYS_shutdown) {
575 print_number(ip,narg,c);
577 shutdownhowname((int)*ip);
580 } else if (ktr->ktr_code == SYS_socketpair) {
582 sockdomainname((int)*ip);
586 socktypename((int)*ip);
590 } else if (ktr->ktr_code == SYS_getrlimit ||
591 ktr->ktr_code == SYS_setrlimit) {
593 rlimitname((int)*ip);
597 } else if (ktr->ktr_code == SYS_quotactl) {
598 print_number(ip,narg,c);
599 quotactlname((int)*ip);
603 } else if (ktr->ktr_code == SYS_nfssvc) {
605 nfssvcname((int)*ip);
609 } else if (ktr->ktr_code == SYS_rtprio) {
611 rtprioname((int)*ip);
615 } else if (ktr->ktr_code == SYS___semctl) {
616 print_number(ip,narg,c);
617 print_number(ip,narg,c);
618 semctlname((int)*ip);
621 } else if (ktr->ktr_code == SYS_semget) {
622 print_number(ip,narg,c);
623 print_number(ip,narg,c);
624 semgetname((int)*ip);
627 } else if (ktr->ktr_code == SYS_msgctl) {
628 print_number(ip,narg,c);
629 shmctlname((int)*ip);
632 } else if (ktr->ktr_code == SYS_shmat) {
633 print_number(ip,narg,c);
634 print_number(ip,narg,c);
638 } else if (ktr->ktr_code == SYS_shmctl) {
639 print_number(ip,narg,c);
640 shmctlname((int)*ip);
643 } else if (ktr->ktr_code == SYS_minherit) {
644 print_number(ip,narg,c);
645 print_number(ip,narg,c);
646 minheritname((int)*ip);
649 } else if (ktr->ktr_code == SYS_rfork) {
655 } else if (ktr->ktr_code == SYS_lio_listio) {
657 lio_listioname((int)*ip);
661 } else if (ktr->ktr_code == SYS_mlockall) {
663 mlockallname((int)*ip);
666 } else if (ktr->ktr_code == SYS_sched_setscheduler) {
667 print_number(ip,narg,c);
668 schedpolicyname((int)*ip);
671 } else if (ktr->ktr_code == SYS_sched_get_priority_max ||
672 ktr->ktr_code == SYS_sched_get_priority_min) {
674 schedpolicyname((int)*ip);
677 } else if (ktr->ktr_code == SYS_sendfile) {
678 print_number(ip,narg,c);
679 print_number(ip,narg,c);
680 print_number(ip,narg,c);
681 print_number(ip,narg,c);
682 print_number(ip,narg,c);
683 print_number(ip,narg,c);
684 sendfileflagsname((int)*ip);
687 } else if (ktr->ktr_code == SYS_kldsym) {
688 print_number(ip,narg,c);
689 kldsymcmdname((int)*ip);
692 } else if (ktr->ktr_code == SYS_sigprocmask) {
694 sigprocmaskhowname((int)*ip);
698 } else if (ktr->ktr_code == SYS___acl_get_file ||
699 ktr->ktr_code == SYS___acl_set_file ||
700 ktr->ktr_code == SYS___acl_get_fd ||
701 ktr->ktr_code == SYS___acl_set_fd ||
702 ktr->ktr_code == SYS___acl_delete_file ||
703 ktr->ktr_code == SYS___acl_delete_fd ||
704 ktr->ktr_code == SYS___acl_aclcheck_file ||
705 ktr->ktr_code == SYS___acl_aclcheck_fd ||
706 ktr->ktr_code == SYS___acl_get_link ||
707 ktr->ktr_code == SYS___acl_set_link ||
708 ktr->ktr_code == SYS___acl_delete_link ||
709 ktr->ktr_code == SYS___acl_aclcheck_link) {
710 print_number(ip,narg,c);
711 acltypename((int)*ip);
714 } else if (ktr->ktr_code == SYS_sigaction) {
720 } else if (ktr->ktr_code == SYS_extattrctl) {
721 print_number(ip,narg,c);
722 extattrctlname((int)*ip);
725 } else if (ktr->ktr_code == SYS_nmount) {
726 print_number(ip,narg,c);
727 print_number(ip,narg,c);
729 mountflagsname ((int)*ip);
732 } else if (ktr->ktr_code == SYS_kse_thr_interrupt) {
733 print_number(ip,narg,c);
735 ksethrcmdname ((int)*ip);
738 } else if (ktr->ktr_code == SYS_thr_create) {
739 print_number(ip,narg,c);
740 print_number(ip,narg,c);
742 thrcreateflagsname ((int)*ip);
745 } else if (ktr->ktr_code == SYS_thr_kill) {
746 print_number(ip,narg,c);
751 } else if (ktr->ktr_code == SYS_kldunloadf) {
752 print_number(ip,narg,c);
754 kldunloadfflagsname ((int)*ip);
760 print_number(ip,narg,c);
768 ktrsysret(struct ktr_sysret *ktr)
770 register_t ret = ktr->ktr_retval;
771 int error = ktr->ktr_error;
772 int code = ktr->ktr_code;
774 if (code >= nsyscalls || code < 0)
775 (void)printf("[%d] ", code);
777 (void)printf("%s ", syscallnames[code]);
781 (void)printf("%d", ret);
782 if (ret < 0 || ret > 9)
783 (void)printf("/%#lx", (long)ret);
786 (void)printf("%ld", (long)ret);
788 (void)printf("%#lx", (long)ret);
790 } else if (error == ERESTART)
791 (void)printf("RESTART");
792 else if (error == EJUSTRETURN)
793 (void)printf("JUSTRETURN");
795 (void)printf("-1 errno %d", ktr->ktr_error);
797 (void)printf(" %s", strerror(ktr->ktr_error));
803 ktrnamei(char *cp, int len)
805 (void)printf("\"%.*s\"\n", len, cp);
809 hexdump(char *p, int len, int screenwidth)
817 i = 13; /* base offset */
818 i += (width / 2) + 1; /* spaces every second byte */
819 i += (width * 2); /* width of bytes */
821 i += width; /* each byte */
823 } while (i < screenwidth);
826 for (n = 0; n < len; n += width) {
827 for (i = n; i < n + width; i++) {
828 if ((i % width) == 0) { /* beginning of line */
829 printf(" 0x%04x", i);
835 printf("%02x", p[i] & 0xff);
840 for (i = n; i < n + width; i++) {
843 if (p[i] >= ' ' && p[i] <= '~')
850 if ((i % width) != 0)
855 visdump(char *dp, int datalen, int screenwidth)
864 for (;datalen > 0; datalen--, dp++) {
865 (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
868 * Keep track of printables and
869 * space chars (like fold(1)).
881 width = 8 - (col&07);
886 if (col + width > (screenwidth-2)) {
887 (void)printf("\\\n\t");
892 (void)putchar(*cp++);
897 (void)printf("\"\n");
901 ktrgenio(struct ktr_genio *ktr, int len)
903 int datalen = len - sizeof (struct ktr_genio);
904 char *dp = (char *)ktr + sizeof (struct ktr_genio);
905 static int screenwidth = 0;
908 if (screenwidth == 0) {
911 if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 &&
913 screenwidth = ws.ws_col;
917 printf("fd %d %s %d byte%s\n", ktr->ktr_fd,
918 ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen,
919 datalen == 1 ? "" : "s");
922 if (maxdata && datalen > maxdata)
925 for (i = 0, binary = 0; i < datalen && binary == 0; i++) {
926 if (dp[i] >= 32 && dp[i] < 127)
928 if (dp[i] == 10 || dp[i] == 13 || dp[i] == 0 || dp[i] == 9)
933 hexdump(dp, datalen, screenwidth);
935 visdump(dp, datalen, screenwidth);
938 const char *signames[] = {
939 "NULL", "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", /* 1 - 6 */
940 "EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", /* 7 - 12 */
941 "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", /* 13 - 18 */
942 "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", /* 19 - 24 */
943 "XFSZ", "VTALRM", "PROF", "WINCH", "29", "USR1", /* 25 - 30 */
944 "USR2", NULL, /* 31 - 32 */
948 ktrpsig(struct ktr_psig *psig)
950 if (psig->signo > 0 && psig->signo < NSIG)
951 (void)printf("SIG%s ", signames[psig->signo]);
953 (void)printf("SIG %d ", psig->signo);
954 if (psig->action == SIG_DFL)
955 (void)printf("SIG_DFL\n");
957 (void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
958 (u_long)psig->action, psig->mask.__bits[0], psig->code);
963 ktrcsw(struct ktr_csw *cs)
965 (void)printf("%s %s\n", cs->out ? "stop" : "resume",
966 cs->user ? "user" : "kernel");
969 #define UTRACE_DLOPEN_START 1
970 #define UTRACE_DLOPEN_STOP 2
971 #define UTRACE_DLCLOSE_START 3
972 #define UTRACE_DLCLOSE_STOP 4
973 #define UTRACE_LOAD_OBJECT 5
974 #define UTRACE_UNLOAD_OBJECT 6
975 #define UTRACE_ADD_RUNDEP 7
976 #define UTRACE_PRELOAD_FINISHED 8
977 #define UTRACE_INIT_CALL 9
978 #define UTRACE_FINI_CALL 10
981 char sig[4]; /* 'RTLD' */
987 char name[MAXPATHLEN];
991 ktruser_rtld(int len, unsigned char *p)
993 struct utrace_rtld *ut = (struct utrace_rtld *)p;
998 case UTRACE_DLOPEN_START:
1000 printf("dlopen(%s, ", ut->name);
1001 switch (mode & RTLD_MODEMASK) {
1006 printf("RTLD_LAZY");
1009 printf("%#x", mode & RTLD_MODEMASK);
1011 if (mode & RTLD_GLOBAL)
1012 printf(" | RTLD_GLOBAL");
1013 if (mode & RTLD_TRACE)
1014 printf(" | RTLD_TRACE");
1015 if (mode & ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE))
1016 printf(" | %#x", mode &
1017 ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE));
1020 case UTRACE_DLOPEN_STOP:
1021 printf("%p = dlopen(%s) ref %d\n", ut->handle, ut->name,
1024 case UTRACE_DLCLOSE_START:
1025 printf("dlclose(%p) (%s, %d)\n", ut->handle, ut->name,
1028 case UTRACE_DLCLOSE_STOP:
1029 printf("dlclose(%p) finished\n", ut->handle);
1031 case UTRACE_LOAD_OBJECT:
1032 printf("RTLD: loaded %p @ %p - %p (%s)\n", ut->handle,
1033 ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1,
1036 case UTRACE_UNLOAD_OBJECT:
1037 printf("RTLD: unloaded %p @ %p - %p (%s)\n", ut->handle,
1038 ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1,
1041 case UTRACE_ADD_RUNDEP:
1042 parent = ut->mapbase;
1043 printf("RTLD: %p now depends on %p (%s, %d)\n", parent,
1044 ut->handle, ut->name, ut->refcnt);
1046 case UTRACE_PRELOAD_FINISHED:
1047 printf("RTLD: LD_PRELOAD finished\n");
1049 case UTRACE_INIT_CALL:
1050 printf("RTLD: init %p for %p (%s)\n", ut->mapbase, ut->handle,
1053 case UTRACE_FINI_CALL:
1054 printf("RTLD: fini %p for %p (%s)\n", ut->mapbase, ut->handle,
1060 printf("RTLD: %d ", len);
1063 printf(" %d", *p++);
1065 printf(" %02x", *p++);
1070 struct utrace_malloc {
1077 ktruser_malloc(int len, unsigned char *p)
1079 struct utrace_malloc *ut = (struct utrace_malloc *)p;
1081 if (ut->p == NULL) {
1082 if (ut->s == 0 && ut->r == NULL)
1083 printf("malloc_init()\n");
1085 printf("%p = malloc(%zu)\n", ut->r, ut->s);
1088 printf("free(%p)\n", ut->p);
1090 printf("%p = realloc(%p, %zu)\n", ut->r, ut->p, ut->s);
1095 ktruser(int len, unsigned char *p)
1098 if (len >= 8 && bcmp(p, "RTLD", 4) == 0) {
1099 ktruser_rtld(len, p);
1103 if (len == sizeof(struct utrace_malloc)) {
1104 ktruser_malloc(len, p);
1108 (void)printf("%d ", len);
1111 (void)printf(" %d", *p++);
1113 (void)printf(" %02x", *p++);
1120 (void)fprintf(stderr,
1121 "usage: kdump [-dEnlHRsT] [-f trfile] [-m maxdata] [-p pid] [-t [cnisuw]]\n");