lib/Devel/Trepan/Processor/Running.pm

filter: Statementstmt 18.8% 36 / 191 Branchbran 0.0% 0 / 56 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 42.3% 11 / 26 Podpod 0.0% 0 / 16 totaltotal 14.9% 47 / 315 CC 41 SCAR 36.9
CC
41
Cov
14%
is_stepping_skip
90.0
is_stepping_skip
90.0
restart_args
47.5
CRAP 39.8
« blib/lib/Devel/Trepan/CmdProcessor/Validate.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Parse/Range.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org>
3 12 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use rlib '../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use Devel::Trepan::Position;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package Devel::Trepan::Processor;
9 12 ▶use English qw( -no_match_vars );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 12 ▶use constant SINGLE_STEPPING_EVENT => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use constant NEXT_STEPPING_EVENT => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use constant DEEP_RECURSION_EVENT => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use constant RETURN_EVENT => 32;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub continue($$) {
Subroutine continue: not called CC=4 SCAR=30.0
Pod undocumented
17 0 ▶ my ($self, $args) = @_;
Subroutine continue: not called CC=4 SCAR=30.0
Pod undocumented
18 0 $self->{skip_count} = -1;
19 0 ▶ if ($self->{settings}{traceprint}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{"settings"}{"traceprint"}) 0 0 0
if ($self->{"settings"}{"traceprint"}) 0 0 0
20 0 $self->step();
21 0 return;
22 }
23 0 ▶ if (scalar @{$args} != 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$args;} != 1) { } 0 0 0
if (scalar @{$args;} != 1) { } 0 0 0
24 # Form is: "continue"
25 # my $(line_number, $condition, $negate) =
26 # $self->breakpoint_position($self->{proc}{cmd_argstr}, 0);
27 # return unless iseq && vm_offset;
28 # $bp = $self->.breakpoint_offset($condition, $negate, 1);
29 #return unless bp;
30 0 $self->{leave_cmd_loop} = $self->{dbgr}->cont($args->[1]);
31 } else {
32 0 $self->{leave_cmd_loop} = $self->{dbgr}->cont;
33 };
34 0 ▶ if ($self->{leave_cmd_loop}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{"leave_cmd_loop"}) 0 0 0
if ($self->{"leave_cmd_loop"}) 0 0 0
35 0 $self->{DB_running} = 1;
36 0 $self->{DB_single} = 0;
37 }
38 }
39  
40 # sub quit(cmd='quit')
41 # {
42 # @next_level = 32000; # I'm guessing the stack size can't ever
43 # # reach this
44 # @next_thread = undef;
45 # @core.skip_count = -1; # No more event stepping
46 # @leave_cmd_loop = 1; # Break out of the processor command loop.
47 # @settings[:autoirb] = 0;
48 # @cmdloop_prehooks.delete_by_name('autoirb');
49 # @commands['quit'].run([cmd]);
50 # }
51  
52 sub parse_next_step_suffix($$)
53 0 ▶{
Subroutine parse_next_step_suffix: not called CC=4 SCAR=30.0
Pod undocumented
54 0 ▶ my ($self, $step_cmd) = @_;
Subroutine parse_next_step_suffix: not called CC=4 SCAR=30.0
Pod undocumented
55 0 my $opts = {};
56 0 my $sigil = substr($step_cmd, -1);
57 0 ▶ if ('-' eq $sigil) {
Branch: 6 branches
BranchTrueFalseTotal
if ('-' eq $sigil) { } 0 0 0
elsif ('+' eq $sigil) { } 0 0 0
elsif ('=' eq $sigil) { } 0 0 0
if ('-' eq $sigil) { } 0 0 0
elsif ('+' eq $sigil) { } 0 0 0
elsif ('=' eq $sigil) { } 0 0 0
58 0 $opts->{different_pos} = 0;
59 } elsif ('+' eq $sigil) {
60 0 $opts->{different_pos} = 1;
61 } elsif ('=' eq $sigil) {
62 0 $opts->{different_pos} = $self->{settings}{different};
63 # when ('!') { $opts->{stop_events} = {'raise' => 1} };
64 # when ('<') { $opts->{stop_events} = {'return' => 1}; }
65 # when ('>') {
66 # if (length($step_cmd) > 1 && substr($step_cmd, -2, 1) eq '<') {
67 # $opts->{stop_events} = {'return' => 1 };
68 # } else {
69 # $opts->{stop_events} = {'call' => 1; }
70 # }
71 # }
72 } else {
73 0 $opts->{different_pos} = $self->{settings}{different};
74 }
75 0 return $opts;
76 }
77  
78 # Does whatever setup needs to be done to set to ignore stepping
79 # to the finish of the current method.
80 0 ▶sub finish($$) {
Subroutine finish: not called CC=1 SCAR=6.9
Pod undocumented
81 0 ▶ my ($self, $level_count) = @_;
Subroutine finish: not called CC=1 SCAR=6.9
Pod undocumented
82 0 $self->{leave_cmd_loop} = 1;
83 0 $self->{skip_count} = -1;
84 0 $self->{DB_running} = 1;
85 0 $self->{dbgr}->finish($level_count);
86 }
87  
88 sub next($$)
89 0 ▶{
Subroutine next: not called CC=1 SCAR=6.9
Pod undocumented
90 0 ▶ my ($self, $opts) = @_;
Subroutine next: not called CC=1 SCAR=6.9
Pod undocumented
91 0 $self->{different_pos} = $opts->{different_pos};
92 0 $self->{leave_cmd_loop} = 1;
93 # NEXT_STEPPING_EVENT is sometimes broken.
94 # $self->{DB_single} = NEXT_STEPPING_EVENT;
95 0 $self->{next_level} = $self->{stack_size};
96 0 $self->{DB_single} = SINGLE_STEPPING_EVENT;
97 0 $self->{DB_running} = 1;
98 }
99  
100 sub step($$)
101 0 ▶{
Subroutine step: not called CC=1 SCAR=6.9
Pod undocumented
102 0 ▶ my ($self, $opts) = @_;
Subroutine step: not called CC=1 SCAR=6.9
Pod undocumented
103 0 $self->{different_pos} = $opts->{different_pos};
104 0 $self->{leave_cmd_loop} = 1;
105 0 $self->{DB_single} = SINGLE_STEPPING_EVENT;
106 0 $self->{next_level} = 30000; # Virtually infinite
107 0 $self->{DB_running} = 1;
108 }
109  
110 sub running_initialize($)
111 13 ▶{
Subroutine running_initialize: called CC=1 SCAR=1.2
Pod undocumented
112 0 ▶ my $self = shift;
Subroutine running_initialize: not called CC=1 SCAR=1.2
Pod undocumented
113 0 $self->{stop_condition} = undef;
114 0 $self->{stop_events} = undef;
115 0 $self->{to_method} = undef;
116 $self->{last_pos} =
117 0 Devel::Trepan::Position->new(pkg => '', filename => '',
118 line =>'', event=>'');
119 }
120  
121 # Should we not stop here?
122 # Some reasons for skipping:
123 # - step count was given.
124 # - We want to make sure we stop on a different line
125 # - We want to stop only when some condition is reached (step until ...).
126 sub is_stepping_skip($)
127 0 ▶{
Subroutine is_stepping_skip: not called CC=9 SCAR=45.0
Pod undocumented
128  
129 0 ▶ my $self = shift;
Subroutine is_stepping_skip: not called CC=9 SCAR=45.0
Pod undocumented
130 0 ▶ if ($self->{skip_count} < 0) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'skip_count'} < 0) { } 0 0 0
elsif ($self->{'skip_count'} > 0) { } 0 0 0
if ($self->{'skip_count'} < 0) { } 0 0 0
elsif ($self->{'skip_count'} > 0) { } 0 0 0
131 0 return 1;
132 } elsif ($self->{skip_count} > 0) {
133 0 $self->{skip_count} --;
134 0 return 1
135 }
136  
137 0 ▶ if ($self->{settings}{'debugskip'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{"settings"}{"debugskip"}) 0 0 0
if ($self->{"settings"}{"debugskip"}) 0 0 0
138 0 $self->msg("diff: $self->{different_pos}, event : $self->{event}");
139 0 $self->msg("skip_count : $self->{skip_count}");
140 }
141  
142 0 my $frame = $self->{frame};
143  
144 my $new_pos = Devel::Trepan::Position->new(pkg => $frame->{pkg},
145 filename => $frame->{file},
146 line => $frame->{line},
147 0 event => $self->{event});
148  
149 0 my $skip_val = 0;
150  
151 # If the last stop was a breakpoint, don't stop again if we are at
152 # the same location with a line event.
153  
154 0 my $last_pos = $self->{last_pos};
155 # $skip_val ||= ($last_pos->event eq 'brkpt' && $self->{event} eq 'line');
156  
157 0 ▶ if ($self->{settings}{'debugskip'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{"settings"}{"debugskip"}) 0 0 0
if ($self->{"settings"}{"debugskip"}) 0 0 0
158 0 $self->msg("skip: $skip_val, last: $self->{last_pos}->inspect(), " .
159 "new: $new_pos->inspect()");
160 }
161  
162 # @last_pos[2] = new_pos[2] if 'nostack' eq $self->{different_pos};
163  
164 0 my $condition_met = 1;
165 # if (! $skip_val) {
166 # if (@stop_condition) {
167 # puts 'stop_cond' if @settings[:'debugskip'];
168 # debug_eval_no_errmsg(@stop_condition);
169 # } elsif (@to_method) {
170 # puts "method #{@frame.method} #{@to_method}" if
171 # $self->{setting}{'debugskip'};
172 # @frame.method == @to_method;
173 # } else {
174 # puts 'uncond' if $self->{settings}{'debugskip'};
175 # 1;
176 # };
177  
178 # $self->msg("condition_met: #{condition_met}, last: $self->{last_pos}, " .
179 # "new: $new_pos->inspect(), different #{@different_pos.inspect}") if
180 # $self->{settings}{'debugskip'};
181  
182 $skip_val = (($last_pos && $last_pos->eq($new_pos) && !!$self->{different_pos})
183 0 ▶ || !$condition_met);
Condition0%0/18
$last_pos && $last_pos->eq($new_pos) && !!$self->{'different_pos'} || !$condition_met
l!l&&r!l&&!r
000
$last_pos and $last_pos->eq($new_pos) and not !$self->{"different_pos"}
!ll&&!rl&&r
000
$last_pos and $last_pos->eq($new_pos)
!ll&&!rl&&r
000
$last_pos && $last_pos->eq($new_pos) && !!$self->{'different_pos'} || !$condition_met
l!l&&r!l&&!r
000
$last_pos and $last_pos->eq($new_pos) and not !$self->{"different_pos"}
!ll&&!rl&&r
000
$last_pos and $last_pos->eq($new_pos)
!ll&&!rl&&r
000
MC/DC0%0/4
$last_pos && $last_pos->eq($new_pos) && !!$self->{'different_pos'} || !$condition_met
$last_pos $last_pos->eq($new_pos) not !$self->{"different_pos"} !$condition_met
MC/DC0%0/4
$last_pos && $last_pos->eq($new_pos) && !!$self->{'different_pos'} || !$condition_met
$last_pos $last_pos->eq($new_pos) not !$self->{"different_pos"} !$condition_met
Truth table0%0/7
A and B and C || not(D)
A= $last_posB= $last_pos->eq($new_pos)C= not !$self->{"different_pos"}D= !$condition_met
ABCDresult
111X1
0XX11
10X11
11011
0XX00
10X00
11000
Truth table0%0/7
A and B and C || not(D)
A= $last_posB= $last_pos->eq($new_pos)C= not !$self->{"different_pos"}D= !$condition_met
ABCDresult
111X1
0XX11
10X11
11011
0XX00
10X00
11000
184  
185 0 $self->{last_pos} = $new_pos;
186  
187 0 ▶ unless ($skip_val) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($skip_val) 0 0 0
unless ($skip_val) 0 0 0
188 # Set up the default values for the next time we consider
189 # skipping.
190 0 $self->{different_pos} = $self->{settings}{different};
191 }
192  
193 0 return $skip_val;
194 }
195  
196 0 ▶sub restart_args($$) {
Subroutine restart_args: not called CC=7 SCAR=38.6
Pod undocumented
197 0 ▶ my $self = shift;
Subroutine restart_args: not called CC=7 SCAR=38.6
Pod undocumented
198 0 my @flags = ();
199 # If warn was on before, turn it on again.
200 12 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
201 0 ▶ push @flags, '-w' if $DB::ini_warn;
Branch: 2 branches
BranchTrueFalseTotal
if $DB::ini_warn 0 0 0
if $DB::ini_warn 0 0 0
202  
203 0 ▶ if ($ENV{'TREPANPL_OPTS'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ENV{'TREPANPL_OPTS'}) { } 0 0 0
if ($ENV{'TREPANPL_OPTS'}) { } 0 0 0
204 0 my $opts = $Devel::Trepan::Core::invoke_opts;
205 0 foreach my $inc (@{$opts->{includes}}) {
206 0 push @flags, ('-I' . $inc);
207 }
208 0 foreach my $mod (@{$opts->{modules}}) {
209 0 push @flags, '-M' . $mod;
210 }
211 } else {
212 # Rebuild the -I flags that were on the initial
213 # command line.
214 0 for (@DB::ini_INC) {
215 0 push @flags, '-I', $_;
216 }
217 }
218  
219  
220 # Turn on taint if it was on before.
221 0 ▶ push @flags, '-T' if ${^TAINT};
Branch: 2 branches
BranchTrueFalseTotal
if ${^TAINT} 0 0 0
if ${^TAINT} 0 0 0
222  
223 # Arrange for setting the old INC:
224 # Save the current @init_INC in the environment.
225 0 DB::set_list( "PERLDB_INC", @DB::ini_INC );
226  
227 ( $EXECUTABLE_NAME, @flags, '-d:Trepan', $DB::ini_dollar0,
228 0 @{$self->{dbgr}{exec_strs}},
229 @DB::ini_ARGV );
230 }
231  
232 12 1;
« blib/lib/Devel/Trepan/CmdProcessor/Validate.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Parse/Range.pm »