ktruss

From NetBSD Wiki

Jump to: navigation, search

ktruss(1) enables kernel trace logging for the specified processes. ktruss is functionally the same as ktrace except that trace output is printed on standard output or to the file specified with the -o option. ktruss is useful to see the kernel operations interleaved with the program output.

Example

# ktruss ls
.cshrc                   .login                   .profile                 netbeans
.lesshst                 .logout                  .shrc                    netbeans-5_5.tar.bz2
   813      1 ktruss   emul(netbsd)
   813      1 ktruss   fcntl(0x4, 0x3, 0)          = 1
   813      1 ktruss   fcntl(0x4, 0x4, 0x1)        = 0
   813      1 ktruss   execve("/home/zafer/bin/ls", 0xbfbfed80, 0xbfbfed88) Err#2 ENOENT
   813      1 ls       emul(netbsd)
   813      1 ls       execve("/bin/ls", 0xbfbfed80, 0xbfbfed88) JUSTRETURN
   813      1 ls       mmap(0, 0x8000, 0x3, 0x1002, 0xffffffff, 0, 0, 0) = 0xbbbea000
   813      1 ls       open("/etc/ld.so.conf", 0, 0xffffffff) = 3
   813      1 ls       __fstat30(0x3, 0xbfbfec8c)  = 0
   813      1 ls       mmap(0, 0x37, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe9000
   813      1 ls       close(0x3)                  = 0
   813      1 ls       munmap(0xbbbe9000, 0x37)    = 0
   813      1 ls       open("/lib/libutil.so.7", 0, 0) = 3
   813      1 ls       __fstat30(0x3, 0xbfbfe5a8)  = 0
   813      1 ls       mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe9000
   813      1 ls       munmap(0xbbbe9000, 0x1000)  = 0
   813      1 ls       mmap(0, 0x12000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbbd8000
   813      1 ls       mmap(0xbbbe7000, 0x2000, 0x3, 0x12, 0x3, 0, 0xe000, 0) = 0xbbbe7000
   813      1 ls       mmap(0xbbbe9000, 0x1000, 0x3, 0x1012, 0xffffffff, 0, 0, 0) = 0xbbbe9000
   813      1 ls       close(0x3)                  = 0
   813      1 ls       open("/lib/libc.so.12", 0, 0xbfbfe5a8) = 3
   813      1 ls       __fstat30(0x3, 0xbfbfe5a8)  = 0
   813      1 ls       mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbd7000
   813      1 ls       munmap(0xbbbd7000, 0x1000)  = 0
   813      1 ls       mmap(0, 0xdb000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbafd000
   813      1 ls       mmap(0xbbbc1000, 0x7000, 0x3, 0x12, 0x3, 0, 0xc3000, 0) = 0xbbbc1000
   813      1 ls       mmap(0xbbbc8000, 0x10000, 0x3, 0x1012, 0xffffffff, 0, 0, 0) = 0xbbbc8000
   813      1 ls       close(0x3)                  = 0
   813      1 ls       __sysctl(0xbfbfecb0, 0x2, 0xbbbc7d40, 0xbfbfecb8, 0, 0) = 0
   813      1 ls       issetugid()                 = 0
   813      1 ls       ioctl(0x1, TIOCGETA, 0xbfbfec98) = 0
       "\^B+\0\0\a\0\0\0\0K\0\0\M-K\^E\0 \^D\M^?\M^?\^?\^W\^U\^R\M^?\^C\^\\^Z\^Y\^Q\^S\^V\^O\^A\0\^T\M^?\0\M^V\0\0\0\M^V\0"
   813      1 ls       ioctl(0x1, TIOCGWINSZ, 0xbfbfecf4) = 0
       ",\0}\0\0\0\0\0"
   813      1 ls       getuid()                    = 0
   813      1 ls       __sysctl(0xbfbfeba0, 0x2, 0xbfbfebac, 0xbfbfebb0, 0, 0) = 0
   813      1 ls       readlink("/etc/malloc.conf", 0xbfbfebe0, 0x3f) Err#2 ENOENT
   813      1 ls       mmap(0, 0x1000, 0x3, 0x1002, 0xffffffff, 0, 0, 0) = 0xbbafc000
   813      1 ls       break(0x804c38c)            = 0
   813      1 ls       break(0x804d38c)            = 0
   813      1 ls       break(0x804e000)            = 0
   813      1 ls       break(0x804f000)            = 0
   813      1 ls       break(0x8050000)            = 0
   813      1 ls       break(0x8051000)            = 0
   813      1 ls       __stat30(".", 0xbfbfec04)   = 0
   813      1 ls       open(".", 0, 0)             = 3
   813      1 ls       fcntl(0x3, 0x2, 0x1)        = 0
   813      1 ls       fchdir(0x3)                 = 0
   813      1 ls       open(".", 0, 0)             = 5
   813      1 ls       open(".", 0x4, 0)           = 6
   813      1 ls       fcntl(0x6, 0x2, 0x1)        = 0
   813      1 ls       __fstat30(0x6, 0xbfbfeba8)  = 0
   813      1 ls       __sysctl(0xbfbfe288, 0x2, 0xbbbd72c0, 0xbfbfe290, 0, 0) = 0
   813      1 ls       fstatvfs1(0x6, 0xbfbfe2f4, 0x2) = 0
   813      1 ls       break(0x8052000)            = 0
   813      1 ls       break(0x8053000)            = 0
   813      1 ls       lseek(0x6, 0, 0, 0, 0x1)    = 0
   813      1 ls       __getdents30(0x6, 0x8051000, 0x1000) = 240
       "\^Y\M-5\0\0\0\0\0\0\^P\0\^A\0\^D.\0\0\^X\M-5\0\0\0\0\0\0\^P\0\^B\0\^D..\0H\^C\0\0\0\0\0\0\^X\0\b\0\^Dnetbeans\0\0"
   813      1 ls       lseek(0x6, 0, 0, 0, 0x1)    = 512
   813      1 ls       __getdents30(0x6, 0x8051000, 0x1000) = 0
       ""
   813      1 ls       close(0x6)                  = 0
   813      1 ls       fchdir(0x5)                 = 0
   813      1 ls       close(0x5)                  = 0
   813      1 ls       __fstat30(0x1, 0xbfbfe9c8)  = 0
   813      1 ls       ioctl(0x1, TIOCGETA, 0xbfbfea08) = 0
       "\^B+\0\0\a\0\0\0\0K\0\0\M-K\^E\0 \^D\M^?\M^?\^?\^W\^U\^R\M^?\^C\^\\^Z\^Y\^Q\^S\^V\^O\^A\0\^T\M^?\0\M^V\0\0\0\M^V\0"
   813      1 ls       write(0x1, 0x8052000, 0x54) = 84
       ".cshrc                   .login                   .profile                 netbeans\n"
   813      1 ls       write(0x1, 0x8052000, 0x60) = 96
       ".lesshst                 .logout                  .shrc                    netbeans-5_5.tar.bz2\n"
   813      1 ls       fchdir(0x3)                 = 0
   813      1 ls       close(0x3)                  = 0
   813      1 ls       exit(0)

See also

View source code (Please report any bugs or suggestions here).

Personal tools