3 ms·
Pretty nice! I recall having used strace for this, and this is certainly nicer for that use case. I think I used it to determine how a certain file was built. S
by _flux 2y ago
Pretty nice! I recall having used strace for this, and this is certainly nicer for that use case. I think I used it to determine how a certain file was built. Somehow it was easier to do it that way than understand the build system :).
What I did though was generate dot-files for graphviz to process. To that graph it's easy to add information about opened/created files as well.
- _flux 2y agoFound the script, so here it is for posterity! #!/bin/sh if [ -z "$1" ]; then echo "usage (in zsh): 'strace -f program -o logi; okular =(dot -Tpdf =($0 logi))'" exit 0 fi LOG=$1 echo 'digraph {' echo 'rankdir="LR";' sed 's/^\([0-9]*\) \(<... \)\?\(clone\|vfork\).*= \([0-9]*\)/\1 -> \4;/; t; d' "$LOG" sed '/ENOENT/ d; s/^\([0-9]*\) execve("[^"]*\/\([^"]*\)".*/\1 [label="\1: \2"];/; t; d' "$LOG" | sort | uniq sed '/ENOENT/ d; s/^\([0-9]*\) openat([^,]*, "\([^"]*\)", .*\(O_WRONLY\|O_RDWR\).*/\1 -> "\2"; "\2" [shape=rectangle];/; t; d' "$LOG" | sort | uniq echo '}' I imagine it makes a graph of executed programs along the files they created, perhaps it even works in some cases.