| 1 | # -*- coding: utf-8 -*- | ||||||||||||||
| 2 | # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org> | ||||||||||||||
| 3 | 12 | ▶ | use warnings; no warnings 'redefine'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 12 | ▶ | use rlib '../../../..'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | # require_relative '../../app/condition' | ||||||||||||||
| 8 | |||||||||||||||
| 9 | package Devel::Trepan::CmdProcessor::Command::Step; | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 12 | ▶ | use if !@ISA, Devel::Trepan::CmdProcessor::Command ; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | ▶ | unless (@ISA) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 14 | 0 | ▶ | eval <<'EOE'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 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 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 25 | 12 | ▶ | use vars qw(@ISA); @ISA = @CMD_ISA; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | 12 | ▶ | use vars @CMD_VARS; # Value inherited from parent | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 27 | |||||||||||||||
| 28 | 1 | $NAME = set_name(); | |||||||||||||
| 29 | =pod | ||||||||||||||
| 30 | |||||||||||||||
| 31 | =head2 Synopsis: | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =cut | ||||||||||||||
| 34 | 1 | $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 | 1 | 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 | 0 | ▶ | sub run($$) { | ||||||||||||
|
Subroutine
run: not called CC=4 SCAR=24.0
Subroutine
run: not called CC=4 SCAR=24.0
Pod
undocumented
Pod
undocumented
| |||||||||||||||
| 85 | 0 | my ($self, $args) = @_; | |||||||||||||
| 86 | |||||||||||||||
| 87 | 0 | my $proc = $self->{proc}; | |||||||||||||
| 88 | 0 | my $opts = $proc->parse_next_step_suffix($args->[0]); | |||||||||||||
| 89 | # condition = nil | ||||||||||||||
| 90 | 0 | ▶ | if (0 == $#$args) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 91 | # Form is: "step" which means "step 1" | ||||||||||||||
| 92 | 0 | $proc->{skip_count} = 0; | |||||||||||||
| 93 | } else { | ||||||||||||||
| 94 | 0 | my $replace_cmd = $Keyword_to_related_cmd->{$args->[1]}; | |||||||||||||
| 95 | 0 | ▶ | if (defined($replace_cmd)) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 96 | 0 | my $cmd = $proc->{commands}{$replace_cmd}; | |||||||||||||
| 97 | 0 | return $cmd->run( [$replace_cmd, splice(@$args, 2)] ); | |||||||||||||
| 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]; | |||||||||||||
| 123 | 0 | my $int_opts = { | |||||||||||||
| 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); | |||||||||||||
| 130 | 0 | ▶ | return unless defined($count); | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 131 | # step 1 is $proc->{skip_count} = 0 or "stop next event" | ||||||||||||||
| 132 | 0 | $proc->{skip_count} = $count - 1 ; | |||||||||||||
| 133 | } | ||||||||||||||
| 134 | } | ||||||||||||||
| 135 | 0 | $proc->step($opts) | |||||||||||||
| 136 | } | ||||||||||||||
| 137 | |||||||||||||||
| 138 | 1 | ▶ | unless (caller) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 139 | # require_relative '../mock' | ||||||||||||||
| 140 | # dbgr, cmd = MockDebugger::setup | ||||||||||||||
| 141 | # p cmd.run([cmd.name]) | ||||||||||||||
| 142 | } | ||||||||||||||
| 143 | |||||||||||||||
| 144 | 1 | 1; | |||||||||||||