Hi,
I'm having some trouble working with Apache::DB. I would like to
override the debugger subs DB::DB and DB::sub with my own custom
versions. I tried several tips found on here and clpm, but can't quite
get it to work.
I'm running Perl 5.8.8, mod_perl 2, apache 2.0.55, Freebsd 5.5.

Here's what I'm doing:
# From httpd.conf. Note I've compiled perl so that @INC contains a lib directory
# in my /home where my modules are, and perl and httpd are able to use/require
# those modules.

PerlSetEnv PERL5DB 'require "SubTrace.pm"'
<Perl>
 use APR::Pool ();
 use Apache::DB ();
 Apache::DB->init();
</Perl>

<Location ~ "/MyProject/.*cgi$">
 Options Indexes FollowSymLinks ExecCGI
 AllowOverride All
 SetHandler perl-script
 PerlResponseHandler ModPerl::Registry
 PerlOptions +ParseHeaders
 PerlFixupHandler +Apache::DB
 Order allow,deny
 Allow from 127.0.0.1
</Location>

#and package SubTrace.pm contains:
package SubTrace;
sub DB::DB {}
sub DB::sub {
   if ($DB::sub =~ /^MyModule/ and $DB::sub !~ /DESTROY|CODE/) {
     warn "DB::sub: $DB::sub", $/;
   }

   if ( $DB::sub eq 'DESTROY'
        or substr($DB::sub, -9) eq '::DESTROY'
        or not defined wantarray)
   {
        &$DB::sub;
        $DB::ret = undef;
   }elsif (wantarray) {
     @DB::ret = &$DB::sub;
     @DB::ret;
   }else{
     $DB::ret = &$DB::sub;
     $DB::ret;
   }
}
1;

Now for some reason this just blows up when I run 'httpd -X', the
httpd process becomes several hundred megs and the cgi never displays
anything. To make matters worse, I can't just ^C out, because the
debugger has taken over and spits out info that I don't want, so I
have to kill httpd.

I've looked through Apache::DB, and it should be eval'ing what I've
placed in PERL5DB
but instead it goes ahead and loads Apache/perl5db.pl which I don't
want. I don't want an interactive debugger, instead I want to generate
profiling logs based on my custom DB::DB and DB::sub routines. Maybe
there is a setting I overlooked to disable the interactive debugger
and its output in .perldb and maybe I can get Apache::DB to load
.perldb?

Because the process blew up, I also tried not setting the
PerlFixupHandler to Apache::DB and instead wrapped my SubTrace.pm code
in a BEGIN block, and also added $^P |= 1 to turn on the debugger at
compile time.
This seems to work, because I see output in the log file generated by
my DB::sub routine, however, my DB::DB routine does not seem to be
called at all, which was puzzling, so I think debugging is maybe not
enabled.

Thanks in advance for any tips or advice!
RK

Reply via email to