lib/Devel/Trepan/CmdProcessor/Command/Finish.pm

filter: Statementstmt 75.2% 79 / 105 Branchbran 20.0% 4 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 22 / 24 Podpod 0.0% 0 / 2 totaltotal 69.5% 105 / 151 CC 13 SCAR 20.9
CC
13
Cov
66%
run
18.4
run
18.4
run
18.4
CRAP 8.1
« lib/Devel/Trepan/CmdProcessor/Command/Action.pm ↑ Summary blib/lib/Devel/Trepan/IO/TCPPack.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2014 Rocky Bernstein <rocky@cpan.org>
3 12 ▶use warnings; use utf8;
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 # rlib '../running'
8 # rlib '../../app/breakpoint' # FIXME: possibly temporary
9  
10 package Devel::Trepan::CmdProcessor::Command::Finish;
11  
12 12 ▶use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ISA) 0 1 1
15 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
16 use constant ALIASES => qw(fin);
17 use constant CATEGORY => 'running';
18 use constant SHORT_HELP => 'Step to end of current method (step out)';
19 use constant MIN_ARGS => 0; # Need at least this many
20 use constant MAX_ARGS => 1; # Need at most this many
21 use constant NEED_STACK => 1;
22 EOE
23 }
24  
25 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 @ISA = @CMD_ISA;
27 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
28  
29 1 our $NAME = set_name();
30 =pod
31  
32 =head2 Synopsis:
33  
34 =cut
35 1 our $HELP = <<'HELP';
36 =pod
37  
38 B<finish> [I<levels>]
39  
40 Continue execution until the program is about to leave the current
41 function. Sometimes this is called "step out".
42  
43 When integer I<levels> is specified, that many frame levels need to be
44 popped. The default is 1.
45  
46 =head2 See also:
47  
48 L<C<break>|Devel::Trepan::CmdProcessor::Command::Break>,
49 L<C<continue>|Devel::Trepan::CmdProcessor::Command::Continue>,
50 L<C<next> (step over)|Devel::Trepan::CmdProcessor::Command::Next>, and
51 L<C<step> (step into)|Devel::Trepan::CmdProcessor::Command::Step>.
52  
53 =cut
54 HELP
55  
56 12 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 # This method runs the command
59 0 ▶sub run($$) {
Subroutine run: not called CC=5 SCAR=29.1
Subroutine run: not called CC=5 SCAR=29.1
Pod undocumented
Pod undocumented
60 0 my ($self, $args) = @_;
61 0 my $proc = $self->{proc};
62 0 my $event = $proc->{event};
63 0 ▶ if ($event eq 'return') {
Branch: 4 branches
BranchTrueFalseTotal
if ($event eq 'return') { } 0 0 0
elsif ($event eq 'call') { } 0 0 0
if ($event eq 'return') { } 11 0 11
elsif ($event eq 'call') { } 0 11 11
64 0 $proc->errmsg("Can't run ${NAME} while inside a return. Step and try again.");
65 0 return;
66 } elsif ($event eq 'call') {
67 0 $proc->errmsg("Can't run ${NAME} while inside a call. Step and try again.");
68 0 return;
69 }
70  
71 0 my ($opts, $level_count) = ({}, 1);
72 0 ▶ if (scalar @$args != 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @$args != 1) 0 0 0
if (scalar @$args != 1) 0 0 0
73 # Form is not "finish" which means "finish 1"
74 0 my $count_str = $args->[1];
75 0 $opts = {
76 msg_on_error =>
77 "The '${NAME}' command argument must eval to an integer. Got: ${count_str}",
78 min_value => 1
79 };
80 0 my $count = $proc->get_an_int($count_str, $opts);
81 0 ▶ return unless defined $count;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $count 0 0 0
unless defined $count 0 0 0
82 0 $level_count = $count;
83 }
84 0 $proc->finish($level_count);
85 }
86  
87 1 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
88 # require_relative '../mock'
89 # dbgr, cmd = MockDebugger::setup
90 # p cmd.run([cmd.name])
91 }
92  
93 1 1;
« lib/Devel/Trepan/CmdProcessor/Command/Action.pm ↑ Summary blib/lib/Devel/Trepan/IO/TCPPack.pm »