strace on 64 bit host can't trace reads() of 32-bit app?

Lavrentiev, Anton (NIH/NLM/NCBI) [C] lavr at ncbi.nlm.nih.gov
Wed Feb 2 19:38:29 UTC 2011


Hi,

Could you please confirm the limitation noted in $subject?

Here's an example of what I was doing and could not get strace
to print detailed data output for fd=3:

> which strace
/usr/bin/strace

> ls -l /usr/bin/strace
-rwxr-xr-x 1 root root 293744 Jun 12  2010 /usr/bin/strace

> strace -V
strace -- version 4.5.18

> file my_test_app
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped

> ldd ./my_test_app
        linux-gate.so.1 =>  (0xffffe000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00c24000)
        librt.so.1 => /lib/librt.so.1 (0x00acc000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xf7ede000)
        libm.so.6 => /lib/libm.so.6 (0x00b77000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xf7ed2000)
        libc.so.6 => /lib/libc.so.6 (0x0094f000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00aaa000)
        /lib/ld-linux.so.2 (0x00930000)

> strace -o out.strace -e trace=all -e read=3 -tt -v ./my_test_app
[ Process PID=27910 runs in 32 bit mode. ]

The file out.strace then contained the following:

...
13:45:00.281455 open("/lib/libnsl.so.1", O_RDONLY) = 3
13:45:00.281481 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 at q\302\0004\0\0\0"..., 512) = 512
13:45:00.281509 fstat64(3, {st_dev=makedev(253, 0), st_ino=2392095, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096,
...
13:45:00.287440 readlink("/proc/self/fd/0", "/dev/pts/44"..., 511) = 11
13:45:00.287493 access("/var/run/utmpx", F_OK) = -1 ENOENT (No such file or directory)
13:45:00.287515 open("/var/run/utmp", O_RDONLY|O_LARGEFILE) = 3
13:45:00.287537 fcntl64(3, F_GETFD)     = 0
13:45:00.287554 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
13:45:00.287572 _llseek(3, 0, [0], SEEK_SET) = 0
13:45:00.287591 alarm(0)                = 0
13:45:00.287609 rt_sigaction(SIGALRM, {0xa54b10, [], 0}, {SIG_DFL, [], SA_STACK|SA_RESTART|SA_NODEFER|0x2c302d0}, 8) = 0
13:45:00.287635 alarm(1)                = 0
13:45:00.287651 fcntl64(3, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13:45:00.287674 read(3, "\10\0\0\0\375\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
13:45:00.287711 read(3, "\2\0\0\0\0\0\0\0~\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
13:45:00.287734 read(3, "\1\0\0\0003N\0\0~\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
13:45:00.287756 read(3, "\10\0\0\0\324\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
...

When I run strace (same command) for the very same app but built in 64-bit mode, I get the proper "picture":

> file my_test_app
ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not stripped

> ldd ./my_test_app
        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003f61400000)
        librt.so.1 => /lib64/librt.so.1 (0x0000003f5dc00000)
        libstdc++.so.6 => /usr/lib64/gcc-4.0.1/libstdc++.so.6 (0x0000003cc9c00000)
        libm.so.6 => /lib64/libm.so.6 (0x000000345d400000)
        libgcc_s.so.1 => /usr/lib64/gcc-4.0.1/libgcc_s.so.1 (0x0000003f5c400000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003f5ac00000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003f5b800000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003f5a800000)

14:08:38.919920 open("/lib64/libnsl.so.1", O_RDONLY) = 3
14:08:38.919953 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240@@a?\0\0\0"..., 832) = 832
 | 00000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  .ELF.... ........ |
 | 00010  03 00 3e 00 01 00 00 00  a0 40 40 61 3f 00 00 00  ..>..... .@@a?... |
 | 00020  40 00 00 00 00 00 00 00  f0 b5 01 00 00 00 00 00  @....... ........ |
...
14:08:38.929667 readlink("/proc/self/fd/0", "/dev/pts/44"..., 511) = 11
14:08:38.929719 access("/var/run/utmpx", F_OK) = -1 ENOENT (No such file or directory)
14:08:38.929741 open("/var/run/utmp", O_RDONLY) = 3
14:08:38.929762 fcntl(3, F_GETFD)       = 0
14:08:38.929783 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
14:08:38.929802 lseek(3, 0, SEEK_SET)   = 0
14:08:38.929818 alarm(0)                = 0
14:08:38.929836 rt_sigaction(SIGALRM, {0x3f5ad06bc0, [], SA_RESTORER, 0x3f5ac302d0}, {SIG_DFL, [], 0}, 8) = 0
14:08:38.929860 alarm(1)                = 0
14:08:38.929876 fcntl(3, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
14:08:38.929899 read(3, "\10\0\0\0\375\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
 | 00000  08 00 00 00 fd 02 00 00  00 00 00 00 00 00 00 00  ........ ........ |
...
14:08:38.930005 read(3, "\2\0\0\0\0\0\0\0~\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
 | 00000  02 00 00 00 00 00 00 00  7e 00 00 00 00 00 00 00  ........ ~....... |
...

BTW, when I added "-e write=1" to the strace command when launching the 32-bit app, it produced
the detailed dumps for data written to stdout.

Thanks,

Anton Lavrentiev
Contractor NIH/NLM/NCBI





More information about the Strace-devel mailing list