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

catch syscall

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.

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: