title: Tool to trace local function calls in Linux
body: <p>I am looking for a tool like <a href="http://linux.die.net/man/1/ltrace" rel="noreferrer">ltrace</a> or <a href="http://linux.die.net/man/1/strace" rel="noreferrer">strace</a> that can trace locally defined functions in an executable.  ltrace only traces dynamic library calls and strace only traces system calls.  For example, given the following C program:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int triple ( int x )
  {
    return 3 * x;
  }
  
  int main (void)
  {
    printf("%d\n", triple(10));
    return 0;
  }
  </code></pre>
  
  <p>Running the program with <code>ltrace</code> will show the call to <code>printf</code> since that is a standard library function (which is a dynamic library on my system) and <code>strace</code> will show all the system calls from the startup code, the system calls used to implement printf, and the shutdown code, but I want something that will show me that the function <code>triple</code> was called.  Assuming that the local functions have not been inlined by an optimizing compiler and that the binary has not been stripped (symbols removed), is there a tool that can do this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>A couple of clarifications:</p>
  
  <ul>
  <li>It is okay if the tool also provides trace information for non-local functions.</li>
  <li>I don't want to have to recompile the program(s) with support for specific tools, the symbol information in the executable should be enough.</li>
  <li>I would be really nice if I could use the tool to attach to existing processes like I can with ltrace/strace.</li>
  </ul>