Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

how did I get here?

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


pc88mxer at gmail

Apr 8, 2009, 1:14 PM

Post #1 of 6 (1124 views)
Permalink
how did I get here?

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.


andy at hexten

Apr 8, 2009, 1:23 PM

Post #2 of 6 (1069 views)
Permalink
Re: how did I get here? [In reply to]

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


pharkins at gmail

Apr 8, 2009, 1:39 PM

Post #3 of 6 (1062 views)
Permalink
Re: how did I get here? [In reply to]

On Wed, Apr 8, 2009 at 4:14 PM, E R <pc88mxer [at] gmail> 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


emmanuel.seyman at club-internet

Apr 8, 2009, 2:46 PM

Post #4 of 6 (1058 views)
Permalink
Re: how did I get here? [In reply to]

* 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


pc88mxer at gmail

Apr 9, 2009, 9:27 AM

Post #5 of 6 (1043 views)
Permalink
Re: how did I get here? [In reply to]

On Wed, Apr 8, 2009 at 3:23 PM, Andy Armstrong <andy [at] hexten> 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.


pgollucci at p6m7g8

Apr 13, 2009, 10:54 AM

Post #6 of 6 (1004 views)
Permalink
Re: how did I get here? [In reply to]

> 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 [at] p6m7g8) 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.

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.