https://jvns.ca/blog/2021/04/03/what-problems-do-people-solve-with-strace/
Yesterday I asked on Twitter about what problems people are solving with strace and as usual everyone really delivered! I got 200 answers and then spent a bunch of time manually categorizing them into 9 categories of problems.
All of the problems are about either finding files a program depends on, figuring out why a program is stuck or slow, or finding out why a program is failing. These generally matched up with what I use strace for myself, but there were some things I hadn’t thought of too!
I’m not going to explain what strace is in this post but I have a free zine about it and a talk and lots of blog posts.
The #1 most popular problem was “this program has a configuration file and I don’t know where it is”. This is probably my most common use for strace too, because it’s such a simple question.
This is great because there are a million ways for a program to document where its config file is (in a man page, on its website, in --help, etc), but there’s only one way for it to actually open it (with a system call!)
You can also use strace to find other types of files a program depends on, like:
.so file?“) like this ruby problem I debugged in 2014You have a program, it’s just sitting there doing nothing, what’s going on? This one is especially easy to answer because a lot of the time you just need to run strace -p PID and look at what system call is currently running. You don’t even have to look through hundreds of lines of output!
The answer is usually ‘waiting for some kind of I/O’. Some possible answers for “why is this stuck” (though there are a lot more!):
select()wait()ing for a subprocess to finish