diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-07-13 11:41:44 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-07-13 11:49:14 -0700 |
commit | bf2614180a655fadfe4ad9de9bbcf01c42b29e7e (patch) | |
tree | 3f3869bd576d4ed5812f911e1863d2b9bc6fde1e /lib/perl5db | |
parent | c4a26ef3f320212167cfd6d700bfcc92f04a6939 (diff) | |
download | perl-bf2614180a655fadfe4ad9de9bbcf01c42b29e7e.tar.gz |
[perl #118839] Make ānā debugger cmd respect lv subs
The ānā debugger command, which is supposed to step over subs, was not
stepping over lvalue subs.
This is a regression from 5.8, but 5.8 was worse.
This bug did not occur in 5.8 because there was no mechanism back then
for handling lvalue subs specially (via DB::lsub), so assignment to an
lvalue sub was completely broken under the debugger.
Perl 5.10 introduced DB::lsub. The implementation in perl5db.pl
contains these lines at the end of the sub:
# Pop the single-step value back off the stack.
$single |= $stack[ $stack_depth-- ];
# call the original lvalue sub.
&$sub;
The regular DB::sub does this:
{
no strict 'refs';
@ret = &$sub;
}
# Pop the single-step value back off the stack.
$single |= $stack[ $stack_depth-- ];
Notice how $single (i.e., $DB::single) is modified before and after
the sub call, respectively. The order is different.
There are two types of lvalue list context for lvalue subs. (foo)=3
will allow sub foo:lvalue{@a} to return the array itself. \(foo) and
bar(foo) will flatten the array.
So there is no way in pure Perl to capture the return value and have
it returned to the caller unchanged. That is why DB::lsub has to call
the sub last of all (and have the context propagated).
The solution here is to use localisation to accomplish the assigment
to $single after the lvalue sub exits.
Diffstat (limited to 'lib/perl5db')
-rw-r--r-- | lib/perl5db/t/lsub-n | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/perl5db/t/lsub-n b/lib/perl5db/t/lsub-n new file mode 100644 index 0000000000..83257b47e2 --- /dev/null +++ b/lib/perl5db/t/lsub-n @@ -0,0 +1,6 @@ +sub foo : lvalue { + $x+=10; +} +$x++; +foo(); +$x+=100; |