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

filter: Statementstmt 32.4% 70 / 216 Branchbran 5.8% 4 / 68 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.3% 19 / 30 Podpod 0.0% 0 / 11 totaltotal 28.6% 93 / 325 CC 43 SCAR 33.4
CC
43
Cov
26%
run
63.3
run
63.3
run
63.3
CRAP 28.1
« blib/lib/Devel/Trepan/CmdProcessor/Command/Subcmd/SubMgr.pm ↑ Summary lib/Devel/Trepan/DB/Eval.pm »
1 # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org>
2 # -*- coding: utf-8 -*-
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 # disable breakpoint command. The difference however is that the
7 # parameter to @proc.en_disable_breakpoint_by_number is different (set
8 # as ENABLE_PARM below).
9 #
10 # NOTE: The enable command subclasses this, so beware when changing!
11 package Devel::Trepan::CmdProcessor::Command::Disable;
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 strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 12 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@Devel::Trepan::CmdProcessor::Command::Disable::ISA) 0 1 1
18 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
19 use constant CATEGORY => 'breakpoints';
20 use constant SHORT_HELP => 'Disable some breakpoints';
21 use constant MIN_ARGS => 0; # Need at least this many
22 use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
23 use constant NEED_STACK => 0;
24 EOE
25 }
26  
27 1 @ISA = @CMD_ISA;
28 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
29  
30 # require_relative '../breakpoint'
31 # require_relative '../../app/util'
32  
33 1 our $NAME = set_name();
34 =pod
35  
36 =head2 Synopsis:
37  
38 =cut
39 1 our $HELP = <<'HELP';
40 =pod
41  
42 B<disable> I<bp-number> [I<bp-number> ...]
43  
44 Disables the breakpoints given as a space separated list of breakpoint
45 numbers.
46  
47 =head2 Examples:
48  
49 disable 1 2 # Enable breakpoint 1 and 2
50 disable b1 b2 # Same as above
51 disable a4 # Enable action 4
52 disable w1 2 # Enable watch expression 1 and breakpoint 2
53  
54 =head2 See also:
55  
56 L<C<info break>|Devel::Trepan::CmdProcessor::Command::Info::Breakpoints> to
57 get a list of breakpoints, and
58 L<C<enable>|<Devel::Trepan::CmdProcessor::Command::Enable> to
59 enable breakpoints.
60  
61 =cut
62 HELP
63  
64 ### FIXME: parameterize and combine these. Also combine with enable.
65 0 ▶sub disable_breakpoint($$) {
Subroutine disable_breakpoint: not called CC=3 SCAR=24.8
Subroutine disable_breakpoint: not called CC=3 SCAR=24.8
Pod undocumented
Pod undocumented
66 0 ▶ my ($proc, $i) = @_;
Subroutine disable_breakpoint: not called CC=3 SCAR=24.8
Pod undocumented
67 0 my $bp = $proc->{brkpts}->find($i);
68 0 my $msg;
69 0 ▶ if ($bp) {
Branch: 3 branches
BranchTrueFalseTotal
if ($bp) { } 0 0 0
if ($bp) { } 0 0 0
if ($bp) { } 0 0 0
70 0 ▶ if ($bp->enabled) {
Branch: 3 branches
BranchTrueFalseTotal
if ($bp->enabled) { } 0 0 0
if ($bp->enabled) { } 0 0 0
if ($bp->enabled) { } 0 0 0
71 0 $bp->enabled(0);
72 0 $msg = sprintf("Breakpoint %d disabled", $bp->id);
73 0 $proc->msg($msg);
74 } else {
75 0 $msg = sprintf("Breakpoint %d already disabled", $bp->id);
76 0 $proc->errmsg($msg);
77 }
78 } else {
79 0 $msg = sprintf("No breakpoint %d found", $i);
80 0 $proc->errmsg($msg);
81 }
82 }
83  
84 0 ▶sub disable_watchpoint($$) {
Subroutine disable_watchpoint: not called CC=3 SCAR=24.8
Subroutine disable_watchpoint: not called CC=3 SCAR=24.8
Pod undocumented
Pod undocumented
85 0 ▶ my ($proc, $i) = @_;
Subroutine disable_watchpoint: not called CC=3 SCAR=24.8
Pod undocumented
86 0 my $wp = $proc->{dbgr}{watch}->find($i);
87 0 my $msg;
88 0 ▶ if ($wp) {
Branch: 3 branches
BranchTrueFalseTotal
if ($wp) { } 0 0 0
if ($wp) { } 0 0 0
if ($wp) { } 0 0 0
89 0 ▶ if ($wp->enabled) {
Branch: 3 branches
BranchTrueFalseTotal
if ($wp->enabled) { } 0 0 0
if ($wp->enabled) { } 0 0 0
if ($wp->enabled) { } 0 0 0
90 0 $wp->enabled(0);
91 0 $msg = sprintf("Watch expression %d disabled", $wp->id);
92 0 $proc->msg($msg);
93 } else {
94 0 $msg = sprintf("Watch expression %d already disabled", $wp->id);
95 0 $proc->errmsg($msg);
96 }
97 } else {
98 0 $msg = sprintf("No watchpoint %d found", $i);
99 0 $proc->errmsg($msg);
100 }
101 }
102  
103 0 ▶sub disable_action($$) {
Subroutine disable_action: not called CC=3 SCAR=24.8
Subroutine disable_action: not called CC=3 SCAR=24.8
Pod undocumented
Pod undocumented
104 0 ▶ my ($proc, $i) = @_;
Subroutine disable_action: not called CC=3 SCAR=24.8
Pod undocumented
105 0 my $act = $proc->{actions}->find($i);
106 0 my $msg;
107 0 ▶ if ($act) {
Branch: 3 branches
BranchTrueFalseTotal
if ($act) { } 0 0 0
if ($act) { } 0 0 0
if ($act) { } 0 0 0
108 0 ▶ if ($act->enabled) {
Branch: 3 branches
BranchTrueFalseTotal
if ($act->enabled) { } 0 0 0
if ($act->enabled) { } 0 0 0
if ($act->enabled) { } 0 0 0
109 0 $act->enabled(0);
110 0 $msg = sprintf("Action %d disabled", $act->id);
111 0 $proc->msg($msg);
112 } else {
113 0 $msg = sprintf("Action %d already disabled", $act->id);
114 0 $proc->errmsg($msg);
115 }
116 } else {
117 0 $msg = sprintf("No action %d found", $i);
118 0 $proc->errmsg($msg);
119 }
120 }
121  
122 sub run($$)
123 0 ▶{
Subroutine run: not called CC=9 SCAR=41.5
Subroutine run: not called CC=9 SCAR=41.5
Pod undocumented
Pod undocumented
124 0 my ($self, $args) = @_;
125 0 my $proc = $self->{proc};
126 0 my @args = @{$args};
127 0 ▶ if (scalar @args == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @args == 1) 0 0 0
if (scalar @args == 1) 11 0 11
128 0 $proc->errmsg('No breakpoint number given.');
129 0 return;
130 }
131 0 my $first = shift @args;
132 0 for my $num_str (@args) {
133 0 my $type = lc(substr($num_str,0,1));
134 0 ▶ if ($type !~ /[0-9baw]/) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type =~ /[0-9baw]/) 0 0 0
unless ($type =~ /[0-9baw]/) 0 11 11
135 0 $proc->errmsg("Invalid prefix $type. Argument $num_str ignored");
136 0 next;
137 }
138 0 ▶ if ($type =~ /[0-9]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /[0-9]/) { } 0 0 0
if ($type =~ /[0-9]/) { } 0 0 0
139 0 $type='b';
140 } else {
141 0 $num_str = substr($num_str, 1);
142 }
143 0 my $i = $proc->get_an_int($num_str);
144 0 ▶ if (defined $i) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $i) 0 0 0
if (defined $i) 0 0 0
145 0 ▶ if ('a' eq $type) {
Branch: 6 branches
BranchTrueFalseTotal
if ('a' eq $type) { } 0 0 0
elsif ('b' eq $type) { } 0 0 0
elsif ('w' eq $type) { } 0 0 0
if ('a' eq $type) { } 0 0 0
elsif ('b' eq $type) { } 0 0 0
elsif ('w' eq $type) { } 0 0 0
146 0 disable_action($proc, $i);
147 } elsif ('b' eq $type) {
148 0 disable_breakpoint($proc, $i);
149 } elsif ('w' eq $type) {
150 0 disable_watchpoint($proc, $i);
151 }
152 }
153 }
154 }
155  
156 1 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
157 # require_relative '../mock'
158 # dbgr, cmd = MockDebugger::setup
159 # cmd.run([cmd.name])
160 # cmd.run([cmd.name, '1'])
161 # cmdproc = dbgr.core.processor
162 # cmds = cmdproc.commands
163 # break_cmd = cmds['break']
164 # break_cmd.run(['break', cmdproc.frame.source_location[0].to_s])
165 # # require_relative '../../lib/trepanning'
166 # # Trepan.debug
167 # cmd.run([cmd.name, '1'])
168 }
169  
170 1 1;
« blib/lib/Devel/Trepan/CmdProcessor/Command/Subcmd/SubMgr.pm ↑ Summary lib/Devel/Trepan/DB/Eval.pm »