<p>How do I make gdb print functions of interest as they are called, indented according to how deep in the stack they are?</p>

<p>I want to be able to say something like (made up):</p>

<pre><code>(gdb) trace Foo* Bar* printf
</code></pre>

<p>And have gdb print all functions which begin with Foo or Bar, as they are called. Kind of like gnu cflow, except using the debugging symbols and only printing functions which actually get called, not all possible call flows.</p>

<p>Tools which won't help include cachegrind, callgrind and oprofile, which order the results by which functions were called most often. I need the order of calling preserved.</p>

<p>The wildcarding (or equivalent) is essential, as there are a lot of Foo and Bar funcs. Although I would settle for recording absolutely every function. Or, perhaps telling gdb to record all functions in a particular library.</p>

<p>Some GDB wizard must have a script for this common job!</p>

Did you see litb's excellent anwser to a similar post
here
?
He uses readelf to get interesting symbols, gdb commands to get the trace, and awk to glue all that.
Basically what you have to change is to modify his gdb command script to remove the 1 depth from backtrace to see the stack and filter specific functions, and reformat the output with an awk/python/(...) script to present it as a tree. (I admit I'm too lazy to do it now...)