SYNOPSIS

#!/usr/bin/perl -d:CallTrace

package foo;

sub bar {

  print \*(L"bar\n\*(R";
  baz();

}

sub baz {

    print \*(L"boo\n\*(R";

}

foo::bar();

RATIONALE

There are a number of perl modules in the \s-1CPAN\s0 that are designed to trace a program's execution as it runs. Each uses a different trick to do its job, but none of them quite met my needs. The technique this module uses is quite simple and seems to be quite robust.

DB::sub

perl will automatically call DB::sub on each subroutine call and leave it up to us to dispatch to where we want to go.

Devel::CallTrace::called

This routine is called with two parameters:

\s-1DEPTH\s0

The integer \*(L"depth\*(R" that this call is being called at.

\s-1PARAMS\s0

A reference to the routine's @INC

To get at the subroutine that was being called, have a look at $DB::sub

BUGS

It uses the debugger. How could it not have bugs?

RELATED TO Devel::CallTrace…

perldebguts, \s-1DB\s0, a licensed therapist.

trace - Uses source filters. Scares me.

Devel::TraceCalls - Very robust \s-1API\s0. The code seems to do all sorts of scary magic

Debug::Trace - Uses symbol table magic to wrap your functions.

Devel::TRaceFuncs - Requires developers to instrument their source files.

COPYRIGHT

Copyright 2005 Jesse Vincent <[email protected]>

This module may be redistributed under the same terms as perl itself