Skip to content

Commit

Permalink
Fix RT#71678 (-d a command after exit) with a test.
Browse files Browse the repository at this point in the history
Credits to Heiko Eissfeldt for the reported bug, the test program and a
proposed fix.
  • Loading branch information
shlomif authored and tonycoz committed Jun 3, 2015
1 parent 22055af commit 0b1fcdc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4230,6 +4230,7 @@ lib/perl5db/t/source-cmd-test.perldb Tests for the Perl debugger
lib/perl5db/t/symbol-table-bug Tests for the Perl debugger
lib/perl5db/t/taint Tests for the Perl debugger
lib/perl5db/t/test-a-statement-1 Tests for the Perl debugger
lib/perl5db/t/test-a-statement-2 Tests for the Perl debugger
lib/perl5db/t/test-dieLevel-option-1 Tests for the Perl debugger
lib/perl5db/t/test-frame-option-1 Tests for the Perl debugger
lib/perl5db/t/test-l-statement-1 Tests for the Perl debugger
Expand Down
5 changes: 4 additions & 1 deletion lib/perl5db.pl
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ BEGIN
# Debugger for Perl 5.00x; perl5db.pl patch level:
use vars qw($VERSION $header);

$VERSION = '1.49';
$VERSION = '1.49_01';

$header = "perl5db.pl version $VERSION";

Expand Down Expand Up @@ -3319,6 +3319,9 @@ sub _DB__grab_control
EOP

# Set the DB::eval context appropriately.
# At program termination disable any user actions.
$DB::action = undef;

$DB::package = 'main';
$DB::usercontext = DB::_calc_usercontext($DB::package);
} ## end elsif ($package eq 'DB::fake')
Expand Down
27 changes: 26 additions & 1 deletion lib/perl5db.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BEGIN {
$ENV{PERL_RL} = 'Perl'; # Suppress system Term::ReadLine::Gnu
}

plan(120);
plan(121);

my $rc_filename = '.perldb';

Expand Down Expand Up @@ -2774,6 +2774,31 @@ SKIP:
);
}

# [perl #71678] debugger bug in evaluation of user actions ('a' command)
# Still evaluated after the script finishes.
{
my $wrapper = DebugWrap->new(
{
cmds =>
[
q#a 9 print " \$arg = $arg\n"#,
'c 9',
's',
'q',
],
prog => '../lib/perl5db/t/test-a-statement-2',
switches => [ '-dw', ],
stderr => 1,
}
);

$wrapper->contents_unlike(qr/
Use\ of\ uninitialized\ value\ \$arg\ in\ concatenation\ [\S ]+\ or\ string\ at
/msx,
'Test that the a command does not emit warnings on program exit.',
);
}

END {
1 while unlink ($rc_filename, $out_fn);
}
10 changes: 10 additions & 0 deletions lib/perl5db/t/test-a-statement-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use strict; use warnings;

greet('Hello');

sub greet
{
my $arg = shift;
print "$arg\n";
return;
}

0 comments on commit 0b1fcdc

Please sign in to comment.