lib/Devel/Trepan/DB/Breakpoint.pm

filter: Statementstmt 22.3% 78 / 349 Branchbran 7.6% 19 / 250 Conditioncond 15.7% 6 / 38 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 42.8% 15 / 35 Podpod 0.0% 0 / 20 totaltotal 16.4% 118 / 716 CC 143 SCAR 47.7
CC
143
Cov
16%
set_break
253.8
set_break
253.8
clr_breaks
132.0
CRAP 118.2
« lib/Devel/Trepan/CmdProcessor/Command/Break.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Command/Info_Subcmd/Breakpoints.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2014 Rocky Bernstein <rocky@cpan.org>
3 # largely rewritten from perl5db.
4  
5 13 ▶use Class::Struct;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 struct DBBreak => {
9 id => '$', # breakpoint/action number
10 enabled => '$', # True if breakpoint or action is enabled
11 type => '$', # 'tbrkpt', 'brkpt' or 'action'
12 condition => '$', # Condition to evaluate or '1' fo unconditional
13 # if type is 'action' this is the action to run
14 hits => '$', # Number of times the breakpoint/action hit
15 negate => '$', # break/step if ... or until .. ?
16 filename => '$',
17 line_num => '$'
18 };
19  
20 package DBBreak;
21 sub inspect($)
22 0 ▶{
Subroutine inspect: not called CC=2 SCAR=17.9
23 0 ▶ my $self = shift;
Subroutine inspect: not called CC=2 SCAR=17.9
24 0 ▶ sprintf("id %d, file %s, line %s, type: %s, enabled: %d, negate %s, hits: %s, cond: %s",
Condition0%0/4
$self->negate || 0
l!l
00
$self->negate || 0
l!l
00
MC/DC0%0/1
$self->negate || 0
$self->negate
MC/DC0%0/1
$self->negate || 0
$self->negate
Truth table0%0/2
A
A= $self->negate
Aresult
11
00
Truth table0%0/2
A
A= $self->negate
Aresult
11
00
25 $self->id,
26 $self->filename, $self->line_num,
27 $self->type,
28 $self->enabled,
29 $self->negate || 0,
30 $self->hits, $self->condition
31 );
32 };
33  
34 sub icon_char($)
35 0 ▶{
Subroutine icon_char: not called CC=4 SCAR=30.0
36 0 ▶ my $self = shift;
Subroutine icon_char: not called CC=4 SCAR=30.0
37 0 ▶ if ('tbrkpt' eq $self->type) {
Branch: 6 branches
BranchTrueFalseTotal
if ('tbrkpt' eq $self->type) { } 0 0 0
elsif ('brkpt' eq $self->type) { } 0 0 0
elsif ('action' eq $self->type) { } 0 0 0
if ('tbrkpt' eq $self->type) { } 0 0 0
elsif ('brkpt' eq $self->type) { } 0 0 0
elsif ('action' eq $self->type) { } 0 0 0
38 0 return 'T';
39 } elsif ('brkpt' eq $self->type) {
40 0 return 'B';
41 } elsif ('action' eq $self->type) {
42 0 return 'A';
43 }
44 }
45  
46 package DB;
47 13 ▶use vars qw($brkpt $package $lineno $max_bp $max_action);
Subroutine BEGIN: called CC=1 SCAR=0.0
48 13 ▶use strict; 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
49 13 ▶use English qw( -no_match_vars );
Subroutine BEGIN: called CC=1 SCAR=0.0
50 13 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 13 ▶use rlib '../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 13 ▶use Devel::Trepan::DB::LineCache; # For eval_ok
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 13 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
56 13 $DB::brkpt = undef; # current breakpoint
57 13 $max_bp = $max_action = 0;
58 }
59  
60 # return info on lines with actions
61 0 ▶sub line_events {
Subroutine line_events: not called CC=4 SCAR=30.0
Pod undocumented
62 0 ▶ my $s = shift;
Subroutine line_events: not called CC=4 SCAR=30.0
Pod undocumented
63 0 my $fname = shift;
64 0 my(%ret) = ();
65 0 ▶ $fname = $DB::filename unless $fname;
Branch: 2 branches
BranchTrueFalseTotal
unless $fname 0 0 0
unless $fname 0 0 0
66 0 local(*DB::dbline) = "::_<$fname";
67 0 ▶ for (my $i = 1; $i <= $#DB::dbline; $i++) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i <= $#DB::dbline) 0 0 0
if ($i <= $#DB::dbline) 0 0 0
68 0 ▶ $ret{$i} = $DB::dbline[$i] if defined $DB::dbline{$i};
Branch: 2 branches
BranchTrueFalseTotal
if defined $DB::dbline{$i} 0 0 0
if defined $DB::dbline{$i} 0 0 0
69 }
70 0 return %ret;
71 }
72  
73 # Find a subroutine. Return ($filename, $fn_name, $start_line);
74 # If not found, return (undef, undef, undef);
75 0 ▶sub find_subline($;$) {
Subroutine find_subline: not called CC=5 SCAR=34.0
Pod undocumented
76 0 ▶ my $fn_name = shift;
Subroutine find_subline: not called CC=5 SCAR=34.0
Pod undocumented
77 0 $fn_name =~ s/\'/::/;
78 0 ▶ $fn_name = "${DB::package}\:\:" . $fn_name if $fn_name !~ /::/;
Branch: 2 branches
BranchTrueFalseTotal
unless $fn_name =~ /::/ 0 0 0
unless $fn_name =~ /::/ 0 0 0
79 0 ▶ $fn_name = "main" . $fn_name if substr($fn_name,0,2) eq "::";
Branch: 2 branches
BranchTrueFalseTotal
if substr($fn_name, 0, 2) eq "::" 0 0 0
if substr($fn_name, 0, 2) eq "::" 0 0 0
80 0 my $filename = $DB::filename;
81 0 ▶ if (exists $DB::sub{$fn_name}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $DB::sub{$fn_name}) 0 0 0
if (exists $DB::sub{$fn_name}) 0 0 0
82 0 my($filename, $from, $to) = ($DB::sub{$fn_name} =~ /^(.*):(\d+)-(\d+)$/);
83 0 ▶ if ($from) {
Branch: 2 branches
BranchTrueFalseTotal
if ($from) 0 0 0
if ($from) 0 0 0
84 0 local *DB::dbline = "::_<$filename";
85 0 return ($filename, $fn_name, $from);
86 }
87 }
88 0 return (undef, undef, undef);
89 }
90  
91 # Return a warning message if breakpoint position is invalid.
92 # undef is returned if the breakpont is valid.
93 1 ▶sub break_invalid {
Subroutine break_invalid: called CC=13 SCAR=46.6
Pod undocumented
94 0 ▶ my ($s, $filename_ref, $fn_or_lineno) = @_;
Subroutine break_invalid: not called CC=13 SCAR=46.6
Pod undocumented
95 0 my $filename = $$filename_ref;
96 0 ▶ $filename = $DB::filename unless defined $filename;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $filename 0 1 1
unless defined $filename 0 0 0
97 0 my $change_dbline = $filename ne $DB::filename;
98 0 ▶ $fn_or_lineno ||= $DB::lineno;
Condition16%1/6
$fn_or_lineno ||= $DB::lineno
l!l&&r!l&&!r
100
$fn_or_lineno ||= $DB::lineno
l!l&&r!l&&!r
000
MC/DC0%0/2
$fn_or_lineno ||= $DB::lineno
$fn_or_lineno $DB::lineno
MC/DC0%0/2
$fn_or_lineno ||= $DB::lineno
$fn_or_lineno $DB::lineno
Truth table33%1/3
A ||= B
A= $fn_or_linenoB= $DB::lineno
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $fn_or_linenoB= $DB::lineno
ABresult
1X1
011
000
99  
100 # If we're not in that file, switch over to it.
101 0 ▶ if ( $change_dbline ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($change_dbline) 0 1 1
if ($change_dbline) 0 0 0
102 # Switch debugger's magic structures.
103 0 my $filekey = '_<' . $filename;
104 0 ▶ *DB::dbline = $main::{ $filekey } if exists $main::{ $filekey };
Branch: 2 branches
BranchTrueFalseTotal
if exists $main::main::{$filekey} 0 0 0
if exists $main::main::{$filekey} 0 0 0
105 }
106  
107 0 my $lineno = $fn_or_lineno;
108 0 ▶ if ($fn_or_lineno =~ /\D/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fn_or_lineno =~ /\D/) { } 0 1 1
if ($fn_or_lineno =~ /\D/) { } 0 0 0
109 0 my $junk;
110 0 ($filename, $junk, $lineno) = find_subline($fn_or_lineno) ;
111 0 ▶ unless ($lineno) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($lineno) 0 0 0
unless ($lineno) 0 0 0
112 0 ▶ *DB::dbline = $main::{ '_<' . $DB::filename } if $change_dbline;
Branch: 2 branches
BranchTrueFalseTotal
if $change_dbline 0 0 0
if $change_dbline 0 0 0
113 0 return "Subroutine $fn_or_lineno not found"
114 }
115 0 $change_dbline = $filename ne $DB::filename;
116 0 ▶ if ( $change_dbline ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($change_dbline) 0 0 0
if ($change_dbline) 0 0 0
117 # Switch debugger's magic structures.
118 0 my $filekey = '_<' . $filename;
119 0 ▶ *DB::dbline = $main::{ $filekey } if exists $main::{ $filekey };
Branch: 2 branches
BranchTrueFalseTotal
if exists $main::main::{$filekey} 0 0 0
if exists $main::main::{$filekey} 0 0 0
120 }
121 0 $$filename_ref = $filename;
122 0 return undef;
123 } else {
124 0 ▶ if (!defined($DB::dbline[$lineno]) || $DB::dbline[$lineno] == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $DB::dbline[$lineno] or $DB::dbline[$lineno] == 0) 1 0 1
if (not defined $DB::dbline[$lineno] or $DB::dbline[$lineno] == 0) 0 0 0
Condition16%1/6
not defined $DB::dbline[$lineno] or $DB::dbline[$lineno] == 0
l!l&&r!l&&!r
100
not defined $DB::dbline[$lineno] or $DB::dbline[$lineno] == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $DB::dbline[$lineno] or $DB::dbline[$lineno] == 0
not defined $DB::dbline[$lineno] $DB::dbline[$lineno] == 0
MC/DC0%0/2
not defined $DB::dbline[$lineno] or $DB::dbline[$lineno] == 0
not defined $DB::dbline[$lineno] $DB::dbline[$lineno] == 0
Truth table33%1/3
not(A) or B
A= not defined $DB::dbline[$lineno]B= $DB::dbline[$lineno] == 0
ABresult
1X1
011
000
Truth table0%0/3
not(A) or B
A= not defined $DB::dbline[$lineno]B= $DB::dbline[$lineno] == 0
ABresult
1X1
011
000
125 0 ▶ *DB::dbline = $main::{ '_<' . $DB::filename } if $change_dbline;
Branch: 2 branches
BranchTrueFalseTotal
if $change_dbline 0 1 1
if $change_dbline 0 0 0
126 0 $$filename_ref = $filename;
127 0 return "Line $lineno of $filename not known to be a trace line";
128 }
129 }
130 0 return undef;
131 }
132  
133 =head2 set_breakpoint
134  
135 # Set a breakpoint, temporary breakpoint, or action.
136  
137 =cut
138 1 ▶sub set_break {
Subroutine set_break: called CC=22 SCAR=55.4
Pod undocumented
139 0 ▶ my ($s, $filename, $fn_or_lineno, $cond, $id, $type, $enabled, $force) = @_;
Subroutine set_break: not called CC=22 SCAR=55.4
Pod undocumented
140 0 ▶ $filename = $DB::filename unless defined $filename;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $filename 0 1 1
unless defined $filename 0 0 0
141 0 my $change_dbline = $filename ne $DB::filename;
142 0 ▶ $type = 'brkpt' unless defined $type;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $type 0 1 1
unless defined $type 0 0 0
143 0 ▶ $enabled = 1 unless defined $enabled;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $enabled 1 0 1
unless defined $enabled 0 0 0
144 0 ▶ $fn_or_lineno ||= $DB::lineno;
Condition16%1/6
$fn_or_lineno ||= $DB::lineno
l!l&&r!l&&!r
100
$fn_or_lineno ||= $DB::lineno
l!l&&r!l&&!r
000
MC/DC0%0/2
$fn_or_lineno ||= $DB::lineno
$fn_or_lineno $DB::lineno
MC/DC0%0/2
$fn_or_lineno ||= $DB::lineno
$fn_or_lineno $DB::lineno
Truth table33%1/3
A ||= B
A= $fn_or_linenoB= $DB::lineno
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $fn_or_linenoB= $DB::lineno
ABresult
1X1
011
000
145 0 ▶ $cond ||= '1';
Condition25%1/4
$cond ||= 1
l!l
10
$cond ||= 1
l!l
00
MC/DC0%0/1
$cond ||= 1
$cond
MC/DC0%0/1
$cond ||= 1
$cond
Truth table50%1/2
A
A= $cond
Aresult
11
00
Truth table0%0/2
A
A= $cond
Aresult
11
00
146  
147 # If we're not in that file, switch over to it.
148 0 ▶ if ( $change_dbline ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($change_dbline) 0 1 1
if ($change_dbline) 0 0 0
149 # Switch debugger's magic structures.
150 0 my $filekey = '_<' . $filename;
151 0 ▶ *DB::dbline = $main::{ $filekey } if exists $main::{ $filekey };
Branch: 2 branches
BranchTrueFalseTotal
if exists $main::main::{$filekey} 0 0 0
if exists $main::main::{$filekey} 0 0 0
152 }
153  
154 0 my $lineno = $fn_or_lineno;
155 0 my $function = undef;
156 0 ▶ if ($fn_or_lineno =~ /\D/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fn_or_lineno =~ /\D/) { } 0 1 1
if ($fn_or_lineno =~ /\D/) { } 0 0 0
157 0 my $junk;
158 0 ($filename, $function, $lineno) = find_subline($fn_or_lineno, $filename) ;
159 0 ▶ unless ($lineno) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($lineno) 0 0 0
unless ($lineno) 0 0 0
160 0 $s->warning("Subroutine $fn_or_lineno not found.\n");
161 0 ▶ *DB::dbline = $main::{ '_<' . $DB::filename } if $change_dbline;
Branch: 2 branches
BranchTrueFalseTotal
if $change_dbline 0 0 0
if $change_dbline 0 0 0
162 0 return undef;
163 }
164 0 $change_dbline = $filename ne $DB::filename;
165 0 ▶ if ( $change_dbline ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($change_dbline) 0 0 0
if ($change_dbline) 0 0 0
166 # Switch debugger's magic structures.
167 0 my $filekey = '_<' . $filename;
168 0 ▶ *DB::dbline = $main::{ $filekey } if exists $main::{ $filekey };
Branch: 2 branches
BranchTrueFalseTotal
if exists $main::main::{$filekey} 0 0 0
if exists $main::main::{$filekey} 0 0 0
169 }
170 } else {
171 0 ▶ unless (is_breakable($filename, $lineno) || $force) {
Branch: 2 branches
BranchTrueFalseTotal
unless (is_breakable($filename, $lineno) or $force) 0 1 1
unless (is_breakable($filename, $lineno) or $force) 0 0 0
Condition16%1/6
is_breakable($filename, $lineno) or $force
l!l&&r!l&&!r
100
is_breakable($filename, $lineno) or $force
l!l&&r!l&&!r
000
MC/DC0%0/2
is_breakable($filename, $lineno) or $force
is_breakable($filename, $lineno) $force
MC/DC0%0/2
is_breakable($filename, $lineno) or $force
is_breakable($filename, $lineno) $force
Truth table33%1/3
A or B
A= is_breakable($filename, $lineno)B= $force
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= is_breakable($filename, $lineno)B= $force
ABresult
1X1
011
000
172 0 $s->warning("Line $lineno of $filename not known to be a trace line.\n");
173  
174 0 ▶ *DB::dbline = $main::{ '_<' . $DB::filename } if $change_dbline;
Branch: 2 branches
BranchTrueFalseTotal
if $change_dbline 0 0 0
if $change_dbline 0 0 0
175 0 return undef;
176 }
177 }
178 0 ▶ unless (defined $id) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $id) 1 0 1
unless (defined $id) 0 0 0
179 0 ▶ if ($type eq 'action') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'action') { } 0 1 1
if ($type eq 'action') { } 0 0 0
180 0 $id = ++$max_action;
181 } else {
182 0 $id = ++$max_bp;
183 }
184 }
185 0 my $brkpt = DBBreak->new(
186 type => $type,
187 condition => $cond,
188 id => $id,
189 hits => 0,
190 enabled => $enabled,
191 filename => $filename,
192 line_num => $lineno
193 );
194  
195 0 my $ary_ref;
196 0 ▶ if (defined($function)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $function) { } 0 1 1
if (defined $function) { } 0 0 0
197 0 ▶ $DB::fn_brkpt{$function} = [] unless exists $DB::fn_brkpt{$fn_or_lineno};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $DB::fn_brkpt{$fn_or_lineno} 0 0 0
unless exists $DB::fn_brkpt{$fn_or_lineno} 0 0 0
198 0 $ary_ref = $DB::fn_brkpt{$function};
199 } else {
200 0 ▶ $DB::dbline{$lineno} = [] unless (exists $DB::dbline{$lineno});
Branch: 2 branches
BranchTrueFalseTotal
unless exists $DB::dbline{$lineno} 1 0 1
unless exists $DB::dbline{$lineno} 0 0 0
201 0 $ary_ref = $DB::dbline{$lineno};
202 }
203 0 push @$ary_ref, $brkpt;
204 0 ▶ *DB::dbline = $main::{ '_<' . $DB::filename } if $change_dbline;
Branch: 2 branches
BranchTrueFalseTotal
if $change_dbline 0 1 1
if $change_dbline 0 0 0
205 0 return $brkpt;
206 }
207  
208 =head2 is_breakable
209  
210 Return 1 if C<$filename> has code associated with C<$lineno>; 0 otherwise.
211  
212 =cut
213 # Return 1 if $lineno is
214 1 ▶sub is_breakable {
Subroutine is_breakable: called CC=2 SCAR=12.2
Pod undocumented
215 0 ▶ my($filename, $lineno) = @_;
Subroutine is_breakable: not called CC=2 SCAR=12.2
Pod undocumented
216 0 ▶ return defined($DB::dbline[$lineno]) && ($DB::dbline[$lineno] != 0)
Condition16%1/6
defined $DB::dbline[$lineno] && $DB::dbline[$lineno] != 0
!ll&&!rl&&r
001
defined $DB::dbline[$lineno] && $DB::dbline[$lineno] != 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $DB::dbline[$lineno] && $DB::dbline[$lineno] != 0
defined $DB::dbline[$lineno] $DB::dbline[$lineno] != 0
MC/DC0%0/2
defined $DB::dbline[$lineno] && $DB::dbline[$lineno] != 0
defined $DB::dbline[$lineno] $DB::dbline[$lineno] != 0
Truth table33%1/3
A && B
A= defined $DB::dbline[$lineno]B= $DB::dbline[$lineno] != 0
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= defined $DB::dbline[$lineno]B= $DB::dbline[$lineno] != 0
ABresult
0X0
100
111
217 }
218  
219 # Set a temporary breakpoint
220 0 ▶sub set_tbreak {
Subroutine set_tbreak: not called CC=1 SCAR=6.9
Pod undocumented
221 0 ▶ my ($s, $filename, $lineno, $cond, $id) = @_;
Subroutine set_tbreak: not called CC=1 SCAR=6.9
Pod undocumented
222 0 return set_break($s, $filename, $lineno, $cond, $id, 'tbrkpt');
223 }
224  
225 1 ▶sub delete_bp($$) {
Subroutine delete_bp: called CC=7 SCAR=36.5
Pod undocumented
226 0 ▶ my ($s, $bp) = @_;
Subroutine delete_bp: not called CC=7 SCAR=36.5
Pod undocumented
227 0 my $i = $bp->line_num;
228 0 my $file_key = '_<' . $bp->filename;
229 0 ▶ return unless exists $main::{ $file_key };
Branch: 2 branches
BranchTrueFalseTotal
unless exists $main::main::{$file_key} 0 1 1
unless exists $main::main::{$file_key} 0 0 0
230 0 local *dbline = $main::{ $file_key };
231 0 ▶ if (defined $DB::dbline{$i}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $DB::dbline{$i}) 0 1 1
if (defined $DB::dbline{$i}) 0 0 0
232 0 my $brkpts = $DB::dbline{$i};
233 0 my $count = 0;
234 0 my $break_count = scalar @$brkpts;
235 0 ▶ for (my $j=0; $j <= $break_count; $j++) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j <= $break_count) 0 0 0
if ($j <= $break_count) 0 0 0
236 0 $brkpt = $brkpts->[$j];
237 0 ▶ next unless defined $brkpt;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $DB::brkpt 0 0 0
unless defined $DB::brkpt 0 0 0
238 0 ▶ if ($brkpt eq $bp) {
Branch: 2 branches
BranchTrueFalseTotal
if ($DB::brkpt eq $bp) 0 0 0
if ($DB::brkpt eq $bp) 0 0 0
239 0 undef $brkpts->[$j];
240 0 last;
241 }
242 0 $count++;
243 }
244 0 ▶ delete $DB::dbline{$i} if $count == 0;
Branch: 2 branches
BranchTrueFalseTotal
if $count == 0 0 0 0
if $count == 0 0 0 0
245 }
246 }
247  
248 0 ▶sub clr_breaks {
Subroutine clr_breaks: not called CC=11 SCAR=48.8
Pod undocumented
249 0 ▶ my $s = shift;
Subroutine clr_breaks: not called CC=11 SCAR=48.8
Pod undocumented
250 0 my $i;
251 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (@_) { } 0 0 0
252 0 ▶ while (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 0 0 0
if (@_) 0 0 0
253 0 $i = shift;
254 0 ▶ $i = _find_subline($i) if ($i =~ /\D/);
Branch: 2 branches
BranchTrueFalseTotal
if $i =~ /\D/ 0 0 0
if $i =~ /\D/ 0 0 0
255 0 ▶ $s->output("Subroutine not found.\n") unless $i;
Branch: 2 branches
BranchTrueFalseTotal
unless $i 0 0 0
unless $i 0 0 0
256 0 ▶ if (defined $DB::dbline{$i}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $DB::dbline{$i}) 0 0 0
if (defined $DB::dbline{$i}) 0 0 0
257 0 my $brkpts = $DB::dbline{$i};
258 0 my $j = 0;
259 0 for my $brkpt (@$brkpts) {
260 0 ▶ if ($brkpt->action ne 'brkpt') {
Branch: 2 branches
BranchTrueFalseTotal
if ($brkpt->action ne "brkpt") 0 0 0
if ($brkpt->action ne "brkpt") 0 0 0
261 0 $j++;
262 0 next;
263 }
264 0 undef $brkpts->[$j];
265 }
266 0 ▶ delete $DB::dbline{$i} if $j == 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j == 0 0 0 0
if $j == 0 0 0 0
267 }
268 }
269 } else {
270 0 ▶ for ($i = 1; $i <= $#DB::dbline ; $i++) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i <= $#DB::dbline) 0 0 0
if ($i <= $#DB::dbline) 0 0 0
271 0 ▶ if (defined $DB::dbline{$i}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $DB::dbline{$i}) 0 0 0
if (defined $DB::dbline{$i}) 0 0 0
272 0 clr_breaks($s, $i);
273 }
274 }
275 }
276 }
277  
278 # Set a an action
279 0 ▶sub set_action {
Subroutine set_action: not called CC=1 SCAR=6.9
Pod undocumented
280 0 ▶ my ($s, $lineno, $filename, $action, $id) = @_;
Subroutine set_action: not called CC=1 SCAR=6.9
Pod undocumented
281 0 return set_break($s, $filename, $lineno, $action, $id, 'action');
282 }
283  
284 # FIXME: combine with clear_breaks
285 0 ▶sub clr_actions {
Subroutine clr_actions: not called CC=11 SCAR=48.8
Pod undocumented
286 0 ▶ my $s = shift;
Subroutine clr_actions: not called CC=11 SCAR=48.8
Pod undocumented
287 0 my $i;
288 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (@_) { } 0 0 0
289 0 ▶ while (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 0 0 0
if (@_) 0 0 0
290 0 $i = shift;
291 0 ▶ $i = _find_subline($i) if ($i =~ /\D/);
Branch: 2 branches
BranchTrueFalseTotal
if $i =~ /\D/ 0 0 0
if $i =~ /\D/ 0 0 0
292 0 ▶ $s->output("Subroutine not found.\n") unless $i;
Branch: 2 branches
BranchTrueFalseTotal
unless $i 0 0 0
unless $i 0 0 0
293 0 ▶ if (defined $DB::dbline{$i}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $DB::dbline{$i}) 0 0 0
if (defined $DB::dbline{$i}) 0 0 0
294 0 my $brkpts = $DB::dbline{$i};
295 0 my $j = 0;
296 0 for my $brkpt (@$brkpts) {
297 0 ▶ if ($brkpt->action ne 'action') {
Branch: 2 branches
BranchTrueFalseTotal
if ($brkpt->action ne "action") 0 0 0
if ($brkpt->action ne "action") 0 0 0
298 0 $j++;
299 0 next;
300 }
301 0 undef $brkpts->[$j];
302 }
303 0 ▶ delete $DB::dbline{$i} if $j == 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j == 0 0 0 0
if $j == 0 0 0 0
304 }
305 }
306 } else {
307 0 ▶ for ($i = 1; $i <= $#DB::dbline ; $i++) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i <= $#DB::dbline) 0 0 0
if ($i <= $#DB::dbline) 0 0 0
308 0 ▶ if (defined $DB::dbline{$i}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $DB::dbline{$i}) 0 0 0
if (defined $DB::dbline{$i}) 0 0 0
309 0 clr_breaks($s, $i);
310 }
311 }
312 }
313 }
314  
315 # Demo it.
316 13 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 13 13
317 0 my $brkpt = DBBreak->new(
318 filename => __FILE__, line_num => __LINE__,
319 type=>'action', condition=>'1', id=>1, hits => 0, enbled => 1,
320 negate => 0
321 );
322 0 print $brkpt->inspect, "\n";
323 # This line is a comment for below.
324 0 $DB::filename = __FILE__;
325 0 my $filename = __FILE__;
326 0 my $msg = break_invalid(undef, \$filename, __LINE__ - 3);
327 0 print $msg, "\n";
328 }
329  
330 13 1;
« lib/Devel/Trepan/CmdProcessor/Command/Break.pm ↑ Summary blib/lib/Devel/Trepan/CmdProcessor/Command/Info_Subcmd/Breakpoints.pm »