New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] caller() skips frames (such as eval() frames) if $^P set #7888
Comments
From glasser@tang-eleven-seventy-nine.mit.eduCreated by glasser@tang-eleven-seventy-nine.mit.eduIf the glob DB::sub exists but the subroutine &DB::sub does not, caller() can This is the same issue that was addressed by change 21842, but that change only Inline Patchdiff -ruN bleadperl.orig/mg.c bleadperl/mg.c
--- bleadperl.orig/mg.c Tue Apr 19 06:26:03 2005
+++ bleadperl/mg.c Wed Apr 20 13:11:18 2005
@@ -2162,8 +2162,7 @@
break;
case '\020': /* ^P */
PL_perldb = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
- if ((PERLDB_SUB || PERLDB_LINE || PERLDB_SUBLINE || PERLDB_ASSERTION)
- && !PL_DBsingle)
+ if (PL_perldb && !PL_DBsingle)
init_debugger();
break;
case '\024': /* ^T */
diff -ruN bleadperl.orig/pp_ctl.c bleadperl/pp_ctl.c
--- bleadperl.orig/pp_ctl.c Mon Apr 18 08:44:18 2005
+++ bleadperl/pp_ctl.c Wed Apr 20 13:55:24 2005
@@ -1567,7 +1567,8 @@
}
RETURN;
}
- if (PL_DBsub && cxix >= 0 &&
+ /* caller() should not report the automatic calls to &DB::sub */
+ if (PL_DBsub && GvCV(PL_DBsub) && cxix >= 0 &&
ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub))
count++;
if (!count--)
@@ -1580,7 +1581,8 @@
dbcxix = dopoptosub_at(ccstack, cxix - 1);
/* We expect that ccstack[dbcxix] is CXt_SUB, anyway, the
field below is defined for any cx. */
- if (PL_DBsub && dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub))
+ /* caller() should not report the automatic calls to &DB::sub */
+ if (PL_DBsub && GvCV(PL_DBsub) && dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub))
cx = &ccstack[dbcxix];
}
diff -ruN bleadperl.orig/t/op/caller.t bleadperl/t/op/caller.t
--- bleadperl.orig/t/op/caller.t Fri Apr 8 08:45:08 2005
+++ bleadperl/t/op/caller.t Wed Apr 20 14:06:25 2005
@@ -5,7 +5,7 @@
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
- plan( tests => 27 );
+ plan( tests => 31 );
}
my @c;
@@ -87,3 +87,32 @@
BEGIN { is( ${^WARNING_BITS}, "UUUUUUUUUUUU", 'warning bits on via "use warnings::register"' ) }
testwarn("UUUUUUUUUUUU","#3");
}
+
+
+# The next two cases test for a bug where caller ignored evals if
+# the DB::sub glob existed but &DB::sub did not (for example, if
+# $^P had been set but no debugger has been loaded). The tests
+# thus assume that there is no &DB::sub: if there is one, they
+# should both pass no matter whether or not this bug has been
+# fixed.
+
+my $debugger_test = q<
+ my @stackinfo = caller(0);
+ return scalar @stackinfo;
+>;
+
+sub pb { return (caller(0))[3] }
+
+my $i = eval $debugger_test;
+is( $i, 10, "do not skip over eval (and caller returns 10 elements)" );
+
+is( eval 'pb()', 'main::pb', "actually return the right function name" );
+
+my $saved_perldb = $^P;
+$^P = 16;
+$^P = $saved_perldb;
+
+$i = eval $debugger_test;
+is( $i, 10, 'do not skip over eval even if $^P had been on at some point' );
+is( eval 'pb()', 'main::pb', 'actually return the right function name even if $^P had been on at some point' );
+ Perl Info
|
From @iabynOn Wed, Apr 20, 2005 at 07:28:14PM -0000, glasser @ tang-eleven-seventy-nine. mit. edu wrote:
thanks, applied as change #24265 -- |
The RT System itself - Status changed from 'new' to 'open' |
@iabyn - Status changed from 'open' to 'rejected' |
@iabyn - Status changed from 'rejected' to 'resolved' |
Migrated from rt.perl.org#35059 (status was 'resolved')
Searchable as RT35059$
The text was updated successfully, but these errors were encountered: