In perl.git, the branch maint-5.18 has been updated <http://perl5.git.perl.org/perl.git/commitdiff/0a77bcb9c5bd03b2f2473da45a2247126c327a9a?hp=ae335535b7b6324036b86df6c92202864c0516c3>
- Log ----------------------------------------------------------------- commit 0a77bcb9c5bd03b2f2473da45a2247126c327a9a Author: Ricardo Signes <[email protected]> Date: Mon Jun 10 18:23:27 2013 -0400 perldelta for debugger @_ fix M pod/perldelta.pod commit 70a2dad880f94d9f3789e347e581bce94d4c41da Author: Shlomi Fish <[email protected]> Date: Sun May 26 18:55:48 2013 +0300 Fix the mutability of @_ in perl -d. With a test. See Father C.'s comment on RT #118169. M lib/perl5db.pl M lib/perl5db.t commit 21810b688fa5c2c2a8a2bf876eb5bc3fe5b2aaf7 Author: Shlomi Fish <[email protected]> Date: Sun May 26 16:35:04 2013 +0300 Fix for RT #118169 https://rt.perl.org/rt3/Public/Bug/Display.html?id=118169 subroutine arguments are no longer shown in perl debugger ( x @_ in perl -d) . Regression from perl-5.16.x due to the perl -d refactoring. Fixed with a test. M MANIFEST M lib/perl5db.pl M lib/perl5db.t A lib/perl5db/t/test-passing-at-underscore-to-x-etc ----------------------------------------------------------------------- Summary of changes: MANIFEST | 1 + lib/perl5db.pl | 29 +++++++++----- lib/perl5db.t | 46 ++++++++++++++++++++- lib/perl5db/t/test-passing-at-underscore-to-x-etc | 15 +++++++ pod/perldelta.pod | 5 ++ 5 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 lib/perl5db/t/test-passing-at-underscore-to-x-etc diff --git a/MANIFEST b/MANIFEST index fa9f37f..53c64b4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4381,6 +4381,7 @@ lib/perl5db/t/test-frame-option-1 Tests for the Perl debugger lib/perl5db/t/test-l-statement-1 Tests for the Perl debugger lib/perl5db/t/test-l-statement-2 Tests for the Perl debugger lib/perl5db/t/test-m-statement-1 Tests for the Perl debugger +lib/perl5db/t/test-passing-at-underscore-to-x-etc Tests for the Perl debugger lib/perl5db/t/test-PrintRet-option-1 Tests for the Perl debugger lib/perl5db/t/test-r-statement Tests for the Perl debugger lib/perl5db/t/test-warnLevel-option-1 Tests for the Perl debugger diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 71dc920..bcb4dd5 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -744,7 +744,7 @@ sub eval { # Since we're only saving $@, we only have to localize the array element # that it will be stored in. local $saved[0]; # Preserve the old value of $@ - eval { DB::save() }; + eval { &DB::save }; # Now see whether we need to report an error back to the user. if ($at) { @@ -1793,7 +1793,8 @@ sub _DB__determine_if_we_should_break # see if we should stop. If so, remove the one-time sigil. elsif ($stop) { $evalarg = "\$DB::signal |= 1 if do {$stop}"; - DB::eval(); + # The &-call is here to ascertain the mutability of @_. + &DB::eval; # If the breakpoint is temporary, then delete its enabled status. if ($dbline{$line} =~ s/;9($|\0)/$1/) { _cancel_breakpoint_temp_enabled_status($filename, $line); @@ -2562,7 +2563,8 @@ sub DB { # Last line in the program. $max = $#dbline; - _DB__determine_if_we_should_break(@_); + # The &-call is here to ascertain the mutability of @_. + &_DB__determine_if_we_should_break; # Preserve the current stop-or-not, and see if any of the W # (watch expressions) has changed. @@ -2655,7 +2657,8 @@ If there are any preprompt actions, execute those as well. # If there's an action, do it now. if ($action) { $evalarg = $action; - DB::eval(); + # The &-call is here to ascertain the mutability of @_. + &DB::eval; } # Are we nested another level (e.g., did we evaluate a function @@ -2667,7 +2670,8 @@ If there are any preprompt actions, execute those as well. # Do any pre-prompt actions. foreach $evalarg (@$pre) { - DB::eval(); + # The &-call is here to ascertain the mutability of @_. + &DB::eval; } # Complain about too much recursion if we passed the limit. @@ -3082,7 +3086,8 @@ any variables we might want to address in the C<DB> package. $evalarg = "\$^D = \$^D | \$DB::db_stop;\n$cmd"; # Run *our* eval that executes in the caller's context. - DB::eval(); + # The &-call is here to ascertain the mutability of @_. + &DB::eval; # Turn off the one-time-dump stuff now. if ($onetimeDump) { @@ -3128,7 +3133,8 @@ again. # Evaluate post-prompt commands. foreach $evalarg (@$post) { - DB::eval(); + # The &-call is here to ascertain the mutability of @_. + &DB::eval; } } # if ($single || $signal) @@ -5431,7 +5437,8 @@ sub cmd_i { my $line = shift; foreach my $isa ( split( /\s+/, $line ) ) { $evalarg = $isa; - ($isa) = DB::eval(); + # The &-call is here to ascertain the mutability of @_. + ($isa) = &DB::eval; no strict 'refs'; print join( ', ', @@ -6000,7 +6007,8 @@ sub _add_watch_expr { # in the user's context. This version can handle expressions which # return a list value. $evalarg = $expr; - my ($val) = join( ' ', DB::eval() ); + # The &-call is here to ascertain the mutability of @_. + my ($val) = join( ' ', &DB::eval); $val = ( defined $val ) ? "'$val'" : 'undef'; # Save the current value of the expression. @@ -10249,7 +10257,8 @@ sub cmd_pre580_W { # Get the current value of the expression. # Doesn't handle expressions returning list values! $evalarg = $1; - my ($val) = DB::eval(); + # The &-call is here to ascertain the mutability of @_. + my ($val) = &DB::eval; $val = ( defined $val ) ? "'$val'" : 'undef'; # Save it. diff --git a/lib/perl5db.t b/lib/perl5db.t index 4aff839..9a57960 100644 --- a/lib/perl5db.t +++ b/lib/perl5db.t @@ -28,7 +28,7 @@ BEGIN { } } -plan(114); +plan(116); my $rc_filename = '.perldb'; @@ -812,6 +812,50 @@ sub _calc_trace_wrapper ); } +# Tests for x with @_ +{ + my $wrapper = DebugWrap->new( + { + cmds => + [ + 'b 10', + 'c', + 'x @_', + 'q', + ], + prog => '../lib/perl5db/t/test-passing-at-underscore-to-x-etc', + } + ); + + $wrapper->contents_like( + # qr/^0\s+HASH\([^\)]+\)\n\s+500 => 600\n/, + qr/Arg1.*?Capsula.*GreekHumor.*Socrates/ms, + q/x command test with '@_'./, + ); +} + +# Tests for mutating @_ +{ + my $wrapper = DebugWrap->new( + { + cmds => + [ + 'b 10', + 'c', + 'shift(@_)', + 'print "\n\n\n(((" . join(",", @_) . ")))\n\n\n"', + 'q', + ], + prog => '../lib/perl5db/t/test-passing-at-underscore-to-x-etc', + } + ); + + $wrapper->output_like( + qr/^\(\(\(Capsula,GreekHumor,Socrates\)\)\)$/ms, + q/Mutating '@_'./, + ); +} + # Tests for x with AutoTrace=1. { my $wrapper = DebugWrap->new( diff --git a/lib/perl5db/t/test-passing-at-underscore-to-x-etc b/lib/perl5db/t/test-passing-at-underscore-to-x-etc new file mode 100644 index 0000000..ff14df6 --- /dev/null +++ b/lib/perl5db/t/test-passing-at-underscore-to-x-etc @@ -0,0 +1,15 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +print "One\n"; + +sub my_pass_args_to +{ + print "Two\n"; +} + +my_pass_args_to ("Arg1", "Capsula", "GreekHumor", "Socrates"); + +print "Three\n"; diff --git a/pod/perldelta.pod b/pod/perldelta.pod index cc8964a..8cf8e1f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -351,6 +351,11 @@ all now work again. =item * +C<@_> is now correctly visible in the debugger, fixing a regression +introduced in v5.18.0's debugger. [RT #118169] + +=item * + Perl v5.16 inadvertently introduced a bug whereby calls to XSUBs that were not visible at compile time were treated as lvalues and could be assigned to, even when the subroutine was not an lvalue sub. This has been fixed. -- Perl5 Master Repository
