Understanding the actual code flow of an application can be tricky at times, particularly in the presence of function pointers. A typical methodology for following code flow is to step through the program in gdb, but that can be tediously slow. What if you could record every function entry and exit?
By utilizing the gcc compiler option -finstrument-functions a dynamic function address trace can be recorded. Once you have that dynamic stack trace, the pvtrace utility written by M. Tim Jones can convert that recorded trace into a graphviz dot graph that can then be visualised.
An article containing full details of this procedure and how it works behind the scenes was written by the pvtrace source code author M. Tim Jones in 2005. This article was once available on the IBM developer works website but now both the article and source code are a little hard to come by. Thanks to the wayback machine I’ve been able to acquire both the article and the source code and I’ve created a github repository (https://github.com/DrGeoff/pvtrace.git) to make them more easily accessible.