Process Tracing Tips and Tools - oils-for-unix/oils GitHub Wiki
Tracing Processes You Don't Control
e.g. busybox ash on an Alpine machine, for reducing bugs from regtest/aports. These techniques do NOT require recompilation, debug symbols, or source code modification
-
Shell interpreter tracing with
set -xakaset -o xtrace- show shell statements executed- Example from Andy: I used this to discover that autotool configure scripts call
rmandcatcommonly, and then we implementedbuiltin rmandbuiltin cat - multi-process tracing with
set -x; export SHELLOPTS- bash and OSH have a feature where you canexport SHELLOPTStoset -xon all child processes - Note: bash also has an
XTRACE_FD=env var to send all the traces to the same place; I don't think OSH has this yet
- Example from Andy: I used this to discover that autotool configure scripts call
-
strace myprog- show syscalls- Samuel used this for the
$PWDbug - It can be helpful to use
-f -o FILEand then start replacing the PIDs with a human name in the file to analyze e.g. races - use something like
-e t=chdir,file,read,write, to limit the shown syscalls (e.g.memoryis usually irrelevant) -vto not abbreviate-s 1000to abbreviate strings only after 1000 characters (needs to be in addition to-v- the
-cflag creates a histogram of syscalls - the
-fflag follows child processes - multi-process tracing with
strace -ff -o prefix- follow forks, createsprefix.$PIDfiles
- Samuel used this for the
-
ltrace myprog- showlibccalls- has an
-eflag - Example from Andy: I used this to debug
setlocale()calls in bash versus OSH
- has an
Tracing or Debugging Processes You Can Modify
Require Symbols / Recompilation
gdb --args myprog --flag- ASAN gives nicer stack traces
- We are using
uftrace- user space function tracing- it traces all function call entry and exit, by putting probes in the code
Require Source Code Instrumentation
systemtap- we haveDTRACE_PROBE()calls in the Oils C++ source code
Related
- Process Tracing Projects
- Implementing Debuggers
- Tips on Reducing Bugs to Small Test Cases - for
regtest/aports