On 8 Apr 2009, at 21:14, E R wrote:
When diving into a large code base and trying to understand how it
works, one thing that would be very helpful to know is how control
gets to a particular point in the code. That is, for a given
subroutine, what does the stack look like when the subroutine is
executed?


I agree - it'd be lovely just to have something like dtrace that you could turn on for a running process but which would consume negligible CPU while inactive.

I've had some success with manually adding instrumentation that captures the stack backtrace at strategic points and spooling it to a file then post-processing the captured data to produce a dynamic call graph.

On Solaris and Mac OS you could actually use a dtrace-enabled Perl. You only get sub entry / exit but you can infer a call graph from that.

If you'd like to take the idea further yourself you could also take a look at Devel::DTrace[1] which uses a custom runops loop to instrument sub entry/exit. With minor hacking that could capture a raw trace.

[1] http://search.cpan.org/dist/Devel-DTrace

--
Andy Armstrong, Hexten

Reply via email to