I had a problem with one of my programs going abnormally slow. Being a linux developer, one of the steps I took to diagnosing the problem was to strace the executable. Interestingly it showed me that I was accessing /usr/share/zoneinfo/GMT a ridiculous quantity of times. What I needed then was a stack trace at the time /usr/share/zoneinfo/GMT was opened. strace doesn’t provide that information.
A bit of search engine work reveals
but that seemed a bit like too much work.
A bit more learning about gdb taught me that you can break on syscalls using
Now this might have worked but the file I was opening a lot was well after the program startup, so I decided to keep looking for a better solution. That’s when I discovered
strace-plus is a version of strace with a call stack print out at every syscall. Exactly what I wanted. There are two points to note about that webpage. First is that the make produces an executable called strace not strace+; so you’ll need to
cp strace strace+
if you want to stay sane. Secondly in step 3 where they say
./strace+ -o hello.out ./hello
you actually need to use
./strace+ -k -o hello.out ./hello
Note the -k which gets the actual stack trace.