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

filter: Statementstmt 71.4% 85 / 119 Branchbran 20.0% 4 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 24 / 26 Podpod 0.0% 0 / 2 totaltotal 67.6% 113 / 167 CC 13 SCAR 20.9
CC
13
Cov
64%
run
19.5
run
19.5
run
19.5
CRAP 8.1
« lib/Devel/Trepan/Position.pm ↑ Summary lib/Devel/Trepan/CmdProcessor/Command/Finish.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-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 12 ▶use rlib '../../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Devel::Trepan::CmdProcessor::Command::Action;
7 12 ▶use English qw( -no_match_vars );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 ▶use if !@ISA, Devel::Trepan::Condition ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ISA) 0 1 1
13 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
14 use constant ALIASES => qw(a);
15 use constant CATEGORY => 'breakpoints';
16 use constant NEED_STACK => 0;
17 use constant MIN_ARGS => 2; # Need at least this many
18 use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
19 use constant SHORT_HELP =>
20 'Set an action to be done before the line is executed.';
21 EOE
22 }
23  
24 12 ▶use strict; use vars qw(@ISA); @ISA = @CMD_ISA;
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
25 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
26  
27 1 our $NAME = set_name();
28 =pod
29  
30 =head2 Synopsis:
31  
32 =cut
33 1 our $HELP = <<'HELP';
34 =pod
35  
36 B<action> I<position> I<Perl-statement>
37  
38 Set an action to be done before the line is executed. If line is
39 C<.>, set an action on the line about to be executed. The sequence
40 of steps taken by the debugger is:
41  
42 =over
43  
44 =item 1.
45 check for a breakpoint at this line
46  
47 =item 2.
48 print the line if necessary (tracing)
49  
50 =item 3.
51 do any actions associated with that line
52  
53 =item 4.
54 prompt user if at a breakpoint or in single-step
55  
56 =item 5.
57 evaluate line
58  
59 =back
60  
61 For example, this will print out the value of C<$foo> every time line
62 53 is passed:
63  
64 =head2 Examples:
65  
66 action 53 print "DB FOUND $foo\n"
67  
68 =head2 See also:
69  
70 C<help breakpoints>
71  
72 =cut
73 HELP
74  
75 # This method runs the command
76 0 ▶sub run($$) {
Subroutine run: not called CC=5 SCAR=29.7
Subroutine run: not called CC=5 SCAR=29.7
Pod undocumented
Pod undocumented
77 0 my ($self, $args) = @_;
78 0 my $proc = $self->{proc};
79 0 my $frame = $proc->{frame};
80 0 my @args = @$args;
81 0 shift @args;
82  
83 0 my ($filename, $lineno, $fn, $gobble_count, $rest) =
84 $proc->parse_position(\@args, 0); # should be: , 1);
85 0 ▶ shift @args if $gobble_count-- > 0;
Branch: 2 branches
BranchTrueFalseTotal
if $gobble_count-- > 0 0 0 0
if $gobble_count-- > 0 11 0 11
86 0 ▶ shift @args if $gobble_count-- > 0;
Branch: 2 branches
BranchTrueFalseTotal
if $gobble_count-- > 0 0 0 0
if $gobble_count-- > 0 0 11 11
87 # error should have been shown previously
88  
89 0 my $action_expression = join(' ', @args);
90 0 ▶ unless (is_valid_condition($action_expression)) {
Branch: 2 branches
BranchTrueFalseTotal
unless (&is_valid_condition($action_expression)) 0 0 0
unless (&is_valid_condition($action_expression)) 0 0 0
91 0 $proc->errmsg("Invalid action: $action_expression");
92 return
93 0 }
94 0 my $action = $self->{dbgr}->set_action($lineno, $filename,
95 $action_expression);
96 0 ▶ if ($action) {
Branch: 2 branches
BranchTrueFalseTotal
if ($action) 0 0 0
if ($action) 0 0 0
97 0 my $id = $action->id;
98 0 my $filename = $proc->canonic_file($action->filename);
99 0 my $line_num = $action->line_num;
100 0 $proc->{actions}->add($action);
101 0 $proc->msg("Action $id set in $filename at line $line_num");
102  
103 }
104 }
105  
106 1 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
107 0 require Devel::Trepan::CmdProcessor::Mock;
108 0 my $proc = Devel::Trepan::CmdProcessor::Mock::setup();
109 # my $cmd = __PACKAGE__->new($proc);
110 # $cmd->run([$NAME]);
111 }
112  
113 1 1;
« lib/Devel/Trepan/Position.pm ↑ Summary lib/Devel/Trepan/CmdProcessor/Command/Finish.pm »