in reply to Automatic Debugging

See Devel::TraceFuncs for one way to do this.

It wouldn't be too hard to write a module, say Devel::TraceMethods that would be used like:

use Module::Name; use Devel::TraceMethods qw( Module::Name );
And would import all function from Module::Name into Devel::TraceMethods::Module::Name and then undef them from Module::Name. Then it would define Module::Name::AUTOLOAD that logged the call and then called the real function Devel::TraceMethods::Module::Name.

You could even make this work in the face of a module that used AUTOLOAD (by having your AUTOLOAD log and then, if needed, call their AUTOLOAD, but then shuffle the new routine into the other namespace when that returns).

Unfortunately, I'm not free to write one at the moment.

Update: The above would break can for this module, so the start-up and AUTOLOAD should build shim routines that log and then call the real routine.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Automatic Debugging
by chromatic (Archbishop) on May 30, 2001 at 08:24 UTC
Re: (tye)Re: Automatic Debugging
by DBX (Pilgrim) on May 30, 2001 at 03:34 UTC
    That's clever. I suppose a quick and dirty way would be to define ChildModule of Module and only define an ChildModule::Autoload. ChildModule::Autoload would log the function call, then call SUPER::ModuleSub

      Sorry, no. SUPER:: requires @ChildModule::ISA contain your Module, which also means that AUTOLOAD won't be called for methods that are defined in your Module.

      But you can do something like:

      package AutoTrace; my %pkgMap; sub AUTOLOAD { logCall( $AUTOLOAD, @_ ); my $wantPkg= $AUTOLOAD =~ s/(.*):://; $AUTOLOAD= $pkgMap{$wantPkg}."::".$AUTOLOAD; goto &$AUTOLOAD; } $pkgMap{ChildModule}= "Module"; *ChildModule::AUTOLOAD= \&AUTOLOAD;
      instead of the SUPER:: trick (again, can won't work, which often won't be a problem).

              - tye (but my friends call me "Tye")