Truss

From pressy's brainbackup
Jump to: navigation, search

Never forget the mega truss command

Sometimes a very useful output if you really want to see everything:

# truss -elfda -rall -wall -vall -xall [-o output.txt ] -p <pid>

But; did you know that debug tool set:

root@solaris~# LD_DEBUG=help /usr/bin/true
debug:
debug: Solaris ELF Utilities: 11.4-1.3170
debug:
debug: The runtime linker and link-editor support a shared debugging
debug: facility. Options are selected via a comma separated list of tokens,
debug: each of which specifies a display option or a category for which
debug: information is desired. Many tokens apply to both linker components,
debug: while some are specific to one or the other. Diagnostics are printed,
debug: one per line, with a standard prefix prepended to each one. Output
debug: for the help token, used by itself, is sent to stdout. Use of
debug: any other tokens causes diagnostic output to be sent to stderr
debug: unless otherwise redirected.
debug:
[...] ~snip

Example, prepend time stamps entering ld or ld.so.1 and elapsed time:

root@solaris~# LD_DEBUG=dtime,ttime,all <cmd> 

Or used files:

root@solaris~#  LD_DEBUG=files /usr/bin/who
debug:
debug: Solaris ELF Utilities: 11.4-1.3170
debug:
23632:
23632: platform capability (CA_SUNW_PLAT) - sun4v
23632: machine capability (CA_SUNW_MACH) - sun4v
23632: hardware capabilities (CA_SUNW_HW_2) - 0x40002  [ VIS3C VIS3B ]
23632: hardware capabilities (CA_SUNW_HW_1) - 0x3ffe8df7  [ CRC32C CBCOND PAUSE MONT MPMUL SHA512 SHA256 SHA1 MD5 CAMELLIA KASUMI DES AES IMA HPC VIS3 FMAF ASI_BLK_INIT VIS2 VIS POPC FSMULD DIV32 MUL32 ]
23632:
23632:
23632: configuration file=/var/ld/64/ld.config: unable to process file
23632:
23632: file=/usr/bin/who  [ ELF ]; generating link map
23632:     addr:        0x7fdee83c00000  size:             0x105c34
23632:     lmid:                   BASE  lmco:                 0x20
23632:
23632: file=/usr/bin/who;  analyzing  [ RTLD_LAZY RTLD_GLOBAL RTLD_WORLD RTLD_NODELETE ]
23632:
23632: file=libc.so.1;  needed by /usr/bin/who
23632: file=/lib/64/libc.so.1  [ ELF ]; generating link map
23632:     addr:        0x7fdee82f00000  size:             0x343a80
23632:     lmid:                   BASE  lmco:                 0x20
23632:
23632: file=/lib/64/libc.so.1;  analyzing  [ RTLD_NOW RTLD_GLOBAL RTLD_WORLD RTLD_NODELETE ]
23632:
23632: file=/lib/64/libc.so.1;  filter for /usr/lib/sparcv9/ld.so.1
23632:
23632: file=/usr/lib/sparcv9/ld.so.1;  filtered by /lib/64/libc.so.1
23632:
23632: 1:
23632: 1: transferring control: /usr/bin/who
23632: 1:
root       pts/93       Jul 13 09:04    (123.123.13.200)
root       pts/67       Jul 13 13:43    (123.123.13.200)
23632: 1:
root@solaris~#