develooper Front page | perl.debugger | Postings from August 2008

Re: accelerated stepping

Thread Previous
From:
Heiko EixDFfeldt
Date:
August 31, 2008 05:02
Subject:
Re: accelerated stepping
Message ID:
20080830202134.1726.qmail@lists.develooper.com
--- perl5db.pl.org	2007-12-18 10:47:07.000000000 +0100
+++ perl5db.pl	2008-08-30 22:15:46.921875000 +0200
@@ -2643,7 +2643,7 @@
 demarcation' above which commands can be entered anytime, and below which
 they can't.
 
-=head4 C<n> - single step, but don't trace down into subs
+=head4 C<n> - single step, but don't trace down into subs, and not even into grep/map/sort
 
 Done by setting C<$single> to 2, which forces subs to execute straight through
 when entered (see C<DB::sub>). We also save the C<n> command in C<$laststep>,
@@ -2655,9 +2655,41 @@
                 $cmd =~ /^n$/ && do {
                     end_report(), next CMD if $finished and $level <= 1;
 
-                    # Single step, but don't enter subs.
-                    $single = 2;
+                    if (   $dbline[$line] =~ m{\bgrep\b}xms
+                        || $dbline[$line] =~ m{\bmap\b}xms
+                        || $dbline[$line] =~ m{\bsort\b}xms
+                       ) {
+                            # Scan forward to the next executable line
+                            $i = $line;
+                            ++$i;
 
+                            $max = $#dbline;
+                            ++$i while $dbline[$i] == 0 && $i < $max;
+                            # Check if we would leave the sub
+                            my @sublast = split m{-}xms, $sub{$sub};
+                            if ($sub eq '' || $i <= $sublast[-1]) {
+                                # Next line is in current sub
+
+                                # Breakable?
+                                if ( $dbline[$i] == 0 ) {
+                                    print $OUT "Line $i not breakable.\n";
+                                    next CMD;
+                                }
+
+                                # Set up the one-time-break sigil.
+                                $dbline{$i} =~ s/($|\0)/;9$1/;  # add one-time-only b.p.
+
+                                # Clear single stepping flags
+                                $DB::single &= ~3;	
+                            } else {
+                                # About to leave the sub...
+                                # Turn on stack tracing one up.
+                                $stack[ -1 ] |= 1;
+                            }
+                    } else {
+                        # Single step, but don't enter subs.
+                        $single = 2;
+                    }
                     # Save for empty command (repeat last).
                     $laststep = $cmd;
                     last CMD;

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About