how did I get here?
am 08.04.2009 22:14:02 von E R
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?
This is similar to what dtrace on Solaris can do for system calls, but
I am only looking to instrument perl subroutines (or points in perl
code.)
Also, like dtrace, it would be nice to do this on a running
perl/mod_perl process. It's kinda like being able to attach the perl
debugger to a running process.
I realize I'm probably just dreaming right now, but I figured I'd at
least bring up the idea with other perl users.
Re: how did I get here?
am 08.04.2009 22:23:21 von Brock Diegel
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
Re: how did I get here?
am 08.04.2009 22:39:23 von Perrin Harkins
On Wed, Apr 8, 2009 at 4:14 PM, 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?
The closest thing (aside from actually using Dtrace where Perl is
built with it) is either PERL_TRACE or a stack trace from
Devel::StackTrace.
> Also, like dtrace, it would be nice to do this on a running
> perl/mod_perl process. It's kinda like being able to attach the perl
> debugger to a running process.
A cheap hack for this would be to build in stack trace logging calls
together with a logging system like Log::Log4Perl that can watch a
file to see when you turn logging on for a certain section. It's no
Dtrace, but it's better than nothing if you need it.
- Perrin
Re: how did I get here?
am 08.04.2009 23:46:47 von Emmanuel Seyman
* E R [08/04/2009 22:42] :
>
> That is, for a given
> subroutine, what does the stack look like when the subroutine is
> executed?
Does Acme::JavaTrace do what you're looking for?
Emmanuel
Re: how did I get here?
am 09.04.2009 18:27:29 von E R
On Wed, Apr 8, 2009 at 3:23 PM, Andy Armstrong wrote:
>
> 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.
Thanks for the pointer to dtrace perl on Mac OS - now I've got a good
reason to upgrade to Leopard.
Re: how did I get here?
am 13.04.2009 19:54:14 von Philip Gollucci
> 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.
dtrace is on FreeBSD too, but kernel only atm. Work is in on-going for
userland. It might make it in 8.0 or 8.x
--
------------------------------------------------------------ ------------
1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70 3F8C 75B8 8FFB DB9B 8C1C
Philip M. Gollucci (pgollucci@p6m7g8.com) c: 703.336.9354
Consultant - P6M7G8 Inc. http://p6m7g8.net
Senior Sys Admin - RideCharge, Inc. http://ridecharge.com
Contractor - PositiveEnergyUSA http://positiveenergyusa.com
ASF Member - Apache Software Foundation http://apache.org
FreeBSD Committer - FreeBSD Foundation http://freebsd.org
Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.