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

filter: Statementstmt 64.8% 85 / 131 Branchbran 20.0% 4 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 24 / 26 Podpod 0.0% 0 / 2 totaltotal 63.1% 113 / 179 CC 13 SCAR 21.7
CC
13
Cov
59%
run
21.1
run
21.1
run
21.1
CRAP 8.7
« lib/Devel/Trepan/CmdProcessor/Command/Alias.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Command.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2012 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::Condition;
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(cond);
15 use constant CATEGORY => 'breakpoints';
16 use constant NEED_STACK => 0;
17 use constant SHORT_HELP =>
18 'Specify a condition on a breakpoint';
19 use constant MIN_ARGS => 2; # Need at least this many
20 use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
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<condition> I<bp-number> I<Perl-expression>
37  
38 I<bp-number> is a breakpoint number. I<Perl-expresion> is a Perl
39 expression which must evaluate to true before the breakpoint is
40 honored. If I<perl-expression> is absent, any existing condition is removed;
41 i.e., the breakpoint is made unconditional.
42  
43 =head2 Examples:
44  
45 condition 5 x > 10 # Breakpoint 5 now has condition x > 10
46 condition 5 # Remove above condition
47  
48 =head2 See also:
49  
50 L<C<break>|Devel::Trepan::CmdProcessor::Command::Break>,
51 L<C<enable>|Devel::Trepan::CmdProcessor::Command::Enable> and
52 L<C<disable>|Devel::Trepan::CmdProcessor::Command::Disable>.
53  
54 =cut
55 HELP
56  
57 # This method runs the command
58 0 ▶sub run($$) {
Subroutine run: not called CC=5 SCAR=30.5
Subroutine run: not called CC=5 SCAR=30.5
Pod undocumented
Pod undocumented
59 0 my ($self, $args) = @_;
60 0 my $proc = $self->{proc};
61 0 my $bpnum = $proc->get_an_int($args->[1]);
62 0 ▶ return unless defined($bpnum);
Branch: 2 branches
BranchTrueFalseTotal
unless defined $bpnum 0 0 0
unless defined $bpnum 11 0 11
63 0 my $bp = $proc->{brkpts}->find($bpnum);
64 0 ▶ unless ($bp) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($bp) 0 0 0
unless ($bp) 0 11 11
65 0 $proc->errmsg("No breakpoint number $bpnum");
66 0 return;
67 }
68  
69 0 my $condition;
70 0 ▶ if (scalar @{$args} > 2) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$args;} > 2) { } 0 0 0
if (scalar @{$args;} > 2) { } 0 0 0
71 0 my @args = @{$args};
72 0 shift @args; shift @args;
73 0 $condition = join(' ', @args);
74 0 my $msg = &DB::eval_not_ok($condition);
75 0 ▶ if ($msg) {
Branch: 2 branches
BranchTrueFalseTotal
if ($msg) 0 0 0
if ($msg) 0 0 0
76 0 $proc->errmsg("Invalid condition: $condition");
77 0 chomp $msg;
78 0 $proc->errmsg($msg);
79 return
80 0 }
81 } else {
82 0 $condition = '1';
83 0 $proc->msg('Breakpoint $bp->id is now unconditional.');
84 }
85 0 $bp->condition($condition);
86 }
87  
88 1 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
89 0 require Devel::Trepan::CmdProcessor::Mock;
90 0 my $proc = Devel::Trepan::CmdProcessor::Mock::setup();
91 # my $cmd = __PACKAGE__->new($proc);
92 # $cmd->run([$NAME]);
93 }
94  
95 1 1;
« lib/Devel/Trepan/CmdProcessor/Command/Alias.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Command.pm »