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 } else if (ktr->ktr_code == SYS_mmap) {
457 print_number(ip,narg,c);
458 print_number(ip,narg,c);
460 mmapprotname ((int)*ip);
464 mmapflagsname ((int)*ip);
467 } else if (ktr->ktr_code == SYS_mprotect) {
468 print_number(ip,narg,c);
469 print_number(ip,narg,c);
471 mmapprotname ((int)*ip);
474 } else if (ktr->ktr_code == SYS_madvise) {
475 print_number(ip,narg,c);
476 print_number(ip,narg,c);
478 madvisebehavname((int)*ip);
481 } else if (ktr->ktr_code == SYS_setpriority) {
482 print_number(ip,narg,c);
483 print_number(ip,narg,c);
488 } else if (ktr->ktr_code == SYS_fcntl) {
491 print_number(ip,narg,c);
495 fcntlcmdname(cmd, arg, decimal);
498 } else if (ktr->ktr_code == SYS_socket) {
502 sockdomainname(sockdomain);
506 socktypename((int)*ip);
509 if (sockdomain == PF_INET ||
510 sockdomain == PF_INET6) {
512 sockipprotoname((int)*ip);
517 } else if (ktr->ktr_code == SYS_setsockopt ||
518 ktr->ktr_code == SYS_getsockopt) {
519 print_number(ip,narg,c);
521 sockoptlevelname((int)*ip, decimal);
525 sockoptname((int)*ip);
528 } else if (ktr->ktr_code == SYS_lseek) {
529 print_number(ip,narg,c);
530 /* Hidden 'pad' argument, not in lseek(2) */
531 print_number(ip,narg,c);
532 print_number(ip,narg,c);
534 whencename ((int)*ip);
537 } else if (ktr->ktr_code == SYS_flock) {
538 print_number(ip,narg,c);
543 } else if (ktr->ktr_code == SYS_mkfifo ||
544 ktr->ktr_code == SYS_mkdir) {
545 print_number(ip,narg,c);
550 } else if (ktr->ktr_code == SYS_shutdown) {
551 print_number(ip,narg,c);
553 shutdownhowname((int)*ip);
556 } else if (ktr->ktr_code == SYS_socketpair) {
558 sockdomainname((int)*ip);
562 socktypename((int)*ip);
566 } else if (ktr->ktr_code == SYS_getrlimit ||
567 ktr->ktr_code == SYS_setrlimit) {
569 rlimitname((int)*ip);
573 } else if (ktr->ktr_code == SYS_quotactl) {
574 print_number(ip,narg,c);
575 quotactlname((int)*ip);
579 } else if (ktr->ktr_code == SYS_nfssvc) {
581 nfssvcname((int)*ip);
585 } else if (ktr->ktr_code == SYS_rtprio) {
587 rtprioname((int)*ip);
591 } else if (ktr->ktr_code == SYS___semctl) {
592 print_number(ip,narg,c);
593 print_number(ip,narg,c);
594 semctlname((int)*ip);
597 } else if (ktr->ktr_code == SYS_semget) {
598 print_number(ip,narg,c);
599 print_number(ip,narg,c);
600 semgetname((int)*ip);
603 } else if (ktr->ktr_code == SYS_msgctl) {
604 print_number(ip,narg,c);
605 shmctlname((int)*ip);
608 } else if (ktr->ktr_code == SYS_shmat) {
609 print_number(ip,narg,c);
610 print_number(ip,narg,c);
614 } else if (ktr->ktr_code == SYS_shmctl) {
615 print_number(ip,narg,c);
616 shmctlname((int)*ip);
619 } else if (ktr->ktr_code == SYS_minherit) {
620 print_number(ip,narg,c);
621 print_number(ip,narg,c);
622 minheritname((int)*ip);
625 } else if (ktr->ktr_code == SYS_rfork) {
631 } else if (ktr->ktr_code == SYS_lio_listio) {
633 lio_listioname((int)*ip);
637 } else if (ktr->ktr_code == SYS_mlockall) {
639 mlockallname((int)*ip);
642 } else if (ktr->ktr_code == SYS_sched_setscheduler) {
643 print_number(ip,narg,c);
644 schedpolicyname((int)*ip);
647 } else if (ktr->ktr_code == SYS_sched_get_priority_max ||
648 ktr->ktr_code == SYS_sched_get_priority_min) {
650 schedpolicyname((int)*ip);
653 } else if (ktr->ktr_code == SYS_sendfile) {
654 print_number(ip,narg,c);
655 print_number(ip,narg,c);
656 print_number(ip,narg,c);
657 print_number(ip,narg,c);
658 print_number(ip,narg,c);
659 print_number(ip,narg,c);
660 sendfileflagsname((int)*ip);
663 } else if (ktr->ktr_code == SYS_kldsym) {
664 print_number(ip,narg,c);
665 kldsymcmdname((int)*ip);
668 } else if (ktr->ktr_code == SYS_sigprocmask) {
670 sigprocmaskhowname((int)*ip);
674 } else if (ktr->ktr_code == SYS___acl_get_file ||
675 ktr->ktr_code == SYS___acl_set_file ||
676 ktr->ktr_code == SYS___acl_get_fd ||
677 ktr->ktr_code == SYS___acl_set_fd ||
678 ktr->ktr_code == SYS___acl_delete_file ||
679 ktr->ktr_code == SYS___acl_delete_fd ||
680 ktr->ktr_code == SYS___acl_aclcheck_file ||
681 ktr->ktr_code == SYS___acl_aclcheck_fd ||
682 ktr->ktr_code == SYS___acl_get_link ||
683 ktr->ktr_code == SYS___acl_set_link ||
684 ktr->ktr_code == SYS___acl_delete_link ||
685 ktr->ktr_code == SYS___acl_aclcheck_link) {
686 print_number(ip,narg,c);
687 acltypename((int)*ip);
690 } else if (ktr->ktr_code == SYS_sigaction) {
696 } else if (ktr->ktr_code == SYS_extattrctl) {
697 print_number(ip,narg,c);
698 extattrctlname((int)*ip);
701 } else if (ktr->ktr_code == SYS_nmount) {
702 print_number(ip,narg,c);
703 print_number(ip,narg,c);
705 mountflagsname ((int)*ip);
708 } else if (ktr->ktr_code == SYS_kse_thr_interrupt) {
709 print_number(ip,narg,c);
711 ksethrcmdname ((int)*ip);
714 } else if (ktr->ktr_code == SYS_thr_create) {
715 print_number(ip,narg,c);
716 print_number(ip,narg,c);
718 thrcreateflagsname ((int)*ip);
721 } else if (ktr->ktr_code == SYS_thr_kill) {
722 print_number(ip,narg,c);
727 } else if (ktr->ktr_code == SYS_kldunloadf) {
728 print_number(ip,narg,c);
730 kldunloadfflagsname ((int)*ip);
736 print_number(ip,narg,c);
744 ktrsysret(struct ktr_sysret *ktr)
746 register_t ret = ktr->ktr_retval;
747 int error = ktr->ktr_error;
748 int code = ktr->ktr_code;
750 if (code >= nsyscalls || code < 0)
751 (void)printf("[%d] ", code);
753 (void)printf("%s ", syscallnames[code]);
757 (void)printf("%d", ret);
758 if (ret < 0 || ret > 9)
759 (void)printf("/%#lx", (long)ret);
762 (void)printf("%ld", (long)ret);
764 (void)printf("%#lx", (long)ret);
766 } else if (error == ERESTART)
767 (void)printf("RESTART");
768 else if (error == EJUSTRETURN)
769 (void)printf("JUSTRETURN");
771 (void)printf("-1 errno %d", ktr->ktr_error);
773 (void)printf(" %s", strerror(ktr->ktr_error));
779 ktrnamei(char *cp, int len)
781 (void)printf("\"%.*s\"\n", len, cp);
785 hexdump(char *p, int len, int screenwidth)
793 i = 13; /* base offset */
794 i += (width / 2) + 1; /* spaces every second byte */
795 i += (width * 2); /* width of bytes */
797 i += width; /* each byte */
799 } while (i < screenwidth);
802 for (n = 0; n < len; n += width) {
803 for (i = n; i < n + width; i++) {
804 if ((i % width) == 0) { /* beginning of line */
805 printf(" 0x%04x", i);
811 printf("%02x", p[i] & 0xff);
816 for (i = n; i < n + width; i++) {
819 if (p[i] >= ' ' && p[i] <= '~')
826 if ((i % width) != 0)
831 visdump(char *dp, int datalen, int screenwidth)
840 for (;datalen > 0; datalen--, dp++) {
841 (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
844 * Keep track of printables and
845 * space chars (like fold(1)).
857 width = 8 - (col&07);
862 if (col + width > (screenwidth-2)) {
863 (void)printf("\\\n\t");
868 (void)putchar(*cp++);
873 (void)printf("\"\n");
877 ktrgenio(struct ktr_genio *ktr, int len)
879 int datalen = len - sizeof (struct ktr_genio);
880 char *dp = (char *)ktr + sizeof (struct ktr_genio);
881 static int screenwidth = 0;
884 if (screenwidth == 0) {
887 if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 &&
889 screenwidth = ws.ws_col;
893 printf("fd %d %s %d byte%s\n", ktr->ktr_fd,
894 ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen,
895 datalen == 1 ? "" : "s");
898 if (maxdata && datalen > maxdata)
901 for (i = 0, binary = 0; i < datalen && binary == 0; i++) {
902 if (dp[i] >= 32 && dp[i] < 127)
904 if (dp[i] == 10 || dp[i] == 13 || dp[i] == 0 || dp[i] == 9)
909 hexdump(dp, datalen, screenwidth);
911 visdump(dp, datalen, screenwidth);
914 const char *signames[] = {
915 "NULL", "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", /* 1 - 6 */
916 "EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", /* 7 - 12 */
917 "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", /* 13 - 18 */
918 "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", /* 19 - 24 */
919 "XFSZ", "VTALRM", "PROF", "WINCH", "29", "USR1", /* 25 - 30 */
920 "USR2", NULL, /* 31 - 32 */
924 ktrpsig(struct ktr_psig *psig)
926 if (psig->signo > 0 && psig->signo < NSIG)
927 (void)printf("SIG%s ", signames[psig->signo]);
929 (void)printf("SIG %d ", psig->signo);
930 if (psig->action == SIG_DFL)
931 (void)printf("SIG_DFL\n");
933 (void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
934 (u_long)psig->action, psig->mask.__bits[0], psig->code);
939 ktrcsw(struct ktr_csw *cs)
941 (void)printf("%s %s\n", cs->out ? "stop" : "resume",
942 cs->user ? "user" : "kernel");
945 #define UTRACE_DLOPEN_START 1
946 #define UTRACE_DLOPEN_STOP 2
947 #define UTRACE_DLCLOSE_START 3
948 #define UTRACE_DLCLOSE_STOP 4
949 #define UTRACE_LOAD_OBJECT 5
950 #define UTRACE_UNLOAD_OBJECT 6
951 #define UTRACE_ADD_RUNDEP 7
952 #define UTRACE_PRELOAD_FINISHED 8
953 #define UTRACE_INIT_CALL 9
954 #define UTRACE_FINI_CALL 10
957 char sig[4]; /* 'RTLD' */
963 char name[MAXPATHLEN];
967 ktruser_rtld(int len, unsigned char *p)
969 struct utrace_rtld *ut = (struct utrace_rtld *)p;
974 case UTRACE_DLOPEN_START:
976 printf("dlopen(%s, ", ut->name);
977 switch (mode & RTLD_MODEMASK) {
985 printf("%#x", mode & RTLD_MODEMASK);
987 if (mode & RTLD_GLOBAL)
988 printf(" | RTLD_GLOBAL");
989 if (mode & RTLD_TRACE)
990 printf(" | RTLD_TRACE");
991 if (mode & ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE))
992 printf(" | %#x", mode &
993 ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE));
996 case UTRACE_DLOPEN_STOP:
997 printf("%p = dlopen(%s) ref %d\n", ut->handle, ut->name,
1000 case UTRACE_DLCLOSE_START:
1001 printf("dlclose(%p) (%s, %d)\n", ut->handle, ut->name,
1004 case UTRACE_DLCLOSE_STOP:
1005 printf("dlclose(%p) finished\n", ut->handle);
1007 case UTRACE_LOAD_OBJECT:
1008 printf("RTLD: loaded %p @ %p - %p (%s)\n", ut->handle,
1009 ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1,
1012 case UTRACE_UNLOAD_OBJECT:
1013 printf("RTLD: unloaded %p @ %p - %p (%s)\n", ut->handle,
1014 ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1,
1017 case UTRACE_ADD_RUNDEP:
1018 parent = ut->mapbase;
1019 printf("RTLD: %p now depends on %p (%s, %d)\n", parent,
1020 ut->handle, ut->name, ut->refcnt);
1022 case UTRACE_PRELOAD_FINISHED:
1023 printf("RTLD: LD_PRELOAD finished\n");
1025 case UTRACE_INIT_CALL:
1026 printf("RTLD: init %p for %p (%s)\n", ut->mapbase, ut->handle,
1029 case UTRACE_FINI_CALL:
1030 printf("RTLD: fini %p for %p (%s)\n", ut->mapbase, ut->handle,
1036 printf("RTLD: %d ", len);
1039 printf(" %d", *p++);
1041 printf(" %02x", *p++);
1046 struct utrace_malloc {
1053 ktruser_malloc(int len, unsigned char *p)
1055 struct utrace_malloc *ut = (struct utrace_malloc *)p;
1057 if (ut->p == NULL) {
1058 if (ut->s == 0 && ut->r == NULL)
1059 printf("malloc_init()\n");
1061 printf("%p = malloc(%zu)\n", ut->r, ut->s);
1064 printf("free(%p)\n", ut->p);
1066 printf("%p = realloc(%p, %zu)\n", ut->r, ut->p, ut->s);
1071 ktruser(int len, unsigned char *p)
1074 if (len >= 8 && bcmp(p, "RTLD", 4) == 0) {
1075 ktruser_rtld(len, p);
1079 if (len == sizeof(struct utrace_malloc)) {
1080 ktruser_malloc(len, p);
1084 (void)printf("%d ", len);
1087 (void)printf(" %d", *p++);
1089 (void)printf(" %02x", *p++);
1096 (void)fprintf(stderr,
1097 "usage: kdump [-dEnlHRsT] [-f trfile] [-m maxdata] [-p pid] [-t [cnisuw]]\n");