develooper Front page | perl.perl5.porters | Postings from February 2006

Distinguish method/function call during debugger?

Thread Next
From:
Joshua ben Jore
Date:
February 23, 2006 14:33
Subject:
Distinguish method/function call during debugger?
Message ID:
dc5c751d0602231432gca42412p2c5bdb23bf9be1b6@mail.gmail.com
I posted this message on perlmonks but on reflection, it seems like
the kind of thing I'm better off asking p5p about.

I'm writing a small debugger for myself to generate Test::MockObject
scripts. I'm able to trap method calls and function calls but I don't
know how to distinguish between the two. Can any of you help?

The following code results in:
  Deb::meth( Deb=SCALAR(0x97f3c4c) )
  Deb::func( Deb=SCALAR(0x97f3c4c) )

BEGIN {
    $ENV{PERL5DB} = '';
    $^P = 0x01; # Debug subroutine enter/exit.
}

$obj = bless do { \ my $x }, "Deb";
$obj->meth;
Deb::func( $obj );

sub Deb::meth { }
sub Deb::func { }

package DB;
sub sub {
    print "$sub( " . join( ', ', @_ ) . " )\n";
}

Thanks,
Josh

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About