Made "c [line_num]" working again.
authorShlomi Fish <shlomif@iglu.org.il>
Wed, 7 Dec 2011 17:36:39 +0000 (19:36 +0200)
committerTony Cook <tony@develop-help.com>
Fri, 9 Dec 2011 12:45:02 +0000 (23:45 +1100)
This is a bug-fix to
https://rt.perl.org/rt3//Public/Bug/Display.html?id=104820 .

Both the fix and a regression tests were added.

lib/perl5db.pl
lib/perl5db.t

index 84a38f1..f62f2ab 100644 (file)
@@ -1956,7 +1956,10 @@ sub DB {
         elsif ($stop) {
             $evalarg = "\$DB::signal |= 1 if do {$stop}";
             &eval;
-            $dbline{$line} =~ s/;9($|\0)/$1/;
+            # If the breakpoint is temporary, then delete its enabled status.
+            if ($dbline{$line} =~ s/;9($|\0)/$1/) {
+                _cancel_breakpoint_temp_enabled_status($filename, $line);
+            }
         }
     } ## end if ($dbline{$line} && ...
 
@@ -2812,6 +2815,7 @@ in this and all call levels above this one.
 
                         # Yes. Set up the one-time-break sigil.
                         $dbline{$i} =~ s/($|\0)/;9$1/;  # add one-time-only b.p.
+                        _enable_breakpoint_temp_enabled_status($filename, $i);
                     } ## end if ($i)
 
                     # Turn off stack tracing from here up.
@@ -4002,10 +4006,33 @@ sub _set_breakpoint_enabled_status {
     return;
 }
 
+sub _enable_breakpoint_temp_enabled_status {
+    my ($filename, $line) = @_;
+
+    _get_breakpoint_data_ref($filename, $line)->{'temp_enabled'} = 1;
+
+    return;
+}
+
+sub _cancel_breakpoint_temp_enabled_status {
+    my ($filename, $line) = @_;
+
+    my $ref = _get_breakpoint_data_ref($filename, $line);
+    
+    delete ($ref->{'temp_enabled'});
+
+    if (! %$ref) {
+        _delete_breakpoint_data_ref($filename, $line);
+    }
+
+    return;
+}
+
 sub _is_breakpoint_enabled {
     my ($filename, $line) = @_;
 
-    return _get_breakpoint_data_ref($filename, $line)->{'enabled'};
+    my $data_ref = _get_breakpoint_data_ref($filename, $line);
+    return ($data_ref->{'enabled'} || $data_ref->{'temp_enabled'});
 }
 
 =head2 C<cmd_wrapper()> (API)
index 0adae25..ba5d585 100644 (file)
@@ -28,7 +28,7 @@ BEGIN {
     }
 }
 
-plan(19);
+plan(20);
 
 my $rc_filename = '.perldb';
 
@@ -434,6 +434,28 @@ EOF
         "Restart and delete all breakpoints work properly.");
 }
 
+{
+    rc(<<'EOF');
+&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
+
+sub afterinit {
+    push (@DB::typeahead,
+    'c 15',
+    q/print "X={$x}\n";/,
+    'c',
+    'q',
+    );
+
+}
+EOF
+
+    my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-1'); +
+    like($output, qr/
+        X=\{ThirdVal\}
+        /msx,
+        "'c line_num' is working properly.");
+}
+
 END {
     1 while unlink ($rc_filename, $out_fn);
 }