blib/lib/Devel/Camelcadedb.pm

filter: Statementstmt 30.4% 265 / 870 Branchbran 13.4% 61 / 454 Conditioncond 8.4% 18 / 213 MC/DCmcdc 4.7% 6 / 126 Subroutinesub 33.3% 32 / 96 Podpod 0.0% 0 / 10 totaltotal 21.5% 382 / 1769 CC 317 SCAR 50.0
CC
317
Cov
22%
step_handler
756.0
_set_break_points_for_files
420.0
sub_handler
348.2
CRAP 148.5
↑ Summary
1 package Devel::Camelcadedb;
2 # must be quoted to work correctly with JSON protocol
3 1 our $VERSION = "v2026.2"; # DO NOT REMOVE FUCKING v, IT KEEPS PROPER VERSIONING
4  
5 # to ensure protocol compatibility between the IDE and the debugger, we will use $API_VERSION variable, to be able
6 # to bump debugger version without necessity to update IDE part.
7 1 my $API_VERSION = "2019.1";
8  
9 # http://perldoc.perl.org/DB.html
10 # http://perldoc.perl.org/perldebug.html
11 # http://perldoc.perl.org/perldebtut.html
12 # http://perldoc.perl.org/perldebguts.html
13 package DB;
14 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use IO::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use PadWalker qw/peek_my peek_our/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use overload;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use PerlIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Hash::StoredIterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use B qw/svref_2object SVf_IOK SVf_NOK/;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 #use Carp;
27  
28 #sub FLAG_REPORT_GOTO() {0x80;}
29  
30 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 STEP_CONTINUE => 0,
32 STEP_INTO => 1,
33 STEP_OVER => 2,
34 1 };
35  
36 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
37 # see PERLDBf_* constants in perl.h
38 1 DEBUG_ALL => 0x7ff,
39 DEBUG_SINGLE_STEP_ON => 0x20,
40 DEBUG_USE_SUB_ADDRESS => 0x40,
41 DEBUG_REPORT_GOTO => 0x80,
42 1 };
43 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
44 # debugger enabled
45 1 DEBUG_DEFAULT_FLAGS => DEBUG_ALL & ~(DEBUG_USE_SUB_ADDRESS|DEBUG_REPORT_GOTO), # 0x73f
46 # instrument code, but don't call DB::DB (see sub disable for DB::sub)
47 DEBUG_PREPARE_FLAGS => DEBUG_ALL & ~(DEBUG_USE_SUB_ADDRESS|DEBUG_REPORT_GOTO|DEBUG_SINGLE_STEP_ON), # 0x73c
48 1 };
49  
50  
51 # Each array @{"::_<$filename"} holds the lines of $filename for a file compiled by Perl. The same is also true for evaled
52 # strings that contain subroutines, or which are currently being executed. The $filename for evaled strings looks like
53 # (eval 34) .
54 # Values in this array are magical in numeric context: they compare equal to zero only if the line is not breakable.
55 #
56 # # @DB::dbline is an alias for @{"::_<current_file"} , which holds the lines of the currently-selected file (compiled by
57 # Perl), either explicitly chosen with the debugger's f command, or implicitly by flow of execution.
58 #
59 1 our @dbline = (); # list of lines in currently loaded file
60  
61 # Each hash %{"::_<$filename"} contains breakpoints and actions keyed by line number. Individual entries (as opposed to
62 # the whole hash) are settable. Perl only cares about Boolean true here, although the values used by perl5db.pl have the
63 # form "$break_condition\0$action" .
64 #
65 # The same holds for evaluated strings that contain subroutines, or which are currently being executed. The $filename
66 # for evaled strings looks like (eval 34) .
67 #
68 # %DB::dbline is an alias for %{"::_<current_file"} , which contains breakpoints and actions keyed by line number in
69 # the currently-selected file, either explicitly chosen with the debugger's f command, or implicitly by flow of execution.
70 # As previously noted, individual entries (as opposed to the whole hash) are settable. Perl only cares about Boolean
71 # true here, although the values used by perl5db.pl have the form "$break_condition\0$action" .
72 #
73 # Actions in current file (keys are line numbers). The values are strings that have the sprintf(3) format
74 # ("%s\000%s", breakcondition, actioncode) .
75 1 our %dbline = (); # actions in current file (keyed by line number)
76  
77 # Each scalar ${"::_<$filename"} contains "::_<$filename" . This is also the case for evaluated strings that contain
78 # subroutines, or which are currently being executed. The $filename for evaled strings looks like (eval 34) .
79 #
80 1 our $dbline;
81  
82 # DB::dump_trace(skip[,count]) skips the specified number of frames and returns a list containing information about the
83 # calling frames (all of them, if count is missing). Each entry is reference to a hash with keys context (either ., $ ,
84 # or @ ), sub (subroutine name, or info about eval), args (undef or a reference to an array), file , and line .
85 #
86  
87 # these are hardcoded in perl source (some are magical)
88  
89 # When execution of the program reaches a subroutine call, a call to &DB::sub (args) is made instead, with $DB::sub
90 # holding the name of the called subroutine. (This doesn't happen if the subroutine was compiled in the DB package.)
91 1 our $sub = ''; # Name of current executing subroutine.
92  
93 # A hash %DB::sub is maintained, whose keys are subroutine names and whose values have the form
94 # filename:startline-endline . filename has the form (eval 34) for subroutines defined inside evals.
95 #
96 # The keys of this hash are the names of all the known subroutines. Each value is an encoded string that has the
97 # sprintf(3) format ("%s:%d-%d", filename, fromline, toline) .
98 1 our %sub = (); # "filename:fromline-toline" for every known sub
99  
100 # If you set $DB::single to 2, it's equivalent to having just typed the step over command, whereas a value of 1
101 # means the step into command.
102 1 our $single = 0; # single-step flag (set it to 1 to enable stops in BEGIN/use) 1 -into, 2 - over
103  
104 # Signal flag. Will be set to a true value if a signal was caught. Clients may check for this flag to abort
105 # time-consuming operations.
106 1 our $signal = 0;
107  
108 # The $DB::trace variable should be set to 1 to simulate having typed the t command.
109 # This flag is set to true if the API is tracing through subroutine calls.
110 1 our $trace = 0; # are we tracing through subroutine calls?
111  
112 # For example, whenever you call Perl's built-in caller function from the package DB , the arguments that the
113 # corresponding stack frame was called with are copied to the @DB::args array. These mechanisms are enabled by calling
114 # Perl with the -d switch. Specifically, the following additional features are enabled (cf. $^P in perlvar):
115 1 our @args = (); # arguments of current subroutine or @ARGV array
116  
117 1 our @ret = (); # return value of last sub executed in list context
118 1 our $ret = ''; # return value of last sub executed in scalar context
119  
120 # custom values renderers. Consists of two items arrayrefs, with class as a first field, and code text as second field
121 # every blessed item is checked with this list and if it matches with some renderer - it is used as value in ide.
122 # e.g. ['Foo::Bar', '$it->as_string`] meaning that any 'Foo::Bar' object will be represented with as_string value
123 1 my @renderers = ();
124  
125 1 my %_perl_file_id_to_path_map = (); # map of perl file ids without _< => real path detected on loading
126 1 my %_paths_to_perl_file_id_map = (); # maps real paths to _<filename
127  
128 1 my %_loaded_breakpoints = (); # map of loaded breakpoints, set and not in form: path => line => object
129 1 my %_queued_breakpoints_files = (); # map of files with loaded and not set breakpoints
130 1 my %_references_cache = (); # cache of soft references from peek_my
131  
132 1 my %_source_been_sent = (); # flags that source been sent
133 1 my %_file_name_sent = (); # flags that idea been notfied about this file loading
134 1 my %_evals_to_templates_map = (); # map of evals to templates or something (see template_handler). Structure: eval => target file
135 1 my %_templates_to_evals_map = (); # map of templates to evals or something (see template_handler). Structure: template => [eval1, eval2, ...]
136  
137 1 my @glob_slots = qw/SCALAR ARRAY HASH CODE IO FORMAT/;
138 1 my $glob_slots = join '|', @glob_slots;
139  
140 1 my $_dev_mode = $ENV{CAMELCADEDB_DEV_MODE}; # enable this to get verbose STDERR output from process
141 1 my $_debug_log_fh = *STDERR; # debug log fh. If omited, file will be created
142 1 my $_debug_log_filename = 'current_debug.log';
143 1 my $_debug_sub_handler = 1; # debug entering/leaving subs, works in dev mode
144 1 my $_debug_load_handler = 0; # debug modules loading
145 1 my $_debug_breakpoints = 0; # debug breakpoints setting
146  
147 1 my $_script_charset = 'utf8'; # all sources and strings without utf flag will be encoded from this encoding to the utf
148  
149 1 my $_skip_run_stop = 0; # flag for skipping forced stop on run phase
150  
151 # this enables pausing and breakpoints setting while script is running, gives moderate overhead
152 1 my $_enable_noninteractive_mode = 0;
153  
154 # this enables attemp to set a breakpoint on each leaving/entering sub, gives large overhead, proportional number of breakpoints
155 1 my $_enable_compile_time_breakpoints = 0;
156  
157 1 my $_debug_socket;
158 my $_debug_packed_address;
159 1 my IO::Select $_debug_socket_select;
160  
161 1 my $coder; # JSON::XS coder
162 1 my $deparser; # B::Deparse deparser
163  
164 1 my $frame_prefix_step = " ";
165 1 my $frame_prefix = '';
166  
167 1 my $_internal_process = 0;
168  
169 1 my @saved; # saved runtime environment
170  
171 my $current_package;
172 1 my $current_file_id;
173 1 my $current_line;
174  
175 1 my $trace_code_stack_and_frames = 0; # report traces on entering code
176 1 my $trace_real_path = 0; # trasing real path transition
177  
178 1 my $ready_to_go = 0; # set after debugger been initialized
179  
180 1 my $_stack_frames = [ ]; # stack frames
181  
182 sub _report($;@)
183 0 ▶{
Subroutine _report: not called CC=5 SCAR=34.0
184 0 ▶ return unless $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
unless $_dev_mode 0 0 0
185 0 my ($message, @sprintf_args) = @_;
186 0 chomp $message;
187  
188 0 ▶ unless ($_debug_log_fh)
Branch: 1 branch
BranchTrueFalseTotal
unless ($_debug_log_fh) 0 0 0
189 {
190 0 ▶ open $_debug_log_fh, ">", $_debug_log_filename or die "Unable to open debug log $_debug_log_filename $!";
Branch: 1 branch
BranchTrueFalseTotal
open $_debug_log_fh, ">", $_debug_log_filename or die "Unable to open debug log $_debug_log_filename $!" 0 0 0
191 0 $_debug_log_fh->autoflush( 1 );
192 }
193  
194 0 ▶ printf $_debug_log_fh "$frame_prefix$message\n", map {$_ // 'undef'} @sprintf_args;
Condition0%0/2
$_ // "undef"
l!l
00
MC/DC0%0/1
$_ // "undef"
$_
Truth table0%0/2
A
A= $_
Aresult
11
00
195 }
196  
197 sub _format_caller
198 0 ▶{
Subroutine _format_caller: not called CC=8 SCAR=42.8
199 0 my (@caller) = @_;
200 0 ▶ return sprintf "%s %s%s%s from %s::, %s line %s; %s %s %s %s",
Branch: 5 branches
BranchTrueFalseTotal
defined $caller[5] ? : 0 0 0
$caller[5] ? : 0 0 0
$caller[4] ? : 0 0 0
$caller[7] ? : 0 0 0
$caller[7] ? : 0 0 0
Condition0%0/4
$_ // "undef"
l!l
00
$caller[6] // ""
l!l
00
MC/DC0%0/1
$_ // "undef"
$_
MC/DC0%0/1
$caller[6] // ""
$caller[6]
Truth table0%0/2
A
A= $_
Aresult
11
00
Truth table0%0/2
A
A= $caller[6]
Aresult
11
00
201 map $_ // 'undef',
202 defined $caller[5] ? $caller[5] ? 'array' : 'scalar' : 'void', # wantarray
203 $caller[3], # target sub
204 $caller[4] ? '(@_)' : '', # has args
205 $caller[7] ? ' [require '.$caller[6].']' : '', # is_require and evaltext
206 $caller[0], # package
207 $caller[1], # filename
208 $caller[2], # line
209 $caller[7] ? '' : $caller[6] // '', # evaltext if no isrequire
210 $caller[8], # strcit
211 $caller[9], # warnings
212 $caller[10], # hinthash
213 ;
214 }
215  
216 sub _get_loaded_files_map
217 0 ▶{
Subroutine _get_loaded_files_map: not called CC=5 SCAR=34.0
218 0 my %result = ();
219 0 foreach my $key (keys %::)
220 {
221 0 my $glob = $::{$key};
222 0 ▶ next unless $key =~ s/^_<//;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ s/^_<// 0 0 0
223 0 ▶ next unless *$glob{ARRAY} && scalar @{*$glob{ARRAY}};
Branch: 1 branch
BranchTrueFalseTotal
unless *$glob{"ARRAY"} and scalar @{*$glob{"ARRAY"};} 0 0 0
Condition0%0/2
*$glob{"ARRAY"} and scalar @{*$glob{"ARRAY"};}
!ll
00
MC/DC0%0/1
*$glob{"ARRAY"} and scalar @{*$glob{"ARRAY"};}
*$glob{"ARRAY"}
Truth table0%0/2
A
A= *$glob{"ARRAY"}
Aresult
00
11
224 0 $result{$key} = ${*$glob};
225 }
226 0 return \%result;
227 }
228  
229 sub _get_file_descriptor_by_id
230 0 ▶{
Subroutine _get_file_descriptor_by_id: not called CC=4 SCAR=30.0
231 0 my ($file_id) = @_;
232  
233 0 my $real_path = _get_real_path_by_normalized_perl_file_id( $file_id );
234 0 my $presentable_name;
235  
236 0 ▶ if ($real_path =~ /^\(eval \d+\)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($real_path =~ /^\(eval \d+\)/) 0 0 0
237 {
238 0 my $eval_map_entry = $_evals_to_templates_map{$real_path};
239 0 ▶ if ($eval_map_entry && $eval_map_entry->{path})
Branch: 1 branch
BranchTrueFalseTotal
if ($eval_map_entry and $eval_map_entry->{"path"}) 0 0 0
Condition0%0/3
$eval_map_entry and $eval_map_entry->{"path"}
!ll&&!rl&&r
000
MC/DC0%0/2
$eval_map_entry and $eval_map_entry->{"path"}
$eval_map_entry $eval_map_entry->{"path"}
Truth table0%0/3
A and B
A= $eval_map_entryB= $eval_map_entry->{"path"}
ABresult
0X0
100
111
240 {
241 0 $presentable_name = $eval_map_entry->{path};
242 }
243 # else
244 # {
245 # $presentable_name = $real_path;
246 # $presentable_name =~ s/^(\(eval \d+\)).+$/$1/;
247 # }
248 }
249  
250 return {
251 0 path => $real_path,
252 name => $presentable_name,
253 };
254 }
255  
256 sub _send_loaded_files_names
257 0 ▶{
Subroutine _send_loaded_files_names: not called CC=7 SCAR=40.3
258 0 my $loaded_files_map = _get_loaded_files_map();
259 0 my @files_to_add = ();
260 0 my @files_to_remove = ();
261  
262 0 foreach my $file_id (keys %$loaded_files_map)
263 {
264 0 ▶ next if index( $file_id, 'Camelcadedb.pm' ) != -1 || exists $_file_name_sent{$file_id};
Branch: 1 branch
BranchTrueFalseTotal
if index($file_id, "Camelcadedb.pm") != -1 or exists $_file_name_sent{$file_id} 0 0 0
Condition0%0/3
index($file_id, "Camelcadedb.pm") != -1 or exists $_file_name_sent{$file_id}
l!l&&r!l&&!r
000
MC/DC0%0/2
index($file_id, "Camelcadedb.pm") != -1 or exists $_file_name_sent{$file_id}
index($file_id, "Camelcadedb.pm") != -1 exists $_file_name_sent{$file_id}
Truth table0%0/3
A or B
A= index($file_id, "Camelcadedb.pm") != -1B= exists $_file_name_sent{$file_id}
ABresult
1X1
011
000
265 0 $_file_name_sent{$file_id} = 1;
266 0 push @files_to_add, _get_file_descriptor_by_id( $file_id );
267 }
268  
269 0 foreach my $file_id (keys %_file_name_sent)
270 {
271 0 ▶ next if exists $loaded_files_map->{$file_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $loaded_files_map->{$file_id} 0 0 0
272 0 delete $_file_name_sent{$file_id};
273 0 push @files_to_remove, _get_file_descriptor_by_id( $file_id );
274 }
275  
276 0 ▶ if (scalar @files_to_add + scalar @files_to_remove)
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @files_to_add + scalar(@files_to_remove)) 0 0 0
277 {
278 0 _send_event( "LOADED_FILES_DELTA", {
279 add => \@files_to_add,
280 remove => \@files_to_remove
281 } );
282 }
283 }
284  
285  
286 sub _send_breakpoint_reached_event
287 0 ▶{
Subroutine _send_breakpoint_reached_event: not called CC=2 SCAR=17.9
288 0 my ($breakpoint) = @_;
289  
290 my $event_data = {
291 path => $breakpoint->{path},
292 line => $breakpoint->{line} - 1,
293 logmessage => $breakpoint->{action_result},
294 0 };
295  
296 0 ▶ if ($breakpoint->{suspend})
Branch: 1 branch
BranchTrueFalseTotal
if ($breakpoint->{'suspend'}) { } 0 0 0
297 {
298 0 $event_data->{suspend} = \1;
299 0 $event_data->{frames} = _calc_stack_frames();
300 }
301 else
302 {
303 0 $event_data->{suspend} = \0;
304 0 $event_data->{frames} = [ ];
305 }
306  
307 0 _send_event( 'BREAKPOINT_REACHED', $event_data );
308 }
309  
310 sub _send_event
311 0 ▶{
Subroutine _send_event: not called CC=1 SCAR=6.9
312 0 my ($name, $data) = @_;
313  
314 0 _send_data_to_debugger( +{
315 event => $name,
316 data => $data
317 } );
318 }
319  
320 sub _dump_stack
321 0 ▶{
Subroutine _dump_stack: not called CC=4 SCAR=30.0
322 0 my $depth = 0;
323 0 ▶ _report "Stack trace:\n" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
324 0 while()
325 {
326 0 my @caller = caller( $depth );
327 0 ▶ last unless defined $caller[2];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $caller[2] 0 0 0
328 0 ▶ _report $frame_prefix_step."%s: %s\n", $depth++, _format_caller( @caller ) if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
329 }
330 0 1;
331 }
332  
333 sub _dump_frames
334 0 ▶{
Subroutine _dump_frames: not called CC=6 SCAR=37.4
335 0 my $depth = 0;
336 0 ▶ _report "Frames trace:\n" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
337 0 foreach my $frame (@$_stack_frames)
338 {
339 _report $frame_prefix_step."%s: %s\n", $depth++,
340 join ', ', map $_ // 'undef', @$frame{qw/subname file current_line single/},
341 0 ▶ $frame->{is_use_block} ? '(use block)' : ''
Branch: 2 branches
BranchTrueFalseTotal
if $_dev_mode 0 0 0
$frame->{'is_use_block'} ? : 0 0 0
Condition0%0/2
$_ // "undef"
l!l
00
MC/DC0%0/1
$_ // "undef"
$_
Truth table0%0/2
A
A= $_
Aresult
11
00
342 if $_dev_mode;
343 }
344 0 1;
345 }
346  
347 sub _deparse_code
348 0 ▶{
Subroutine _deparse_code: not called CC=2 SCAR=17.9
349 0 my ($code) = @_;
350 0 ▶ $deparser ||= B::Deparse->new();
Condition0%0/3
$deparser ||= "B::Deparse"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$deparser ||= "B::Deparse"->new
$deparser "B::Deparse"->new
Truth table0%0/3
A ||= B
A= $deparserB= "B::Deparse"->new
ABresult
1X1
011
000
351 0 return $deparser->coderef2text( $code );
352 }
353  
354 sub _send_transaction_response
355 0 ▶{
Subroutine _send_transaction_response: not called CC=1 SCAR=6.9
356 0 my ($transaction_id, $data) = @_;
357  
358 0 _send_data_to_debugger( +{
359 event => 'RESPONSE',
360 transactionId => $transaction_id,
361 data => $data,
362 }
363 );
364 }
365  
366 sub _get_file_source_by_file_id
367 0 ▶{
Subroutine _get_file_source_by_file_id: not called CC=2 SCAR=13.4
368 0 my ($file_id) = @_;
369 0 $_source_been_sent{$file_id} = 1;
370 {
371 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
372 0 ▶ _report "Getting source of main::_<$file_id" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
373 0 my @lines = @{"main::_<$file_id"};
374 0 shift @lines;
375 0 return _to_utf8( join '', @lines );
376 }
377 }
378  
379 sub _get_file_source_once_by_file_id
380 0 ▶{
Subroutine _get_file_source_once_by_file_id: not called CC=2 SCAR=17.9
381 0 my ($file_id) = @_;
382 0 ▶ return if $_source_been_sent{$file_id};
Branch: 1 branch
BranchTrueFalseTotal
if $_source_been_sent{$file_id} 0 0 0
383 0 return _get_file_source_by_file_id( $file_id );
384 }
385  
386 sub _get_file_source_handler
387 0 ▶{
Subroutine _get_file_source_handler: not called CC=3 SCAR=24.8
388 0 my ($request_serialized_object) = @_;
389 0 my $transaction_wrapper = _deserialize( $request_serialized_object );
390 0 my ($transaction_id, $request_object) = @$transaction_wrapper{qw/id data/};
391  
392 0 my $file_id = _get_perl_file_id_by_real_path( $request_object->{path} );
393  
394 0 ▶ _report "Fetching source for $file_id $request_object->{path}" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
395  
396 0 ▶ _send_transaction_response(
Condition0%0/2
_get_file_source_once_by_file_id($file_id) // '# No source found for ' . $file_id
l!l
00
MC/DC0%0/1
_get_file_source_once_by_file_id($file_id) // '# No source found for ' . $file_id
_get_file_source_once_by_file_id($file_id)
Truth table0%0/2
A
A= _get_file_source_once_by_file_id($file_id)
Aresult
11
00
397 $transaction_id,
398 _get_file_source_once_by_file_id( $file_id ) // '# No source found for '.$file_id
399 );
400 }
401  
402 2 ▶sub _compute_reference_subelements {
Subroutine _compute_reference_subelements: called CC=21 SCAR=47.9
403 2 my $request_object = shift;
404  
405 2 my ($offset, $size, $key) = @$request_object{qw/offset limit key/};
406 2 my $data = [];
407  
408 2 my $source_data;
409  
410 2 ▶ if ($key =~ /^\*(.+?)(?:\{($glob_slots)\})?$/) # hack for globs by names
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^\*(.+?)(?:\{($glob_slots)\})?$/) { } 0 2 2
411 {
412 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
413 0 my ($name, $slot) = ($1, $2);
414  
415 0 ▶ if ($slot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($slot) { } 0 0 0
416 0 $source_data = *{$name}{$slot};
417 }
418 else {
419 0 $source_data = \*{$name};
420 }
421  
422 0 ▶ _report "Got glob ref $key => $source_data" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
423 }
424 else {
425 2 $source_data = $_references_cache{$key};
426 }
427 2 ▶ if ($source_data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source_data) { } 2 0 2
428 2 my $reftype = Scalar::Util::reftype($source_data);
429  
430 2 ▶ if ($reftype eq 'ARRAY' && $#$source_data >= $offset) {
Branch: 4 branches
BranchTrueFalseTotal
if ($reftype eq 'ARRAY' and $source_data->$#* >= $offset) { } 0 2 2
elsif ($reftype eq 'HASH') { } 2 0 2
elsif ($reftype eq 'REF') { } 0 0 0
elsif ($reftype eq 'GLOB') { } 0 0 0
Condition33%1/3
$reftype eq "ARRAY" and $source_data->$#* >= $offset
!ll&&!rl&&r
200
MC/DC0%0/2
$reftype eq "ARRAY" and $source_data->$#* >= $offset
$reftype eq "ARRAY" $source_data->$#* >= $offset
Truth table33%1/3
A and B
A= $reftype eq "ARRAY"B= $source_data->$#* >= $offset
ABresult
0X0
100
111
431 0 my $last_index = $offset + $size;
432  
433 0 ▶ for (my $item_number = $offset; $item_number < $last_index && $item_number < @$source_data; $item_number++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item_number < $last_index and $item_number < @$source_data) 0 0 0
Condition0%0/3
$item_number < $last_index and $item_number < @$source_data
!ll&&!rl&&r
000
MC/DC0%0/2
$item_number < $last_index and $item_number < @$source_data
$item_number < $last_index $item_number < @$source_data
Truth table0%0/3
A and B
A= $item_number < $last_indexB= $item_number < @$source_data
ABresult
0X0
100
111
434 0 push @$data, _get_reference_descriptor("[$item_number]", \$source_data->[$item_number]);
435 }
436 }
437 elsif ($reftype eq 'HASH') {
438 2 my $hash_iterator = Hash::StoredIterator::hash_get_iterator($source_data);
439 2 my @keys = sort keys %$source_data;
440 2 Hash::StoredIterator::hash_set_iterator($source_data, $hash_iterator);
441  
442 2 ▶ if ($#keys >= $offset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#keys >= $offset) 2 0 2
443 2 my $last_index = $offset + $size;
444  
445 2 ▶ for (my $item_number = $offset; $item_number < $last_index && $item_number < @keys; $item_number++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item_number < $last_index and $item_number < @keys) 13 2 15
Condition66%2/3
$item_number < $last_index and $item_number < @keys
!ll&&!rl&&r
0213
MC/DC50%1/2
$item_number < $last_index and $item_number < @keys
$item_number < $last_index $item_number < @keys
Truth table66%2/3
A and B
A= $item_number < $last_indexB= $item_number < @keys
ABresult
0X0
100
111
446 13 my $hash_key = $keys[$item_number];
447 13 push @$data, _get_reference_descriptor("'$hash_key'", \$source_data->{$hash_key});
448 }
449 }
450 }
451 elsif ($reftype eq 'REF') {
452 0 push @$data, _get_reference_descriptor($source_data, $$source_data);
453 }
454 elsif ($reftype eq 'GLOB') {
455 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
456  
457 0 foreach my $glob_slot (@glob_slots) {
458 0 my $reference = *$source_data{$glob_slot};
459 0 ▶ next unless $reference;
Branch: 1 branch
BranchTrueFalseTotal
unless $reference 0 0 0
460 0 my $desciptor = _get_reference_descriptor($glob_slot, \$reference);
461  
462 # hack for DB namespace, see https://github.com/hurricup/Perl5-IDEA/issues/1151
463 0 ▶ if ($glob_slot eq 'HASH' && $key =~ /^\*(::)*(main::)*(::)*DB(::)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($glob_slot eq "HASH" and $key =~ /^\*(::)*(main::)*(::)*DB(::)?$/) 0 0 0
Condition0%0/3
$glob_slot eq "HASH" and $key =~ /^\*(::)*(main::)*(::)*DB(::)?$/
!ll&&!rl&&r
000
MC/DC0%0/2
$glob_slot eq "HASH" and $key =~ /^\*(::)*(main::)*(::)*DB(::)?$/
$glob_slot eq "HASH" $key =~ /^\*(::)*(main::)*(::)*DB(::)?$/
Truth table0%0/3
A and B
A= $glob_slot eq "HASH"B= $key =~ /^\*(::)*(main::)*(::)*DB(::)?$/
ABresult
0X0
100
111
464 0 $desciptor->{expandable} = \0;
465 0 $desciptor->{size} = 0;
466 }
467  
468 0 push @$data, $desciptor;
469 }
470  
471 }
472 else {
473 0 ▶ _report "Dont know how to iterate $reftype" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
474 }
475  
476 }
477 else {
478 0 ▶ _report "No source data for $key\n" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
479 }
480 2 return $data;
481 }
482  
483 sub _get_reference_subelements
484 0 ▶{
Subroutine _get_reference_subelements: not called CC=1 SCAR=6.9
485 0 my ($request_serialized_object) = @_;
486 0 my $transaction_wrapper = _deserialize( $request_serialized_object );
487 0 my ($transaction_id, $request_object) = @$transaction_wrapper{qw/id data/};
488 0 _send_transaction_response($transaction_id, _compute_reference_subelements($request_object));
489 }
490  
491 sub _format_variables_hash
492 1 ▶{
Subroutine _format_variables_hash: called CC=2 SCAR=6.9
493 1 my ($vars_hash) = @_;
494  
495 1 my $result = [ ];
496  
497 1 foreach my $variable (sort keys %$vars_hash)
498 {
499 8 my $value = $vars_hash->{$variable};
500 8 push @$result, _get_reference_descriptor( $variable, $value );
501 }
502  
503 1 return $result;
504 }
505  
506 sub _to_utf8
507 58 ▶{
Subroutine _to_utf8: called CC=4 SCAR=14.0
508 58 my ($value) = @_;
509  
510 58 ▶ return $value unless $value;
Branch: 1 branch
BranchTrueFalseTotal
unless $value 2 56 58
511  
512 56 ▶ if (utf8::is_utf8( $value )) # if values is marked as utf8
Branch: 2 branches
BranchTrueFalseTotal
if (utf8::is_utf8($value)) { } 9 47 56
elsif ($value =~ /[\x80-\xFF]/) { } 0 47 47
513 {
514 9 utf8::encode( $value ); # we just making octets from it
515 }
516 elsif ($value =~ /[\x80-\xFF]/) # otherwise, if we've got non-ascii symbols, we suppose it's in configured encoding
517 {
518 0 Encode::from_to( $value, $_script_charset, 'utf8' );
519 }
520  
521 56 return $value;
522 }
523  
524 sub _from_utf8
525 0 ▶{
Subroutine _from_utf8: not called CC=3 SCAR=24.8
526 0 my ($value) = @_;
527  
528 0 ▶ return $value unless $value;
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 0 0
529  
530 0 ▶ if ($_script_charset ne 'utf8') # if script uses non-utf encoding, just encode data to the script encoding
Branch: 1 branch
BranchTrueFalseTotal
if ($_script_charset ne 'utf8') { } 0 0 0
531 {
532 0 Encode::from_to( $value, 'utf8', $_script_charset );
533 }
534 else # otherwise, decode octets to characters
535 {
536 0 utf8::decode( $value );
537 }
538  
539 0 return $value;
540 }
541  
542 # Returns true if the scalar behind the given reference holds a number rather than a string.
543 # We rely on the SV's IOK/NOK flags (the same ones Devel::Peek reports) instead of the stringified
544 # content: a value is a string only when it is POK without any numeric flag. This mirrors the runtime
545 # semantics that distinguish e.g. string vs numeric bitwise `&` (see Camelcade/Perl5-IDEA#3198).
546 sub _is_numeric_scalar
547 18 ▶{
Subroutine _is_numeric_scalar: called CC=1 SCAR=0.0
548 18 my ($scalar_ref) = @_;
549 18 return svref_2object( $scalar_ref )->FLAGS & (SVf_IOK | SVf_NOK);
550 }
551  
552 sub _get_reference_descriptor
553 29 ▶{
Subroutine _get_reference_descriptor: called CC=37 SCAR=41.6
554 29 my ($name, $value) = @_;
555  
556 29 my $key = $value;
557 29 my $reftype = Scalar::Util::reftype( $value );
558 29 my $ref = ref $value;
559  
560 29 my $size = 0;
561 29 my $type = overload::StrVal( $value );
562  
563 29 my $expandable = \0;
564 29 ▶ my $is_blessed = $ref && Scalar::Util::blessed( $value ) ? \1 : \0;
Branch: 1 branch
BranchTrueFalseTotal
$ref && builtin::blessed($value) ? : 1 28 29
Condition100%3/3
$ref and builtin::blessed($value)
!ll&&!rl&&r
5231
MC/DC100%2/2
$ref and builtin::blessed($value)
$ref builtin::blessed($value)
Truth table100%3/3
A and B
A= $refB= builtin::blessed($value)
ABresult
0X0
100
111
565 29 my $ref_depth = 0;
566 29 my $is_utf = \0;
567 29 my $layers = undef;
568 29 my $fileno = undef;
569 29 my $rendered = undef;
570 29 my $rendered_error = \0;
571 29 my $tied;
572  
573 29 ▶ if (!$reftype)
Branch: 6 branches
BranchTrueFalseTotal
if (not $reftype) { } 5 24 29
elsif ($reftype eq 'SCALAR') { } 15 9 24
elsif ($reftype eq 'REF') { } 5 4 9
elsif ($reftype eq 'ARRAY') { } 1 3 4
elsif ($reftype eq 'HASH') { } 3 0 3
elsif ($reftype eq 'GLOB') { } 0 0 0
574 {
575 5 $type = "SCALAR";
576 5 $tied = tied $value;
577 5 ▶ $is_utf = defined $value && utf8::is_utf8( $value ) ? \1 : \0;
Branch: 1 branch
BranchTrueFalseTotal
defined $value && utf8::is_utf8($value) ? : 0 5 5
Condition66%2/3
defined $value and utf8::is_utf8($value)
!ll&&!rl&&r
140
MC/DC0%0/2
defined $value and utf8::is_utf8($value)
defined $value utf8::is_utf8($value)
Truth table66%2/3
A and B
A= defined $valueB= utf8::is_utf8($value)
ABresult
0X0
100
111
578 5 ▶ $value = !defined $value ? 'undef'
Branch: 2 branches
BranchTrueFalseTotal
!defined($value) ? : 1 4 5
_is_numeric_scalar(\$value) ? : 2 2 4
579 : _is_numeric_scalar( \$value ) ? "$value"
580 : "\"$value\""; #_escape_scalar(
581 5 ▶ $key //= 'undef';
Condition100%2/2
$key //= "undef"
l!l
41
MC/DC100%1/1
$key //= "undef"
$key
Truth table100%2/2
A
A= $key
Aresult
11
00
582 }
583 elsif ($reftype eq 'SCALAR')
584 {
585 15 $tied = tied $$value;
586 15 ▶ $is_utf = defined $$value && utf8::is_utf8( $$value ) ? \1 : \0;
Branch: 1 branch
BranchTrueFalseTotal
defined $$value && utf8::is_utf8($$value) ? : 1 14 15
Condition100%3/3
defined $$value and utf8::is_utf8($$value)
!ll&&!rl&&r
1131
MC/DC100%2/2
defined $$value and utf8::is_utf8($$value)
defined $$value utf8::is_utf8($$value)
Truth table100%3/3
A and B
A= defined $$valueB= utf8::is_utf8($$value)
ABresult
0X0
100
111
587 15 ▶ $value = !defined $$value ? 'undef'
Branch: 2 branches
BranchTrueFalseTotal
!defined($$value) ? : 1 14 15
_is_numeric_scalar($value) ? : 10 4 14
588 : _is_numeric_scalar( $value ) ? "$$value"
589 : "\"$$value\""; #_escape_scalar(
590 }
591 elsif ($reftype eq 'REF') {
592 5 ▶ $type = overload::StrVal($$value) || 'unknown';
Condition50%1/2
overload::StrVal($$value) || 'unknown'
l!l
50
MC/DC0%0/1
overload::StrVal($$value) || 'unknown'
overload::StrVal($$value)
Truth table50%1/2
A
A= overload::StrVal($$value)
Aresult
11
00
593 5 $tied = tied $value;
594 5 $size = 1;
595 5 $expandable = \1;
596 5 $ref_depth = 1;
597 5 $ref = undef; # to prevent rendering data
598 }
599 elsif ($reftype eq 'ARRAY')
600 {
601 1 $size = scalar @$value;
602 1 $tied = tied @$value;
603 1 $value = sprintf "size = %s", $size;
604 1 ▶ $expandable = $size ? \1 : \0;
Branch: 1 branch
BranchTrueFalseTotal
$size ? : 1 0 1
605 }
606 elsif ($reftype eq 'HASH')
607 {
608 3 $tied = tied %$value;
609 3 my $hash_iterator = Hash::StoredIterator::hash_get_iterator( $value );
610 3 $size = scalar keys %$value;
611 3 Hash::StoredIterator::hash_set_iterator( $value, $hash_iterator );
612  
613 3 $value = sprintf "size = %s", $size;
614 3 ▶ $expandable = $size ? \1 : \0;
Branch: 1 branch
BranchTrueFalseTotal
$size ? : 3 0 3
615 }
616 elsif ($reftype eq 'GLOB')
617 {
618 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
619 0 $tied = tied *$value;
620 0 $size = scalar grep *$value{$_}, @glob_slots;
621 0 $value = "*".*$value{PACKAGE}."::".*$value{NAME};
622 0 $layers = _get_layers($key);
623 0 $fileno = fileno($key);
624 0 ▶ $expandable = $size ? \1 : \0;
Branch: 1 branch
BranchTrueFalseTotal
$size ? : 0 0 0
625 }
626  
627 29 my $char_code;
628 29 my $stringified_key = "$key";
629 29 $stringified_key =~ s{(.)}{
630 532 $char_code = ord( $1 );
631 532 ▶ $char_code < 32 ? '^'.chr( $char_code + 0x40 ) : $1
Branch: 1 branch
BranchTrueFalseTotal
$char_code < 32 ? : 0 532 532
632 }gsex;
633  
634 29 ▶ if ($reftype)
Branch: 1 branch
BranchTrueFalseTotal
if ($reftype) 24 5 29
635 {
636 24 $_references_cache{$stringified_key} = $key;
637 }
638  
639 29 ▶ if ($ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref) 19 10 29
640 19 my $got_renderer = 0;
641 19 for my $renderer (@renderers) {
642 0 ▶ if (UNIVERSAL::isa($key, $renderer->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($key, $renderer->[0])) 0 0 0
643 0 $got_renderer = 1;
644 0 $DB::Sandbox::it = $key;
645 0 $rendered = eval 'package DB::Sandbox;our $it;' . $renderer->[1];
646 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
647 0 $rendered = $@;
648 0 $rendered_error = \1;
649 }
650 0 last;
651 }
652 }
653 19 ▶ unless ($got_renderer) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($got_renderer) 19 0 19
654 19 $rendered = "$key";
655 19 ▶ if ($rendered eq $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rendered eq $type) 19 0 19
656 19 $rendered = undef;
657 }
658 }
659 }
660  
661 29 $name = "$name";
662 29 $value = "$value";
663  
664 29 $name =~ s{(.)}{
665 319 $char_code = ord( $1 );
666 319 ▶ $char_code < 32 ? '^'.chr( $char_code + 0x40 ) : $1
Branch: 1 branch
BranchTrueFalseTotal
$char_code < 32 ? : 0 319 319
667 }gsex;
668 29 $value =~ s{([^\n\r\f\t])}{
669 195 $char_code = ord($1);
670 195 ▶ $char_code < 32 ? '^' . chr($char_code + 0x40) : $1
Branch: 1 branch
BranchTrueFalseTotal
$char_code < 32 ? : 0 195 195
671 }gsex;
672  
673 # handling encoding
674  
675 29 my $result = {
676 name => _to_utf8("$name"),
677 value => _to_utf8("$value"),
678 type => "$type",
679 expandable => $expandable,
680 key => $stringified_key,
681 size => $size,
682 blessed => $is_blessed,
683 ref_depth => $ref_depth,
684 is_utf => $is_utf
685 };
686  
687 29 ▶ if (defined $rendered) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rendered) 0 29 29
688 0 $rendered =~ s{([^\n\r\f\t])}{
689 0 $char_code = ord($1);
690 0 ▶ $char_code < 32 ? '^' . chr($char_code + 0x40) : $1
Branch: 1 branch
BranchTrueFalseTotal
$char_code < 32 ? : 0 0 0
691 }gsex;
692  
693 0 $result->{rendered} = _to_utf8($rendered);
694 0 $result->{rendered_error} = $rendered_error;
695 }
696 29 ▶ $result->{layers} = $layers if $layers;
Branch: 1 branch
BranchTrueFalseTotal
if $layers 0 29 29
697 29 ▶ $result->{fileno} = "".$fileno if defined $fileno;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fileno 0 29 29
698 29 ▶ $result->{tied_with} = _get_reference_descriptor(object => $tied) if $tied;
Branch: 1 branch
BranchTrueFalseTotal
if $tied 0 29 29
699  
700 29 return $result;
701 }
702  
703 0 ▶sub _get_layers{
Subroutine _get_layers: not called CC=6 SCAR=37.4
704 0 my $glob = shift;
705  
706 0 my %result = ();
707 0 my $input_layers = _pack_layers(PerlIO::get_layers($glob, details => 1));
708 0 ▶ $result{input} = $input_layers if $input_layers && @$input_layers;
Branch: 1 branch
BranchTrueFalseTotal
if $input_layers and @$input_layers 0 0 0
Condition0%0/3
$input_layers and @$input_layers
!ll&&!rl&&r
000
MC/DC0%0/2
$input_layers and @$input_layers
$input_layers @$input_layers
Truth table0%0/3
A and B
A= $input_layersB= @$input_layers
ABresult
0X0
100
111
709  
710 0 my $output_layers = _pack_layers(PerlIO::get_layers($glob, details => 1, output=>1));
711 0 ▶ $result{output} = $output_layers if $output_layers && @$output_layers;
Branch: 1 branch
BranchTrueFalseTotal
if $output_layers and @$output_layers 0 0 0
Condition0%0/3
$output_layers and @$output_layers
!ll&&!rl&&r
000
MC/DC0%0/2
$output_layers and @$output_layers
$output_layers @$output_layers
Truth table0%0/3
A and B
A= $output_layersB= @$output_layers
ABresult
0X0
100
111
712  
713 0 ▶ return scalar keys %result ? \%result: undef;
Branch: 1 branch
BranchTrueFalseTotal
scalar keys %result ? : 0 0 0
714 }
715  
716 0 ▶sub _pack_layers{
Subroutine _pack_layers: not called CC=2 SCAR=17.9
717 0 my @result = ();
718 0 ▶ push @result, { name => shift, param => shift, flags => shift} while @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ and do { push @result, {"name", shift(), "param", shift(), "flags", shift()} } 0 0 0
719 0 return \@result;
720 }
721  
722 #
723 # Making scalar control elements visible, \n\r for now, need cool conception
724 #
725 1 my %map = (
726 "\n" => '\n',
727 "\r" => '\r',
728 "\f" => '\f',
729 "\t" => '\t',
730 );
731  
732 sub _escape_scalar
733 0 ▶{
Subroutine _escape_scalar: not called CC=1 SCAR=6.9
734 0 my ($scalar) = @_;
735 0 $scalar =~ s{\\(?=[rnft])}{\\\\}sg;
736 0 $scalar =~ s/([\r\n\f\t])/$map{$1}/seg;
737 0 return $scalar;
738 }
739  
740 sub _get_current_stack_frame
741 0 ▶{
Subroutine _get_current_stack_frame: not called CC=1 SCAR=6.9
742 0 return $_stack_frames->[-1];
743 }
744  
745 sub _send_data_to_debugger
746 0 ▶{
Subroutine _send_data_to_debugger: not called CC=1 SCAR=6.9
747 0 my ($event) = @_;
748 0 _send_string_to_debugger( _serialize( $event ) );
749 }
750  
751 sub _send_string_to_debugger
752 0 ▶{
Subroutine _send_string_to_debugger: not called CC=2 SCAR=17.9
753 0 my ($string) = @_;
754 0 $string .= "\n";
755 0 print $_debug_socket $string;
756 0 ▶ _report "Sent to debugger: %s", $string if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
757 }
758  
759 sub _get_adjusted_line_number
760 0 ▶{
Subroutine _get_adjusted_line_number: not called CC=1 SCAR=6.9
761 0 my ($line_number) = @_;
762 0 return $line_number - 1;
763 }
764  
765 #@returns JSON::XS
766 sub _get_seraizlier
767 0 ▶{
Subroutine _get_seraizlier: not called CC=2 SCAR=17.9
768 0 ▶ unless ($coder)
Branch: 1 branch
BranchTrueFalseTotal
unless ($coder) 0 0 0
769 {
770 0 $coder = JSON::XS->new();
771 0 $coder->latin1();
772 }
773 0 return $coder;
774 }
775  
776 sub _serialize
777 0 ▶{
Subroutine _serialize: not called CC=1 SCAR=6.9
778 0 my ($data) = @_;
779 0 return _get_seraizlier->encode( $data );
780 }
781  
782 sub _deserialize
783 0 ▶{
Subroutine _deserialize: not called CC=1 SCAR=6.9
784 0 my ($json_string) = @_;
785 0 return _get_seraizlier->decode( $json_string );
786 }
787  
788 sub _calc_stack_frames
789 0 ▶{
Subroutine _calc_stack_frames: not called CC=9 SCAR=45.0
790 0 my $frames = [ ];
791 0 my $depth = 0;
792 0 %_references_cache = ();
793  
794 0 while ()
795 {
796 0 my ($package, $filename, $line, $subroutine, $hasargs,
797 $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller( $depth );
798  
799 0 my $cnt = 0;
800 0 my @frame_args = map _get_reference_descriptor( '$_['.$cnt++.']', $_ ), @DB::args;
801  
802 0 ▶ last unless defined $filename;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename 0 0 0
803  
804 0 ▶ if ($package && $package ne 'DB')
Branch: 1 branch
BranchTrueFalseTotal
if ($package and $package ne "DB") 0 0 0
Condition0%0/3
$package and $package ne "DB"
!ll&&!rl&&r
000
MC/DC0%0/2
$package and $package ne "DB"
$package $package ne "DB"
Truth table0%0/3
A and B
A= $packageB= $package ne "DB"
ABresult
0X0
100
111
805 {
806 0 ▶ if (@$frames && $subroutine ne '(eval)')
Branch: 1 branch
BranchTrueFalseTotal
if (@$frames and $subroutine ne "(eval)") 0 0 0
Condition0%0/3
@$frames and $subroutine ne "(eval)"
!ll&&!rl&&r
000
MC/DC0%0/2
@$frames and $subroutine ne "(eval)"
@$frames $subroutine ne "(eval)"
Truth table0%0/3
A and B
A= @$framesB= $subroutine ne "(eval)"
ABresult
0X0
100
111
807 {
808 0 $frames->[-1]->{file}->{name} = $subroutine;
809 }
810  
811 0 my $global_variables = [ ];
812 0 my $global_variables_hash = eval {peek_our( $depth + 1 )};
813 0 ▶ unless ($@)
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
814 {
815 0 $global_variables = _format_variables_hash( $global_variables_hash );
816 }
817  
818 0 my $lexical_variables = [ ];
819 0 my $variables_hash = eval {peek_my( $depth + 1 )};
820 0 ▶ unless ($@)
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
821 {
822 0 $lexical_variables = _format_variables_hash( $variables_hash );
823 }
824  
825 0 ▶ $frames->[-1]->{args} = \@frame_args if scalar @$frames;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$frames 0 0 0
826  
827 0 my $descriptor = _get_file_descriptor_by_id( $filename );
828  
829 0 push @$frames, {
830 file => $descriptor,
831 line => $line - 1,
832 lexicals => $lexical_variables,
833 globals => $global_variables,
834 main_size => scalar keys %::,
835 args => [ ],
836 };
837 }
838  
839 0 $depth++;
840 }
841  
842 0 return $frames;
843 }
844  
845 sub _is_use_frame
846 0 ▶{
Subroutine _is_use_frame: not called CC=2 SCAR=17.9
847 0 my $stack_frame = shift;
848 0 my $is_use_block = 0;
849  
850 0 ▶ if (ref $stack_frame->{subname})
Branch: 1 branch
BranchTrueFalseTotal
if (ref $stack_frame->{"subname"}) 0 0 0
851 {
852 0 my $deparsed_block = _deparse_code( $stack_frame->{subname} );
853 0 $is_use_block = $deparsed_block =~ /require\s+[\w\:]+\s*;\s*do/si;
854 }
855  
856 0 return $is_use_block;
857 }
858  
859 sub _set_frames_single
860 0 ▶{
Subroutine _set_frames_single: not called CC=2 SCAR=17.9
861 0 my ($new_value) = @_;
862 0 foreach my $frame (@{$_stack_frames})
863 {
864 0 $frame->{single} = $new_value;
865 }
866 0 $DB::single = $new_value;
867 }
868  
869 sub _hold_the_line
870 0 ▶{
Subroutine _hold_the_line: not called CC=1 SCAR=6.9
871 0 _set_frames_single( STEP_INTO );
872 }
873  
874 sub _release_the_hounds
875 0 ▶{
Subroutine _release_the_hounds: not called CC=1 SCAR=6.9
876 0 _set_frames_single( STEP_CONTINUE );
877 }
878  
879 sub _process_command
880 0 ▶{
Subroutine _process_command: not called CC=17 SCAR=57.2
881 0 my ($command) = @_;
882 0 ▶ _report "============> Got command: '%s'\n", $command if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
883  
884 0 ▶ if ($command eq 'q')
Branch: 10 branches
BranchTrueFalseTotal
if ($command eq 'q') { } 0 0 0
elsif ($command =~ /^e\s+(.+)$/) { } 0 0 0
elsif ($command eq 'pause') { } 0 0 0
elsif ($command eq 'g') { } 0 0 0
elsif ($command =~ /^b (.+)$/) { } 0 0 0
elsif ($command =~ /^p (.+)$/) { } 0 0 0
elsif ($command eq 'o') { } 0 0 0
elsif ($command =~ /^getchildren (.+)$/) { } 0 0 0
elsif ($command =~ /^get_source (.+)$/) { } 0 0 0
elsif ($command eq 'u') { } 0 0 0
885 {
886 0 ▶ _report "Exiting" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
887 0 exit;
888 }
889 elsif ($command =~ /^e\s+(.+)$/) # eval expresion
890 {
891 0 my $data = $1;
892 0 my $transaction_data = _deserialize( $data );
893  
894 0 my ($transaction_id, $request_object) = @$transaction_data{qw/id data/};
895  
896 0 ▶ my $result = _eval_expression( _from_utf8( $request_object->{expression} // '' ) );
Condition0%0/2
$request_object->{"expression"} // ""
l!l
00
MC/DC0%0/1
$request_object->{"expression"} // ""
$request_object->{"expression"}
Truth table0%0/2
A
A= $request_object->{"expression"}
Aresult
11
00
897 0 $result->{result} = _get_reference_descriptor( result => $result->{result} );
898  
899 0 _send_transaction_response( $transaction_id, $result );
900  
901 0 ▶ _report "Result is $result\n" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
902 }
903 elsif ($command eq 'pause')
904 {
905 0 _hold_the_line;
906 }
907 elsif ($command eq 'g')
908 {
909 0 _release_the_hounds();
910 0 return;
911 }
912 elsif ($command =~ /^b (.+)$/) # set breakpoints from proto
913 {
914 0 _process_new_breakpoints( $1 );
915 }
916 elsif ($command =~ /^p (.+)$/) # Run to cursor
917 {
918 0 _set_run_to_cursor_breakpoint( $1 );
919 0 _release_the_hounds();
920 0 return;
921 }
922 elsif ($command eq 'o') # over,
923 {
924 0 my $current_frame = _get_current_stack_frame;
925 0 ▶ if (_is_use_frame( $current_frame ))
Branch: 1 branch
BranchTrueFalseTotal
if (_is_use_frame($current_frame)) { } 0 0 0
926 {
927 0 $current_frame->{single} = STEP_INTO;
928 0 $DB::single = STEP_CONTINUE;
929 }
930 else
931 {
932 0 $DB::single = STEP_OVER;
933 }
934 0 return;
935 }
936 elsif ($command =~ /^getchildren (.+)$/) # expand,
937 {
938 0 _get_reference_subelements( $1 );
939 }
940 elsif ($command =~ /^get_source (.+)$/) # get eval/file source
941 {
942 0 _get_file_source_handler( $1 );
943 }
944 elsif ($command eq 'u') # step out
945 {
946 0 my $current_frame = _get_current_stack_frame;
947 0 ▶ if (_is_use_frame( $current_frame ))
Branch: 1 branch
BranchTrueFalseTotal
if (_is_use_frame($current_frame)) 0 0 0
948 {
949 0 $current_frame->{single} = STEP_CONTINUE;
950 }
951 0 $DB::single = STEP_CONTINUE;
952  
953 0 return;
954 }
955 else
956 {
957 0 $DB::single = STEP_INTO;
958 0 return;
959 }
960 0 return 1;
961 }
962  
963 1 my $input_buffer = '';
964  
965 sub _get_next_command
966 0 ▶{
Subroutine _get_next_command: not called CC=7 SCAR=40.3
967 0 my $read_bytes;
968 0 my $new_line_index = index $input_buffer, "\n";
969  
970 0 ▶ if ($new_line_index == -1)
Branch: 1 branch
BranchTrueFalseTotal
if ($new_line_index == -1) 0 0 0
971 {
972 0 ▶ while( $read_bytes = sysread( $_debug_socket, $input_buffer, 10240, length( $input_buffer ) ))
Branch: 1 branch
BranchTrueFalseTotal
if ($read_bytes = sysread($_debug_socket, $input_buffer, 10240, length $input_buffer)) 0 0 0
973 {
974 0 ▶ last if ($new_line_index = index $input_buffer, "\n") > -1;
Branch: 1 branch
BranchTrueFalseTotal
if ($new_line_index = index($input_buffer, "\n")) > -1 0 0 0
975 }
976 0 ▶ unless (defined $read_bytes)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $read_bytes) 0 0 0
977 {
978 0 die 'Debugging socket disconnected';
979 }
980 0 ▶ unless ($new_line_index > -1)
Branch: 1 branch
BranchTrueFalseTotal
unless ($new_line_index > -1) 0 0 0
981 {
982 0 ▶ if (scalar @saved) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @saved) 0 0 0
983 0 ($@, $!, $^E, $,, $/, $\, $^W) = @saved;
984 0 @saved = ();
985 }
986 0 print STDERR "Buffer $input_buffer has no newlines in it and nothing is in the socket\n";
987 0 exit -1;
988 }
989 }
990 0 my $command = substr $input_buffer, 0, $new_line_index + 1, '';
991 0 $command =~ s/[\r\n]+$//;
992 # printf STDERR "Got command: %s and left in buffer %s\n%s\n\%s\n", length $command, length $input_buffer ,$command, $input_buffer;
993 0 return $command;
994 }
995  
996 sub _can_read
997 0 ▶{
Subroutine _can_read: not called CC=4 SCAR=30.0
998 0 ▶ return length( $input_buffer ) > 0 || ($_debug_socket && $_debug_socket_select && scalar $_debug_socket_select->can_read( 0 ));
Condition0%0/8
length $input_buffer > 0 || $_debug_socket && $_debug_socket_select && scalar $_debug_socket_select->can_read(0)
l!l&&r!l&&!r
000
$_debug_socket and $_debug_socket_select and scalar $_debug_socket_select->can_read(0)
!ll
00
$_debug_socket and $_debug_socket_select
!ll&&!rl&&r
000
MC/DC0%0/3
length $input_buffer > 0 || $_debug_socket && $_debug_socket_select && scalar $_debug_socket_select->can_read(0)
length $input_buffer > 0 $_debug_socket $_debug_socket_select
Truth table0%0/4
A || B and C
A= length $input_buffer > 0B= $_debug_socketC= $_debug_socket_select
ABCresult
1XX1
0111
00X0
0100
999 }
1000  
1001 sub _event_handler
1002 0 ▶{
Subroutine _event_handler: not called CC=5 SCAR=34.0
1003 0 my ($breakpoint) = @_;
1004 0 _send_loaded_files_names();
1005  
1006 0 ▶ if ($breakpoint && !$breakpoint->{run_to_cursor})
Branch: 1 branch
BranchTrueFalseTotal
if ($breakpoint and not $breakpoint->{'run_to_cursor'}) { } 0 0 0
Condition0%0/3
$breakpoint and not $breakpoint->{"run_to_cursor"}
!ll&&!rl&&r
000
MC/DC0%0/2
$breakpoint and not $breakpoint->{"run_to_cursor"}
$breakpoint not $breakpoint->{"run_to_cursor"}
Truth table0%0/3
A and not(B)
A= $breakpointB= not $breakpoint->{"run_to_cursor"}
ABresult
0X0
100
111
1007 {
1008 0 _send_breakpoint_reached_event( $breakpoint );
1009 }
1010 else
1011 {
1012 0 _send_event( "STOP", _calc_stack_frames() );
1013 }
1014  
1015 0 while()
1016 {
1017 0 ▶ _report "Waiting for input\n" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1018 0 ▶ _process_command( _get_next_command ) || return;
Branch: 1 branch
BranchTrueFalseTotal
_process_command(_get_next_command()) or return 0 0 0
1019 }
1020 }
1021  
1022  
1023 sub _enter_frame
1024 0 ▶{
Subroutine _enter_frame: not called CC=10 SCAR=47.0
1025 0 my ($old_db_single, $wantarray) = @_;
1026  
1027 0 ▶ _report "Entering frame %s: %s %s-%s-%s, %s",
Branch: 3 branches
BranchTrueFalseTotal
if $_debug_sub_handler and $_dev_mode 0 0 0
$wantarray ? : 0 0 0
defined $wantarray ? : 0 0 0
Condition0%0/9
$_debug_sub_handler and $_dev_mode
!ll&&!rl&&r
000
$DB::trace // "undef"
l!l
00
$DB::signal // "undef"
l!l
00
$old_db_single // "undef"
l!l
00
MC/DC0%0/2
$_debug_sub_handler and $_dev_mode
$_debug_sub_handler $_dev_mode
MC/DC0%0/1
$DB::trace // "undef"
$DB::trace
MC/DC0%0/1
$DB::signal // "undef"
$DB::signal
MC/DC0%0/1
$old_db_single // "undef"
$old_db_single
Truth table0%0/3
A and B
A= $_debug_sub_handlerB= $_dev_mode
ABresult
0X0
100
111
Truth table0%0/2
A
A= $DB::trace
Aresult
11
00
Truth table0%0/2
A
A= $DB::signal
Aresult
11
00
Truth table0%0/2
A
A= $old_db_single
Aresult
11
00
1028 scalar @$_stack_frames + 1,
1029 $DB::sub,
1030 $DB::trace // 'undef',
1031 $DB::signal // 'undef',
1032 $old_db_single // 'undef',
1033 $wantarray ? 'ARRAY' : defined $wantarray ? 'SCALAR' : 'VOID'
1034 if $_debug_sub_handler && $_dev_mode;
1035  
1036 0 $frame_prefix = $frame_prefix_step x (scalar @$_stack_frames + 1);
1037  
1038 0 my $new_stack_frame = {
1039 subname => $DB::sub,
1040 single => $old_db_single,
1041 };
1042 0 push @{$_stack_frames}, $new_stack_frame;
1043 0 ▶ _set_break_points_for_files() if $_enable_compile_time_breakpoints && $ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
if $_enable_compile_time_breakpoints and $ready_to_go 0 0 0
Condition0%0/3
$_enable_compile_time_breakpoints and $ready_to_go
!ll&&!rl&&r
000
MC/DC0%0/2
$_enable_compile_time_breakpoints and $ready_to_go
$_enable_compile_time_breakpoints $ready_to_go
Truth table0%0/3
A and B
A= $_enable_compile_time_breakpointsB= $ready_to_go
ABresult
0X0
100
111
1044 0 return $new_stack_frame;
1045 }
1046  
1047  
1048 sub _exit_frame
1049 0 ▶{
Subroutine _exit_frame: not called CC=3 SCAR=24.8
1050 0 $_internal_process = 1;
1051 0 my $frame = pop @$_stack_frames;
1052 0 $frame_prefix = $frame_prefix_step x (scalar @$_stack_frames);
1053 _report "Leaving frame %s, setting single to %s", (scalar @$_stack_frames + 1),
1054 0 ▶ $frame->{single} if $_debug_sub_handler && $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_debug_sub_handler and $_dev_mode 0 0 0
Condition0%0/3
$_debug_sub_handler and $_dev_mode
!ll&&!rl&&r
000
MC/DC0%0/2
$_debug_sub_handler and $_dev_mode
$_debug_sub_handler $_dev_mode
Truth table0%0/3
A and B
A= $_debug_sub_handlerB= $_dev_mode
ABresult
0X0
100
111
1055 0 $DB::single = $frame->{single};
1056 0 $_internal_process = 0;
1057 }
1058  
1059 sub _get_normalized_perl_file_id
1060 0 ▶{
Subroutine _get_normalized_perl_file_id: not called CC=2 SCAR=17.9
1061 0 my ($perl_file_id) = @_;
1062 0 ▶ if ($perl_file_id =~ /_<(.+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_file_id =~ /_<(.+)$/) { } 0 0 0
1063 {
1064 0 return $1;
1065 }
1066 else
1067 {
1068 0 die "PANIC: Incorrect perl file id $perl_file_id";
1069 }
1070  
1071 }
1072  
1073 sub _get_perl_file_id_by_real_path
1074 0 ▶{
Subroutine _get_perl_file_id_by_real_path: not called CC=3 SCAR=24.8
1075 0 my ($path) = @_;
1076  
1077 0 ▶ return $path if $path =~ /^\(eval \d+\)/;
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ /^\(eval \d+\)/ 0 0 0
1078 0 ▶ return exists $_paths_to_perl_file_id_map{$path} ? $_paths_to_perl_file_id_map{$path} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $_paths_to_perl_file_id_map{$path} ? : 0 0 0
1079 }
1080  
1081  
1082  
1083 sub _get_real_path_by_normalized_perl_file_id
1084 158 ▶{
Subroutine _get_real_path_by_normalized_perl_file_id: called CC=6 SCAR=20.1
1085 158 my $perl_file_id = shift;
1086  
1087 158 ▶ unless ($perl_file_id)
Branch: 1 branch
BranchTrueFalseTotal
unless ($perl_file_id) 0 158 158
1088 {
1089 0 ▶ _dump_stack && _dump_frames && die "Perl normalized file id undefined";
Branch: 1 branch
BranchTrueFalseTotal
_dump_stack() and _dump_frames() and die "Perl normalized file id undefined" 0 0 0
Condition0%0/3
_dump_stack() and _dump_frames()
!ll&&!rl&&r
000
MC/DC0%0/2
_dump_stack() and _dump_frames()
_dump_stack() _dump_frames()
Truth table0%0/3
A and B
A= _dump_stack()B= _dump_frames()
ABresult
0X0
100
111
1090 }
1091  
1092 158 ▶ if (!exists $_perl_file_id_to_path_map{$perl_file_id})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_perl_file_id_to_path_map{$perl_file_id}) 158 0 158
1093 {
1094 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1095 158 my $path = ${*{"::_<$perl_file_id"}};
1096 158 ▶ return '' unless defined $path; # some subs created via XS
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 0 158 158
1097 158 my $real_path = _calc_real_path( $path, $perl_file_id );
1098  
1099 158 $_perl_file_id_to_path_map{$perl_file_id} = $real_path;
1100 158 $_paths_to_perl_file_id_map{$real_path} = $perl_file_id;
1101 }
1102 158 return $_perl_file_id_to_path_map{$perl_file_id};
1103 }
1104  
1105 sub _get_real_path_by_perl_file_id
1106 0 ▶{
Subroutine _get_real_path_by_perl_file_id: not called CC=1 SCAR=6.9
1107 0 my ($perl_file_id) = @_;
1108 0 return _get_real_path_by_normalized_perl_file_id( _get_normalized_perl_file_id( $perl_file_id ) );
1109 }
1110  
1111 sub _get_loaded_breakpoints_by_real_path
1112 0 ▶{
Subroutine _get_loaded_breakpoints_by_real_path: not called CC=16 SCAR=56.1
1113 0 my ($real_path) = @_;
1114  
1115 0 my $result = { };
1116  
1117 0 ▶ if ($_loaded_breakpoints{$real_path})
Branch: 1 branch
BranchTrueFalseTotal
if ($_loaded_breakpoints{$real_path}) 0 0 0
1118 {
1119 0 ▶ _report "Found real breakpoints" if $_dev_mode && $_debug_breakpoints;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode and $_debug_breakpoints 0 0 0
Condition0%0/3
$_dev_mode and $_debug_breakpoints
!ll&&!rl&&r
000
MC/DC0%0/2
$_dev_mode and $_debug_breakpoints
$_dev_mode $_debug_breakpoints
Truth table0%0/3
A and B
A= $_dev_modeB= $_debug_breakpoints
ABresult
0X0
100
111
1120 0 %$result = %{$_loaded_breakpoints{$real_path}};
1121 }
1122  
1123 # append breakpoints from templates
1124 0 ▶ if (my $substituted_file_descriptor = $_evals_to_templates_map{$real_path})
Branch: 1 branch
BranchTrueFalseTotal
if (my $substituted_file_descriptor = $_evals_to_templates_map{$real_path}) 0 0 0
1125 {
1126 0 my ($template_path, $lines_map) = @$substituted_file_descriptor{qw/path lines_map/};
1127 0 ▶ _report "Found template file %s", $template_path if $_dev_mode && $_debug_breakpoints;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode and $_debug_breakpoints 0 0 0
Condition0%0/3
$_dev_mode and $_debug_breakpoints
!ll&&!rl&&r
000
MC/DC0%0/2
$_dev_mode and $_debug_breakpoints
$_dev_mode $_debug_breakpoints
Truth table0%0/3
A and B
A= $_dev_modeB= $_debug_breakpoints
ABresult
0X0
100
111
1128 0 ▶ if (my $template_breakpoints = $_loaded_breakpoints{$template_path})
Branch: 1 branch
BranchTrueFalseTotal
if (my $template_breakpoints = $_loaded_breakpoints{$template_path}) 0 0 0
1129 {
1130 0 ▶ _report "Found template breakpoints" if $_dev_mode && $_debug_breakpoints;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode and $_debug_breakpoints 0 0 0
Condition0%0/3
$_dev_mode and $_debug_breakpoints
!ll&&!rl&&r
000
MC/DC0%0/2
$_dev_mode and $_debug_breakpoints
$_dev_mode $_debug_breakpoints
Truth table0%0/3
A and B
A= $_dev_modeB= $_debug_breakpoints
ABresult
0X0
100
111
1131 0 foreach my $line (keys %$template_breakpoints)
1132 {
1133 0 ▶ if (my $mapped_line = $lines_map->{$line})
Branch: 1 branch
BranchTrueFalseTotal
if (my $mapped_line = $lines_map->{$line}) 0 0 0
1134 {
1135 0 ▶ _report "Got mapped breakpoint %s => %s", $line, $mapped_line if $_dev_mode && $_debug_breakpoints;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode and $_debug_breakpoints 0 0 0
Condition0%0/3
$_dev_mode and $_debug_breakpoints
!ll&&!rl&&r
000
MC/DC0%0/2
$_dev_mode and $_debug_breakpoints
$_dev_mode $_debug_breakpoints
Truth table0%0/3
A and B
A= $_dev_modeB= $_debug_breakpoints
ABresult
0X0
100
111
1136 0 ▶ $result->{$mapped_line} //= $template_breakpoints->{$line};
Condition0%0/3
$result->{$mapped_line} //= $template_breakpoints->{$line}
l!l&&r!l&&!r
000
MC/DC0%0/2
$result->{$mapped_line} //= $template_breakpoints->{$line}
$result->{$mapped_line} $template_breakpoints->{$line}
Truth table0%0/3
A //= B
A= $result->{$mapped_line}B= $template_breakpoints->{$line}
ABresult
1X1
011
000
1137 }
1138 }
1139 }
1140 }
1141  
1142 0 ▶ return scalar keys %$result ? $result : undef;
Branch: 1 branch
BranchTrueFalseTotal
scalar keys %$result ? : 0 0 0
1143 }
1144  
1145 sub _get_current_breakpoint
1146 0 ▶{
Subroutine _get_current_breakpoint: not called CC=5 SCAR=34.0
1147 0 ▶ return if $DB::single || $DB::signal;
Branch: 1 branch
BranchTrueFalseTotal
if $DB::single or $DB::signal 0 0 0
Condition0%0/3
$DB::single or $DB::signal
l!l&&r!l&&!r
000
MC/DC0%0/2
$DB::single or $DB::signal
$DB::single $DB::signal
Truth table0%0/3
A or B
A= $DB::singleB= $DB::signal
ABresult
1X1
011
000
1148 0 my $current_breakpoint = $DB::dbline{$current_line};
1149 0 ▶ return unless $current_breakpoint;
Branch: 1 branch
BranchTrueFalseTotal
unless $current_breakpoint 0 0 0
1150 0 ▶ if ($current_breakpoint->{run_to_cursor})
Branch: 1 branch
BranchTrueFalseTotal
if ($current_breakpoint->{"run_to_cursor"}) 0 0 0
1151 {
1152 0 $current_breakpoint->{remove} = 1;
1153 0 $current_breakpoint->{line}--; # fixme find out why works without it
1154 0 _process_breakpoints_descriptors( [ $current_breakpoint ] );
1155 }
1156 0 return $current_breakpoint;
1157 }
1158  
1159 sub _eval_expression
1160 0 ▶{
Subroutine _eval_expression: not called CC=4 SCAR=30.0
1161 0 my ($expression ) = @_;
1162  
1163 0 my $expr = "no strict; package $current_package;".'( $@, $!, $^E, $,, $/, $\, $^W ) = @DB::saved;'."$expression";
1164 0 ▶ _report "Running %s\n", $expr if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1165  
1166 0 my $result;
1167  
1168 {
1169 0 ▶ local $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
1170 0 $result = eval $expr;
1171 }
1172  
1173 0 ▶ if (my $e = $@)
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) { } 0 0 0
1174 {
1175 # fixme handle object exceptions
1176 0 ▶ unless (ref $e) # message, change it
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $e) 0 0 0
1177 {
1178 0 $e = join "; ", map {s/ at \(eval \d+.+$//;
1179 0 $_ } grep $_, split /[\r\n]+/, $e;
1180 }
1181 $result = {
1182 0 error => \1,
1183 result => $e
1184 };
1185 }
1186 else
1187 {
1188 0 $result = {
1189 error => \0,
1190 result => $result
1191 };
1192 }
1193  
1194 0 return $result;
1195 }
1196  
1197 sub _reset_breakpoint
1198 0 ▶{
Subroutine _reset_breakpoint: not called CC=4 SCAR=30.0
1199 0 my ($breakpoint_descriptor, $real_line, $perl_breakpoints_map) = @_;
1200  
1201 0 my $real_path = $breakpoint_descriptor->{path};
1202  
1203 0 ▶ if (exists $_loaded_breakpoints{$real_path} && exists $_loaded_breakpoints{$real_path}->{$real_line})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_loaded_breakpoints{$real_path} and exists $_loaded_breakpoints{$real_path}{$real_line}) 0 0 0
Condition0%0/3
exists $_loaded_breakpoints{$real_path} and exists $_loaded_breakpoints{$real_path}{$real_line}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $_loaded_breakpoints{$real_path} and exists $_loaded_breakpoints{$real_path}{$real_line}
exists $_loaded_breakpoints{$real_path} exists $_loaded_breakpoints{$real_path}{$real_line}
Truth table0%0/3
A and B
A= exists $_loaded_breakpoints{$real_path}B= exists $_loaded_breakpoints{$real_path}{$real_line}
ABresult
0X0
100
111
1204 {
1205 0 delete $_loaded_breakpoints{$real_path}->{$real_line};
1206 }
1207  
1208 0 ▶ if ($perl_breakpoints_map)
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_breakpoints_map) 0 0 0
1209 {
1210 0 $perl_breakpoints_map->{$real_line} = 0;
1211 }
1212 }
1213  
1214 sub _set_run_to_cursor_breakpoint
1215 0 ▶{
Subroutine _set_run_to_cursor_breakpoint: not called CC=1 SCAR=6.9
1216 0 my ($serialized_descriptor) = @_;
1217 0 my $descriptor = _deserialize( $serialized_descriptor );
1218 0 @$descriptor{qw/run_to_cursor condition remove suspend/} = (1, undef, undef, \1);
1219 0 _process_breakpoints_descriptors( [ $descriptor ] );
1220 }
1221  
1222 sub _set_breakpoint
1223 0 ▶{
Subroutine _set_breakpoint: not called CC=6 SCAR=37.4
1224 0 my ($breakpoint_descriptor, $real_line, $perl_breakpoints_map, $perl_source_lines) = @_;
1225  
1226 my $event_data = {
1227 path => $breakpoint_descriptor->{path},
1228 0 line => $breakpoint_descriptor->{line} - 1,
1229 };
1230  
1231 0 ▶ _report 'Setting breakpoint to %s, real line %s, %s', $breakpoint_descriptor->{path}, $real_line,
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode and $_debug_breakpoints 0 0 0
Condition0%0/3
$_dev_mode and $_debug_breakpoints
!ll&&!rl&&r
000
MC/DC0%0/2
$_dev_mode and $_debug_breakpoints
$_dev_mode $_debug_breakpoints
Truth table0%0/3
A and B
A= $_dev_modeB= $_debug_breakpoints
ABresult
0X0
100
111
1232 $perl_source_lines->[$real_line] if $_dev_mode && $_debug_breakpoints;
1233  
1234 0 $breakpoint_descriptor->{_processed} = 1;
1235  
1236 0 ▶ if (!defined $perl_source_lines->[$real_line] || $perl_source_lines->[$real_line] == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $perl_source_lines->[$real_line] or $perl_source_lines->[$real_line] == 0) { } 0 0 0
Condition0%0/3
not defined $perl_source_lines->[$real_line] or $perl_source_lines->[$real_line] == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $perl_source_lines->[$real_line] or $perl_source_lines->[$real_line] == 0
not defined $perl_source_lines->[$real_line] $perl_source_lines->[$real_line] == 0
Truth table0%0/3
not(A) or B
A= not defined $perl_source_lines->[$real_line]B= $perl_source_lines->[$real_line] == 0
ABresult
1X1
011
000
1237 0 _send_event("BREAKPOINT_DENIED", $event_data);
1238 }
1239 else {
1240 0 $perl_breakpoints_map->{$real_line} = $breakpoint_descriptor;
1241 0 ▶ _send_event("BREAKPOINT_SET", $event_data) unless $breakpoint_descriptor->{run_to_cursor};
Branch: 1 branch
BranchTrueFalseTotal
unless $breakpoint_descriptor->{"run_to_cursor"} 0 0 0
1242 }
1243 }
1244  
1245 sub _set_up_debugger
1246 0 ▶{
Subroutine _set_up_debugger: not called CC=13 SCAR=52.0
1247 0 my ($json_data) = @_;
1248 0 ▶ _report 'Setting up debugger: %s', $json_data if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1249 0 my $set_up_data = _deserialize( $json_data );
1250 0 $_script_charset = $set_up_data->{charset};
1251 0 _process_breakpoints_descriptors( $set_up_data->{breakpoints} );
1252  
1253 0 ▶ $_enable_compile_time_breakpoints = 1 if $set_up_data->{enableCompileTimeBreakpoints};
Branch: 1 branch
BranchTrueFalseTotal
if $set_up_data->{"enableCompileTimeBreakpoints"} 0 0 0
1254 0 ▶ $_enable_noninteractive_mode = 1 if $set_up_data->{enableNonInteractiveMode};
Branch: 1 branch
BranchTrueFalseTotal
if $set_up_data->{"enableNonInteractiveMode"} 0 0 0
1255  
1256 0 ▶ if (ref $set_up_data->{renderers} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $set_up_data->{"renderers"} eq "ARRAY") 0 0 0
1257 0 for my $entry (@{$set_up_data->{renderers}}) {
1258 0 ▶ if (ref $entry ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $entry ne "HASH") 0 0 0
1259 0 next;
1260 }
1261 0 my ($package, $code) = @$entry{qw/packageName renderExpression/};
1262 0 ▶ if (!$package || !$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($package and $code) 0 0 0
Condition0%0/3
$package and $code
!ll&&!rl&&r
000
MC/DC0%0/2
$package and $code
$package $code
Truth table0%0/3
A and B
A= $packageB= $code
ABresult
0X0
100
111
1263 0 next;
1264 }
1265 0 push @renderers, [ $package, $code ];
1266 }
1267 }
1268  
1269 0 my $start_mode = $set_up_data->{startMode};
1270  
1271 0 ▶ if ($set_up_data->{initCode})
Branch: 1 branch
BranchTrueFalseTotal
if ($set_up_data->{"initCode"}) 0 0 0
1272 {
1273 0 eval $set_up_data->{initCode};
1274 0 ▶ die "*** Debugger init code error:\n$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1275 }
1276  
1277 0 ▶ if ($start_mode eq 'RUN')
Branch: 2 branches
BranchTrueFalseTotal
if ($start_mode eq 'RUN') { } 0 0 0
elsif ($start_mode eq 'COMPILE') { } 0 0 0
1278 {
1279 0 return STEP_CONTINUE;
1280 }
1281 elsif ($start_mode eq 'COMPILE')
1282 {
1283 0 return STEP_INTO;
1284 }
1285 else # here we should have a RUN_TO_BREAKPOINT
1286 {
1287 0 $_skip_run_stop = 1;
1288 0 return STEP_CONTINUE;
1289 }
1290 }
1291  
1292 sub _set_up_after_connect
1293 0 ▶{
Subroutine _set_up_after_connect: not called CC=5 SCAR=34.0
1294 0 my ($allow_fail) = @_;
1295  
1296 0 $_debug_socket->autoflush( 1 );
1297 0 $_debug_socket_select = IO::Select->new();
1298 0 $_debug_socket_select->add( $_debug_socket );
1299  
1300 0 _send_data_to_debugger( +{
1301 event => 'READY',
1302 version => $API_VERSION,
1303 } );
1304 0 ▶ _report "Waiting for set up data..." if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1305 0 my $set_up_data = <$_debug_socket>;
1306 0 ▶ return if !defined $set_up_data && $allow_fail;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $set_up_data and $allow_fail 0 0 0
Condition0%0/3
not defined $set_up_data and $allow_fail
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $set_up_data and $allow_fail
not defined $set_up_data $allow_fail
Truth table0%0/3
not(A) and B
A= not defined $set_up_dataB= $allow_fail
ABresult
0X0
100
111
1307 0 ▶ die "Connection closed" unless defined $set_up_data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $set_up_data 0 0 0
1308  
1309 0 $ready_to_go = 1;
1310 0 $DB::single = _set_up_debugger( $set_up_data );
1311 }
1312  
1313 sub _process_new_breakpoints
1314 0 ▶{
Subroutine _process_new_breakpoints: not called CC=2 SCAR=17.9
1315 0 my ($json_data) = @_;
1316 0 ▶ _report "Processing breakpoints: %s", $json_data if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1317 0 return _process_breakpoints_descriptors( _deserialize( $json_data ) );
1318 }
1319  
1320 sub _process_breakpoints_descriptors
1321 0 ▶{
Subroutine _process_breakpoints_descriptors: not called CC=6 SCAR=37.4
1322 0 my ($descriptors) = @_;
1323  
1324 0 foreach my $descriptor (@$descriptors)
1325 {
1326 0 $descriptor->{line}++;
1327 0 $descriptor->{condition} = _from_utf8( $descriptor->{condition} );
1328 0 $descriptor->{action} = _from_utf8( $descriptor->{action} );
1329  
1330 _report "Processing descriptor: %s %s %s", $descriptor->{path}, $descriptor->{line},
1331 0 ▶ $descriptor->{remove} ? 'remove' : 'set' if $_dev_mode;
Branch: 2 branches
BranchTrueFalseTotal
if $_dev_mode 0 0 0
$descriptor->{'remove'} ? : 0 0 0
1332  
1333 0 my ($real_path, $line) = @$descriptor{qw/path line/};
1334 0 ▶ $_loaded_breakpoints{$real_path} //= { };
Condition0%0/2
$_loaded_breakpoints{$real_path} //= {}
l!l
00
MC/DC0%0/1
$_loaded_breakpoints{$real_path} //= {}
$_loaded_breakpoints{$real_path}
Truth table0%0/2
A
A= $_loaded_breakpoints{$real_path}
Aresult
11
00
1335 0 $_loaded_breakpoints{$real_path}->{$line} = $descriptor;
1336 0 $_queued_breakpoints_files{$real_path} = 1;
1337 }
1338 0 ▶ _set_break_points_for_files() if $ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
if $ready_to_go 0 0 0
1339 }
1340  
1341  
1342 sub _set_break_points_for_files
1343 0 ▶{
Subroutine _set_break_points_for_files: not called CC=20 SCAR=60.4
1344 0 ▶ return unless $ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
unless $ready_to_go 0 0 0
1345  
1346 0 my $paths_array = [ keys %_queued_breakpoints_files ];
1347 0 ▶ return unless @{$paths_array};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$paths_array;} 0 0 0
1348  
1349 0 my $default_context = undef;
1350  
1351 0 foreach my $real_path (@{$paths_array})
1352 {
1353 0 ▶ _report "Setting breakpoints for %s", $real_path if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1354  
1355 # mapping real path to file id
1356 my $perl_file_id = $real_path =~ /^\(eval \d+\)/
1357 ? $real_path
1358 0 ▶ : exists $_paths_to_perl_file_id_map{$real_path} ? $_paths_to_perl_file_id_map{$real_path} : next;
Branch: 2 branches
BranchTrueFalseTotal
$real_path =~ /^\(eval \d+\)/ ? : 0 0 0
exists $_paths_to_perl_file_id_map{$real_path} ? : 0 0 0
1359  
1360 # getting perl source lines and breakpoints
1361 0 my $glob = $::{"_<$perl_file_id"};
1362 0 ▶ next unless $glob && *{$glob}{ARRAY} && scalar @{*{$glob}{ARRAY}};
Branch: 1 branch
BranchTrueFalseTotal
unless $glob and *{$glob;}{"ARRAY"} and scalar @{*{$glob;}{"ARRAY"};} 0 0 0
Condition0%0/4
$glob and *{$glob;}{"ARRAY"} and scalar @{*{$glob;}{"ARRAY"};}
!ll
00
$glob and *{$glob;}{"ARRAY"}
!ll
00
MC/DC0%0/1
$glob and *{$glob;}{"ARRAY"} and scalar @{*{$glob;}{"ARRAY"};}
$glob
Truth table0%0/2
A
A= $glob
Aresult
00
11
1363 0 my $perl_source_lines = *{$glob}{ARRAY};
1364 0 my $perl_breakpoints_map = *{$glob}{HASH};
1365  
1366 # getting breakpoints passed from the IDE
1367 0 ▶ my $loaded_breakpoints_descriptors = _get_loaded_breakpoints_by_real_path( $real_path ) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $loaded_breakpoints_descriptors = _get_loaded_breakpoints_by_real_path($real_path) or next 0 0 0
1368  
1369 # switching context
1370 0 my $old_context = _switch_context( $perl_file_id );
1371 0 ▶ $default_context //= $old_context;
Condition0%0/3
$default_context //= $old_context
l!l&&r!l&&!r
000
MC/DC0%0/2
$default_context //= $old_context
$default_context $old_context
Truth table0%0/3
A //= B
A= $default_contextB= $old_context
ABresult
1X1
011
000
1372  
1373 0 my @lines = keys %{$loaded_breakpoints_descriptors};
1374 0 my $breakpoints_left = scalar @lines;
1375  
1376 0 foreach my $real_line (@lines) {
1377 0 my $breakpoint_descriptor = $loaded_breakpoints_descriptors->{$real_line};
1378  
1379 0 ▶ if (exists $breakpoint_descriptor->{_processed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $breakpoint_descriptor->{"_processed"}) 0 0 0
1380 0 $breakpoints_left--;
1381 _report "Breakpoint is already set: %s, %s, %s",
1382 0 ▶ @{$breakpoint_descriptor}{qw/path line remove/} if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1383 0 next;
1384 }
1385  
1386 0 ▶ if ($real_line > $#$perl_source_lines) {
Branch: 1 branch
BranchTrueFalseTotal
if ($real_line > $perl_source_lines->$#*) 0 0 0
1387 _report "Skip breakpoint setting, file seems not completely compiled. Breakpoint: %s, %s, %s, script lines: %s",
1388 0 ▶ @{$breakpoint_descriptor}{qw/path line remove/}, $#$perl_source_lines if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1389 0 next;
1390 }
1391 0 ▶ _report "Processing descriptor %s, %s, %s", @{$breakpoint_descriptor}{qw/path line remove/} if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1392  
1393 0 ▶ if ($breakpoint_descriptor->{remove}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breakpoint_descriptor->{'remove'}) { } 0 0 0
1394 0 _reset_breakpoint($breakpoint_descriptor, $real_line, $perl_breakpoints_map);
1395 }
1396 else {
1397 0 _set_breakpoint($breakpoint_descriptor, $real_line, $perl_breakpoints_map, $perl_source_lines);
1398 }
1399 0 $breakpoints_left--;
1400 }
1401  
1402 0 ▶ delete $_queued_breakpoints_files{$real_path} unless $breakpoints_left;
Branch: 1 branch
BranchTrueFalseTotal
unless $breakpoints_left 0 0 0
1403 }
1404 0 _switch_context( $default_context );
1405 }
1406  
1407 #sub mydie
1408 #{
1409 # my ($msg) = @_;
1410 # print "$msg\n";
1411 # print Carp::longmess;
1412 # foreach my $key (sort keys %::)
1413 # {
1414 # print $key."\n" if $key =~ /^_</;
1415 # }
1416 # exit -1;
1417 #}
1418  
1419 sub _calc_real_path
1420 158 ▶{
Subroutine _calc_real_path: called CC=6 SCAR=21.5
1421 158 my $path = shift;
1422 158 my $new_filename = shift;
1423  
1424 158 my $real_path;
1425 158 ▶ if ($path =~ /^\(eval (\d+)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /^\(eval (\d+)/) { } 0 158 158
1426 {
1427 0 $real_path = $path;
1428 }
1429 else
1430 {
1431 158 $real_path = eval {Cwd::realpath( $path )};
1432 158 ▶ unless ($real_path)
Branch: 1 branch
BranchTrueFalseTotal
unless ($real_path) 0 158 158
1433 {
1434 0 ▶ _report 'Unable to find real path for %s use as it is', $path if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1435 0 $real_path = $path;
1436 }
1437 158 $real_path =~ s{\\}{/}g;
1438 }
1439  
1440 158 ▶ _report "$new_filename real path is $real_path\n" if $trace_real_path && $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $trace_real_path and $_dev_mode 0 158 158
Condition33%1/3
$trace_real_path and $_dev_mode
!ll&&!rl&&r
15800
MC/DC0%0/2
$trace_real_path and $_dev_mode
$trace_real_path $_dev_mode
Truth table33%1/3
A and B
A= $trace_real_pathB= $_dev_mode
ABresult
0X0
100
111
1441 158 return $real_path;
1442 }
1443  
1444 sub _switch_context
1445 0 ▶{
Subroutine _switch_context: not called CC=2 SCAR=13.0
1446 0 my ($context_key) = @_;
1447 0 ▶ return unless $context_key;
Branch: 1 branch
BranchTrueFalseTotal
unless $context_key 0 0 0
1448 0 $context_key =~ s/^_<//;
1449 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1450 0 my $current_context = $DB::dbline;
1451 0 *DB::dbline = *{"::_<$context_key"};
1452 0 return $current_context;
1453 }
1454  
1455  
1456 # When the execution of your program reaches a point that can hold a breakpoint, the DB::DB() subroutine is called if
1457 # any of the variables $DB::trace , $DB::single , or $DB::signal is true. These variables are not localizable. This
1458 # feature is disabled when executing inside DB::DB() , including functions called from it unless $^D & (1<<30) is true.
1459 sub step_handler
1460 0 ▶{
Subroutine step_handler: not called CC=27 SCAR=66.3
Pod undocumented
1461 0 ▶ return if $_internal_process || !$ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
if $_internal_process or not $ready_to_go 0 0 0
Condition0%0/3
$_internal_process or not $ready_to_go
l!l&&r!l&&!r
000
MC/DC0%0/2
$_internal_process or not $ready_to_go
$_internal_process not $ready_to_go
Truth table0%0/3
A or not(B)
A= $_internal_processB= not $ready_to_go
ABresult
1X1
011
000
1462 0 $_internal_process = 1;
1463  
1464 # Save eval failure, command failure, extended OS error, output field
1465 # separator, input record separator, output record separator and
1466 # the warning setting.
1467 0 @saved = ( $@, $!, $^E, $,, $/, $\, $^W );
1468  
1469 0 $, = ""; # output field separator is null string
1470 0 $/ = "\n"; # input record separator is newline
1471 0 $\ = ""; # output record separator is null string
1472 0 $^W = 0; # warnings are off
1473  
1474 # set breakpoints for evals if any appeared
1475 0 ▶ _set_break_points_for_files() if $ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
if $ready_to_go 0 0 0
1476  
1477 # updating current position
1478 0 my @caller = caller();
1479 0 ($current_package, $current_file_id, $current_line) = @caller[0, 1, 2];
1480  
1481 0 ▶ if (defined $current_file_id)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $current_file_id) { } 0 0 0
1482 {
1483 0 ▶ _report( <<'EOM',
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
Condition0%0/2
${^GLOBAL_PHASE} // "unknown"
l!l
00
MC/DC0%0/1
${^GLOBAL_PHASE} // "unknown"
${^GLOBAL_PHASE}
Truth table0%0/2
A
A= ${^GLOBAL_PHASE}
Aresult
11
00
1484 Calling %s %s
1485 EOM
1486 _format_caller( @caller ),
1487 ${^GLOBAL_PHASE} // 'unknown',
1488 ) if $_dev_mode;
1489 0 _switch_context( $current_file_id );
1490 }
1491 else
1492 {
1493 0 ▶ _dump_stack && _dump_frames && warn "CAN'T FIND CALLER;\n";
Branch: 1 branch
BranchTrueFalseTotal
_dump_stack() and _dump_frames() and warn "CAN'T FIND CALLER;\n" 0 0 0
Condition0%0/3
_dump_stack() and _dump_frames()
!ll&&!rl&&r
000
MC/DC0%0/2
_dump_stack() and _dump_frames()
_dump_stack() _dump_frames()
Truth table0%0/3
A and B
A= _dump_stack()B= _dump_frames()
ABresult
0X0
100
111
1494 }
1495  
1496 0 my $skip_event_handler = 0;
1497 0 my $breakpoint;
1498 0 ▶ if ($breakpoint = _get_current_breakpoint)
Branch: 3 branches
BranchTrueFalseTotal
if ($breakpoint = _get_current_breakpoint()) { } 0 0 0
elsif ($DB::single and $_skip_run_stop) { } 0 0 0
elsif ($_skip_run_stop) { } 0 0 0
1499 {
1500 0 my $condition = $breakpoint->{condition};
1501  
1502 0 ▶ if ($condition && !_eval_expression( $condition )->{result})
Branch: 1 branch
BranchTrueFalseTotal
if ($condition and not _eval_expression($condition)->{"result"}) 0 0 0
Condition0%0/3
$condition and not _eval_expression($condition)->{"result"}
!ll&&!rl&&r
000
MC/DC0%0/2
$condition and not _eval_expression($condition)->{"result"}
$condition not _eval_expression($condition)->{"result"}
Truth table0%0/3
A and not(B)
A= $conditionB= not _eval_expression($condition)->{"result"}
ABresult
0X0
100
111
1503 {
1504 0 ($@, $!, $^E, $,, $/, $\, $^W) = @saved;
1505 0 @saved = ();
1506 0 $_internal_process = 0;
1507 0 return;
1508 }
1509  
1510 0 ▶ if (my $action = $breakpoint->{action})
Branch: 1 branch
BranchTrueFalseTotal
if (my $action = $breakpoint->{"action"}) 0 0 0
1511 {
1512 0 $breakpoint->{action_result} = _to_utf8( _eval_expression( $action )->{result} );
1513 }
1514  
1515 0 ▶ if (!$breakpoint->{suspend})
Branch: 1 branch
BranchTrueFalseTotal
unless ($breakpoint->{"suspend"}) 0 0 0
1516 {
1517 0 _send_breakpoint_reached_event( $breakpoint );
1518 0 ($@, $!, $^E, $,, $/, $\, $^W) = @saved;
1519 0 @saved = ();
1520 0 $_internal_process = 0;
1521 0 return;
1522 }
1523  
1524 0 foreach my $frame (@{$_stack_frames})
1525 {
1526 0 $frame->{single} = STEP_INTO;
1527 }
1528 0 $DB::single = STEP_INTO;
1529 }
1530 ▶ elsif ($DB::single && $_skip_run_stop)
Condition0%0/3
$DB::single and $_skip_run_stop
!ll&&!rl&&r
000
MC/DC0%0/2
$DB::single and $_skip_run_stop
$DB::single $_skip_run_stop
Truth table0%0/3
A and B
A= $DB::singleB= $_skip_run_stop
ABresult
0X0
100
111
1531 {
1532 0 $_skip_run_stop = 0;
1533 0 $skip_event_handler = 1;
1534 0 $DB::single = STEP_CONTINUE;
1535 }
1536 elsif ($_skip_run_stop)
1537 {
1538 0 $_skip_run_stop = 0;
1539 }
1540  
1541 0 my $old_db_single = $DB::single;
1542 0 $DB::single = STEP_CONTINUE;
1543  
1544 0 ▶ _report "Step with %s %s %s, %s-%s-%s %s",
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
Condition0%0/12
$current_package // "undef"
l!l
00
$current_file_id // "undef"
l!l
00
$current_line // "undef"
l!l
00
$DB::trace // "undef"
l!l
00
$DB::signal // "undef"
l!l
00
$old_db_single // "undef"
l!l
00
MC/DC0%0/1
$current_package // "undef"
$current_package
MC/DC0%0/1
$current_file_id // "undef"
$current_file_id
MC/DC0%0/1
$current_line // "undef"
$current_line
MC/DC0%0/1
$DB::trace // "undef"
$DB::trace
MC/DC0%0/1
$DB::signal // "undef"
$DB::signal
MC/DC0%0/1
$old_db_single // "undef"
$old_db_single
Truth table0%0/2
A
A= $current_package
Aresult
11
00
Truth table0%0/2
A
A= $current_file_id
Aresult
11
00
Truth table0%0/2
A
A= $current_line
Aresult
11
00
Truth table0%0/2
A
A= $DB::trace
Aresult
11
00
Truth table0%0/2
A
A= $DB::signal
Aresult
11
00
Truth table0%0/2
A
A= $old_db_single
Aresult
11
00
1545 $current_package // 'undef',
1546 $current_file_id // 'undef',
1547 $current_line // 'undef',
1548 $DB::trace // 'undef',
1549 $DB::signal // 'undef',
1550 $old_db_single // 'undef',
1551 ${^GLOBAL_PHASE}
1552 if $_dev_mode;
1553  
1554 0 ▶ _report $DB::dbline[$current_line] if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1555 0 ▶ _event_handler( $breakpoint ) unless $skip_event_handler;
Branch: 1 branch
BranchTrueFalseTotal
unless $skip_event_handler 0 0 0
1556  
1557 0 $_internal_process = 0;
1558 0 ($@, $!, $^E, $,, $/, $\, $^W) = @saved;
1559 0 @saved = ();
1560 0 ();
1561 }
1562  
1563 #
1564 # This is a hook for templating engines working using perl evals.
1565 # This hook should be invoked after evaluation of compiled template with template path
1566 # and map of lines template_line => compiled_source_line
1567 #
1568 # {
1569 # no strict 'refs';
1570 # my $glob = *{'::DB::template_handler'};
1571 #
1572 # if ($glob && *{$glob}{CODE})
1573 # {
1574 # *{$glob}{CODE}->($filepath, $lines_map);
1575 # }
1576 # }
1577 #
1578 #
1579 sub template_handler
1580 0 ▶{
Subroutine template_handler: not called CC=9 SCAR=45.0
Pod undocumented
1581 0 my ($real_path, $lines_map) = @_;
1582  
1583 0 my $last_eval_id = 0;
1584 0 my $eval_target;
1585 0 foreach my $main_key (keys %::)
1586 {
1587 0 ▶ if ($main_key =~ /^_<(\(eval (\d+)\).+?)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($main_key =~ /^_<(\(eval (\d+)\).+?)$/) 0 0 0
1588 {
1589 0 ▶ if ($last_eval_id < $2)
Branch: 1 branch
BranchTrueFalseTotal
if ($last_eval_id < $2) 0 0 0
1590 {
1591 0 $last_eval_id = $2;
1592 0 $eval_target = $1;
1593 }
1594 }
1595 }
1596  
1597 0 ▶ if ($last_eval_id)
Branch: 1 branch
BranchTrueFalseTotal
if ($last_eval_id) { } 0 0 0
1598 {
1599 0 $real_path = Cwd::realpath( $real_path );
1600  
1601 0 $_evals_to_templates_map{$eval_target} = {
1602 path => $real_path,
1603 lines_map => $lines_map
1604 };
1605 0 ▶ $_templates_to_evals_map{$real_path} //= {
Condition0%0/2
$_templates_to_evals_map{$real_path} //= {"lines_map", $lines_map, "evals", []}
l!l
00
MC/DC0%0/1
$_templates_to_evals_map{$real_path} //= {"lines_map", $lines_map, "evals", []}
$_templates_to_evals_map{$real_path}
Truth table0%0/2
A
A= $_templates_to_evals_map{$real_path}
Aresult
11
00
1606 lines_map => $lines_map,
1607 evals => [ ]
1608 };
1609 0 push @{$_templates_to_evals_map{$real_path}->{evals}}, $eval_target;
1610  
1611 0 delete $_file_name_sent{$eval_target}; # forces re-sending file descriptor
1612 0 ▶ _report "Mapped template: %s to eval %s", $real_path, $eval_target if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1613  
1614 0 $_queued_breakpoints_files{$eval_target} = 1;
1615 0 ▶ _set_break_points_for_files() if $ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
if $ready_to_go 0 0 0
1616 }
1617 else
1618 {
1619 0 ▶ _report "Unable to locate top level eval for %s", $real_path if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1620 }
1621 }
1622  
1623  
1624 # this pass-through flag handles quotation overload loop
1625 sub sub_handler
1626 0 ▶{
Subroutine sub_handler: not called CC=21 SCAR=58.5
Pod undocumented
1627 0 my $stack_frame = undef;
1628  
1629 0 my $old_db_single = $DB::single;
1630 0 my $wantarray = wantarray;
1631  
1632 0 ▶ if (!$_internal_process)
Branch: 1 branch
BranchTrueFalseTotal
unless ($_internal_process) 0 0 0
1633 {
1634 0 $_internal_process = 1;
1635  
1636 0 ▶ _process_command( _get_next_command ) while $_enable_noninteractive_mode && _can_read;
Branch: 1 branch
BranchTrueFalseTotal
$_enable_noninteractive_mode and _can_read() and do { _process_command(_get_next_command()) } 0 0 0
Condition0%0/3
$_enable_noninteractive_mode and _can_read()
!ll&&!rl&&r
000
MC/DC0%0/2
$_enable_noninteractive_mode and _can_read()
$_enable_noninteractive_mode _can_read()
Truth table0%0/3
A and B
A= $_enable_noninteractive_modeB= _can_read()
ABresult
0X0
100
111
1637 0 $old_db_single = $DB::single; # might be overriden in commands
1638  
1639 0 $DB::single = STEP_CONTINUE;
1640  
1641 0 $stack_frame = _enter_frame( $old_db_single, $wantarray );
1642  
1643 0 ▶ if ($current_package && $current_package eq 'DB')
Branch: 1 branch
BranchTrueFalseTotal
if ($current_package and $current_package eq "DB") 0 0 0
Condition0%0/3
$current_package and $current_package eq "DB"
!ll&&!rl&&r
000
MC/DC0%0/2
$current_package and $current_package eq "DB"
$current_package $current_package eq "DB"
Truth table0%0/3
A and B
A= $current_packageB= $current_package eq "DB"
ABresult
0X0
100
111
1644 {
1645 0 ▶ _report "PANIC: Catched internal call" if $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_dev_mode 0 0 0
1646 0 ▶ _dump_stack && _dump_frames();
Branch: 1 branch
BranchTrueFalseTotal
_dump_stack() and _dump_frames() 0 0 0
1647 0 die;
1648 }
1649  
1650 0 $DB::single = $old_db_single;
1651 0 $_internal_process = 0;
1652 }
1653  
1654 0 my $stack_pointer = $#$_stack_frames;
1655  
1656 0 ▶ if ($DB::single == STEP_OVER)
Branch: 1 branch
BranchTrueFalseTotal
if ($DB::single == 2) { } 0 0 0
1657 {
1658 _report "Disabling step in in subcalls, will restore %s\n",
1659 $_stack_frames->[-1]->{single}
1660 0 ▶ if $_debug_sub_handler && $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $_debug_sub_handler and $_dev_mode 0 0 0
Condition0%0/3
$_debug_sub_handler and $_dev_mode
!ll&&!rl&&r
000
MC/DC0%0/2
$_debug_sub_handler and $_dev_mode
$_debug_sub_handler $_dev_mode
Truth table0%0/3
A and B
A= $_debug_sub_handlerB= $_dev_mode
ABresult
0X0
100
111
1661 0 $DB::single = STEP_CONTINUE;
1662  
1663 # my $die_handler = $SIG{__DIE__};
1664 # local $SIG{__DIE__} = sub{
1665 # _hold_the_line;
1666 # goto &$die_handler if $die_handler;
1667 # };
1668 }
1669 else
1670 {
1671 0 ▶ _report "Keeping step as %s\n", $old_db_single if $stack_frame && $_debug_sub_handler && $_dev_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $stack_frame and $_debug_sub_handler and $_dev_mode 0 0 0
Condition0%0/6
$stack_frame and $_debug_sub_handler and $_dev_mode
!ll&&!rl&&r
000
$stack_frame and $_debug_sub_handler
!ll&&!rl&&r
000
MC/DC0%0/3
$stack_frame and $_debug_sub_handler and $_dev_mode
$stack_frame $_debug_sub_handler $_dev_mode
Truth table0%0/4
A and B and C
A= $stack_frameB= $_debug_sub_handlerC= $_dev_mode
ABCresult
0XX0
10X0
1100
1111
1672 }
1673  
1674 0 ▶ if ($DB::sub eq 'DESTROY' or substr( $DB::sub, -9 ) eq '::DESTROY' or !defined $wantarray)
Branch: 2 branches
BranchTrueFalseTotal
if ($DB::sub eq 'DESTROY' or substr($DB::sub, -9) eq '::DESTROY' or not defined $wantarray) { } 0 0 0
elsif ($wantarray) { } 0 0 0
Condition0%0/6
$DB::sub eq "DESTROY" or substr($DB::sub, -9) eq "::DESTROY" or not defined $wantarray
l!l&&r!l&&!r
000
$DB::sub eq "DESTROY" or substr($DB::sub, -9) eq "::DESTROY"
l!l&&r!l&&!r
000
MC/DC0%0/3
$DB::sub eq "DESTROY" or substr($DB::sub, -9) eq "::DESTROY" or not defined $wantarray
$DB::sub eq "DESTROY" substr($DB::sub, -9) eq "::DESTROY" not defined $wantarray
Truth table0%0/4
A or B or not(C)
A= $DB::sub eq "DESTROY"B= substr($DB::sub, -9) eq "::DESTROY"C= not defined $wantarray
ABCresult
1XX1
01X1
0011
0000
1675 {
1676 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1677 0 &$DB::sub;
1678 0 $#$_stack_frames = $stack_pointer;
1679 0 ▶ if ($stack_frame)
Branch: 1 branch
BranchTrueFalseTotal
if ($stack_frame) { } 0 0 0
1680 {
1681 0 _exit_frame();
1682 }
1683 else
1684 {
1685 0 $DB::single = $old_db_single;
1686 }
1687  
1688 0 $DB::ret = undef; # return value
1689 }
1690 elsif ($wantarray)
1691 {
1692 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1693 0 my @result = &$DB::sub;
1694 0 $#$_stack_frames = $stack_pointer;
1695 0 ▶ if ($stack_frame)
Branch: 1 branch
BranchTrueFalseTotal
if ($stack_frame) { } 0 0 0
1696 {
1697 0 _exit_frame();
1698 }
1699 else
1700 {
1701 0 $DB::single = $old_db_single;
1702 }
1703 0 @DB::ret = @result; # return value
1704 }
1705 else
1706 {
1707 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1708 0 my $result = &$DB::sub;
1709 0 $#$_stack_frames = $stack_pointer;
1710 0 ▶ if ($stack_frame)
Branch: 1 branch
BranchTrueFalseTotal
if ($stack_frame) { } 0 0 0
1711 {
1712 0 _exit_frame();
1713 }
1714 else
1715 {
1716 0 $DB::single = $old_db_single;
1717 }
1718 0 $DB::ret = $result; # return value
1719 }
1720 }
1721  
1722 # If the call is to an lvalue subroutine, and &DB::lsub is defined &DB::lsub (args) is called instead, otherwise
1723 # falling back to &DB::sub (args).
1724 #sub lsub_handler: lvalue
1725 #{
1726 # my $stack_frame = undef;
1727 #
1728 # my $old_db_single = $DB::single;
1729 # if (!$_internal_process)
1730 # {
1731 # $_internal_process = 1;
1732 #
1733 # $DB::single = STEP_CONTINUE;
1734 # $stack_frame = _enter_frame( $old_db_single );
1735 #
1736 # $DB::single = $old_db_single;
1737 # $_internal_process = 0;
1738 # }
1739 #
1740 # if ($DB::single == STEP_OVER)
1741 # {
1742 # _report "Disabling step in in subcalls\n" if $_dev_mode;
1743 # $DB::single = STEP_CONTINUE;
1744 # }
1745 # else
1746 # {
1747 # _report "Keeping step as %s\n", $old_db_single if $stack_frame if $_dev_mode;
1748 # }
1749 #
1750 # {
1751 # no strict 'refs';
1752 # my $result = &$DB::sub;
1753 # if ($stack_frame)
1754 # {
1755 # _exit_frame();
1756 # }
1757 # else
1758 # {
1759 # $DB::single = $old_db_single;
1760 # }
1761 # return $DB::ret = $result;
1762 # }
1763 #}
1764  
1765  
1766 # After each required file is compiled, but before it is executed, DB::postponed(*{"::_<$filename"}) is called if the
1767 # subroutine DB::postponed exists. Here, the $filename is the expanded name of the required file, as found in the values
1768 # of %INC.
1769 #
1770 # After each subroutine subname is compiled, the existence of $DB::postponed{subname} is checked. If this key exists,
1771 # DB::postponed(subname) is called if the DB::postponed subroutine also exists.
1772 sub load_handler
1773 0 ▶{
Subroutine load_handler: not called CC=7 SCAR=40.3
Pod undocumented
1774 0 my $old_db_single = $DB::single;
1775 0 $DB::single = STEP_CONTINUE;
1776  
1777 0 my $old_internal_process = $_internal_process;
1778 0 $_internal_process = 1;
1779  
1780 0 my $perl_file_id = $_[0];
1781 0 my $real_path = _get_real_path_by_perl_file_id( $perl_file_id );
1782  
1783 0 ▶ _report "Loading module: %s => %s %s-%s-%s",
Branch: 1 branch
BranchTrueFalseTotal
if $_debug_load_handler and $_dev_mode 0 0 0
Condition0%0/9
$_debug_load_handler and $_dev_mode
!ll&&!rl&&r
000
$DB::trace // "undef"
l!l
00
$DB::signal // "undef"
l!l
00
$old_db_single // "undef"
l!l
00
MC/DC0%0/2
$_debug_load_handler and $_dev_mode
$_debug_load_handler $_dev_mode
MC/DC0%0/1
$DB::trace // "undef"
$DB::trace
MC/DC0%0/1
$DB::signal // "undef"
$DB::signal
MC/DC0%0/1
$old_db_single // "undef"
$old_db_single
Truth table0%0/3
A and B
A= $_debug_load_handlerB= $_dev_mode
ABresult
0X0
100
111
Truth table0%0/2
A
A= $DB::trace
Aresult
11
00
Truth table0%0/2
A
A= $DB::signal
Aresult
11
00
Truth table0%0/2
A
A= $old_db_single
Aresult
11
00
1784 $perl_file_id,
1785 $real_path,
1786 $DB::trace // 'undef',
1787 $DB::signal // 'undef',
1788 $old_db_single // 'undef',
1789 if $_debug_load_handler && $_dev_mode
1790 ;
1791  
1792 0 ▶ _set_break_points_for_files() if $ready_to_go;
Branch: 1 branch
BranchTrueFalseTotal
if $ready_to_go 0 0 0
1793  
1794 0 $_internal_process = $old_internal_process;
1795  
1796 0 $DB::single = $old_db_single;
1797 }
1798 # When execution of the program uses goto to enter a non-XS subroutine and the 0x80 bit is set in $^P , a call to
1799 # &DB::goto is made, with $DB::sub holding the name of the subroutine being entered.
1800 #$^P |= FLAG_REPORT_GOTO;
1801 #sub goto_handler
1802 #{
1803 # return if $_internal_process;
1804 # $_internal_process = 1;
1805 #
1806 # my $old_db_single = $DB::single;
1807 # $DB::single = STEP_CONTINUE;
1808 #
1809 # _report "Goto called%s from %s-%s-%s-%s",
1810 # scalar @_ ? ' with '.(join ',', @_) : '',
1811 # $DB::trace // 'undef',
1812 # $DB::signal // 'undef',
1813 # $old_db_single // 'undef',
1814 # ${^GLOBAL_PHASE} // 'unknown',
1815 # if $_dev_mode;
1816 # $DB::single = $old_db_single;
1817 # $_internal_process = 0;
1818 #}
1819  
1820 1 ▶unless ($ENV{PERL5_DEBUG_ROLE} && $ENV{PERL5_DEBUG_HOST} && $ENV{PERL5_DEBUG_PORT})
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"PERL5_DEBUG_ROLE"} and $ENV{"PERL5_DEBUG_HOST"} and $ENV{"PERL5_DEBUG_PORT"}) 0 1 1
Condition33%2/6
$ENV{"PERL5_DEBUG_ROLE"} and $ENV{"PERL5_DEBUG_HOST"} and $ENV{"PERL5_DEBUG_PORT"}
!ll&&!rl&&r
001
$ENV{"PERL5_DEBUG_ROLE"} and $ENV{"PERL5_DEBUG_HOST"}
!ll&&!rl&&r
001
MC/DC0%0/3
$ENV{"PERL5_DEBUG_ROLE"} and $ENV{"PERL5_DEBUG_HOST"} and $ENV{"PERL5_DEBUG_PORT"}
$ENV{"PERL5_DEBUG_ROLE"} $ENV{"PERL5_DEBUG_HOST"} $ENV{"PERL5_DEBUG_PORT"}
Truth table25%1/4
A and B and C
A= $ENV{"PERL5_DEBUG_ROLE"}B= $ENV{"PERL5_DEBUG_HOST"}C= $ENV{"PERL5_DEBUG_PORT"}
ABCresult
0XX0
10X0
1100
1111
1821 {
1822 0 ▶ printf STDERR <<'EOM', map $_ // 'undefined', @ENV{qw/PERL5_DEBUG_ROLE PERL5_DEBUG_HOST PERL5_DEBUG_PORT/};
Condition0%0/2
$_ // "undefined"
l!l
00
MC/DC0%0/1
$_ // "undefined"
$_
Truth table0%0/2
A
A= $_
Aresult
11
00
1823 Can't start debugging session. In order to make it work, you should set up environment variables:
1824  
1825 PERL5_DEBUG_ROLE - set this to 'server' if you want to make Perl process act as a server, and to 'client' to make it connect to IDEA.
1826 PERL5_DEBUG_HOST - host to bind or connect, depending on role.
1827 PERL5_DEBUG_PORT - host to listen or connect, depending on role.
1828  
1829 Atm we've got:
1830 PERL5_DEBUG_ROLE=%s
1831 PERL5_DEBUG_HOST=%s
1832 PERL5_DEBUG_PORT=%s
1833 EOM
1834  
1835 0 exit;
1836 }
1837  
1838 1 ▶my $_connect_at_start = exists $ENV{PERL5_DEBUG_AUTOSTART} ? $ENV{PERL5_DEBUG_AUTOSTART} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'PERL5_DEBUG_AUTOSTART'} ? : 1 0 1
1839  
1840 sub is_connected
1841 0 ▶{
Subroutine is_connected: not called CC=1 SCAR=6.9
Pod undocumented
1842 0 return !!$_debug_socket;
1843 }
1844  
1845 sub _connect
1846 0 ▶{
Subroutine _connect: not called CC=10 SCAR=47.0
1847 0 my $_perl5_debug_host = $ENV{PERL5_DEBUG_HOST};
1848 0 my $_perl5_debug_port = $ENV{PERL5_DEBUG_PORT};
1849  
1850 # ${^TAINT} will be truthy if taint mode is on.
1851 0 ▶ if (${^TAINT})
Branch: 1 branch
BranchTrueFalseTotal
if (${^TAINT}) 0 0 0
1852 {
1853 # The debugger will fail with "Insecure dependency in connect..."
1854 # if we do not untaint the host and port variables, so we do so here.
1855 0 ($_perl5_debug_host) = $_perl5_debug_host =~ /(.*)/;
1856 0 ($_perl5_debug_port) = $_perl5_debug_port =~ /(.*)/;
1857 }
1858  
1859 0 my ($attempts, $allow_fail) = @_;
1860 # http://perldoc.perl.org/perlipc.html#Sockets%3a-Client%2fServer-Communication
1861 0 ▶ if ($ENV{PERL5_DEBUG_ROLE} eq 'server')
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PERL5_DEBUG_ROLE'} eq 'server') { } 0 0 0
1862 {
1863 0 printf STDERR "Listening for the IDE connection at %s:%s...\n", $_perl5_debug_host, $_perl5_debug_port;
1864 0 ▶ my $_server_socket = IO::Socket::INET->new(
Condition0%0/2
'IO::Socket::INET'->new('Listen', 1, 'LocalAddr', $_perl5_debug_host, 'LocalPort', $_perl5_debug_port, 'ReuseAddr', 1, 'Proto', 'tcp') || die("Error binding to ${_perl5_debug_host}:$_perl5_debug_port")
l!l
00
MC/DC0%0/1
'IO::Socket::INET'->new('Listen', 1, 'LocalAddr', $_perl5_debug_host, 'LocalPort', $_perl5_debug_port, 'ReuseAddr', 1, 'Proto', 'tcp') || die("Error binding to ${_perl5_debug_host}:$_perl5_debug_port")
'IO::Socket::INET'->new('Listen', 1, 'LocalAddr', $_perl5_debug_host, 'LocalPort', $_perl5_debug_port, 'ReuseAddr', 1, 'Proto', 'tcp')
Truth table0%0/2
A
A= 'IO::Socket::INET'->new('Listen', 1, 'LocalAddr', $_perl5_debug_host, 'LocalPort', $_perl5_debug_port, 'ReuseAddr', 1, 'Proto', 'tcp')
Aresult
11
00
1865 Listen => 1,
1866 LocalAddr => $_perl5_debug_host,
1867 LocalPort => $_perl5_debug_port,
1868 ReuseAddr => 1,
1869 Proto => 'tcp',
1870 ) || die "Error binding to ${_perl5_debug_host}:${_perl5_debug_port}";
1871 0 $_debug_packed_address = accept( $_debug_socket, $_server_socket );
1872 }
1873 else
1874 {
1875 0 foreach my $attempt (1 .. $attempts)
1876 {
1877 0 printf STDERR "($attempt)Connecting to the IDE from process %s at %s:%s...\n", $$, ${_perl5_debug_host},
1878 ${_perl5_debug_port};
1879 0 $_debug_socket = IO::Socket::INET->new(
1880 PeerAddr => $_perl5_debug_host,
1881 PeerPort => $_perl5_debug_port,
1882 ReuseAddr => 1,
1883 Proto => 'tcp',
1884 );
1885 0 ▶ last if $_debug_socket || $attempt == $attempts;
Branch: 1 branch
BranchTrueFalseTotal
if $_debug_socket or $attempt == $attempts 0 0 0
Condition0%0/3
$_debug_socket or $attempt == $attempts
l!l&&r!l&&!r
000
MC/DC0%0/2
$_debug_socket or $attempt == $attempts
$_debug_socket $attempt == $attempts
Truth table0%0/3
A or B
A= $_debug_socketB= $attempt == $attempts
ABresult
1X1
011
000
1886 0 sleep( 1 ); # this is kinda hacky
1887 }
1888 0 ▶ die "Error connecting to ${_perl5_debug_host}:${_perl5_debug_port}" if !$_debug_socket && !$allow_fail;
Branch: 1 branch
BranchTrueFalseTotal
unless $_debug_socket or $allow_fail 0 0 0
Condition0%0/3
$_debug_socket or $allow_fail
l!l&&r!l&&!r
000
MC/DC0%0/2
$_debug_socket or $allow_fail
$_debug_socket $allow_fail
Truth table0%0/3
A or B
A= $_debug_socketB= $allow_fail
ABresult
1X1
011
000
1889 }
1890 0 ▶ _set_up_after_connect( $allow_fail ) if $_debug_socket;
Branch: 1 branch
BranchTrueFalseTotal
if $_debug_socket 0 0 0
1891 }
1892  
1893 sub connect
1894 0 ▶{
Subroutine connect: not called CC=1 SCAR=6.9
Pod undocumented
1895 0 _connect( 1, 1 );
1896 }
1897  
1898 sub disconnect
1899 0 ▶{
Subroutine disconnect: not called CC=2 SCAR=17.9
Pod undocumented
1900 0 ▶ return unless is_connected();
Branch: 1 branch
BranchTrueFalseTotal
unless is_connected() 0 0 0
1901 0 $_debug_socket->close();
1902 0 undef $_debug_socket_select;
1903 0 undef $_debug_socket;
1904 0 $ready_to_go = 0;
1905 }
1906  
1907 sub connect_or_reconnect
1908 0 ▶{
Subroutine connect_or_reconnect: not called CC=2 SCAR=17.9
Pod undocumented
1909 0 ▶ disconnect() if is_connected();
Branch: 1 branch
BranchTrueFalseTotal
if is_connected() 0 0 0
1910 0 _connect( 1, 1 );
1911 }
1912  
1913 # we want disable() to completely bypass the debugger (except for the parts
1914 # which are required for bookkeeping, like DB::postponed)
1915 #
1916 # setting %^P can disable DB::DB, but the only way to disable DB::sub is to
1917 # make sure *DB::sub{CODE} is undef, while keeping %DB::sub and $DB::sub
1918 # intact; the only way to do that is to save the glob slots we want to
1919 # preserve, undef the glob and then restore the slots
1920 #
1921 # DB::lsub and DB::goto are easier, because we don't need to preserve the
1922 # corresponding scalar/array/hash variables
1923 1 my (%_orig_db_sub, %_disabled_db_sub, $_orig_db_lsub);
1924  
1925 BEGIN
1926 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
1927 %_orig_db_sub = %_disabled_db_sub = map {
1928 1 ($_ => *DB::sub{$_}) x !!*DB::sub{$_}
1929 } qw(SCALAR ARRAY HASH);
1930 1 $_orig_db_sub{CODE} = \&sub_handler;
1931 1 $_orig_db_lsub = undef; # \&lsub_handler
1932 }
1933  
1934 sub enable
1935 0 ▶{
Subroutine enable: not called CC=2 SCAR=17.9
Pod undocumented
1936 0 $^P = DEBUG_DEFAULT_FLAGS;
1937 0 undef *DB::sub;
1938 0 *DB::sub = $_orig_db_sub{$_} for keys %_orig_db_sub;
1939 #*DB::lsub = $_orig_db_lsub;
1940 #*DB::goto = \&goto_handler;
1941 }
1942  
1943 sub disable
1944 0 ▶{
Subroutine disable: not called CC=2 SCAR=17.9
Pod undocumented
1945 0 $DB::single = 0;
1946 0 $^P = DEBUG_PREPARE_FLAGS;
1947 0 undef *DB::sub;
1948 0 undef *DB::lsub;
1949 0 undef *DB::goto;
1950 0 *DB::sub = $_disabled_db_sub{$_} for keys %_disabled_db_sub;
1951 }
1952  
1953 1 push @$_stack_frames, {
1954 subname => 'SCRIPT',
1955 file => $current_file_id,
1956 current_line => $current_line,
1957 single => STEP_INTO,
1958 };
1959  
1960 1 ▶_dump_stack && _dump_frames if $trace_code_stack_and_frames;
Branch: 1 branch
BranchTrueFalseTotal
if $trace_code_stack_and_frames 0 1 1
Condition20%1/5
$trace_code_stack_and_frames && (_dump_stack() && _dump_frames())
!ll
10
_dump_stack() and _dump_frames()
!ll&&!rl&&r
000
MC/DC0%0/3
$trace_code_stack_and_frames && (_dump_stack() && _dump_frames())
$trace_code_stack_and_frames _dump_stack() _dump_frames()
Truth table0%0/4
A && B and C
A= $trace_code_stack_and_framesB= _dump_stack()C= _dump_frames()
ABCresult
0XX0
10X0
1100
1111
1961  
1962 1 $_internal_process = 1;
1963  
1964 1 require Cwd;
1965 1 Cwd::getcwd();
1966 1 require B::Deparse;
1967 1 require JSON::XS;
1968  
1969 1 $frame_prefix = $frame_prefix_step;
1970  
1971 1 foreach my $main_key (keys %::)
1972 {
1973 328 ▶ if ($main_key =~ /_<(.+)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($main_key =~ /_<(.+)/) 158 170 328
1974 {
1975 158 _get_real_path_by_normalized_perl_file_id( $1 );
1976 }
1977 }
1978  
1979 1 *DB::DB = \&step_handler;
1980 1 *DB::postponed = \&load_handler;
1981  
1982 1 ▶if ($_connect_at_start)
Branch: 1 branch
BranchTrueFalseTotal
if ($_connect_at_start) 0 1 1
1983 {
1984 0 _connect( 10, 0 );
1985 0 enable();
1986 }
1987  
1988 1 $_internal_process = 0;
1989  
1990 1 1; # End of Devel::Camelcadedb
↑ Summary