$ git clone https://code.google.com/p/strace-plus/
$ cd strace-plus/ $ autoreconf -f -i $ ./configure $ make $ cp strace strace+
hello.c
. hello.c is a simple program that makes four write system calls via printf statements:
#include void bar() { printf("bar\n"); printf("bar again\n"); } void foo() { printf("foo\n"); bar(); } int main() { printf("Hello world\n"); foo(); return 0; }
$ gcc hello.c -o hello
$ ./hello
strace+
on the hello executable to generate a trace file named hello.out.$ ./strace+ -o hello.out ./hello
hello.out
to print out a list of system calls each augmented with stack tracespython scripts/pretty_print_strace_out.py hello.out --trace
I like to always try and compile tools statically if possible. Especially in a case like this where you don't want strace+
to replace strace
.
$ cd strace-plus/ $ export CFLAGS="-Os -fomit-frame-pointer -static -static-libgcc -ffunction-sections -fdata-sections -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -Wl,--gc-sections -Wl,-Map=strace.mapfile" $ autoreconf -i -f $ ./configure $ make CFLAGS="$CFLAGS" $ cp strace strace+
# Normal strace $ file /usr/bin/strace /usr/bin/strace: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped # Static strace-plus $ file strace+ strace+: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, not stripped
Useful to stick in your .bash_profile
alias strace='command strace -fq -s1000 -e trace=all 2>&1'
alias stracef='command strace -fq -s1000 -e trace=file 2>&1'
function tputtrace () { ( 2>&2 strace -s5000 -e write tput $1 2>&1 ) | tee -a /dev/stderr | grep --color=always -o '"[^"]*"'; }
vistrace: a visualization of strace