strace
#
What's strace?#
- Trace calls to system calls, signals
- Debug programs for which no source is available
- Simple profiling
Profiling#
strace -wc ./a.out # wall time
Use strace "in the wild"#
systemd#
Prepend the command: ExecStart=/usr/bin/strace /path/to/bin
Replace the binary1#
mv /usr/bin/something /usr/bin/something.real
cat <<EOF > /usr/bin/something
#!/usr/bin/env bash
strace "@!" 2>&1 | tee /tmp/something.log.$$
EOF
chmod +x /usr/bin/something