diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-04 05:51:14 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-04 05:51:14 +0000 |
commit | 83ee9e095f68fdbdc131f9a00306fb151d58abe2 (patch) | |
tree | f0460c4669eb8df6bd5bf9f2a5f9b5f8e4a4045c /lib/dumpvar.pl | |
parent | b48f1ba55530934180c410ecc1fb73c4bc730b30 (diff) | |
download | perl-83ee9e095f68fdbdc131f9a00306fb151d58abe2.tar.gz |
patch to provide more informative names for evals and anonymous
subroutines (from Ilya Zakharevich)
p4raw-id: //depot/perl@4975
Diffstat (limited to 'lib/dumpvar.pl')
-rw-r--r-- | lib/dumpvar.pl | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl index f473c45bd3..c72781801b 100644 --- a/lib/dumpvar.pl +++ b/lib/dumpvar.pl @@ -312,14 +312,27 @@ sub dumpglob { } } +sub CvGV_name_or_bust { + my $in = shift; + return if $skipCvGV; # Backdoor to avoid problems if XS broken... + $in = \&$in; # Hard reference... + eval {require Devel::Peek; 1} or return; + my $gv = Devel::Peek::CvGV($in) or return; + *$gv{PACKAGE} . '::' . *$gv{NAME}; +} + sub dumpsub { my ($off,$sub) = @_; + my $ini = $sub; + my $s; $sub = $1 if $sub =~ /^\{\*(.*)\}$/; - my $subref = \&$sub; - my $place = $DB::sub{$sub} || (($sub = $subs{"$subref"}) && $DB::sub{$sub}) - || ($subdump && ($sub = findsubs("$subref")) && $DB::sub{$sub}); + my $subref = defined $1 ? \&$sub : \&$ini; + my $place = $DB::sub{$sub} || (($s = $subs{"$subref"}) && $DB::sub{$s}) + || (($s = CvGV_name_or_bust($subref)) && $DB::sub{$s}) + || ($subdump && ($s = findsubs("$subref")) && $DB::sub{$s}); $place = '???' unless defined $place; - print( (' ' x $off) . "&$sub in $place\n" ); + $s = $sub unless defined $s; + print( (' ' x $off) . "&$s in $place\n" ); } sub findsubs { |