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

filter: Statementstmt 66.2% 94 / 142 Branchbran 28.1% 9 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 95.8% 23 / 24 Podpod 0.0% 0 / 2 totaltotal 63.0% 126 / 200 CC 22 SCAR 27.5
CC
22
Cov
59%
run
29.0
run
29.0
run
29.0
CRAP 15.6
« lib/Devel/Trepan/IO/FIFOClient.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Command/Info_Subcmd/Variables_Subcmd/My.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2015 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::Clear;
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::CmdProcessor::Command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ISA) 1 1 2
12 12 ▶ 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
13 use constant ALIASES => qw(d);
14 use constant CATEGORY => 'breakpoints';
15 use constant SHORT_HELP => 'Clear some breakpoints';
16 use constant MIN_ARGS => 0; # Need at least this many
17 use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
18 use constant NEED_STACK => 0;
19 EOE
20 }
21  
22 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
23 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
24  
25 2 our $NAME = set_name();
26 =pod
27  
28 =head2 Synopsis:
29  
30 =cut
31 2 our $HELP = <<'HELP';
32 =pod
33  
34 B<clear> [I<line-number>]
35  
36 =head2 See also:
37  
38 L<C<delete>|Devel::Trepan::CmdProcessor::Command::Delete>,
39  
40 =cut
41 HELP
42  
43 # This method runs the command
44 0 ▶sub run($$) {
Subroutine run: not called CC=8 SCAR=33.7
Subroutine run: called CC=8 SCAR=33.7
Pod undocumented
Pod undocumented
45 0 my ($self, $args) = @_;
46 0 my $proc = $self->{proc};
47 0 my @args = @$args;
48 0 my $line_number = $proc->{frame}{line};
49  
50 0 ▶ if (scalar @args > 1) {
Branch: 3 branches
BranchTrueFalseTotal
if (scalar @args > 1) 0 0 0
if (scalar @args > 1) 11 1 12
if (scalar @args > 1) 0 1 1
51 0 $line_number = $proc->get_an_int($args->[1]);
52 0 ▶ return unless $line_number;
Branch: 3 branches
BranchTrueFalseTotal
unless $line_number 0 0 0
unless $line_number 0 11 11
unless $line_number 0 1 1
53 }
54  
55 0 my $bpmgr = $proc->{brkpts};
56 0 my @brkpts = @{$bpmgr->{list}};
57 0 my @line_nos = ();
58 0 foreach my $bp (@brkpts) {
59 0 ▶ if ($bp->line_num == $line_number) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bp->line_num == $line_number) 0 0 0
if ($bp->line_num == $line_number) 0 0 0
60 0 my $bp_num = $bp->id;
61 0 push @line_nos, $bp_num;
62 0 $proc->{brkpts}->delete($bp_num);
63 }
64 }
65 0 my $count = scalar @line_nos;
66 0 ▶ if ($count == 0) {
Branch: 6 branches
BranchTrueFalseTotal
if ($count == 0) { } 0 0 0
elsif ($count == 1) { } 0 0 0
elsif ($count >= 1) { } 0 0 0
if ($count == 0) { } 2 0 2
elsif ($count == 1) { } 0 0 0
elsif ($count >= 1) { } 0 0 0
67 0 $self->errmsg(sprintf "No breakpoint at line %d", $line_number);
68 } elsif ($count == 1) {
69 0 $self->msg(sprintf "Deleted breakpoint %d", $line_nos[0]);
70 } elsif ($count >= 1) {
71 0 $self->msg(sprintf "Deleted breakpoints %s", join(' ', @line_nos));
72 }
73 }
74  
75 2 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 2 2
76 0 require Devel::Trepan::DB;
77 0 require Devel::Trepan::Core;
78 0 my $db = Devel::Trepan::Core->new;
79 0 my $intf = Devel::Trepan::Interface::User->new(undef, undef, {readline => 0});
80 0 my $proc = Devel::Trepan::CmdProcessor->new([$intf], $db);
81  
82 0 $proc->{stack_size} = 0;
83 0 $proc->{frame} = {line => 1};
84 0 my $cmd = __PACKAGE__->new($proc);
85 0 $cmd->run([$NAME]);
86 0 $cmd->run([$NAME, '5']);
87 }
88  
89 2 1;
« lib/Devel/Trepan/IO/FIFOClient.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Command/Info_Subcmd/Variables_Subcmd/My.pm »