How do I track recursion depth?
<p>I have a recursive function that I am troubleshooting.  I want to output the recursion depth...i.e. how many times the function calls itself.</p>

<p>If I use a static variable that increments at the top of the function and decrements at the bottom.</p>

<p>Will this accurately give me the depth level?</p>

<pre><code>recurse()
  {
  static int depth = 0;
  depth++;
  /*
  do stuff
  recurse()
  */
  depth--;
  return return_value;
  }
</code></pre>
