File Coverage

lib/Devel/Trepan/CmdProcessor/Command/Step.pm
Criterion Covered Total %
statement 60 90 66.6
branch 0 12 0.0
condition n/a
subroutine 20 22 90.9
pod 0 2 0.0
total 80 126 63.4


line stmt bran cond sub pod time code
1             # -*- coding: utf-8 -*-
2             # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org>
3 12     12   96 use warnings; no warnings 'redefine';
  12     12   33  
  12     1   374  
  12     1   61  
  12         26  
  12         402  
  1         7  
  1         2  
  1         25  
  1         6  
  1         2  
  1         41  
4              
5 12     12   58 use rlib '../../../..';
  12     1   26  
  12         67  
  1         6  
  1         2  
  1         7  
6              
7             # require_relative '../../app/condition'
8              
9             package Devel::Trepan::CmdProcessor::Command::Step;
10              
11 12     12   4700 use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
  12     1   27  
  12         67  
  1         343  
  1         2  
  1         6  
12              
13             unless (@ISA) {
14 12     12   75 eval <<'EOE';
  12     12   31  
  12     12   880  
  12     12   82  
  12     12   26  
  12     12   1466  
  12         82  
  12         29  
  12         556  
  12         70  
  12         27  
  12         527  
  12         76  
  12         28  
  12         620  
  12         75  
  12         42  
  12         569  
15             use constant ALIASES => qw(s step+ step- s+ s-);
16             use constant CATEGORY => 'running';
17             use constant SHORT_HELP => 'Step program (possibly entering called functions)';
18             use constant MIN_ARGS => 0; # Need at least this many
19             use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
20             use constant NEED_STACK => 1;
21             EOE
22             }
23              
24 12     12   1841 use strict;
  12     1   28  
  12         290  
  1         60  
  1         3  
  1         21  
25 12     12   64 use vars qw(@ISA); @ISA = @CMD_ISA;
  12     1   43  
  12         642  
  1         4  
  1         2  
  1         51  
26 12     12   79 use vars @CMD_VARS; # Value inherited from parent
  12     1   469  
  12         4755  
  1         6  
  1         2  
  1         357  
27              
28             $NAME = set_name();
29             =pod
30              
31             =head2 Synopsis:
32              
33             =cut
34             $HELP = <<'HELP';
35             =pod
36              
37             B<step>[B<+>|B<->] [B<into>] [I<count>]
38              
39             B<step over>
40              
41             B<step out>
42              
43             Execute the current line, stopping at the next event. Sometimes this
44             is called "step into".
45              
46             With an integer argument, step that many times.
47              
48             A suffix of C<+> in a command or an alias forces a move to another
49             position, while a suffix of C<-> disables this requirement. A suffix
50             of C<E<gt>> will continue until the next call. (C<finish> will run until
51             the return for that call.)
52              
53             If no suffix is given, the debugger setting C<different> determines
54             this behavior.
55              
56             =head2 Examples:
57              
58             step # step 1 event, any event obeying 'set different' setting
59             step 1 # same as above
60             step+ # same but force stopping on a new line
61             step- # same but force stopping on a new line a new frame added
62             step over # same as 'next'
63             step out # same as 'finish'
64              
65             =head2 See also:
66              
67             L<C<next> (step over)|Devel::Trepan::CmdProcessor::Command::Step>,
68             L<C<finish> (step out)|Devel::Trepan::CmdProcessor::Command::Finish>,
69             L<C<continue>|Devel::Trepan::CmdProcessor::Command::Continue>, and
70             L<C<set different>|Devel::Trepan::CmdProcessor::Command::Set::Different>.
71              
72             =cut
73             HELP
74              
75             my $Keyword_to_related_cmd = {
76             'out' => 'finish',
77             'over' => 'next',
78             'into' => 'step',
79             };
80              
81             # include Trepan::Condition
82              
83             # This method runs the command
84             sub run($$) {
85 0     0 0   my ($self, $args) = @_;
  0     0 0    
86              
87 0           my $proc = $self->{proc};
  0            
88 0           my $opts = $proc->parse_next_step_suffix($args->[0]);
  0            
89             # condition = nil
90 0 0         if (0 == $#$args) {
  0 0          
91             # Form is: "step" which means "step 1"
92 0           $proc->{skip_count} = 0;
  0            
93             } else {
94 0           my $replace_cmd = $Keyword_to_related_cmd->{$args->[1]};
  0            
95 0 0         if (defined($replace_cmd)) {
  0 0          
96 0           my $cmd = $proc->{commands}{$replace_cmd};
  0            
97 0           return $cmd->run( [$replace_cmd, splice(@$args, 2)] );
  0            
98             # } elsif ('until' eq $args->[1]) {
99             # my $try_condition = join(@$args[2..-1], ' ');
100             # if (valid_condition?(try_condition)) {
101             # $condition = $try_condition;
102             # $opts-{different_pos} = 0;
103             # $proc->{skip_count} = 0;
104             # }
105             # elsif('to' eq $args[1]) {
106             # if args.size != 3;
107             # $self->errmsg('Expecting a method name after "to"');
108             # return;
109             # elsif (!@proc.method?(args[2])) {
110             # $self->errmsg("${args[2]} doesn't seem to be a method name");
111             # return;
112             # } else {
113             # $opts->{to_method{ = $args->[2];
114             # $opts->{different_pos} = 0;
115             # skip_count = 0
116             # }
117             # } elsif ('thread' eq $args->[1]) {
118             # $condition = "Thread.current.object_id == ${Thread.current.object_id}"
119             # $opts[:different_pos] = 0;
120             # $proc->{skip_count] = 0;
121             } else {
122 0           my $count_str = $args->[1];
  0            
123 0           my $int_opts = {
  0            
124             msg_on_error =>
125             "The 'step' command argument must eval to an integer. Got: ${count_str}",
126             min_value => 1
127             };
128             # }.merge(opts)
129 0           my $count = $proc->get_an_int($count_str, $int_opts);
  0            
130 0 0         return unless defined($count);
  0 0          
131             # step 1 is $proc->{skip_count} = 0 or "stop next event"
132 0           $proc->{skip_count} = $count - 1 ;
  0            
133             }
134             }
135 0           $proc->step($opts)
  0            
136             }
137              
138             unless (caller) {
139             # require_relative '../mock'
140             # dbgr, cmd = MockDebugger::setup
141             # p cmd.run([cmd.name])
142             }
143              
144             1;