Open dwmarshall opened 10 years ago
Sounds like a great idea! Here's a few things you might find useful:
First off, there's a little known feature in the built-in perl debugger that lets you do something similar, so if you have something like
for my $i (1..3) {
foo($i);
}
sub foo {
print "$_[0]\n";
}
and run the script via
PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=4" perl -dS scriptname
you'll get
8: for my $i (1..3) {
9: foo($i);
in .=main::foo(1) from ./t:9
13: print "$_[0]\n";
1
9: foo($i);
in .=main::foo(2) from ./t:9
13: print "$_[0]\n";
2
9: foo($i);
in .=main::foo(3) from ./t:9
13: print "$_[0]\n";
3
but unfortunately, that doesn't provide the convenience Log4perl users take for granted :). As for Log4perl, many, many years ago (11 to be precise), someone on CPAN set out to create a Log4perl extension to accomplish something similar:
http://search.cpan.org/~jcromie/Log-Log4perl-AutoCategorize-0.03/
Unfortunately, this module didn't stand the test of time and looks broken today, but you might be able to extract some ideas.
Keep the pull request coming! :)
Another bit of existing art that leverages the Perl debugger is https://metacpan.org/pod/Devel::TraceRun. You might request a takeover of the AutoCategorize module, and then get it back to working.
Particularly when I am debugging a module that I haven't maintained before, I'd like to automatically instrument all the subroutines. Here's what I'd like to do:
This would look through the symbol table for
Foo::Bar
and replace each subroutine something like this:Mike, I wanted to get your thoughts before contributing any code changes.