blib/lib/dbgp-helper/perl5db.pl

filter: Statementstmt 0.0% 0 / 1655 Branchbran 0.0% 0 / 1130 Conditioncond 0.0% 0 / 455 MC/DCmcdc 0.0% 0 / 277 Subroutinesub 0.0% 0 / 78 Podpod 0.0% 0 / 70 totaltotal 0.0% 0 / 3665 CC 738 SCAR 109.5
CC
738
Cov
0%
DB
129240.0
parse_options
1332.0
eval
812.0
CRAP 57088.5
↑ Summary blib/lib/dbgp-helper/DB/Data/Dump.pm »
1 # perl5db.pl
2 #
3 # Modified version of PerlDB.pl, for use with the ActiveState
4 # debugger protocol, DBGp
5 # See http://aspn.activestate.com/ASPN/DBGP for more info.
6 #
7 # Copyright (c) 1998-2006 ActiveState Software Inc.
8 # All rights reserved.
9 #
10 # Xdebug compatibility, UNIX domain socket support and misc fixes
11 # by Mattia Barbon <mattia@barbon.org>
12 #
13 # This software (the Perl-DBGP package) is covered by the Artistic License
14 # (http://www.opensource.org/licenses/artistic-license.php).
15  
16  
17 # Start with some lengthy, unattributed comments from perl5db.pl
18  
19 =head2 REMOTE DEBUGGING
20  
21 Copy the following files from a Komodo installation to
22 the target system
23  
24 <Komodo InstallDir>/perllib/* <TargetDir>
25  
26 Set the following shell variables. On Windows use C<set>
27 instead of C<export>, use double-quoting instead of
28 single-quoting, and use backslashes instead of forward-slashes.
29  
30 export PERLDB_OPTS=RemotePort=hostname:port
31 export PERL5DB='BEGIN { require q(<TargetDir>/perl5db.pl) }'
32 export PERL5LIB=<TargetDir>
33 export DBGP_IDEKEY="username"
34  
35 =cut
36  
37 =head2 FLAGS, FLAGS, FLAGS
38  
39 There is a certain C programming legacy in the debugger. Some variables,
40 such as C<$single>, C<$trace>, and C<$frame>, have "magical" values composed
41 of 1, 2, 4, etc. (powers of 2) OR'ed together. This allows several pieces
42 of state to be stored independently in a single scalar.
43  
44 =head4 C<$signal>
45  
46 Used to track whether or not an C<INT> signal has been detected. C<DB::DB()>,
47 which is called before every statement, checks this and puts the user into
48 command mode if it finds C<$signal> set to a true value.
49  
50 =head4 C<$single>
51  
52 Controls behavior during single-stepping. Stacked in C<@stack> on entry to
53 each subroutine; popped again at the end of each subroutine.
54  
55 =over 4
56  
57 =item * 0 - run continuously.
58  
59 =item * 1 - single-step, go into subs. The 's' command.
60  
61 =item * 2 - single-step, don't go into subs. The 'n' command.
62  
63 =item * 4 - print current sub depth (turned on to force this when "too much
64 recursion" occurs.
65  
66 =back
67  
68 =head4 C<@saved>
69  
70 Saves important globals (C<$@>, C<$!>, C<$^E>, C<$,>, C<$/>, C<$\>, C<$^W>)
71 so that the debugger can substitute safe values while it's running, and
72 restore them when it returns control.
73  
74 =head4 C<@stack>
75  
76 Saves the current value of C<$single> on entry to a subroutine.
77 Manipulated by the C<c> command to turn off tracing in all subs above the
78 current one.
79  
80 =head4 C<%dbline>
81  
82 Keys are line numbers, values are "condition\0action". If used in numeric
83 context, values are 0 if not breakable, 1 if breakable, no matter what is
84 in the actual hash entry.
85  
86 =cut
87  
88 =head1 DEBUGGER INITIALIZATION
89  
90 The debugger\'s initialization actually jumps all over the place inside this
91 package. This is because there are several BEGIN blocks (which of course
92 execute immediately) spread through the code. Why is that?
93  
94 The debugger needs to be able to change some things and set some things up
95 before the debugger code is compiled; most notably, the C<$deep> variable that
96 C<DB::sub> uses to tell when a program has recursed deeply. In addition, the
97 debugger has to turn off warnings while the debugger code is compiled, but then
98 restore them to their original setting before the program being debugged begins
99 executing.
100  
101 The first C<BEGIN> block simply turns off warnings by saving the current
102 setting of C<$^W> and then setting it to zero. The second one initializes
103 the debugger variables that are needed before the debugger begins executing.
104 The third one puts C<$^X> back to its former value.
105  
106 We'll detail the second C<BEGIN> block later; just remember that if you need
107 to initialize something before the debugger starts really executing, that's
108 where it has to go.
109  
110 =cut
111  
112 package DB;
113  
114 sub DB {}
115 BEGIN {
116 # kill the empty sub installed by Enbugger
117 my ($scalar, $array, $hash) = (*DB::sub{SCALAR}, *DB::sub{ARRAY}, *DB::sub{HASH});
118 undef *DB::sub;
119 *DB::sub = $scalar; *DB::sub = $array; *DB::sub = $hash;
120 }
121  
122 sub DEBUG_ALL() { 0x7ff }
123 sub DEBUG_SINGLE_STEP_ON() { 0x20 }
124 sub DEBUG_USE_SUB_ADDRESS() { 0x40 }
125 sub DEBUG_REPORT_GOTO() { 0x80 }
126 sub DEBUG_DEFAULT_FLAGS() # 0x73f
127 { DEBUG_ALL & ~(DEBUG_USE_SUB_ADDRESS|DEBUG_REPORT_GOTO) }
128 sub DEBUG_PREPARE_FLAGS() # 0x73c
129 { DEBUG_ALL & ~(DEBUG_USE_SUB_ADDRESS|DEBUG_REPORT_GOTO|DEBUG_SINGLE_STEP_ON) }
130  
131 sub DB_RECURSIVE_DEBUG() { 0x40000000 }
132  
133 # 'my' variables used here could leak into (that is, be visible in)
134 # the context that the code being evaluated is executing in. This means that
135 # the code could modify the debugger's variables.
136 #
137 # Fiddling with the debugger's context could be Bad. We insulate things as
138 # much as we can.
139  
140 sub eval {
141  
142 # 'my' would make it visible from user code
143 # but so does local! --tchrist
144 # Remember: this localizes @DB::res, not @main::res.
145 0 ▶ local @res;
Subroutine eval: not called CC=28 SCAR=67.0
Pod undocumented
146 {
147 # Try to keep the user code from messing with us. Save these so that
148 # even if the eval'ed code changes them, we can put them back again.
149 # Needed because the user could refer directly to the debugger's
150 # package globals (and any 'my' variables in this containing scope)
151 # inside the eval(), and we want to try to stay safe.
152 0 local $otrace = $trace;
153 0 local $osingle = $single;
154 0 local $od = $^D;
155 0 local $op = $^P;
156 0 local ($^W) = 0; # Switch run-time warnings off during eval.
157  
158 # speed up evaluation if no recursive debugging is required
159 0 ▶ clobber_db_sub() unless $^D & DB_RECURSIVE_DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless $^D & 1073741824 0 0 0
160 0 ▶ $^P = DEBUG_PREPARE_FLAGS unless $^D & DB_RECURSIVE_DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless $^D & 1073741824 0 0 0
161  
162 # Untaint the incoming eval() argument.
163 0 { ($evalarg) = $evalarg =~ /(.*)/s; }
164  
165 # $usercontext built in DB::DB near the comment
166 # "set up the context for DB::eval ..."
167 # Evaluate and save any results.
168  
169 # Do this in case there are user args in the expression --
170 # pull them from the user's context.
171 0 local @_; # Clear each time.
172 0 local @unused = caller($evalSkipFrames);
173 0 local $additionalLevels = 0;
174 # first term is for the extra stack frame of pure-Perl DB::sub
175 # second term is for eval BLOCK stack frames
176 0 ▶ local $notRealSubCall = $unused[0] eq 'DB' || ($unused[3] eq '(eval)' && !$unused[4]);
Condition0%0/6
$unused[0] eq 'DB' || $unused[3] eq '(eval)' && !$unused[4]
l!l&&r!l&&!r
000
$unused[3] eq "(eval)" and not $unused[4]
!ll&&!rl&&r
000
MC/DC0%0/3
$unused[0] eq 'DB' || $unused[3] eq '(eval)' && !$unused[4]
$unused[0] eq 'DB' $unused[3] eq "(eval)" not $unused[4]
Truth table0%0/4
A || B and not(C)
A= $unused[0] eq 'DB'B= $unused[3] eq "(eval)"C= not $unused[4]
ABCresult
1XX1
0111
00X0
0100
177 0 ▶ while ($evalStackLevel > 0 || $notRealSubCall) {
Branch: 1 branch
BranchTrueFalseTotal
if ($evalStackLevel > 0 or $notRealSubCall) 0 0 0
Condition0%0/3
$evalStackLevel > 0 or $notRealSubCall
l!l&&r!l&&!r
000
MC/DC0%0/2
$evalStackLevel > 0 or $notRealSubCall
$evalStackLevel > 0 $notRealSubCall
Truth table0%0/3
A or B
A= $evalStackLevel > 0B= $notRealSubCall
ABresult
1X1
011
000
178 0 ▶ $evalStackLevel-- if !$notRealSubCall;
Branch: 1 branch
BranchTrueFalseTotal
unless $notRealSubCall 0 0 0
179 0 $additionalLevels++;
180 0 @unused = caller($evalSkipFrames + $additionalLevels);
181 0 ▶ $notRealSubCall = $unused[0] eq 'DB' || ($unused[3] eq '(eval)' && !$unused[4]);
Condition0%0/6
$unused[0] eq 'DB' || $unused[3] eq '(eval)' && !$unused[4]
l!l&&r!l&&!r
000
$unused[3] eq "(eval)" and not $unused[4]
!ll&&!rl&&r
000
MC/DC0%0/3
$unused[0] eq 'DB' || $unused[3] eq '(eval)' && !$unused[4]
$unused[0] eq 'DB' $unused[3] eq "(eval)" not $unused[4]
Truth table0%0/4
A || B and not(C)
A= $unused[0] eq 'DB'B= $unused[3] eq "(eval)"C= not $unused[4]
ABCresult
1XX1
0111
00X0
0100
182 0 ▶ last unless @unused;
Branch: 1 branch
BranchTrueFalseTotal
unless @unused 0 0 0
183 }
184 0 ▶ if ($unused[4]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unused[4]) 0 0 0
185 # hasargs field is set -- an instance of @_ was set up.
186 0 eval { @_ = @args; };
187 0 ▶ @_ = () if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
188 }
189 0 ▶ my $usercontext2 = (($evalarg =~ /[\$\@\%]\w*[^\x00-\x7f]/)
Branch: 1 branch
BranchTrueFalseTotal
$evalarg =~ /[\$\@\%]\w*[^\x00-\x7f]/ ? : 0 0 0
190 ? "$usercontext use utf8; "
191 : $usercontext);
192 0 @res = eval "$usercontext2 $evalarg;\n"; # '\n' for nice recursive debug
193  
194 0 ▶ if ($ldebug) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ldebug) { } 0 0 0
elsif (not $@ and scalar @res == 1 and not defined $res[0]) { } 0 0 0
195 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) { } 0 0 0
elsif (scalar @res) { } 0 0 0
196 0 dblog("eval($evalarg) => exception [$@]\n");
197 } elsif (scalar @res) {
198 0 ▶ if (substr($evalarg, 0, 1) eq '%') {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($evalarg, 0, 1) eq '%') { } 0 0 0
elsif (scalar @res == 1 and not defined $res[0]) { } 0 0 0
199 0 dblog("eval($evalarg) => [hash val]\n");
200 ▶ } elsif (scalar @res == 1 && ! defined $res[0]) {
Condition0%0/3
scalar @res == 1 and not defined $res[0]
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @res == 1 and not defined $res[0]
scalar @res == 1 not defined $res[0]
Truth table0%0/3
A and not(B)
A= scalar @res == 1B= not defined $res[0]
ABresult
0X0
100
111
201 0 dblog("eval($evalarg) => (undef)\n");
202 0 $no_value = 1;
203 0 @res = ("");
204 } else {
205 0 my $str_out = join('', @res);
206 0 my $max_len = $settings{max_data}[0];
207 0 ▶ $max_len = 103 if $max_len > 103;
Branch: 1 branch
BranchTrueFalseTotal
if $max_len > 103 0 0 0
208 0 ▶ if (length($str_out) > $max_len) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $str_out > $max_len) 0 0 0
209 0 $str_out = substr($str_out, 0, $max_len - 3) . '...';
210 }
211 0 ▶ $str_out = nonXmlChar_Encode($str_out) unless ref $str_out;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $str_out 0 0 0
212 0 dblog("eval($evalarg) => <<$str_out>>\n");
213 }
214 } else {
215 0 dblog("eval($evalarg) => no value\n");
216 0 $no_value = 1;
217 0 @res = ("");
218 }
219 ▶ } elsif (!$@ && scalar @res == 1 && ! defined $res[0]) {
Condition0%0/6
not $@ and scalar @res == 1 and not defined $res[0]
!ll&&!rl&&r
000
not $@ and scalar @res == 1
!ll&&!rl&&r
000
MC/DC0%0/3
not $@ and scalar @res == 1 and not defined $res[0]
not $@ scalar @res == 1 not defined $res[0]
Truth table0%0/4
not(A) and B and not(C)
A= not $@B= scalar @res == 1C= not defined $res[0]
ABCresult
0XX0
10X0
1100
1111
220 0 $no_value = 1;
221 0 @res = ("");
222 }
223  
224 # Restore those old values.
225 0 $trace = $otrace;
226 0 $single = $osingle;
227 0 $^D = $od;
228 0 $^P = $op;
229 0 ▶ restore_db_sub() unless $^D & DB_RECURSIVE_DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless $^D & 1073741824 0 0 0
230 }
231  
232 # Save the current value of $@, and preserve it in the debugger's copy
233 # of the saved precious globals.
234 0 my $at = $@;
235  
236 # Since we're only saving $@, we only have to localize the array element
237 # that it will be stored in.
238 0 local $saved[0]; # Preserve the old value of $@
239 0 eval { &save };
240  
241 # Now see whether we need to report an error back to the user.
242 0 ▶ if ($at) {
Branch: 1 branch
BranchTrueFalseTotal
if ($at) 0 0 0
243 0 die $at;
244 }
245  
246 0 @res;
247 } ## end sub eval
248  
249 # moved here to avoid it seeing the lexical context
250 sub simple_eval {
251 0 ▶ eval $_[0];
Subroutine simple_eval: not called CC=1 SCAR=6.9
Pod undocumented
252 }
253  
254 use strict qw(vars subs);
255 use IO::Handle;
256  
257 # Debugger for Perl 5.00x; perl5db.pl patch level:
258 our $VERSION = 0.30;
259  
260 # $Log$
261  
262 =head1 DEBUGGER INITIALIZATION
263  
264 The debugger starts up in phases.
265  
266 =head2 BASIC SETUP
267  
268 First, it initializes the environment it wants to run in: turning off
269 warnings during its own compilation, defining variables which it will need
270 to avoid warnings later, setting itself up to not exit when the program
271 terminates, and defaulting to printing return values for the C<r> command.
272  
273 =cut
274  
275 our ($no_value, $evalarg, $usercontext, $evalSkipFrames, $evalStackLevel, @saved); # used by sub eval above
276  
277 our ($single, $trace, $signal, $sub, %sub, @args);
278 our ($ldebug); # it should be my (), as all other $ldebug around the code
279 my ($currentFilename, $currentLine);
280  
281 my ($pending_check_enabled, $pending_check_count, $pending_check_lim, $pending_check_timeout, $pending_check_interval, $skip_alarm, @pending_commands);
282  
283 my ($setup_once_after_connection, $ready, $ini_warn);
284 my %firstFileInfo;
285  
286 my (@stack, $deep);
287 our ($stack_depth, $level); # for local()
288  
289 BEGIN {
290 # Switch compilation warnings off until another BEGIN.
291 $ini_warn = $^W;
292 $^W = 0;
293  
294 #init $deep to avoid warning
295 # By default it doesn't stop.
296 $deep = -1;
297 $skip_alarm = 1;
298 # True if we're logging
299 $ldebug = 0;
300  
301 # uninitialized warning suppression
302 $signal = $single = $trace = 0;
303 # important stuff
304 @stack = (0);
305 $stack_depth = 0; # Localized repeatedly; simple way to track $#stack
306 $level = 0;
307 $evalSkipFrames = $evalStackLevel = 0;
308 }
309  
310 local ($^W) = 0; # Switch run-time warnings off during init.
311  
312 # more stuff
313 require Config;
314  
315 # We set these variables to safe values. We don't want to blindly turn
316 # off warnings, because other packages may still want them.
317 my ($finished, $runnonstop, $fall_off_end) = (0, 0, 0);
318  
319 our ($inPostponed) = (0); # because of local()
320 my @postponedFiles;
321  
322 =head1 DEBUGGER SETTINGS
323  
324 Keep track of the various settings in this hash
325  
326 =cut
327  
328 use DB::DbgrCommon;
329 use DB::DbgrProperties;
330 use DB::DbgrContext;
331 use DB::DbgrXS;
332  
333 my %supportedCommands = (
334 status => 1,
335 feature_get => 1,
336 feature_set => 1,
337 run => 1,
338 step_into => 1,
339 step_over => 1,
340 step_out => 1,
341 stop => 1, #xxxstop
342 detach => 1,
343 breakpoint_set => 1,
344 breakpoint_get => 1,
345 breakpoint_update => 1,
346 breakpoint_remove => 1,
347 breakpoint_list => 1,
348 stack_depth => 1,
349 stack_get => 1,
350 context_names => 1,
351 context_get => 1,
352 typemap_get => 1,
353 property_get => 1,
354 property_set => 1,
355 property_value => 1,
356 source => 1,
357 stdout => 1,
358 stderr => 1,
359 stdin => 0,
360 break => 0,
361 'eval' => 1,
362 interact => 0,
363 );
364  
365 # Feature name => [bool(3): is supported, is settable, has associated value]
366 my %supportedFeatures = (
367 encoding => [1, 1, 1],
368 data_encoding => [1, 1, 1],
369 max_children => [1, 1, 1],
370 max_data => [1, 1, 1],
371 max_depth => [1, 1, 1],
372 multiple_sessions => [0, 0, 0],
373 language_supports_threads => [0, 0, 0],
374 language_name => [1, 0, 1],
375 language_version => [1, 0, 1],
376 protocol_version => [1, 0, 1],
377 supports_async => [0, 0, 0],
378 multiple_sessions => [0, 0, 0],
379 );
380  
381 # Feature name => [value, allowed settable values, if constrained]
382  
383 # this is shared with DB::DbgrCommon and DB::DbgrProperties via exporting
384 %settings = (
385 encoding => ['UTF-8', ['UTF-8', 'iso-8859-1']],
386 # binary and 'none' are the same
387 data_encoding => ['base64', [qw(urlescape base64 none binary)]],
388 max_children => [10, 1],
389 max_data => [32767, 1],
390 max_depth => [1, 1],
391 language_name => ['Perl'],
392 language_version => [sprintf("%vd", $^V)],
393 protocol_version => ['1.0'],
394 );
395  
396 sub xsdNamespace() {
397 0 ▶ return q(xmlns:xsd="http://www.w3.org/2001/XMLSchema");
Subroutine xsdNamespace: not called CC=1 SCAR=6.9
Pod undocumented
398 }
399  
400 sub xsiNamespace() {
401 0 ▶ return q(xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance");
Subroutine xsiNamespace: not called CC=1 SCAR=6.9
Pod undocumented
402 }
403  
404 sub decodeData($;$) {
405 0 ▶ my ($str, $encoding) = @_;
Subroutine decodeData: not called CC=10 SCAR=47.0
Pod undocumented
406 0 my $finalStr;
407 0 ▶ my $currDataEncoding = defined $encoding ? $encoding : $settings{data_encoding}->[0];
Branch: 1 branch
BranchTrueFalseTotal
defined $encoding ? : 0 0 0
408 0 $finalStr = $str;
409 0 eval {
410 0 ▶ if ($currDataEncoding eq 'none' || $currDataEncoding eq 'binary') {
Branch: 3 branches
BranchTrueFalseTotal
if ($currDataEncoding eq 'none' or $currDataEncoding eq 'binary') { } 0 0 0
elsif ($currDataEncoding eq 'urlescape') { } 0 0 0
elsif ($currDataEncoding eq 'base64') { } 0 0 0
Condition0%0/3
$currDataEncoding eq "none" or $currDataEncoding eq "binary"
l!l&&r!l&&!r
000
MC/DC0%0/2
$currDataEncoding eq "none" or $currDataEncoding eq "binary"
$currDataEncoding eq "none" $currDataEncoding eq "binary"
Truth table0%0/3
A or B
A= $currDataEncoding eq "none"B= $currDataEncoding eq "binary"
ABresult
1X1
011
000
411 0 $finalStr = $str;
412 } elsif ($currDataEncoding eq 'urlescape') {
413 0 $finalStr = DB::CGI::Util::unescape($str);
414 } elsif ($currDataEncoding eq 'base64') {
415 0 $finalStr = DB::MIME::Base64::decode_base64($str);
416 } else {
417 0 ▶ dblog("Converting $str with unknown encoding of $currDataEncoding\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
418 0 $finalStr = $str;
419 }
420 };
421 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
422 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
423 # Log the string that caused problems.
424 0 ▶ $str = (substr($str, 0, 100) . '...') if length($str) > 100;
Branch: 1 branch
BranchTrueFalseTotal
if length $str > 100 0 0 0
425 0 dblog("decodeData($str) => [$@]\n");
426 }
427 }
428 0 return $finalStr;
429 }
430  
431 my $fakeFirstStepInto = 0;
432 my $sentInitString = 0;
433 my $startedAsInteractiveShell = undef;
434  
435 my $lastContinuationCommand = undef;
436 my $lastContinuationStatus = 'break';
437 my $lastTranID = 0; # The transactionID that started
438  
439 my $stopReason = STOP_REASON_STARTING();
440 my @stopReasons = (qw(starting stopping stopped running break interactive));
441  
442 =head1 StopReasons
443  
444 Why we are stopping
445  
446 =over 4
447  
448 =item * 0 - started program
449  
450 =item * 1 - user did a step_into
451  
452 =item * 2 - user did a step_over
453  
454 =item * 4 - user did a step_out
455  
456 =item * 8 - program hit max-recursion depth
457  
458 =back
459  
460 =cut
461  
462 # open input and output (to and from console)
463 open(IN, "<&STDIN") || warn "open(IN)";
464 open(OUT, ">&STDERR") || open(OUT, ">&STDOUT") || warn "open(OUT)";
465  
466 # force autoflush of output
467 eval {
468 select(OUT);
469 $| = 1; # for DB::OUT
470 select(STDERR);
471 $| = 1;
472 select(STDOUT);
473 $| = 1; # for real STDOUT
474 };
475  
476 # Variables and subs for doing option processing
477 # (Copied from standard perl5db.pl to support PDK products)
478  
479 my $remoteport;
480 my $remotepath;
481 my $connect_at_start = 1;
482 my $keep_running = 0;
483 my $xdebug_file_line_in_step = undef;
484 our $xdebug_no_value_tag = undef; # used by DB::DbgrProperties
485 my $xdebug_full_values_in_context = undef;
486 my $xdebug_temporary_breakpoint_state = undef;
487 # If the PERLDB_OPTS variable has options in it, parse those out next.
488 if (defined $ENV{PERLDB_OPTS}) {
489 parse_options($ENV{PERLDB_OPTS});
490 }
491 if (!defined $remoteport && !defined $remotepath) {
492 if (exists $ENV{RemotePort}) {
493 $remoteport = $ENV{RemotePort};
494 } else {
495 die "Env variable RemotePort not set.";
496 }
497 }
498 if ($remoteport =~ /^\d+$/) {
499 die "Env variable RemotePort not numeric (set to $remoteport).";
500 }
501  
502 my $has_xs = 0;
503 if (DB::DbgrXS::HAS_XS() && !$ENV{DBGP_PURE_PERL}) {
504 eval {
505 require XSLoader;
506  
507 XSLoader::load('dbgp-helper::perl5db');
508 use_xs_sub();
509 $has_xs = 1;
510  
511 1;
512 } or do {
513 my $error = $@ || "Unknown error";
514  
515 dblog("Error loading XS code: $error") if $ldebug;
516 if ($ENV{DBGP_XS_ONLY}) {
517 dblog("Not falling back to pure-Perl, as per DBGP_XS_ONLY");
518 die "Aborting after error loading XS code: $error";
519 }
520 };
521 } else {
522 if ($ENV{DBGP_XS_ONLY}) {
523 dblog("DBGP_XS_ONLY but XS not compiled: aborting");
524 die "DBGP_XS_ONLY but XS not compiled: aborting";
525 }
526 }
527  
528 sub emitBanner {
529 0 ▶ my $version_str;
Subroutine emitBanner: not called CC=6 SCAR=37.4
Pod undocumented
530 0 ▶ if ($Config::Config{PERL_REVISION}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Config::Config{'PERL_REVISION'}) { } 0 0 0
531 0 $version_str = $Config::Config{PERL_REVISION};
532 0 ▶ if ($Config::Config{PERL_VERSION}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Config::Config{"PERL_VERSION"}) 0 0 0
533 0 $version_str .= '.' . $Config::Config{PERL_VERSION};
534 0 ▶ if ($Config::Config{PERL_SUBVERSION}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Config::Config{"PERL_SUBVERSION"}) 0 0 0
535 0 $version_str .= '.' . $Config::Config{PERL_SUBVERSION};
536 }
537 }
538 } else {
539 0 $version_str = $];
540 }
541 0 my $str = "# ";
542 $str .= ($Config::Config{cf_by} =~ /activestate/i
543 0 ▶ ? "ActivePerl" : ($Config::Config{perl} || "Perl"));
Branch: 1 branch
BranchTrueFalseTotal
$Config::Config{'cf_by'} =~ /activestate/i ? : 0 0 0
Condition0%0/2
$Config::Config{"perl"} or "Perl"
l!l
00
MC/DC0%0/1
$Config::Config{"perl"} or "Perl"
$Config::Config{"perl"}
Truth table0%0/2
A
A= $Config::Config{"perl"}
Aresult
11
00
544 0 $str .= " v$version_str";
545 0 $str .= " [$Config::Config{archname}]\n";
546 # $str .= "# Type `perl -v` for more info.\n";
547 0 print STDOUT $str;
548 }
549  
550 my ($PID, $IN, $OUT, $OUT_selector);
551  
552 sub disconnect {
553 # force-close any copies of the file descriptor in other processes
554 0 ▶ if (ref $OUT and UNIVERSAL::isa($OUT, 'IO::Socket')) {
Subroutine disconnect: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (ref $OUT and UNIVERSAL::isa($OUT, "IO::Socket")) 0 0 0
Condition0%0/3
ref $OUT and UNIVERSAL::isa($OUT, "IO::Socket")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $OUT and UNIVERSAL::isa($OUT, "IO::Socket")
ref $OUT UNIVERSAL::isa($OUT, "IO::Socket")
Truth table0%0/3
A and B
A= ref $OUTB= UNIVERSAL::isa($OUT, "IO::Socket")
ABresult
0X0
100
111
555 0 $OUT->shutdown(2);
556 }
557 0 $OUT = $IN = $OUT_selector = undef;
558 0 $stopReason = STOP_REASON_STARTING();
559 0 $lastContinuationCommand = undef;
560 0 $lastContinuationStatus = 'break';
561 0 $lastTranID = 0; # The transactionID that started
562 }
563  
564 sub connectOrReconnect {
565 0 ▶ dblog("Trying to open connection to client") if $ldebug;
Subroutine connectOrReconnect: not called CC=11 SCAR=48.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
566 0 $PID = $$;
567 0 ▶ disconnect() if $OUT;
Branch: 1 branch
BranchTrueFalseTotal
if $OUT 0 0 0
568 # If RemotePort was defined in the options, connect input and output
569 # to the socket.
570 0 require IO::Socket;
571 0 ▶ if ($remoteport) {
Branch: 2 branches
BranchTrueFalseTotal
if ($remoteport) { } 0 0 0
elsif ($remotepath) { } 0 0 0
572 0 $OUT = new IO::Socket::INET(
573 Timeout => '10',
574 PeerAddr => $remoteport,
575 Proto => 'tcp',
576 );
577 } elsif ($remotepath) {
578 0 $OUT = new IO::Socket::UNIX(
579 Timeout => '10',
580 Peer => $remotepath,
581 );
582 }
583  
584 # disabled by 'detach'
585 0 map { $supportedCommands{$_} = 1 } (qw(run step_into step_over step_out detach));
586  
587 0 ▶ if (!$OUT) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $OUT) { } 0 0 0
588 0 my ($error_num, $error_str) = ($!, "$!");
589 0 ▶ if ($remoteport) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remoteport) { } 0 0 0
590 0 ▶ dblog("Unable to connect to remote host: $remoteport ($error_str)") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
591 0 warn "Unable to connect to remote host: $remoteport ($error_str)\n";
592 } else {
593 0 ▶ dblog("Unable to connect to Unix socket: $remotepath ($error_str)") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
594 0 warn "Unable to connect to Unix socket: $remotepath ($error_str)\n";
595 }
596 0 ▶ dblog("Running program outside the debugger") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
597 0 warn "Running program outside the debugger...\n";
598 # Disable the debugger to keep the Perl program running
599 0 disable();
600 } else {
601 0 $signal = $single = $finished = $runnonstop = 0;
602 0 $stopReason = STOP_REASON_STARTING();
603 0 $sentInitString = 0;
604 0 $fakeFirstStepInto = 1;
605 0 setDefaultOutput($OUT);
606 0 $IN = $OUT;
607 0 eval {
608 0 require IO::Select;
609 0 $OUT_selector = IO::Select->new();
610 0 $OUT_selector->add($OUT);
611 # Indicate that we support asynchrousness
612 0 $supportedCommands{break} = 1;
613 0 ▶ if (!$skip_alarm) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($skip_alarm) 0 0 0
614 0 $supportedFeatures{supports_async} = [1, 1, 1];
615 0 $settings{supports_async} = [1];
616 0 $pending_check_enabled = 1;
617 }
618 0 $pending_check_count = 0;
619 0 $pending_check_lim = 100;
620 0 $pending_check_timeout = .000001;
621 0 $pending_check_interval = 1; # Check for a break every 1 second
622 0 @pending_commands = ();
623 };
624  
625 # print "# Talking to port $remoteport\n" if $ldebug;
626 # Moved stuff to start of init loop
627 # sendInitString();
628 0 setupOnceAfterConnection();
629 }
630 }
631  
632 0 ▶sub isConnected { !!$OUT }
Subroutine isConnected: not called CC=1 SCAR=6.9
Pod undocumented
633  
634 if (!$connect_at_start) {
635 # Keep going
636 disable();
637 } elsif (defined $remoteport || defined $remotepath) {
638 connectOrReconnect();
639 } else {
640 dblog("RemotePort not set for debugger") if $ldebug;
641 warn "RemotePort not set for debugger\n";
642 # Keep going
643 disable();
644 }
645  
646 sub setupOnceAfterConnection {
647 0 ▶ return if $setup_once_after_connection;
Subroutine setupOnceAfterConnection: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $setup_once_after_connection 0 0 0
648 # Unbuffer DB::OUT. We need to see responses right away.
649 0 my $previous = select($OUT);
650 # for DB::OUT
651 0 $| = 1;
652 0 select STDERR;
653 0 $| = 1;
654 0 select($previous);
655 # $single = 1;
656 0 ▶ if (!$skip_alarm) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($skip_alarm) 0 0 0
657 0 $SIG{ALRM} = \&_break_check_handler;
658 }
659 0 $setup_once_after_connection = 1;
660 }
661  
662 # Set a breakpoint for the first line of breakable code now,
663 # so we don't have to duplicate the reason in two places.
664 # Chat with the debug server until we get a continuation command.
665  
666 # things to help the breakpoint mechanism
667  
668 # Data structures for managing breakpoints
669  
670 use DB::DbgrURI qw(canonicalizeFName
671 canonicalizeURI
672 filenameToURI
673 uriToFilename
674 );
675 use DB::RedirectStdOutput;
676  
677 use DB::CGI::Util;
678 use DB::MIME::Base64;
679  
680 use constant BKPT_DISABLE => 1;
681 use constant BKPT_ENABLE => 2;
682 use constant BKPT_TEMPORARY => 3;
683  
684 use constant BKPT_REQ_ENABLED => 'enabled';
685 use constant BKPT_REQ_DISABLED => 'disabled';
686 use constant BKPT_REQ_TEMPORARY => 'temporary';
687  
688 # Indices into the breakpoint Table
689  
690 use constant BKPTBL_FILEURI => 0;
691 use constant BKPTBL_LINENO => 1;
692 use constant BKPTBL_STATE => 2;
693 use constant BKPTBL_TYPE => 3;
694 use constant BKPTBL_FUNCTION_NAME => 4;
695 use constant BKPTBL_CONDITION => 5;
696 use constant BKPTBL_EXCEPTION => 6;
697 use constant BKPTBL_HIT_INFO => 7;
698  
699 use constant HIT_TBL_COUNT => 0; # No. Times we've hit this bpt
700 use constant HIT_TBL_VALUE => 1; # Target hit value
701 use constant HIT_TBL_EVAL_FUNC => 2; # Function to call(VALUE, COUNT)
702 use constant HIT_TBL_COND_STRING => 3; # Condition string
703  
704 use constant STOP_REASON_STARTING => 0;
705 use constant STOP_REASON_STOPPING => 1;
706 use constant STOP_REASON_STOPPED => 2;
707 use constant STOP_REASON_RUNNING => 3;
708 use constant STOP_REASON_BREAK => 4;
709 use constant STOP_REASON_INTERACT => 5;
710  
711 use DB::Data::Dump;
712 use File::Basename;
713 use File::Spec;
714 use Getopt::Std;
715  
716 # Load the proper base class at compile time
717 BEGIN {
718 require File::Spec::Functions;
719 if ($^O eq 'MSWin32') {
720 require File::Spec::Win32;
721 } else {
722 require File::Spec::Unix;
723 }
724 my $junk = File::Spec::Functions::devnull();
725 dblog("dev-null => $junk");
726 }
727  
728 my @bkptLookupTable = (); # Map fileURI_No -> hash of (lineNo => breakPtID)
729 my %bkptInfoTable = (); # Map breakPtID -> [fileURINo, lineNo, state, type, function, expression, exception, hitInfo]
730 my %FQFnNameLookupTable = (); # Map fully qualified fn names =>
731 # { call => breakPtID, return => breakPtID }
732  
733 my @fileNameTable = (); # Map fileURI_No => [
734 # $bFileURI,
735 # $bFileName, (fwd slashes)
736 # $perlFileName (backwd slashes)
737 # ]
738 my %watchedExpressionLookupTable = (); # Map watchedExpn => breakPtID
739  
740 my $nextBkPtIndex = 0;
741  
742 my (@watchPoints, @watchPointValues);
743 my $numWatchPoints = 0;
744  
745 my ($tiedStdout, $tiedStderr);
746  
747 # End of initialization code.
748  
749 my $full_dbgp_prefix;
750 {
751 my $hostname = 'unknown';
752 local $@;
753 eval {
754 require 'Sys/Hostname.pm';
755 $hostname = Sys::Hostname::hostname();
756 $hostname =~ s/\..*$//; # Keep only the first part of a dotted name
757 $hostname =~ s/[^-_\w\d]+/_/g; # Turn non-alnums to safe chars
758 dblog("**** \$hostname=$hostname") if $ldebug;
759 };
760 if ($@) {
761 dblog("Error -- [$@]\n") if $ldebug;
762 }
763 $full_dbgp_prefix = "dbgp://perl/$hostname/$$";
764 }
765  
766 {
767 require Cwd;
768  
769 # get current directory
770 my $cwd = Cwd::cwd();
771  
772 # cwd bug: returns C: rather than C:/ if we're in the root
773 if ($cwd =~ /^[A-Z]:$/i) {
774 $cwd .= "/";
775 }
776  
777 DB::DbgrURI::init(ldebug => $ldebug, cwd => $cwd);
778 }
779  
780 # Handle postponed requests that came in earlier.
781  
782 finish_postponed();
783 $ready = 1;
784 $single = 0;
785  
786 sub sendInitString {
787 # Send the init command at this point
788 0 ▶ my $ppid = $ENV{DEBUGGER_APPID} || "";
Subroutine sendInitString: not called CC=8 SCAR=42.8
Pod undocumented
Condition0%0/2
$ENV{'DEBUGGER_APPID'} || ''
l!l
00
MC/DC0%0/1
$ENV{'DEBUGGER_APPID'} || ''
$ENV{'DEBUGGER_APPID'}
Truth table0%0/2
A
A= $ENV{'DEBUGGER_APPID'}
Aresult
11
00
789 0 my $appid = $$; # getpid
790 0 ▶ my $ideKey = $ENV{DBGP_IDEKEY} || "";
Condition0%0/2
$ENV{'DBGP_IDEKEY'} || ''
l!l
00
MC/DC0%0/1
$ENV{'DBGP_IDEKEY'} || ''
$ENV{'DBGP_IDEKEY'}
Truth table0%0/2
A
A= $ENV{'DBGP_IDEKEY'}
Aresult
11
00
791 0 my $initString = sprintf(qq(%s\n<init %s
792 appid="%s"
793 idekey="%s"
794 parent="%s"
795 ),
796 xmlHeader(),
797 namespaceAttr(),
798 $appid,
799 $ideKey,
800 $ppid,
801 );
802 0 ▶ if (exists $ENV{DBGP_COOKIE} && $ENV{DBGP_COOKIE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"DBGP_COOKIE"} and $ENV{"DBGP_COOKIE"}) 0 0 0
Condition0%0/3
exists $ENV{"DBGP_COOKIE"} and $ENV{"DBGP_COOKIE"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"DBGP_COOKIE"} and $ENV{"DBGP_COOKIE"}
exists $ENV{"DBGP_COOKIE"} $ENV{"DBGP_COOKIE"}
Truth table0%0/3
A and B
A= exists $ENV{"DBGP_COOKIE"}B= $ENV{"DBGP_COOKIE"}
ABresult
0X0
100
111
803 0 $initString .= qq( session="$ENV{DBGP_COOKIE}");
804 }
805 $initString .= sprintf(qq( thread="%s"
806 language="%s"
807 protocol_version="%s"),
808 0, # Main thread in a program defined to be 0
809 'Perl', # Language
810 0 $settings{protocol_version}[0],
811 );
812 0 ▶ if ($startedAsInteractiveShell) {
Branch: 1 branch
BranchTrueFalseTotal
if ($startedAsInteractiveShell) { } 0 0 0
813 0 $initString .= ' interactive="%"';
814 } else {
815 0 $initString .= ' fileuri="' . filenameToURI($0, 0) . '"';
816 }
817 0 my $hostname;
818 0 ▶ if (!($hostname = $ENV{HOST_HTTP})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hostname = $ENV{"HOST_HTTP"}) 0 0 0
819 # Get the hostname from perl
820 0 require Sys::Hostname;
821 0 $hostname = eval { Sys::Hostname::hostname() };
822 }
823 0 ▶ $initString .= qq( hostname="$hostname") if $hostname;
Branch: 1 branch
BranchTrueFalseTotal
if $hostname 0 0 0
824 0 $initString .= '/>';
825 0 printWithLength($initString);
826 0 $ENV{DEBUGGER_APPID} = $appid;
827 }
828  
829 sub getArg {
830 0 ▶ my ($cmdArgsARef, $optString) = @_;
Subroutine getArg: not called CC=4 SCAR=30.0
Pod undocumented
831 0 my $i;
832 # Don't look at the last arg -- if it's an option, we're out of luck
833 0 ▶ for ($i = 0; $i <= $#$cmdArgsARef - 1; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $cmdArgsARef->$#* - 1) 0 0 0
834 0 ▶ if ($cmdArgsARef->[$i] eq $optString) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cmdArgsARef->[$i] eq $optString) { } 0 0 0
elsif ($cmdArgsARef->[$i] eq '--') { } 0 0 0
835 0 return splice(@$cmdArgsARef, $i, 2);
836 } elsif ($cmdArgsARef->[$i] eq '--') {
837 0 last;
838 }
839 }
840 0 return undef;
841 }
842  
843 # Never delete entries here.
844 my (%fileURILookupTable, %perlNameToFileURINo, @fileURI_No_ReverseLookupTable);
845  
846 sub internFileURI {
847 0 ▶ my ($bFileURI) = @_;
Subroutine internFileURI: not called CC=2 SCAR=17.9
Pod undocumented
848 0 $bFileURI = canonicalizeURI($bFileURI);
849 0 ▶ if (!exists $fileURILookupTable{$bFileURI}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $fileURILookupTable{$bFileURI}) 0 0 0
850 0 my $tblSize = scalar keys %fileURILookupTable;
851 0 $fileURILookupTable{$bFileURI} = $tblSize + 1;
852 0 $fileURI_No_ReverseLookupTable[$tblSize + 1] = $bFileURI;
853 }
854 0 return $fileURILookupTable{$bFileURI};
855 }
856  
857 sub internFileURINo_LineNo {
858 0 ▶ my ($bFileURINo, $bLine) = @_;
Subroutine internFileURINo_LineNo: not called CC=3 SCAR=24.8
Pod undocumented
859 0 ▶ if (!$bkptLookupTable[$bFileURINo]) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $bkptLookupTable[$bFileURINo]) { } 0 0 0
elsif (not exists $bkptLookupTable[$bFileURINo]{$bLine}) { } 0 0 0
860 0 $bkptLookupTable[$bFileURINo] = {$bLine => $nextBkPtIndex};
861 0 return $nextBkPtIndex++;
862 } elsif (! exists $bkptLookupTable[$bFileURINo]->{$bLine}) {
863 0 $bkptLookupTable[$bFileURINo]->{$bLine} = $nextBkPtIndex;
864 0 return $nextBkPtIndex++;
865 }
866 0 return $bkptLookupTable[$bFileURINo]->{$bLine};
867 }
868  
869 sub internFunctionName_CallType_Breakpoint($$) {
870 0 ▶ my ($functionName, $bType) = @_;
Subroutine internFunctionName_CallType_Breakpoint: not called CC=3 SCAR=24.8
Pod undocumented
871 0 ▶ if (! exists $FQFnNameLookupTable{$functionName}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $FQFnNameLookupTable{$functionName}) { } 0 0 0
elsif (exists $FQFnNameLookupTable{$functionName}{$bType}) { } 0 0 0
872 0 $FQFnNameLookupTable{$functionName} = { $bType => $nextBkPtIndex };
873 0 return $nextBkPtIndex++;
874 } elsif (exists $FQFnNameLookupTable{$functionName}{$bType}) {
875 # Overwrite existing breakpoint
876 0 return $FQFnNameLookupTable{$functionName}{$bType};
877 } else {
878 0 $FQFnNameLookupTable{$functionName}{$bType} = $nextBkPtIndex;
879 0 return $nextBkPtIndex++;
880 }
881 }
882  
883 sub internFunctionName_watchedExpn($) {
884 0 ▶ my ($bExpn) = @_;
Subroutine internFunctionName_watchedExpn: not called CC=2 SCAR=17.9
Pod undocumented
885 0 ▶ if (! exists $watchedExpressionLookupTable{$bExpn}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $watchedExpressionLookupTable{$bExpn}) 0 0 0
886 0 $watchedExpressionLookupTable{$bExpn} = $nextBkPtIndex++;
887 }
888 0 return $watchedExpressionLookupTable{$bExpn};
889 }
890  
891 sub getURIByNo {
892 0 ▶ my ($fileURINo) = @_;
Subroutine getURIByNo: not called CC=2 SCAR=17.9
Pod undocumented
893 0 ▶ return $fileURI_No_ReverseLookupTable[$fileURINo] || "";
Condition0%0/2
$fileURI_No_ReverseLookupTable[$fileURINo] || ''
l!l
00
MC/DC0%0/1
$fileURI_No_ReverseLookupTable[$fileURINo] || ''
$fileURI_No_ReverseLookupTable[$fileURINo]
Truth table0%0/2
A
A= $fileURI_No_ReverseLookupTable[$fileURINo]
Aresult
11
00
894 }
895  
896 sub storeBkPtInfo {
897 0 ▶ my ($bkptID, $bFileURINo, $bLine, $bstate, $bType, $bFunction, $bCondition) = @_;
Subroutine storeBkPtInfo: not called CC=1 SCAR=6.9
Pod undocumented
898 0 $bkptInfoTable{$bkptID} = [$bFileURINo, $bLine, $bstate, $bType, $bFunction, $bCondition, undef, undef];
899 }
900  
901 # No conditions, but we want to maintain a hit count on the breakpoint.
902  
903 sub setNullBkPtHitInfo {
904 0 ▶ my ($bkptID) = @_;
Subroutine setNullBkPtHitInfo: not called CC=1 SCAR=6.9
Pod undocumented
905 0 $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO] = [0, 0, undef, undef];
906 }
907  
908 # Take a target value and a string representing a hit condition,
909 # and return a closure encapsulating the test.
910 # We need to expose the target, so there's no point encapsulating
911 # it into the closure.
912  
913 # $bkptHitCount is the current value (hit count) on the breakpoint
914 # $bkptHitValue is the target value
915  
916 sub testGE {
917 0 ▶ my ($bkptHitCount, $bkptHitValue) = @_;
Subroutine testGE: not called CC=1 SCAR=6.9
Pod undocumented
918 0 return $bkptHitCount >= $bkptHitValue;
919 }
920  
921 sub testEQ {
922 0 ▶ my ($bkptHitCount, $bkptHitValue) = @_;
Subroutine testEQ: not called CC=1 SCAR=6.9
Pod undocumented
923 0 return $bkptHitCount == $bkptHitValue;
924 }
925  
926 sub testMod {
927 0 ▶ my ($bkptHitCount, $bkptHitValue) = @_;
Subroutine testMod: not called CC=2 SCAR=17.9
Pod undocumented
928 0 ▶ return $bkptHitValue > 0 && $bkptHitCount % $bkptHitValue == 0;
Condition0%0/3
$bkptHitValue > 0 && $bkptHitCount % $bkptHitValue == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$bkptHitValue > 0 && $bkptHitCount % $bkptHitValue == 0
$bkptHitValue > 0 $bkptHitCount % $bkptHitValue == 0
Truth table0%0/3
A && B
A= $bkptHitValue > 0B= $bkptHitCount % $bkptHitValue == 0
ABresult
0X0
100
111
929 }
930  
931 sub parseBkPtHitInfo($) {
932 0 ▶ my ($bkptHitConditionFunc) = @_;
Subroutine parseBkPtHitInfo: not called CC=4 SCAR=30.0
Pod undocumented
933 0 ▶ if ($bkptHitConditionFunc eq '>=') {
Branch: 3 branches
BranchTrueFalseTotal
if ($bkptHitConditionFunc eq '>=') { } 0 0 0
elsif ($bkptHitConditionFunc eq '==') { } 0 0 0
elsif ($bkptHitConditionFunc eq '%') { } 0 0 0
934 0 return \&testGE;
935 } elsif ($bkptHitConditionFunc eq '==') {
936 0 return \&testEQ;
937 } elsif ($bkptHitConditionFunc eq '%') {
938 0 return \&testMod;
939 } else {
940 0 return undef;
941 }
942 }
943  
944 sub setBkPtHitInfo($$$) {
945 0 ▶ my ($bkptID, $bkptHitValue, $bkptHitConditionString) = @_;
Subroutine setBkPtHitInfo: not called CC=4 SCAR=30.0
Pod undocumented
946 0 ▶ $bkptHitConditionString = '>=' if (!defined $bkptHitConditionString);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bkptHitConditionString 0 0 0
947 0 my $sub = parseBkPtHitInfo($bkptHitConditionString);
948 0 ▶ if (!defined $sub) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sub) 0 0 0
949 # Formulate an error condition
950 0 return 0;
951 }
952 0 ▶ if (! defined $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $bkptInfoTable{$bkptID}[7]) 0 0 0
953 0 $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO] = [];
954 }
955 # Always reset hit-count to 0 -- part of bug 40561
956 0 $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO][HIT_TBL_COUNT] = 0;
957 0 $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO][HIT_TBL_VALUE] = $bkptHitValue; # Target
958 0 $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO][HIT_TBL_EVAL_FUNC] = $sub;
959 0 $bkptInfoTable{$bkptID}[BKPTBL_HIT_INFO][HIT_TBL_COND_STRING] = $bkptHitConditionString;
960 }
961
962  
963 sub getBkPtInfo {
964 0 ▶ my ($bkptID) = @_;
Subroutine getBkPtInfo: not called CC=4 SCAR=30.0
Pod undocumented
965 0 ▶ if (!exists $bkptInfoTable{$bkptID} || (ref $bkptInfoTable{$bkptID}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne 'ARRAY') { } 0 0 0
Condition0%0/3
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
not exists $bkptInfoTable{$bkptID} ref $bkptInfoTable{$bkptID} ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not exists $bkptInfoTable{$bkptID}B= ref $bkptInfoTable{$bkptID} ne "ARRAY"
ABresult
1X1
011
000
966 0 return;
967 } else {
968 0 ▶ return wantarray ? @{$bkptInfoTable{$bkptID}} : $bkptInfoTable{$bkptID};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
969 }
970 }
971  
972 sub setBkPtState {
973 0 ▶ my ($bkptID, $bstate) = @_;
Subroutine setBkPtState: not called CC=3 SCAR=24.8
Pod undocumented
974 0 ▶ if (!exists $bkptInfoTable{$bkptID} || (ref $bkptInfoTable{$bkptID}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY") 0 0 0
Condition0%0/3
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
not exists $bkptInfoTable{$bkptID} ref $bkptInfoTable{$bkptID} ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not exists $bkptInfoTable{$bkptID}B= ref $bkptInfoTable{$bkptID} ne "ARRAY"
ABresult
1X1
011
000
975 # No such breakpoint
976 0 return 0;
977 }
978 0 $bkptInfoTable{$bkptID}->[2] = $bstate;
979 0 return 1;
980 }
981  
982 sub getBkPtState {
983 0 ▶ my ($bkptID, $bstate) = @_;
Subroutine getBkPtState: not called CC=3 SCAR=24.8
Pod undocumented
984 0 ▶ if (!exists $bkptInfoTable{$bkptID} || (ref $bkptInfoTable{$bkptID}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY") 0 0 0
Condition0%0/3
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
not exists $bkptInfoTable{$bkptID} ref $bkptInfoTable{$bkptID} ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not exists $bkptInfoTable{$bkptID}B= ref $bkptInfoTable{$bkptID} ne "ARRAY"
ABresult
1X1
011
000
985 # No such breakpoint
986 0 return BKPT_DISABLE;
987 }
988 0 return $bkptInfoTable{$bkptID}->[2];
989 }
990  
991 sub deleteBkPtInfo {
992 0 ▶ my ($bkptID) = @_;
Subroutine deleteBkPtInfo: not called CC=3 SCAR=24.8
Pod undocumented
993 0 ▶ if (!exists $bkptInfoTable{$bkptID} || (ref $bkptInfoTable{$bkptID}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY") 0 0 0
Condition0%0/3
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $bkptInfoTable{$bkptID} or ref $bkptInfoTable{$bkptID} ne "ARRAY"
not exists $bkptInfoTable{$bkptID} ref $bkptInfoTable{$bkptID} ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not exists $bkptInfoTable{$bkptID}B= ref $bkptInfoTable{$bkptID} ne "ARRAY"
ABresult
1X1
011
000
994 # No such breakpoint
995 0 return 0;
996 }
997 0 delete $bkptInfoTable{$bkptID};
998 0 return 1;
999 }
1000  
1001 sub remove_FileURI_LineNo_Breakpoint {
1002 0 ▶ my ($fileURINo, $bLine) = @_;
Subroutine remove_FileURI_LineNo_Breakpoint: not called CC=8 SCAR=42.8
Pod undocumented
1003 0 ▶ if ($bkptLookupTable[$fileURINo]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bkptLookupTable[$fileURINo]) 0 0 0
1004 0 ▶ if (exists $bkptLookupTable[$fileURINo]->{$bLine}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $bkptLookupTable[$fileURINo]{$bLine}) { } 0 0 0
1005 0 ▶ if (defined $fileNameTable[$fileURINo]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fileNameTable[$fileURINo]) { } 0 0 0
1006 0 (undef, undef, my $perlFileName) = @{$fileNameTable[$fileURINo]};
1007 0 ▶ if ($perlFileName) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perlFileName) { } 0 0 0
1008 0 our %dbline;
1009 0 local *dbline = $main::{'_<' . $perlFileName};
1010 0 $dbline{$bLine} = 0;
1011 } else {
1012 0 ▶ dblog("remove_FileURI_LineNo_Breakpoint: No perlFileName entry in info \$fileNameTable[$fileURINo]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1013 }
1014 } else {
1015 0 ▶ dblog("remove_FileURI_LineNo_Breakpoint: No info \$fileNameTable[$fileURINo]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1016 }
1017 0 delete $bkptLookupTable[$fileURINo]->{$bLine};
1018 } else {
1019 0 ▶ dblog("remove_FileURI_LineNo_Breakpoint: Can't find bkpt info for (uri $fileURINo, line $bLine)\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1020 }
1021 }
1022 }
1023  
1024 sub getStateName {
1025 0 ▶ my ($bState) = @_;
Subroutine getStateName: not called CC=4 SCAR=30.0
Pod undocumented
1026 0 ▶ if ($bState == BKPT_DISABLE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($bState == 1) { } 0 0 0
elsif ($bState == 2) { } 0 0 0
elsif ($bState == 3) { } 0 0 0
1027 0 return BKPT_REQ_DISABLED;
1028 } elsif ($bState == BKPT_ENABLE) {
1029 0 return BKPT_REQ_ENABLED;
1030 } elsif ($bState == BKPT_TEMPORARY) {
1031 0 return BKPT_REQ_TEMPORARY;
1032 } else {
1033 0 return BKPT_REQ_DISABLED;
1034 }
1035 }
1036  
1037 sub getExpressionTag {
1038 0 ▶ my ($bExpression) = @_;
Subroutine getExpressionTag: not called CC=2 SCAR=17.9
Pod undocumented
1039 0 ▶ if (!$bExpression) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $bExpression) { } 0 0 0
1040 0 return "";
1041 } else {
1042 0 return sprintf('<expression>%s</expression>',
1043 xmlEncode($bExpression));
1044 }
1045 }
1046  
1047 sub lookupBkptInfo {
1048 0 ▶ my ($fileNameURINo, $lineNo) = @_;
Subroutine lookupBkptInfo: not called CC=7 SCAR=40.3
Pod undocumented
1049 0 ▶ if (!defined $bkptLookupTable[$fileNameURINo]) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $bkptLookupTable[$fileNameURINo]) { } 0 0 0
elsif (not exists $bkptLookupTable[$fileNameURINo]{$lineNo}) { } 0 0 0
1050 0 ▶ dblog("lookupBkptInfo: No \$fileNameURINo ($fileNameURINo)\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1051 0 return undef;
1052 } elsif (!exists $bkptLookupTable[$fileNameURINo]->{$lineNo}) {
1053 0 ▶ dblog("lookupBkptInfo: No entry at \$fileNameURINo ($fileNameURINo)->\{$lineNo}\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1054 0 return undef;
1055 } else {
1056 0 my $bkptID = eval { $bkptLookupTable[$fileNameURINo]->{$lineNo}};
1057 0 ▶ return undef if !defined $bkptID;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bkptID 0 0 0
1058 0 ▶ dblog("lookupBkptInfo: \$bkptID = $bkptID\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1059 0 return $bkptInfoTable{$bkptID};
1060 }
1061 }
1062  
1063  
1064 # Precondition: $bFileName is canonicalized
1065  
1066 sub lookForPerlFileName {
1067 0 ▶ my ($bFileName) = @_;
Subroutine lookForPerlFileName: not called CC=5 SCAR=34.0
Pod undocumented
1068 0 my $result;
1069 # Look at all keys that start with '_<', aren't in eval blocks
1070 # and find one that canonicalizes to the same thing
1071  
1072 0 my @perlKeys = grep /_</, (grep !/eval/, keys %{*main::});
1073 0 foreach my $perlFileKey (@perlKeys) {
1074 0 $perlFileKey =~ s/_<//;
1075 0 my $origKey = $perlFileKey;
1076 0 local $@;
1077 0 eval {
1078 0 $perlFileKey = canonicalizeFName(uriToFilename(filenameToURI($perlFileKey, 1)));
1079 0 ▶ if ($bFileName eq $perlFileKey) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bFileName eq $perlFileKey) 0 0 0
1080 0 $result = $origKey;
1081 }
1082 };
1083 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1084 0 ▶ dblog("Called uriToFilename in " .
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1085 join("\n", dump_trace(0))) if $ldebug;
1086 }
1087 }
1088 0 return $result;
1089 }
1090  
1091 # Variables for the eval things
1092 # Hash on <<(eval \d+)[parentLocn:lineNum]>> to (filename, startLine, @src)
1093 my %evalTable = ();
1094 my @evalTableIdx = (undef); # 0 is special-cased in calcFileURI
1095  
1096 sub internEvalURI($;$) {
1097 0 ▶ my ($filename, $srcLinesARef) = @_;
Subroutine internEvalURI: not called CC=5 SCAR=34.0
Pod undocumented
1098 0 ▶ if (!exists $evalTable{$filename}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $evalTable{$filename}) 0 0 0
1099 0 my ($evalIdx, $parentLocation, $startingPoint) =
1100 ($filename =~ /\(eval\s*(\d+)\)\[(.*):(\d+)\]$/);
1101 0 my $etCount = scalar @evalTableIdx;
1102 0 $evalTable{$filename} = {
1103 file => $parentLocation,
1104 startLine => $startingPoint,
1105 src => $srcLinesARef,
1106 idx => $etCount,
1107 };
1108 0 $evalTableIdx[$etCount] = $filename;
1109 0 ▶ if (!defined $srcLinesARef) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $srcLinesARef) 0 0 0
1110 0 our @dbline;
1111 0 local *dbline = $main::{'_<' . $filename};
1112 0 ▶ dblog("internEvalURI -- found src lines for ($filename), using ", join('', (scalar @dbline > 100 ? @dbline[0..99] : @dbline))) if $ldebug;
Branch: 2 branches
BranchTrueFalseTotal
if $ldebug 0 0 0
scalar @DB::dbline > 100 ? : 0 0 0
1113 0 $evalTable{$filename}{src} = \@dbline;
1114 }
1115 }
1116 }
1117  
1118 # Assume this routine is called from the main routine only
1119 # while we're trying to convert the current filename to a URI
1120 #
1121 # Don't convert the case here.
1122  
1123 sub calcFileURI($) {
1124 0 ▶ my ($filename) = @_;
Subroutine calcFileURI: not called CC=10 SCAR=47.0
Pod undocumented
1125 0 ▶ if ($filename =~ m/^(\(eval\s*\d+\))\[.+:\d+\]$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($filename =~ /^(\(eval\s*\d+\))\[.+:\d+\]$/) { } 0 0 0
elsif (defined &INC and index($filename, '/PerlApp/') == 0 || $filename =~ m[^/<.*>]) { } 0 0 0
1126 0 my $evalName = $1;
1127 0 internEvalURI($filename);
1128 0 my $idx;
1129 0 ▶ if (exists $evalTable{$filename}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $evalTable{$filename} and defined($idx = $evalTable{$filename}{'idx'}) and defined $evalTableIdx[$idx]) { } 0 0 0
Condition0%0/6
exists $evalTable{$filename} and defined($idx = $evalTable{$filename}{"idx"}) and defined $evalTableIdx[$idx]
!ll&&!rl&&r
000
exists $evalTable{$filename} and defined($idx = $evalTable{$filename}{"idx"})
!ll&&!rl&&r
000
MC/DC0%0/3
exists $evalTable{$filename} and defined($idx = $evalTable{$filename}{"idx"}) and defined $evalTableIdx[$idx]
exists $evalTable{$filename} defined($idx = $evalTable{$filename}{"idx"}) defined $evalTableIdx[$idx]
Truth table0%0/4
A and B and C
A= exists $evalTable{$filename}B= defined($idx = $evalTable{$filename}{"idx"})C= defined $evalTableIdx[$idx]
ABCresult
0XX0
10X0
1100
1111
1130 && defined ($idx = $evalTable{$filename}{idx})
1131 && defined $evalTableIdx[$idx]) {
1132 0 my $retName = "$full_dbgp_prefix/$idx/" . encodeData($evalName, 'urlescape');
1133 0 ▶ dblog "calcFileURI: mapping $filename => [$retName]\n" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1134 0 return $retName;
1135 } else {
1136 0 ▶ dblog "Can't map [$filename] to an evalTableIdx entry" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1137 0 return "$full_dbgp_prefix/0/" . encodeData($filename, 'urlescape');
1138 }
1139 ▶ } elsif (defined &INC && (index($filename, "/PerlApp/") == 0 # PDK ... 6
Condition0%0/6
defined &INC and index($filename, "/PerlApp/") == 0 || $filename =~ m[^/<.*>]
!ll&&!rl&&r
000
index($filename, "/PerlApp/") == 0 or $filename =~ m[^/<.*>]
l!l&&r!l&&!r
000
MC/DC0%0/3
defined &INC and index($filename, "/PerlApp/") == 0 || $filename =~ m[^/<.*>]
defined &INC index($filename, "/PerlApp/") == 0 $filename =~ m[^/<.*>]
Truth table0%0/4
A and B or C
A= defined &INCB= index($filename, "/PerlApp/") == 0C= $filename =~ m[^/<.*>]
ABCresult
0XX0
1000
11X1
1011
1140 || $filename =~ m@^/<.*>@ # PDK 7
1141 )) {
1142 0 return "dbgp:///perl/$filename";
1143 } else {
1144 0 return filenameToURI($filename, 0);
1145 }
1146 }
1147  
1148 sub downcaseDriveLetter {
1149 # If we're on windows systems, we'll need to manually
1150 # lcase the drive letter -- the uri canonicalizer
1151 # doesn't do that.
1152 0 ▶ $_[0] =~ s@^([A-Z])(?=:[/\\])@lc $1@e;
Subroutine downcaseDriveLetter: not called CC=1 SCAR=6.9
Pod undocumented
1153 }
1154  
1155 # Functions for manipulating breaking at functions:
1156  
1157 =head1 findAndAddFunctionBreakPoints
1158  
1159 Four ways to break on a sub:
1160  
1161 1. No file or line # given: break at the start (or end) of all instances
1162 of all loaded subs with the given name
1163  
1164 2. File given, no line #: break at the start (or end) of all instances
1165 ot the named function in the given file
1166  
1167 3. File and line # given: use the line # to identify which instance of
1168 a function that matches the given name. This is to allow for a
1169 file that contains multiple packages, with the same function name
1170 in more than one package.
1171  
1172 4. No file given, but line # given: This is weird, but we have a
1173 story:
1174 Find all instances of the given function, and accept only if the
1175 given line # falls in the function's range.
1176  
1177 =cut
1178  
1179 sub addSubBreakPoint($$$$$$$$$);
1180  
1181 sub addSubBreakPoint($$$$$$$$$) {
1182 0 ▶ my ($functionName,
Subroutine addSubBreakPoint: not called CC=3 SCAR=24.8
Pod undocumented
1183 $fileURINo,
1184 $lineNumber,
1185 $bState,
1186 $possibleSub,
1187 $bCondition,
1188 $bType,
1189 $bHitCount,
1190 $bHitConditionOperator) = @_;
1191 0 my $bkptID = internFunctionName_CallType_Breakpoint($functionName, $bType);
1192 0 ▶ dblog("FQFnNameLookupTable: ", DB::Data::Dump::dump(%FQFnNameLookupTable), "\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1193 0 storeBkPtInfo($bkptID, $fileURINo, $lineNumber, $bState,
1194 $bType, $functionName, $bCondition);
1195 0 ▶ if ($bHitCount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bHitCount) { } 0 0 0
1196 0 setBkPtHitInfo($bkptID, $bHitCount, $bHitConditionOperator);
1197 } else {
1198 0 setNullBkPtHitInfo($bkptID);
1199 }
1200 0 return $bkptID;
1201 }
1202  
1203 sub findAndAddFunctionBreakPoints($$$$$$$$$) {
1204 0 ▶ my ($bFunctionName, $perlFileName, $lineNumber,
Subroutine findAndAddFunctionBreakPoints: not called CC=17 SCAR=57.2
Pod undocumented
1205 $bCondition, $bState, $bIsTemporary, $bType,
1206 $bHitCount,
1207 $bHitConditionOperator) = @_;
1208 0 my $isQualified = ($bFunctionName =~ /::/);
1209 0 my $fqSubName;
1210 0 ▶ if (!$isQualified) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $isQualified) { } 0 0 0
1211 0 $fqSubName = 'main::' . $bFunctionName;
1212 } else {
1213 0 $fqSubName = $bFunctionName;
1214 }
1215 0 my @possibleSubNames;
1216 # First try the direct lookup approach
1217 0 ▶ if (exists $sub{$fqSubName}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $sub{$fqSubName}) { } 0 0 0
elsif (not $isQualified) { } 0 0 0
1218 0 @possibleSubNames = ($fqSubName);
1219 } elsif (!$isQualified) {
1220 0 my ($baseFunctionName) = ($bFunctionName =~ /([^:]+)$/);
1221 0 @possibleSubNames = grep(/$baseFunctionName$/, keys %sub);
1222 } else {
1223 # postponed
1224 0 @possibleSubNames = ($fqSubName);
1225 }
1226  
1227 # First find all the packages
1228 0 ▶ return if (!@possibleSubNames);
Branch: 1 branch
BranchTrueFalseTotal
unless @possibleSubNames 0 0 0
1229 0 my @bkptIDs;
1230 0 foreach my $possibleSub (@possibleSubNames) {
1231 0 my $addIt = 0;
1232 0 my ($fileName, $startLineNo, $endLineNo) = ($sub{$possibleSub} =~ /^(.*):(\d+)-(\d+)$/);
1233 0 ▶ if ($fileName) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fileName) { } 0 0 0
elsif ($isQualified) { } 0 0 0
1234 0 ▶ if ($perlFileName) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perlFileName) { } 0 0 0
1235 0 ▶ if (lc $fileName eq lc $perlFileName
Branch: 1 branch
BranchTrueFalseTotal
if (lc $fileName eq lc $perlFileName or $fileName =~ /$perlFileName/i) 0 0 0
Condition0%0/3
lc $fileName eq lc $perlFileName or $fileName =~ /$perlFileName/i
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $fileName eq lc $perlFileName or $fileName =~ /$perlFileName/i
lc $fileName eq lc $perlFileName $fileName =~ /$perlFileName/i
Truth table0%0/3
A or B
A= lc $fileName eq lc $perlFileNameB= $fileName =~ /$perlFileName/i
ABresult
1X1
011
000
1236 || $fileName =~ /$perlFileName/i) {
1237 0 ▶ if (!defined $lineNumber
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $lineNumber or $lineNumber >= $startLineNo and $lineNumber <= $endLineNo) 0 0 0
Condition0%0/6
not defined $lineNumber or $lineNumber >= $startLineNo and $lineNumber <= $endLineNo
l!l&&r!l&&!r
000
$lineNumber >= $startLineNo and $lineNumber <= $endLineNo
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $lineNumber or $lineNumber >= $startLineNo and $lineNumber <= $endLineNo
not defined $lineNumber $lineNumber >= $startLineNo $lineNumber <= $endLineNo
Truth table0%0/4
not(A) or B and C
A= not defined $lineNumberB= $lineNumber >= $startLineNoC= $lineNumber <= $endLineNo
ABCresult
1XX1
0111
00X0
0100
1238 || ($lineNumber >= $startLineNo
1239 && $lineNumber <= $endLineNo)) {
1240 0 $addIt = 1;
1241 }
1242 }
1243 } else {
1244 0 ▶ $addIt = (!defined $lineNumber
Condition0%0/6
!defined($lineNumber) || $lineNumber >= $startLineNo && $lineNumber <= $endLineNo
l!l&&r!l&&!r
000
$lineNumber >= $startLineNo and $lineNumber <= $endLineNo
!ll&&!rl&&r
000
MC/DC0%0/3
!defined($lineNumber) || $lineNumber >= $startLineNo && $lineNumber <= $endLineNo
!defined($lineNumber) $lineNumber >= $startLineNo $lineNumber <= $endLineNo
Truth table0%0/4
not(A) || B and C
A= !defined($lineNumber)B= $lineNumber >= $startLineNoC= $lineNumber <= $endLineNo
ABCresult
1XX1
0111
00X0
0100
1245 || ($lineNumber >= $startLineNo
1246 && $lineNumber <= $endLineNo));
1247 }
1248 } elsif ($isQualified) {
1249 # postponed
1250 0 $addIt = 1;
1251 }
1252 0 ▶ if ($addIt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addIt) 0 0 0
1253 0 my $bFileURINo;
1254 0 my $fileURI = filenameToURI($fileName, 1);
1255 0 my $fileURINo = internFileURI($fileURI);
1256 0 my $bkptID = addSubBreakPoint($possibleSub,
1257 $fileURINo,
1258 $lineNumber,
1259 $bState,
1260 $possibleSub,
1261 $bCondition,
1262 $bType,
1263 $bHitCount,
1264 $bHitConditionOperator);
1265 0 push @bkptIDs, $bkptID;
1266 }
1267 }
1268 0 return @bkptIDs;
1269 }
1270  
1271 # I try to make the types transparent, but we need to give a typemap
1272 # anyway
1273  
1274 sub emitTypeMapInfo($$) {
1275 0 ▶ my ($cmd, $transactionID) = @_;
Subroutine emitTypeMapInfo: not called CC=5 SCAR=34.0
Pod undocumented
1276 0 my $res = sprintf(qq(%s\n<response %s %s %s command="%s"
1277 transaction_id="%s" >),
1278 xmlHeader(),
1279 namespaceAttr(),
1280 xsdNamespace(),
1281 xsiNamespace(),
1282 $cmd,
1283 $transactionID);
1284 # Schema, CommonTypeName (type attr) LanguageTypeName (name attr)
1285 0 foreach my $e (['boolean', 'bool'],
1286 ['float'],
1287 ['integer', 'int'],
1288 ['string'],
1289 [undef, 'undefined', 'undef'],
1290 [undef, 'array', 'ARRAY'],
1291 [undef, 'hash', 'HASH']) {
1292 0 my $xsdName = $e->[0];
1293 0 ▶ my $commonTypeName = $e->[1] || $xsdName;
Condition0%0/3
$e->[1] || $xsdName
l!l&&r!l&&!r
000
MC/DC0%0/2
$e->[1] || $xsdName
$e->[1] $xsdName
Truth table0%0/3
A || B
A= $e->[1]B= $xsdName
ABresult
1X1
011
000
1294 0 ▶ my $languageTypeName = $e->[2] || $commonTypeName;
Condition0%0/3
$e->[2] || $commonTypeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$e->[2] || $commonTypeName
$e->[2] $commonTypeName
Truth table0%0/3
A || B
A= $e->[2]B= $commonTypeName
ABresult
1X1
011
000
1295 0 ▶ if ($xsdName) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xsdName) { } 0 0 0
1296 0 $res .= qq(<map type="$commonTypeName" name="$languageTypeName" xsi:type="xsd:$xsdName"/>);
1297 } else {
1298 0 $res .= qq(<map type="$commonTypeName" name="$languageTypeName"/>);
1299 }
1300 }
1301 0 $res .= "\n</response>";
1302 0 printWithLength($res);
1303 }
1304  
1305 sub decodeCmdLineData($$$$) {
1306 0 ▶ my ($cmd, $transactionID, $dataLength, $argsARef) = @_;
Subroutine decodeCmdLineData: not called CC=5 SCAR=34.0
Pod undocumented
1307 0 my @args = @$argsARef;
1308 0 my $currDataEncoding = $settings{data_encoding}->[0];
1309 0 my $decodedData;
1310 0 ▶ if ($currDataEncoding eq 'none' || $currDataEncoding eq 'binary') {
Branch: 2 branches
BranchTrueFalseTotal
if ($currDataEncoding eq 'none' or $currDataEncoding eq 'binary') { } 0 0 0
elsif (scalar @args == 0) { } 0 0 0
Condition0%0/3
$currDataEncoding eq "none" or $currDataEncoding eq "binary"
l!l&&r!l&&!r
000
MC/DC0%0/2
$currDataEncoding eq "none" or $currDataEncoding eq "binary"
$currDataEncoding eq "none" $currDataEncoding eq "binary"
Truth table0%0/3
A or B
A= $currDataEncoding eq "none"B= $currDataEncoding eq "binary"
ABresult
1X1
011
000
1311 0 $decodedData = join(" ", @args);
1312 0 $dataLength = length ($decodedData);
1313 } elsif (scalar @args == 0) {
1314 0 printWithLength(sprintf
1315 qq(%s\n<response %s command="%s" transaction_id="%s" ><error code="%d" apperr="4"><message>Expecting exactly 1 argument for %s command, got [nothing].</message></error></response>),
1316  
1317 xmlHeader(),
1318 namespaceAttr(),
1319 $cmd,
1320 $transactionID,
1321 DBP_E_CommandUnimplemented,
1322 $cmd,
1323 );
1324 0 return ();
1325 } else {
1326 0 $decodedData = decodeData(join("", @args));
1327 0 $dataLength = length ($decodedData);
1328 }
1329 0 ▶ dblog("decodeCmdLineData: returning [$decodedData]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1330 0 return ($dataLength, $currDataEncoding, $decodedData);
1331 }
1332  
1333 sub checkForEvalStackType($) {
1334 0 ▶ my ($stackDumpTypeValue) = @_;
Subroutine checkForEvalStackType: not called CC=3 SCAR=24.8
Pod undocumented
1335 0 ▶ if ($stackDumpTypeValue && $stackDumpTypeValue =~ /^eval [\"\'q<]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stackDumpTypeValue and $stackDumpTypeValue =~ /^eval [\"\'q<]/) { } 0 0 0
Condition0%0/3
$stackDumpTypeValue and $stackDumpTypeValue =~ /^eval [\"\'q<]/
!ll&&!rl&&r
000
MC/DC0%0/2
$stackDumpTypeValue and $stackDumpTypeValue =~ /^eval [\"\'q<]/
$stackDumpTypeValue $stackDumpTypeValue =~ /^eval [\"\'q<]/
Truth table0%0/3
A and B
A= $stackDumpTypeValueB= $stackDumpTypeValue =~ /^eval [\"\'q<]/
ABresult
0X0
100
111
1336 0 return 'eval';
1337 } else {
1338 0 return 'file';
1339 }
1340 }
1341  
1342 sub getFileInfo($$$$$) {
1343 0 ▶ my ($bFileURI,
Subroutine getFileInfo: not called CC=5 SCAR=34.0
Pod undocumented
1344 $rbFileURI,
1345 $rbFileURINo,
1346 $rbFileName,
1347 $rperlFileName) = @_;
1348  
1349 0 my ($bFileURINo,
1350 $bFileName,
1351 $perlFileName);
1352  
1353 # URIs need to be stored in a canonical format,
1354 # since they're how we look things up.
1355 # Filenames aren't used for lookups directly.
1356 0 $bFileURI = canonicalizeURI($bFileURI);
1357 0 $bFileURINo = internFileURI($bFileURI);
1358 0 ▶ if (defined $fileNameTable[$bFileURINo]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fileNameTable[$bFileURINo]) { } 0 0 0
1359 0 (undef, $bFileName, $perlFileName) = @{$fileNameTable[$bFileURINo]};
1360 } else {
1361 0 local $@;
1362 0 eval {
1363 0 $bFileName = canonicalizeFName(uriToFilename($bFileURI));
1364 0 $perlFileName = lookForPerlFileName($bFileName);
1365 0 ▶ if (defined $perlFileName) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $perlFileName) 0 0 0
1366 0 $perlNameToFileURINo{$perlFileName} = $bFileURINo;
1367 0 $fileNameTable[$bFileURINo] = [$bFileURI,
1368 $bFileName,
1369 $perlFileName];
1370 }
1371 };
1372 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1373 0 my $error = $@;
1374  
1375 0 ▶ dblog("Error in uriToFilename: $error " .
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1376 DB::Data::Dump::dump(dump_trace(0))) if $ldebug;
1377 }
1378 }
1379  
1380 # And set the references
1381 0 $$rbFileURI = $bFileURI;
1382 0 $$rbFileURINo = $bFileURINo;
1383 0 $$rbFileName = $bFileName;
1384 0 $$rperlFileName = $perlFileName;
1385 }
1386
1387  
1388 sub getBreakpointInfoString($%) {
1389 0 ▶ my ($bkptID, %extraInfo) = @_;
Subroutine getBreakpointInfoString: not called CC=23 SCAR=63.1
Pod undocumented
1390 0 my $bkptInfo = $bkptInfoTable{$bkptID};
1391 0 ▶ if (defined $bkptInfo && ref $bkptInfo eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bkptInfo and ref $bkptInfo eq 'ARRAY') { } 0 0 0
Condition0%0/3
defined $bkptInfo and ref $bkptInfo eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $bkptInfo and ref $bkptInfo eq "ARRAY"
defined $bkptInfo ref $bkptInfo eq "ARRAY"
Truth table0%0/3
A and B
A= defined $bkptInfoB= ref $bkptInfo eq "ARRAY"
ABresult
0X0
100
111
1392 0 my ($xbFileURINo, $xbLine, $bState, $bType, $bFunction, $bExpression, $bException, $bHitInfo) = @$bkptInfo;
1393 0 my $res = sprintf(qq(<breakpoint
1394 id="%s"
1395 type="%s"),
1396 $bkptID,
1397 $bType
1398 );
1399 0 ▶ if ($extraInfo{fileURI} || $xbFileURINo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extraInfo{"fileURI"} or $xbFileURINo) 0 0 0
Condition0%0/3
$extraInfo{"fileURI"} or $xbFileURINo
l!l&&r!l&&!r
000
MC/DC0%0/2
$extraInfo{"fileURI"} or $xbFileURINo
$extraInfo{"fileURI"} $xbFileURINo
Truth table0%0/3
A or B
A= $extraInfo{"fileURI"}B= $xbFileURINo
ABresult
1X1
011
000
1400 0 ▶ my $bFileURI = getURIByNo($extraInfo{fileURI} || $xbFileURINo);
Condition0%0/3
$extraInfo{'fileURI'} || $xbFileURINo
l!l&&r!l&&!r
000
MC/DC0%0/2
$extraInfo{'fileURI'} || $xbFileURINo
$extraInfo{'fileURI'} $xbFileURINo
Truth table0%0/3
A || B
A= $extraInfo{'fileURI'}B= $xbFileURINo
ABresult
1X1
011
000
1401 0 ▶ if ($bFileURI) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bFileURI) 0 0 0
1402 0 $res .= sprintf(' filename="%s"',
1403 $bFileURI);
1404 }
1405 }
1406 0 ▶ if ($extraInfo{lineNo} || $xbLine) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extraInfo{"lineNo"} or $xbLine) 0 0 0
Condition0%0/3
$extraInfo{"lineNo"} or $xbLine
l!l&&r!l&&!r
000
MC/DC0%0/2
$extraInfo{"lineNo"} or $xbLine
$extraInfo{"lineNo"} $xbLine
Truth table0%0/3
A or B
A= $extraInfo{"lineNo"}B= $xbLine
ABresult
1X1
011
000
1407 $res .= sprintf(' line="%s" lineno="%s"',
1408 0 ▶ ($extraInfo{lineNo} || $xbLine) x 2);
Condition0%0/3
$extraInfo{'lineNo'} || $xbLine
l!l&&r!l&&!r
000
MC/DC0%0/2
$extraInfo{'lineNo'} || $xbLine
$extraInfo{'lineNo'} $xbLine
Truth table0%0/3
A || B
A= $extraInfo{'lineNo'}B= $xbLine
ABresult
1X1
011
000
1409 }
1410 0 ▶ if ($extraInfo{function} || $bFunction) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extraInfo{"function"} or $bFunction) 0 0 0
Condition0%0/3
$extraInfo{"function"} or $bFunction
l!l&&r!l&&!r
000
MC/DC0%0/2
$extraInfo{"function"} or $bFunction
$extraInfo{"function"} $bFunction
Truth table0%0/3
A or B
A= $extraInfo{"function"}B= $bFunction
ABresult
1X1
011
000
1411 $res .= sprintf(' function="%s"',
1412 0 ▶ ($extraInfo{function} || $bFunction));
Condition0%0/3
$extraInfo{'function'} || $bFunction
l!l&&r!l&&!r
000
MC/DC0%0/2
$extraInfo{'function'} || $bFunction
$extraInfo{'function'} $bFunction
Truth table0%0/3
A || B
A= $extraInfo{'function'}B= $bFunction
ABresult
1X1
011
000
1413 }
1414 0 ▶ $res .= sprintf(' state="%s"',
Branch: 3 branches
BranchTrueFalseTotal
$bState == 3 ? : 0 0 0
$xdebug_temporary_breakpoint_state ? : 0 0 0
$bState == 1 ? : 0 0 0
1415 $bState == BKPT_TEMPORARY ?
1416 ($xdebug_temporary_breakpoint_state ? 'temporary' : 'enabled') :
1417 $bState == BKPT_DISABLE ? 'disabled' :
1418 'enabled');
1419 0 ▶ $res .= sprintf(' temporary="%d"',
Branch: 1 branch
BranchTrueFalseTotal
$bState == 3 ? : 0 0 0
1420 $bState == BKPT_TEMPORARY ? 1 : 0);
1421 0 ▶ $res .= sprintf(' exception="%s"',
Branch: 1 branch
BranchTrueFalseTotal
if defined $bException 0 0 0
1422 $bException) if defined $bException;
1423 0 ▶ if ($bHitInfo && defined $bHitInfo->[HIT_TBL_COUNT]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bHitInfo and defined $bHitInfo->[0]) 0 0 0
Condition0%0/3
$bHitInfo and defined $bHitInfo->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$bHitInfo and defined $bHitInfo->[0]
$bHitInfo defined $bHitInfo->[0]
Truth table0%0/3
A and B
A= $bHitInfoB= defined $bHitInfo->[0]
ABresult
0X0
100
111
1424 0 $res .= sprintf(' hit_count ="%s"', $bHitInfo->[HIT_TBL_COUNT]);
1425 0 ▶ if (defined $bHitInfo->[HIT_TBL_VALUE]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bHitInfo->[1]) 0 0 0
1426 0 $res .= sprintf(' hit_value ="%s"', $bHitInfo->[HIT_TBL_VALUE]);
1427 }
1428 0 ▶ if (defined $bHitInfo->[HIT_TBL_COND_STRING]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bHitInfo->[3]) 0 0 0
1429 0 $res .= sprintf(' hit_condition ="%s"',
1430 xmlAttrEncode($bHitInfo->[HIT_TBL_COND_STRING]));
1431 }
1432 }
1433 0 $res .= sprintf(">%s</breakpoint>\n",
1434 getExpressionTag($bExpression));
1435 0 return $res;
1436 } else {
1437 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
1438 dblog("bkptInfo($bkptID, ",
1439 0 join(", ", map{$_ => "($_, $extraInfo{$_})"} keys %extraInfo),
1440 "), not defined\n");
1441 }
1442 0 return undef;
1443 }
1444 }
1445  
1446 sub processPossibleBreakpoint($$;$$) {
1447 0 ▶ my ($bkptInfoRef, $locationString, $dbline, $line) = @_;
Subroutine processPossibleBreakpoint: not called CC=16 SCAR=56.1
Pod undocumented
1448 # ($bFileURINo, $bLine, $bState, $bType, $bFunction, $bExpression, $bException, $bHitInfo) = @$bkptInfoRef;
1449 0 ▶ if (!defined $bkptInfoRef) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $bkptInfoRef) 0 0 0
1450 0 return;
1451 }
1452 0 my $bState = $bkptInfoRef->[BKPTBL_STATE];
1453 0 ▶ if ($bState == BKPT_DISABLE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bState == 1) { } 0 0 0
elsif ($bkptInfoRef->[3] eq 'watch') { } 0 0 0
1454 0 return;
1455 }
1456 elsif ($bkptInfoRef->[BKPTBL_TYPE] eq 'watch') {
1457 0 ▶ dblog("Don't break on watch-breakpoints in processPossibleBreakpoint") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1458 0 return;
1459 }
1460 0 my $bHitInfo = $bkptInfoRef->[BKPTBL_HIT_INFO];
1461 0 my $breakHere;
1462 0 ▶ if ($bHitInfo && defined $bHitInfo->[HIT_TBL_COUNT]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bHitInfo and defined $bHitInfo->[0]) { } 0 0 0
Condition0%0/3
$bHitInfo and defined $bHitInfo->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$bHitInfo and defined $bHitInfo->[0]
$bHitInfo defined $bHitInfo->[0]
Truth table0%0/3
A and B
A= $bHitInfoB= defined $bHitInfo->[0]
ABresult
0X0
100
111
1463 0 $bHitInfo->[HIT_TBL_COUNT] += 1;
1464  
1465 # Are we doing hit-testing?
1466 0 ▶ if (defined $bHitInfo->[HIT_TBL_EVAL_FUNC]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bHitInfo->[2]) { } 0 0 0
1467 0 $breakHere = $bHitInfo->[HIT_TBL_EVAL_FUNC]->($bHitInfo->[HIT_TBL_COUNT],
1468 $bHitInfo->[HIT_TBL_VALUE]);
1469 } else {
1470 0 $breakHere = 1;
1471 }
1472 } else {
1473 0 $breakHere = 1;
1474 }
1475 0 ▶ if (!$breakHere) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($breakHere) 0 0 0
1476 0 return;
1477 }
1478 0 my $bExpression = $bkptInfoRef->[BKPTBL_CONDITION];
1479 0 ▶ if ($bExpression) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bExpression) 0 0 0
1480 # If we're here, $DB::signal must be false.
1481 # Can only be called from DB -- function breakpoints
1482 # can't be conditional.
1483
1484 # As long as we're only called from DB::DB, there's
1485 # no reason to save the globals.
1486 0 local $evalSkipFrames = $evalSkipFrames + 2;
1487 0 eval {
1488 # $DB::signal because $usercontext overrides the package
1489 0 $evalarg = "\$DB::signal |= do {$bExpression;}"; &eval();
1490 };
1491 0 ▶ if ($@ || !$signal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $signal) 0 0 0
Condition0%0/3
$@ or not $signal
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not $signal
$@ not $signal
Truth table0%0/3
A or not(B)
A= $@B= not $signal
ABresult
1X1
011
000
1492 0 $breakHere = 0;
1493 }
1494 }
1495 0 ▶ if ($breakHere) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breakHere) { } 0 0 0
1496 0 $signal |= 1;
1497 0 ▶ if ($bState == BKPT_TEMPORARY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bState == 3) 0 0 0
1498 0 $bkptInfoRef->[BKPTBL_STATE] = BKPT_DISABLE;
1499 0 ▶ $dbline->{$line} = 0 if $line && $dbline;
Branch: 1 branch
BranchTrueFalseTotal
if $line and $dbline 0 0 0
Condition0%0/3
$line and $dbline
!ll&&!rl&&r
000
MC/DC0%0/2
$line and $dbline
$line $dbline
Truth table0%0/3
A and B
A= $lineB= $dbline
ABresult
0X0
100
111
1500 }
1501 } else {
1502 # Don't break here, but there are no
1503 # more items that need to be turned off.
1504 # If we got to the caller by stepping in, over, or out, we
1505 # wouldn't have invoked this routine at all.
1506 }
1507 }
1508  
1509 sub splitCommandLine {
1510 0 ▶ my ($cmd) = @_;
Subroutine splitCommandLine: not called CC=9 SCAR=45.0
Pod undocumented
1511 0 my @args;
1512 0 ($cmd) = $cmd =~ /^\s*(.*)$/s;
1513 0 ▶ while (length $cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $cmd) 0 0 0
1514 0 ▶ if ($cmd =~ /^([\"\'])/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($cmd =~ /^([\"\'])/) { } 0 0 0
elsif ($cmd =~ /^'((?:\\.|[^\'])*)'\s*(.*)$/s) { } 0 0 0
elsif ($cmd =~ /^([^\s\"]+)\s*(.*)$/s) { } 0 0 0
1515 0 my $q = $1;
1516 0 my $arg = "";
1517 0 $cmd = substr($cmd, 1);
1518 0 ▶ while (length $cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $cmd) 0 0 0
1519 0 ▶ if ($cmd =~ /^$q\s*(.*)$/s) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd =~ /^$q\s*(.*)$/s) { } 0 0 0
elsif ($cmd =~ /^\\([\'\"\\])(.*)$/s) { } 0 0 0
1520 0 $cmd = $1;
1521 0 last;
1522 } elsif ($cmd =~ /^\\([\'\"\\])(.*)$/s) {
1523 0 $arg .= $1;
1524 0 $cmd = $2;
1525 } else {
1526 0 $cmd =~ /^(.[^\'\"\\]*)(.*)$/s;
1527 0 $arg .= $1;
1528 0 $cmd = $2;
1529 }
1530 }
1531 0 push @args, $arg;
1532 } elsif ($cmd =~ /^'((?:\\.|[^\'])*)'\s*(.*)$/s) {
1533 0 push @args, $1;
1534 0 $cmd = $2;
1535 } elsif ($cmd =~ /^([^\s\"]+)\s*(.*)$/s) {
1536 0 push @args, $1;
1537 0 $cmd = $2;
1538 } else {
1539 0 ▶ dblog("Can't deal with input [$cmd]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1540 0 push @args, substr($cmd, 0, 1);
1541 0 $cmd = substr($cmd, 1);
1542 }
1543 }
1544 0 return @args;
1545 }
1546  
1547 sub trimEvalSubNames($) {
1548 0 ▶ my ($subname) = @_;
Subroutine trimEvalSubNames: not called CC=3 SCAR=24.8
Pod undocumented
1549 0 ▶ if ($subname =~ /^eval\s+[\"\'q]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($subname =~ /^eval\s+[\"\'q]/) { } 0 0 0
elsif ($subname =~ /^eval\s+\{/) { } 0 0 0
1550 0 $subname = q(eval '...');
1551 } elsif ($subname =~ /^eval\s+\{/) {
1552 0 $subname = q(eval {...});
1553 }
1554 0 return $subname;
1555 }
1556  
1557 sub _guessScalarOrArray($) {
1558 0 ▶ my $valsARef = shift;
Subroutine _guessScalarOrArray: not called CC=7 SCAR=40.3
1559 0 ▶ if (!$valsARef) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($valsARef) 0 0 0
1560 0 return [];
1561 }
1562 0 my $size = scalar @$valsARef;
1563 0 ▶ if ($size == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($size == 0) { } 0 0 0
elsif ($size == 1) { } 0 0 0
1564 0 return "";
1565 } elsif ($size == 1) {
1566 0 return $valsARef->[0];
1567 } else {
1568 0 foreach my $currLine (@$valsARef) {
1569 0 ▶ if (ref $currLine) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $currLine) { } 0 0 0
elsif (not $currLine =~ /\n$/) { } 0 0 0
1570 0 return $valsARef;
1571 } elsif ($currLine !~ /\n$/) {
1572 0 return $valsARef;
1573 }
1574 }
1575 # They're all strings
1576 0 return join('', @$valsARef);
1577 }
1578 }
1579  
1580 sub _fillMissingPodlines {
1581 0 ▶ my ($beginLine, $endLine, $dblines) = @_;
Subroutine _fillMissingPodlines: not called CC=19 SCAR=59.4
1582 0 my @copy = @$dblines[$beginLine .. $endLine];
1583 # Perl strips away the pod lines as a cheap way of
1584 # determining which lines are breakable -- sort of
1585 # -- we need to put something
1586 # back or Komodo goes berserk.
1587  
1588 0 my $eol;
1589 0 ▶ if ($copy[0] =~ /([\r\n]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($copy[0] =~ /([\r\n]+)$/) { } 0 0 0
1590 0 $eol = $1;
1591 } else {
1592 0 $eol = "\n";
1593 }
1594 0 ▶ for (my $i = 0; $i <= $#copy; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#copy) 0 0 0
1595 0 ▶ dblog("Processing line $i : <<$copy[$i]>>") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1596 0 ▶ if (!defined $copy[$i]) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $copy[$i]) { } 0 0 0
elsif (not $copy[$i] =~ /[\r\n]$/) { } 0 0 0
1597 0 ▶ if (substr($copy[$i - 1], 0, 1) == "=") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($copy[$i - 1], 0, 1) == '=') { } 0 0 0
1598 0 $copy[$i] = "<pod dropped>$eol";
1599 0 ▶ dblog("Setting line $i to pod-dropped") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1600 0 ▶ while (++$i <= $#copy && !defined $copy[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i <= $#copy and not defined $copy[$i]) 0 0 0
Condition0%0/3
++$i <= $#copy and not defined $copy[$i]
!ll&&!rl&&r
000
MC/DC0%0/2
++$i <= $#copy and not defined $copy[$i]
++$i <= $#copy not defined $copy[$i]
Truth table0%0/3
A and not(B)
A= ++$i <= $#copyB= not defined $copy[$i]
ABresult
0X0
100
111
1601 0 $copy[$i] = "?$eol";
1602 0 ▶ dblog("Setting line $i to unknown") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1603 }
1604 0 ▶ if ($i <= $#copy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#copy) { } 0 0 0
1605 0 ▶ if ($copy[$i] !~ /[\r\n]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $copy[$i] =~ /[\r\n]$/) { } 0 0 0
1606 0 $copy[$i] = "=cut$eol";
1607 } else {
1608 0 ▶ dblog("Hey, line $i : $copy[$i] already ends with nl") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1609 }
1610 } else {
1611 0 ▶ dblog("Ran off the end of the file") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1612 }
1613 } else {
1614 0 ▶ dblog("line $i is undefined, but prev line = $copy[$i - 1]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1615 0 $copy[$i] = "$eol";
1616 }
1617 } elsif ($copy[$i] !~ /[\r\n]$/) {
1618 0 ▶ dblog("line $i ($copy[$i]) doesn't end with newline") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1619 0 ▶ if ($copy[$i - 1] =~ /^[\?=]/ && length($copy[$i]) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($copy[$i - 1] =~ /^[\?=]/ and length $copy[$i] == 0) { } 0 0 0
Condition0%0/3
$copy[$i - 1] =~ /^[\?=]/ and length $copy[$i] == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$copy[$i - 1] =~ /^[\?=]/ and length $copy[$i] == 0
$copy[$i - 1] =~ /^[\?=]/ length $copy[$i] == 0
Truth table0%0/3
A and B
A= $copy[$i - 1] =~ /^[\?=]/B= length $copy[$i] == 0
ABresult
0X0
100
111
1620 0 $copy[$i] = "=cut$eol";
1621 } else {
1622 0 $copy[$i] .= "$eol";
1623 }
1624 }
1625 }
1626 0 return join("", @copy);
1627 }
1628  
1629 sub _fileSource {
1630 0 ▶ my ($perlFileName, $beginLine, $endLine, $dblines) = @_;
Subroutine _fileSource: not called CC=23 SCAR=63.1
1631 0 my $sourceKey = '_<' . $perlFileName;
1632 0 my $sourceString;
1633 0 local $@;
1634 0 ▶ if (!defined $sourceString && defined &INC && $perlFileName =~ m,^/(Perl\w{3}/|<.*?>)(.*),) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $sourceString and defined &INC and $perlFileName =~ m[^/(Perl\w{3}/|<.*?>)(.*)]) 0 0 0
Condition0%0/6
not defined $sourceString and defined &INC and $perlFileName =~ m[^/(Perl\w{3}/|<.*?>)(.*)]
!ll&&!rl&&r
000
not defined $sourceString and defined &INC
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $sourceString and defined &INC and $perlFileName =~ m[^/(Perl\w{3}/|<.*?>)(.*)]
not defined $sourceString defined &INC $perlFileName =~ m[^/(Perl\w{3}/|<.*?>)(.*)]
Truth table0%0/4
not(A) and B and C
A= not defined $sourceStringB= defined &INCC= $perlFileName =~ m[^/(Perl\w{3}/|<.*?>)(.*)]
ABCresult
0XX0
10X0
1100
1111
1635 0 my $pdkUtilityName = $1;
1636 0 $sourceString = INC($2);
1637 0 ▶ if ($ldebug && defined $sourceString) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug and defined $sourceString) 0 0 0
Condition0%0/3
$ldebug and defined $sourceString
!ll&&!rl&&r
000
MC/DC0%0/2
$ldebug and defined $sourceString
$ldebug defined $sourceString
Truth table0%0/3
A and B
A= $ldebugB= defined $sourceString
ABresult
0X0
100
111
1638 0 my @lines = split(/\n/, $sourceString);
1639 0 dblog("Debugging a $pdkUtilityName module, grab source and get [" . join("\n", @lines[0..2]) . "]");
1640 }
1641 }
1642 0 ▶ if (!defined $sourceString && exists $main::{$sourceKey}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $sourceString and exists $main::main::{$sourceKey}) 0 0 0
Condition0%0/3
not defined $sourceString and exists $main::main::{$sourceKey}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $sourceString and exists $main::main::{$sourceKey}
not defined $sourceString exists $main::main::{$sourceKey}
Truth table0%0/3
not(A) and B
A= not defined $sourceStringB= exists $main::main::{$sourceKey}
ABresult
0X0
100
111
1643 0 our @dbline;
1644 0 local *dbline = $main::{$sourceKey};
1645 0 ▶ if (@dbline > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@DB::dbline > 0) 0 0 0
1646 0 ▶ $endLine = $#dbline if !$endLine;
Branch: 1 branch
BranchTrueFalseTotal
unless $endLine 0 0 0
1647 0 ▶ $endLine < $beginLine and $endLine = $beginLine;
Branch: 1 branch
BranchTrueFalseTotal
$endLine < $beginLine and $endLine = $beginLine 0 0 0
1648 0 ▶ $sourceString = $] >= 5.012 ?
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.012 ? : 0 0 0
1649 join('', @dbline[$beginLine .. $endLine]) :
1650 _fillMissingPodlines($beginLine, $endLine, $dblines);
1651 }
1652 }
1653 0 ▶ if (!defined $sourceString) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sourceString) 0 0 0
1654 0 ▶ dblog("source: using file [$perlFileName]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1655 0 eval {
1656 0 open my $fh, "<", $perlFileName;
1657 0 ▶ if ($fh) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh) 0 0 0
1658 0 ▶ if ($beginLine == 1 && !$endLine) {
Branch: 1 branch
BranchTrueFalseTotal
if ($beginLine == 1 and not $endLine) { } 0 0 0
Condition0%0/3
$beginLine == 1 and not $endLine
!ll&&!rl&&r
000
MC/DC0%0/2
$beginLine == 1 and not $endLine
$beginLine == 1 not $endLine
Truth table0%0/3
A and not(B)
A= $beginLine == 1B= not $endLine
ABresult
0X0
100
111
1659 0 local $/ = undef;
1660 0 $sourceString = <$fh>;
1661 } else {
1662 0 my @lines = <$fh>;
1663 0 ▶ $sourceString = join '', @lines[($beginLine - 1) .. ((!$endLine || $endLine >= @lines) ? @lines - 1 : $endLine - 1)];
Branch: 1 branch
BranchTrueFalseTotal
!$endLine || $endLine >= @lines ? : 0 0 0
Condition0%0/3
not $endLine or $endLine >= @lines
l!l&&r!l&&!r
000
MC/DC0%0/2
not $endLine or $endLine >= @lines
not $endLine $endLine >= @lines
Truth table0%0/3
not(A) or B
A= not $endLineB= $endLine >= @lines
ABresult
1X1
011
000
1664 }
1665 0 close $fh;
1666 }
1667 };
1668 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1669 0 ▶ dblog("open file $perlFileName: $@\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1670 }
1671 }
1672 0 ▶ if (!defined $sourceString) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sourceString) 0 0 0
1673 0 ▶ if (!$@) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
1674 0 $@ = "# Error: Komodo couldn't find the file $perlFileName\n";
1675 }
1676 }
1677 0 return ($sourceString, $@);
1678 }
1679  
1680  
1681 sub _trimExceptionInfo($) {
1682 0 ▶ my $error = shift;
Subroutine _trimExceptionInfo: not called CC=1 SCAR=6.9
1683 0 $error =~ s/ at (?:\(eval \d+\))?\[.*:\d+\] line \d+, at .+$//;
1684 0 return $error;
1685 }
1686  
1687 # Better to wrap the function than to override it,
1688 # as the user code might rely on alarm() faulting on
1689 # certain systems.
1690  
1691 sub db_alarm {
1692 0 ▶ return if $skip_alarm;
Subroutine db_alarm: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $skip_alarm 0 0 0
1693 0 my $time = shift;
1694 0 local $@;
1695 0 eval {
1696 0 alarm($time);
1697 };
1698 0 ▶ $skip_alarm = 1 if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1699 }
1700  
1701 # DB::eval returns an array, but we can do better
1702 sub eval_term {
1703 0 ▶ my ($term) = @_;
Subroutine eval_term: not called CC=6 SCAR=37.4
Pod undocumented
1704 0 my $valRef;
1705 # Avoid pattern-matching
1706 0 my $firstChar = substr($term, 0, 1);
1707 0 $no_value = undef;
1708 0 $evalarg = $term;
1709 0 local $evalSkipFrames = $evalSkipFrames + 1;
1710 0 ▶ if ($firstChar eq '@') {
Branch: 2 branches
BranchTrueFalseTotal
if ($firstChar eq '@') { } 0 0 0
elsif ($firstChar eq '%') { } 0 0 0
1711 0 my @tmp = &eval();
1712 0 ▶ if ($no_value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no_value) 0 0 0
1713 0 @tmp = ();
1714 }
1715 0 $valRef = \@tmp;
1716 } elsif ($firstChar eq '%') {
1717 0 my %tmp = &eval();
1718 0 ▶ if ($no_value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no_value) 0 0 0
1719 0 %tmp = ();
1720 }
1721 0 $valRef = \%tmp;
1722 } else {
1723 # eval always fires in array context
1724 0 my @tmp = &eval();
1725 0 ▶ if ($no_value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no_value) { } 0 0 0
1726 0 $valRef = undef;
1727 } else {
1728 0 $valRef = _guessScalarOrArray(\@tmp);
1729 }
1730 }
1731 }
1732  
1733 my %firstFileInfo;
1734 our ($full_bypass); # used in DB::RedirectStdOutput
1735  
1736 sub DB {
1737 0 ▶ if ($full_bypass) {
Subroutine DB: not called CC=359 SCAR=117.7
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ($DB::full_bypass) 0 0 0
1738 0 my ($pkg, $filename, $line) = caller;
1739 0 ▶ dblog("Bypassing ($pkg, $filename, $line)") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1740 0 return;
1741 }
1742 # return unless $ready;
1743 0 ▶ if (! $ready) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ready) 0 0 0
1744 #### dblog("Not ready in DB -- returning\n") if $ldebug;
1745 0 return;
1746 }
1747 0 db_alarm(0);
1748  
1749 # do important stuff
1750 #
1751 0 &save;
1752 0 ▶ if ($PID != $$) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PID != $$) 0 0 0
1753 0 connectOrReconnect();
1754 0 ▶ unless ($OUT) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($OUT) 0 0 0
1755 0 ($@, $!, $,, $/, $\, $^W) = @saved;
1756 0 return;
1757 }
1758 }
1759 0 (my $pkg, $currentFilename, $currentLine) = caller;
1760 # stack layout
1761 # Perl DB::sub: call-site -> DB::sub -> actual sub -> DB::DB
1762 # XS DB::sub: call-site -> -> actual sub -> DB::DB
1763 # so we need 2 or 3 levels for DB::eval to get to the actual call
1764 #
1765 # however if we skip the extra frame directly here (with a conditional),
1766 # if makes the interaction of sub foo { eval { ... } } with the logic
1767 # to look at deeper stack frames more complicated, so here we only
1768 # skip the two level required to go to the first non-debugger frame,
1769 # and leave the logic to deal with the XS vs. non-XS DB::sub in DB::eval
1770 0 local $evalSkipFrames = 2;
1771 0 ▶ if (!defined $startedAsInteractiveShell) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $startedAsInteractiveShell) 0 0 0
1772 # This won't work with code that changes $0 to "-e"
1773 # in a BEGIN block.
1774 0 ▶ if ($0 eq '-e') {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 eq '-e') { } 0 0 0
1775 0 $startedAsInteractiveShell = 1;
1776 0 $stopReason = STOP_REASON_INTERACT;
1777 0 emitBanner();
1778 } else {
1779 0 $startedAsInteractiveShell = 0;
1780 0 $stopReason = STOP_REASON_BREAK;
1781 }
1782 }
1783 0 ▶ if ($ldebug && $pkg !~ /^DB::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug and not $pkg =~ /^DB::/) 0 0 0
Condition0%0/3
$ldebug and not $pkg =~ /^DB::/
!ll&&!rl&&r
000
MC/DC0%0/2
$ldebug and not $pkg =~ /^DB::/
$ldebug not $pkg =~ /^DB::/
Truth table0%0/3
A and not(B)
A= $ldebugB= not $pkg =~ /^DB::/
ABresult
0X0
100
111
1784 0 dblog("In $pkg, $currentFilename, $currentLine\n");
1785 }
1786
1787 0 $usercontext = '($@, $!, $,, $/, $\, $^W) = @saved;' .
1788 "package $pkg;"; # this won't let them modify, alas
1789  
1790 0 ▶ if ($currentFilename =~ s/ \(autosplit .*$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currentFilename =~ s/ \(autosplit .*$//) 0 0 0
1791 0 my $substr = $Config::Config{prefix};
1792 0 $currentFilename =~ s/^\.\./$substr/;
1793 }
1794  
1795 0 ▶ if ($pkg eq 'DB::fake') {
Branch: 3 branches
BranchTrueFalseTotal
if ($pkg eq 'DB::fake') { } 0 0 0
elsif ($runnonstop) { } 0 0 0
elsif (not $sentInitString) { } 0 0 0
1796 # Fallen off the end, so allow debugging
1797 # Set the DB::eval context appropriately.
1798 0 ▶ if (exists $firstFileInfo{file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $firstFileInfo{'file'}) { } 0 0 0
1799 0 ($pkg, $currentFilename, $currentLine) = @firstFileInfo{qw/pkg file lastLineNumber/};
1800 } else {
1801 0 $pkg = 'main';
1802 }
1803 0 $usercontext =
1804 '($@, $!, $^E, $,, $/, $\, $^W) = @saved;' .
1805 "package $pkg;"; # this won't let them modify, alas
1806 0 ▶ if ($runnonstop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runnonstop) 0 0 0
1807 0 exit 0;
1808 }
1809 0 $supportedCommands{'detach'} = 1;
1810 # This just doesn't make sense: at the end of the program,
1811 # we aren't executing anymore.
1812 # But we can look at the global variables
1813 # $supportedCommands{'stack_get'} = 0;
1814 0 $supportedCommands{'context_get'} = 0;
1815 0 $single = 1;
1816 } elsif ($runnonstop) {
1817 0 db_alarm($pending_check_interval);
1818 0 ($@, $!, $,, $/, $\, $^W) = @saved;
1819 0 return;
1820 } elsif (!$sentInitString) {
1821 0 sendInitString();
1822 0 $sentInitString = 1;
1823 }
1824  
1825 0 my $fileNameURI;
1826 my $fileNameURINo;
1827 0 our (@dbline, %dbline);
1828  
1829 0 local*dbline = "::_<$currentFilename";
1830 0 ▶ if ($ldebug && $pkg eq 'DB::fake') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug and $pkg eq "DB::fake") 0 0 0
Condition0%0/3
$ldebug and $pkg eq "DB::fake"
!ll&&!rl&&r
000
MC/DC0%0/2
$ldebug and $pkg eq "DB::fake"
$ldebug $pkg eq "DB::fake"
Truth table0%0/3
A and B
A= $ldebugB= $pkg eq "DB::fake"
ABresult
0X0
100
111
1831 0 dblog($dbline[$currentLine]);
1832 }
1833  
1834 0 my $canPerlFileName = canonicalizeFName($currentFilename);
1835 0 ▶ if (exists $perlNameToFileURINo{$canPerlFileName}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $perlNameToFileURINo{$canPerlFileName}) { } 0 0 0
elsif ($currentFilename =~ /\(eval (\d+)\)\[(.*):(\d+)\]$/) { } 0 0 0
1836 0 $fileNameURINo = $perlNameToFileURINo{$canPerlFileName};
1837 0 ($fileNameURI, undef, undef) = @{$fileNameTable[$fileNameURINo]};
1838 } elsif ($currentFilename =~ /\(eval (\d+)\)\[(.*):(\d+)\]$/) {
1839 0 internEvalURI($currentFilename, \@dbline);
1840 0 $fileNameURI = calcFileURI($currentFilename);
1841 0 $fileNameURINo = internFileURI($fileNameURI);
1842 } else {
1843 0 $fileNameURI = filenameToURI($currentFilename, 1);
1844 0 $fileNameURINo = internFileURI($fileNameURI);
1845 }
1846  
1847 0 ▶ if ($pkg !~ /^DB::/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pkg =~ /^DB::/) 0 0 0
1848 0 ▶ if (! exists $firstFileInfo{file}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $firstFileInfo{'file'}) { } 0 0 0
elsif ($firstFileInfo{'file'} eq $currentFilename) { } 0 0 0
1849 0 $firstFileInfo{file} = $currentFilename; # Perl file name
1850 0 $firstFileInfo{pkg} = $pkg;
1851 0 $firstFileInfo{lastLine} = $currentLine; # last line executed
1852 0 $firstFileInfo{lineInfo} = \@dbline;
1853 0 $firstFileInfo{lastLineNumber} = $#dbline;
1854 } elsif ($firstFileInfo{file} eq $currentFilename) {
1855 0 $firstFileInfo{lastLine} = $currentLine; # last line executed
1856 }
1857 }
1858  
1859 0 ▶ if (!$single) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($single) 0 0 0
1860 0 my $bkptInfoRef = lookupBkptInfo($fileNameURINo, $currentLine);
1861 0 processPossibleBreakpoint($bkptInfoRef, "File $fileNameURINo, line $currentLine", \%dbline, $currentLine);
1862 }
1863  
1864 # If we have any watch expressions ...
1865 0 ▶ if (!$single && ($trace & 2) && $pkg !~ /^DB::/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $single and $trace & 2 and not $pkg =~ /^DB::/) 0 0 0
Condition0%0/6
not $single and $trace & 2 and not $pkg =~ /^DB::/
!ll&&!rl&&r
000
not $single and $trace & 2
!ll&&!rl&&r
000
MC/DC0%0/3
not $single and $trace & 2 and not $pkg =~ /^DB::/
not $single $trace & 2 not $pkg =~ /^DB::/
Truth table0%0/4
not(A) and B and not(C)
A= not $singleB= $trace & 2C= not $pkg =~ /^DB::/
ABCresult
0XX0
10X0
1100
1111
1866 0 ▶ for (my $i = 0 ; $i <= $#watchPoints ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#watchPoints) 0 0 0
1867 0 $evalarg = $watchPoints[$i];
1868  
1869 # Fix context DB::eval() wants to return an array, but
1870 # we need a scalar here.
1871 0 my ($val) = eval { join (' ', &eval ) };
1872 0 ▶ $val = ((defined $val) ? "'$val'" : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
1873  
1874 # Did it change?
1875 0 ▶ if ($val ne $watchPointValues[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val ne $watchPointValues[$i]) 0 0 0
1876 0 ▶ dblog("checking watches, {$watchPoints[$i]} was [$watchPointValues[$i]], not [$val]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1877 # Yep! Show the difference, and fake an interrupt.
1878 0 $signal = 1;
1879 0 $watchPointValues[$i] = $val;
1880 0 last;
1881 }
1882 }
1883 }
1884  
1885 0 ▶ if (($single || $signal)
Branch: 3 branches
BranchTrueFalseTotal
if ($single || $signal and $pkg eq 'DB::fake' || !($pkg =~ /^DB::/) and not $inPostponed) { } 0 0 0
elsif ($pkg =~ /^DB::/) { } 0 0 0
elsif ($inPostponed) { } 0 0 0
Condition0%0/12
$single || $signal and $pkg eq "DB::fake" || !($pkg =~ /^DB::/) and not $inPostponed
!ll&&!rl&&r
000
$single || $signal and $pkg eq "DB::fake" || !($pkg =~ /^DB::/)
!ll&&!rl&&r
000
$single or $signal
l!l&&r!l&&!r
000
$pkg eq "DB::fake" or not $pkg =~ /^DB::/
l!l&&r!l&&!r
000
MC/DC0%0/5
$single || $signal and $pkg eq "DB::fake" || !($pkg =~ /^DB::/) and not $inPostponed
$single $signal $pkg eq "DB::fake" not $pkg =~ /^DB::/ not $inPostponed
Truth table0%0/11
A or B and C or not(D) and not(E)
A= $singleB= $signalC= $pkg eq "DB::fake"D= not $pkg =~ /^DB::/E= not $inPostponed
ABCDEresult
00XXX0
1X00X0
0100X0
1X1X00
1X0100
011X00
010100
1X1X11
1X0111
011X11
010111
1886 && ($pkg eq 'DB::fake' || $pkg !~ /^DB::/)
1887 && !$inPostponed) {
1888 # Yes, go down a level.
1889 0 local $level = $level + 1;
1890 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
1891 0 dblog("file:$currentFilename, line:$currentLine, package:$pkg\n");
1892 0 ▶ dblog($#stack . " levels deep in subroutine calls!\n") if $single & 4;
Branch: 1 branch
BranchTrueFalseTotal
if $single & 4 0 0 0
1893 }
1894 # Send a status thing back
1895 0 ▶ if ($pkg eq 'DB::fake') {
Branch: 2 branches
BranchTrueFalseTotal
if ($pkg eq 'DB::fake') { } 0 0 0
elsif (defined $lastContinuationCommand and $lastContinuationCommand eq 'detach' || $lastContinuationStatus ne 'stopping') { } 0 0 0
1896 # Do nothing
1897 ▶ } elsif (defined $lastContinuationCommand &&
Condition0%0/6
defined $lastContinuationCommand and $lastContinuationCommand eq "detach" || $lastContinuationStatus ne "stopping"
!ll&&!rl&&r
000
$lastContinuationCommand eq "detach" or $lastContinuationStatus ne "stopping"
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $lastContinuationCommand and $lastContinuationCommand eq "detach" || $lastContinuationStatus ne "stopping"
defined $lastContinuationCommand $lastContinuationCommand eq "detach" $lastContinuationStatus ne "stopping"
Truth table0%0/4
A and B or C
A= defined $lastContinuationCommandB= $lastContinuationCommand eq "detach"C= $lastContinuationStatus ne "stopping"
ABCresult
0XX0
1000
11X1
1011
1898 ($lastContinuationCommand eq 'detach' ||
1899 $lastContinuationStatus ne 'stopping')) {
1900 0 printWithLength(sprintf(qq(%s\n<response %s command="%s" status="%s"
1901 reason="ok" transaction_id="%s" %s>),
1902 xmlHeader(),
1903 namespaceAttr(),
1904 $lastContinuationCommand,
1905 $lastContinuationStatus,
1906 $lastTranID,
1907 fileAndLineIfXdebug()));
1908 }
1909 0 ▶ $stopReason = STOP_REASON_BREAK unless $finished;
Branch: 1 branch
BranchTrueFalseTotal
unless $finished 0 0 0
1910  
1911 # command loop
1912 0 local $@;
1913 CMD:
1914 0 while (1) {
1915 # dblog("About to get the command...\n") if $ldebug;
1916 0 my $cmd = &readline();
1917 0 ▶ if ($cmd eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "") 0 0 0
1918 0 ▶ if ($keep_running) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep_running) { } 0 0 0
1919 0 disconnect();
1920 0 disable();
1921 0 last CMD;
1922 } else {
1923 # dblog("Got no command\n") if $ldebug;
1924 0 exit 0;
1925 }
1926 }
1927 0 ▶ dblog("Got command [$cmd]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
1928  
1929 0 $single = 0;
1930 0 $signal = 0;
1931  
1932 #### print OUT "cmd: $cmd\n";
1933 0 my @cmdArgs;
1934 # For now assume commands use urlencoding
1935 0 eval { @cmdArgs = splitCommandLine($cmd); };
1936 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1937 0 makeErrorResponse("cmd",
1938 -1,
1939 1,
1940 "Failed to parse command-line [$cmd]");
1941 0 next CMD;
1942 }
1943 0 my $transactionID = getArg(\@cmdArgs, '-i');
1944  
1945 # Enter the big pseudo-switch stmt.
1946  
1947 0 my $cmd = $cmdArgs[0];
1948 0 ▶ if (exists $supportedCommands{$cmd}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $supportedCommands{$cmd}) { } 0 0 0
1949 0 ▶ if (!$supportedCommands{$cmd}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($supportedCommands{$cmd}) 0 0 0
1950 0 printWithLength(sprintf
1951 (qq(%s\n<response %s command="%s"
1952 transaction_id="%s" ><error code="%d" apperr="4">
1953 <message>command '%s' not currently supported</message>
1954 </error></response>),
1955 xmlHeader(),
1956 namespaceAttr(),
1957 $cmd,
1958 $transactionID,
1959 DBP_E_CommandUnimplemented,
1960 $cmd,
1961 ));
1962 0 next CMD;
1963 }
1964 } else {
1965 0 printWithLength(sprintf
1966 (qq(%s\n<response %s command="%s"
1967 transaction_id="%s" ><error code="%d" apperr="4">
1968 <message>command '%s' not recognized</message>
1969 </error></response>),
1970 xmlHeader(),
1971 namespaceAttr(),
1972 $cmd,
1973 $transactionID,
1974 DBP_E_UnrecognizedCommand,
1975 $cmd,
1976 ));
1977 0 next CMD;
1978 }
1979  
1980 0 ▶ if ($cmd eq 'status') {
Branch: 26 branches
BranchTrueFalseTotal
if ($cmd eq 'status') { } 0 0 0
elsif ($cmd eq 'feature_get') { } 0 0 0
elsif ($cmd eq 'feature_set') { } 0 0 0
elsif ($cmd eq 'run') { } 0 0 0
elsif ($cmd eq 'break') { } 0 0 0
elsif ($cmd eq 'step_into') { } 0 0 0
elsif ($cmd eq 'step_over') { } 0 0 0
elsif ($cmd eq 'step_out') { } 0 0 0
elsif ($cmd eq 'stop') { } 0 0 0
elsif ($cmd eq 'detach') { } 0 0 0
elsif ($cmd eq 'breakpoint_update') { } 0 0 0
elsif ($cmd eq 'breakpoint_remove') { } 0 0 0
elsif ($cmd eq 'breakpoint_get') { } 0 0 0
elsif ($cmd eq 'breakpoint_list') { } 0 0 0
elsif ($cmd eq 'breakpoint_set') { } 0 0 0
elsif ($cmd eq 'stack_depth') { } 0 0 0
elsif ($cmd eq 'stack_get') { } 0 0 0
elsif ($cmd eq 'context_names') { } 0 0 0
elsif ($cmd eq 'context_get') { } 0 0 0
elsif ($cmd eq 'typemap_get') { } 0 0 0
elsif ($cmd eq 'property_get' or $cmd eq 'property_value') { } 0 0 0
elsif ($cmd eq 'property_set') { } 0 0 0
elsif ($cmd eq 'source') { } 0 0 0
elsif ($cmd eq 'stdout' or $cmd eq 'stderr') { } 0 0 0
elsif ($cmd eq 'stdin') { } 0 0 0
elsif ($cmd eq 'eval') { } 0 0 0
1981 0 ▶ printWithLength(sprintf
Branch: 1 branch
BranchTrueFalseTotal
$startedAsInteractiveShell ? : 0 0 0
1982 (qq(%s\n<response %s command="status" status="%s"
1983 reason="ok" transaction_id="%s"/>),
1984 xmlHeader(),
1985 namespaceAttr(),
1986 $startedAsInteractiveShell ? 'interactive' : $stopReasons[$stopReason],
1987 $transactionID));
1988  
1989 } elsif ($cmd eq 'feature_get') {
1990 0 my $featureName = getArg(\@cmdArgs, '-n');
1991 0 my ($supported, $innerText);
1992  
1993 0 ▶ if (! defined $featureName) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $featureName) { } 0 0 0
elsif (exists $supportedCommands{$featureName}) { } 0 0 0
elsif (exists $supportedFeatures{$featureName}) { } 0 0 0
1994 0 $featureName = "unspecified";
1995 0 $supported = 0;
1996 0 $innerText = "";
1997 } elsif (exists $supportedCommands{$featureName}) {
1998 0 $supported = $supportedCommands{$featureName};
1999 0 $innerText = "";
2000 } elsif (exists $supportedFeatures{$featureName}) {
2001 0 my @vals = @{$supportedFeatures{$featureName}};
2002 0 $supported = $vals[0];
2003 0 ▶ if (!$vals[2] || !exists $settings{$featureName}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $vals[2] && exists $DB::settings{$featureName}) { } 0 0 0
Condition0%0/3
$vals[2] && exists $DB::settings{$featureName}
!ll&&!rl&&r
000
MC/DC0%0/2
$vals[2] && exists $DB::settings{$featureName}
$vals[2] exists $DB::settings{$featureName}
Truth table0%0/3
A && B
A= $vals[2]B= exists $DB::settings{$featureName}
ABresult
0X0
100
111
2004 0 $innerText = "";
2005 } else {
2006 0 $innerText = $settings{$featureName}->[0];
2007 }
2008 } else {
2009 # Command not recognized
2010 0 $supported = 0;
2011 0 $innerText = "";
2012 }
2013 0 printWithLength(sprintf
2014 (qq(%s\n<response %s command="%s" feature_name="%s"
2015 supported="%d" transaction_id="%s">%s</response>),
2016 xmlHeader(),
2017 namespaceAttr(),
2018 $cmd,
2019 $featureName,
2020 $supported,
2021 $transactionID,
2022 $innerText));
2023 0 ▶ if ($transactionID == 1 && $finished) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transactionID == 1 and $finished) 0 0 0
Condition0%0/3
$transactionID == 1 and $finished
!ll&&!rl&&r
000
MC/DC0%0/2
$transactionID == 1 and $finished
$transactionID == 1 $finished
Truth table0%0/3
A and B
A= $transactionID == 1B= $finished
ABresult
0X0
100
111
2024 # Observed behavior: we've hit the END block,
2025 # and called DB::fake::at_exit(),
2026 # but the debugger is still calling us. Let's
2027 # tell it that we've stopped, and then stop.
2028 #
2029 # This came up in bug 33128.
2030  
2031 0 close $IN;
2032 0 close $OUT;
2033 0 exit 0;
2034 }
2035  
2036 } elsif ($cmd eq 'feature_set') {
2037 0 my $featureName = getArg(\@cmdArgs, '-n');
2038 0 my $featureValue = getArg(\@cmdArgs, '-v');
2039 0 my ($status, $success, $reason);
2040  
2041 # $success not used
2042 0 $reason = undef;
2043 0 ▶ if (!defined $featureName) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $featureName) { } 0 0 0
elsif (not exists $supportedFeatures{$featureName}) { } 0 0 0
2044 0 $success = 0;
2045 0 $reason = "Command not specified";
2046 } elsif (!exists $supportedFeatures{$featureName}) {
2047 0 $status = 0;
2048 0 $reason = "Command $featureName not recognized";
2049 } else {
2050 0 my $vals = $supportedFeatures{$featureName};
2051 0 ▶ if (!$vals->[1]) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $vals->[1]) { } 0 0 0
elsif (not $vals->[2]) { } 0 0 0
elsif (not exists $DB::settings{$featureName}) { } 0 0 0
2052 0 $status = 0;
2053 0 $reason = "Command $featureName not modifiable";
2054 } elsif (!$vals->[2]) {
2055 # No associated data, use boolean value in
2056 # table
2057 0 ▶ $vals->[0] = $featureValue ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$featureValue ? : 0 0 0
2058 0 $status = 1;
2059 0 $success = $vals->[0];
2060 } elsif (!exists $settings{$featureName}) {
2061 0 $status = 0;
2062 0 $reason = "Command $featureName not in settings table";
2063 } else {
2064 0 my $svals = $settings{$featureName}->[1];
2065 0 ▶ if (!defined $svals) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $svals) { } 0 0 0
elsif ($svals == 1) { } 0 0 0
elsif ($svals == 'a') { } 0 0 0
elsif (ref $svals eq 'ARRAY') { } 0 0 0
2066 0 $status = 0;
2067 0 $reason = "Command $featureName is readonly settings table";
2068 } elsif ($svals == 1) {
2069 # Hardwire numeric values
2070 0 ▶ if ($featureValue =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($featureValue =~ /^\d+$/) { } 0 0 0
2071 0 $status = 1;
2072 0 $settings{$featureName}->[0] = $featureValue;
2073 } else {
2074 0 $status = 0;
2075 0 $reason = "Command $featureName value of $featureValue isn't numeric.";
2076 }
2077 } elsif ($svals == 'a') {
2078 # Allow any ascii data
2079 0 $status = 1;
2080 0 $settings{$featureName}->[0] = $featureValue;
2081 } elsif (ref $svals eq 'ARRAY') {
2082 0 $status = 0;
2083 0 foreach my $allowedValue (@$svals) {
2084 0 ▶ if ($featureValue eq $allowedValue) {
Branch: 1 branch
BranchTrueFalseTotal
if ($featureValue eq $allowedValue) 0 0 0
2085 0 $status = 1;
2086 0 $settings{$featureName}->[0] = $featureValue;
2087 0 last;
2088 }
2089 }
2090 0 ▶ if (!$status) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($status) 0 0 0
2091 0 $reason = "Command $featureName value of $featureValue isn't an allowed value.";
2092 }
2093 } else {
2094 0 $status = 0;
2095 0 $reason = "Command $featureName=$featureValue, can't deal with current setting of " . ref $vals . "\n";
2096 }
2097 }
2098 }
2099 0 ▶ printWithLength(sprintf
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 0 0 0
2100 (qq(%s\n<response %s command="%s" feature_name="%s"
2101 success="%d" transaction_id="%s" %s/>),
2102 xmlHeader(),
2103 namespaceAttr(),
2104 $cmd,
2105 $featureName,
2106 $status,
2107 $transactionID,
2108 $reason ? ('reason="' . $reason . '"') : ''
2109 ));
2110  
2111 # Continuation commands
2112 } elsif ($cmd eq 'run') {
2113 0 ▶ if ($finished and $level <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($finished and $level <= 1) 0 0 0
Condition0%0/3
$finished and $level <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$finished and $level <= 1
$finished $level <= 1
Truth table0%0/3
A and B
A= $finishedB= $level <= 1
ABresult
0X0
100
111
2114 0 end_report($cmd, $transactionID);
2115 0 next CMD;
2116 }
2117 0 $lastContinuationCommand = $cmd;
2118 0 $lastContinuationStatus = 'break';
2119 0 $lastTranID = $transactionID;
2120 0 my $getNextCmd;
2121  
2122 # debug message
2123 0 ▶ if ($fakeFirstStepInto) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fakeFirstStepInto) { } 0 0 0
2124 0 my $bkptInfoRef = lookupBkptInfo($fileNameURINo, $currentLine);
2125 0 ▶ if ($bkptInfoRef) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bkptInfoRef) { } 0 0 0
2126 0 ▶ dblog("hit a breakpoint at first breakable line") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2127 0 $getNextCmd = 1;
2128 } else {
2129 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
2130 0 dblog("\$fakeFirstStepInto was true, turning it off.");
2131 0 dblog("\$single = $single");
2132 }
2133 0 $getNextCmd = 0;
2134 }
2135 0 $fakeFirstStepInto = 0;
2136 } else {
2137 0 $getNextCmd = 0;
2138 }
2139 # dblog("Continuing...\n") if $ldebug;
2140  
2141 # continue
2142 0 ▶ for (my $i=0; $i <= $#stack; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#stack) 0 0 0
2143 0 $stack[$i++] &= ~1;
2144 }
2145 0 ▶ if ($getNextCmd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getNextCmd) { } 0 0 0
2146 0 printWithLength(sprintf
2147 (qq(%s\n<response %s command="%s"
2148 status="break"
2149 reason="ok" transaction_id="%s"/>),
2150 xmlHeader(),
2151 namespaceAttr(),
2152 $cmd,
2153 $transactionID));
2154 0 next CMD;
2155 } else {
2156 0 $stopReason = STOP_REASON_RUNNING;
2157 0 last CMD;
2158 }
2159  
2160 } elsif ($cmd eq 'break') {
2161 0 $fakeFirstStepInto = 0;
2162 0 printWithLength(sprintf
2163 (qq(%s\n<response %s command="%s"
2164 status="break"
2165 success="1"
2166 transaction_id="%s"/>),
2167 xmlHeader(),
2168 namespaceAttr(),
2169 $cmd,
2170 $transactionID));
2171 0 next CMD;
2172 } elsif ($cmd eq 'step_into') {
2173 0 ▶ if ($finished and $level <= 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($finished and $level <= 1) { } 0 0 0
elsif ($fakeFirstStepInto) { } 0 0 0
Condition0%0/3
$finished and $level <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$finished and $level <= 1
$finished $level <= 1
Truth table0%0/3
A and B
A= $finishedB= $level <= 1
ABresult
0X0
100
111
2174 0 end_report($cmd, $transactionID);
2175 0 next CMD;
2176 } elsif ($fakeFirstStepInto) {
2177 # We're already at position 1, so don't go anywhere.
2178 0 $fakeFirstStepInto = 0;
2179 0 printWithLength(sprintf
2180 (qq(%s\n<response %s command="%s"
2181 status="break"
2182 reason="ok" transaction_id="%s" %s>),
2183 xmlHeader(),
2184 namespaceAttr(),
2185 $cmd,
2186 $transactionID,
2187 fileAndLineIfXdebug()));
2188 0 next CMD;
2189 }
2190  
2191 0 $lastContinuationCommand = $cmd;
2192 0 $lastContinuationStatus = 'break';
2193 0 $lastTranID = $transactionID;
2194 # debug message
2195 0 ▶ dblog("Stepping into...\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2196  
2197 # step into
2198 0 $single = 1;
2199 0 $stopReason = STOP_REASON_RUNNING;
2200 0 last CMD;
2201  
2202 } elsif ($cmd eq 'step_over') {
2203 0 ▶ if ($finished and $level <= 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($finished and $level <= 1) { } 0 0 0
elsif ($fakeFirstStepInto) { } 0 0 0
Condition0%0/3
$finished and $level <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$finished and $level <= 1
$finished $level <= 1
Truth table0%0/3
A and B
A= $finishedB= $level <= 1
ABresult
0X0
100
111
2204 0 end_report($cmd, $transactionID);
2205 0 next CMD;
2206 } elsif ($fakeFirstStepInto) {
2207 # We're already at position 1, so don't go anywhere.
2208 0 $fakeFirstStepInto = 0;
2209 0 printWithLength(sprintf
2210 (qq(%s\n<response %s command="%s"
2211 status="break"
2212 reason="ok" transaction_id="%s" %s>),
2213 xmlHeader(),
2214 namespaceAttr(),
2215 $cmd,
2216 $transactionID,
2217 fileAndLineIfXdebug()));
2218 0 next CMD;
2219 }
2220  
2221 0 $lastContinuationCommand = $cmd;
2222 0 $lastContinuationStatus = 'break';
2223 0 $lastTranID = $transactionID;
2224 # debug message
2225 0 ▶ dblog("Stepping over...\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2226  
2227 # step over
2228 0 $single = 2;
2229 0 $stopReason = STOP_REASON_RUNNING;
2230 0 last CMD;
2231  
2232 } elsif ($cmd eq 'step_out') {
2233 0 ▶ if ($finished and $level <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($finished and $level <= 1) 0 0 0
Condition0%0/3
$finished and $level <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$finished and $level <= 1
$finished $level <= 1
Truth table0%0/3
A and B
A= $finishedB= $level <= 1
ABresult
0X0
100
111
2234 0 end_report($cmd, $transactionID);
2235 0 next CMD;
2236 }
2237 0 my $getNextCmd;
2238 # This is more like starting with a run than a step
2239 # So always check $fakeFirstStepInto to 0.
2240 0 ▶ if ($fakeFirstStepInto) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fakeFirstStepInto) { } 0 0 0
2241 0 my $bkptInfoRef = lookupBkptInfo($fileNameURINo, $currentLine);
2242 0 ▶ if ($bkptInfoRef) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bkptInfoRef) { } 0 0 0
2243 0 ▶ dblog("hit a breakpoint at first breakable line") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2244 0 $getNextCmd = 1;
2245 } else {
2246 0 ▶ dblog("\$fakeFirstStepInto was true, turning it off.") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2247 0 $getNextCmd = 0;
2248 }
2249 0 $fakeFirstStepInto = 0;
2250 } else {
2251 0 $getNextCmd = 0;
2252 }
2253  
2254 0 $lastContinuationCommand = $cmd;
2255 0 $lastContinuationStatus = 'break';
2256 0 $lastTranID = $transactionID;
2257 # debug message
2258 0 ▶ dblog("Stepping out...\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2259  
2260 # step out
2261 0 $stack[$stack_depth] |= 2;
2262 0 ▶ if ($getNextCmd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getNextCmd) { } 0 0 0
2263 0 printWithLength(sprintf
2264 (qq(%s\n<response %s command="%s"
2265 status="break"
2266 reason="ok" transaction_id="%s" %s>),
2267 xmlHeader(),
2268 namespaceAttr(),
2269 $cmd,
2270 $transactionID,
2271 fileAndLineIfXdebug()));
2272 0 next CMD;
2273 } else {
2274 0 $stopReason = STOP_REASON_RUNNING;
2275 0 last CMD;
2276 }
2277  
2278 } elsif ($cmd eq 'stop') { #xxxstop
2279 0 $fall_off_end = 1;
2280 0 $stopReason = STOP_REASON_STOPPING;
2281 0 printWithLength(sprintf(qq(%s\n<response %s command="%s" status="%s"
2282 reason="ok" transaction_id="%s"/>),
2283 xmlHeader(),
2284 namespaceAttr(),
2285 $cmd,
2286 'stopped',
2287 $transactionID));
2288 0 ▶ dblog("Exiting script on stop command ...\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2289 0 close $IN;
2290 0 close $OUT;
2291 0 exit 0;
2292  
2293 } elsif ($cmd eq 'detach') {
2294 0 $stopReason = STOP_REASON_STOPPED;
2295 0 $runnonstop = 1;
2296 # continue
2297 0 ▶ for (my $i=0; $i <= $#stack; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#stack) 0 0 0
2298 0 $stack[$i++] &= ~1;
2299 }
2300 # Disable all the move commands
2301 0 map { $supportedCommands{$_} = 0 } (qw(run step_into step_over step_out detach));
2302 # status will be emitted when the program hits the end
2303 0 $lastContinuationCommand = $cmd;
2304 0 $lastContinuationStatus = 'stopping';
2305 0 $lastTranID = $transactionID;
2306 0 last CMD;
2307  
2308 # Breakpoint commands...
2309 } elsif ($cmd eq 'breakpoint_update') {
2310 0 my %opts;
2311 {
2312 0 local *ARGV = \@cmdArgs;
2313 0 shift @ARGV;
2314 0 getopts('d:h:n:o:r:s:t:', \%opts);
2315 }
2316 0 my $bkptID = $opts{d};
2317 0 ▶ my $bNewState = $opts{s} || BKPT_REQ_ENABLED;
Condition0%0/2
$opts{'s'} || 'enabled'
l!l
00
MC/DC0%0/1
$opts{'s'} || 'enabled'
$opts{'s'}
Truth table0%0/2
A
A= $opts{'s'}
Aresult
11
00
2318 0 ▶ my $bIsTemporary = $opts{r} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$opts{'r'} ? : 0 0 0
2319 0 my $bHitCount = $opts{h};
2320 0 my $bHitConditionOperator = $opts{o};
2321  
2322 # Currently ignored:
2323 # -n <line no>
2324  
2325 0 my $bptErrorCode = 0;
2326 0 my $bptErrorMsg;
2327 my $fileNameTableInfo;
2328 0 my $bpCmd;
2329 0 my ($bFileURINo, $bLine, $bState, $bType, $bFunction, $bExpression, $bException, $bHitInfo) = getBkPtInfo($bkptID);
2330 0 ▶ if (!defined $bFileURINo) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $bFileURINo) { } 0 0 0
elsif (not getURIByNo($bFileURINo)) { } 0 0 0
elsif (not $fileNameTableInfo = $fileNameTable[$bFileURINo]) { } 0 0 0
2331 0 $bptErrorCode = DBP_E_NoSuchBreakpoint;
2332 0 $bptErrorMsg = "Unknown breakpoint ID $bkptID.";
2333 } elsif (!getURIByNo($bFileURINo)) {
2334 0 $bptErrorCode = DBP_E_NoSuchBreakpoint;
2335 0 $bptErrorMsg = "Unknown fileURI NO $bFileURINo.";
2336 } elsif (!($fileNameTableInfo = $fileNameTable[$bFileURINo])) {
2337 0 $bptErrorCode = DBP_E_NoSuchBreakpoint;
2338 0 $bptErrorMsg = "No fileURI info under URI NO $bFileURINo.";
2339 }
2340  
2341 0 ▶ if ($bptErrorCode == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bptErrorCode == 0) 0 0 0
2342 0 ▶ $bpCmd = ($bNewState eq BKPT_REQ_DISABLED
Branch: 2 branches
BranchTrueFalseTotal
$bNewState eq 'disabled' ? : 0 0 0
$bIsTemporary ? : 0 0 0
2343 ? BKPT_DISABLE
2344 : ($bIsTemporary
2345 ? BKPT_TEMPORARY
2346 : BKPT_ENABLE));
2347 0 ▶ if (!setBkPtState($bkptID, $bpCmd)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not setBkPtState($bkptID, $bpCmd)) { } 0 0 0
elsif ($bHitCount or $bHitConditionOperator) { } 0 0 0
2348 0 $bptErrorCode = DBP_E_BreakpointNotSet;
2349 0 ▶ $bptErrorMsg = sprintf("Can't %able breakpoint ID %s",
Branch: 1 branch
BranchTrueFalseTotal
$bpCmd == 1 ? : 0 0 0
2350 $bpCmd == BKPT_DISABLE ? 'dis' : 'en',
2351  
2352 $bkptID);
2353 ▶ } elsif ($bHitCount || $bHitConditionOperator) {
Condition0%0/3
$bHitCount or $bHitConditionOperator
l!l&&r!l&&!r
000
MC/DC0%0/2
$bHitCount or $bHitConditionOperator
$bHitCount $bHitConditionOperator
Truth table0%0/3
A or B
A= $bHitCountB= $bHitConditionOperator
ABresult
1X1
011
000
2354 # Komodo only sends in changed values, so merge in old values
2355 0 ▶ if (!$bHitCount && $bHitInfo->[HIT_TBL_VALUE]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $bHitCount and $bHitInfo->[1]) 0 0 0
Condition0%0/3
not $bHitCount and $bHitInfo->[1]
!ll&&!rl&&r
000
MC/DC0%0/2
not $bHitCount and $bHitInfo->[1]
not $bHitCount $bHitInfo->[1]
Truth table0%0/3
not(A) and B
A= not $bHitCountB= $bHitInfo->[1]
ABresult
0X0
100
111
2356 0 $bHitCount = $bHitInfo->[HIT_TBL_VALUE];
2357 }
2358 0 ▶ if (!$bHitConditionOperator && $bHitInfo->[HIT_TBL_COND_STRING]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $bHitConditionOperator and $bHitInfo->[3]) 0 0 0
Condition0%0/3
not $bHitConditionOperator and $bHitInfo->[3]
!ll&&!rl&&r
000
MC/DC0%0/2
not $bHitConditionOperator and $bHitInfo->[3]
not $bHitConditionOperator $bHitInfo->[3]
Truth table0%0/3
not(A) and B
A= not $bHitConditionOperatorB= $bHitInfo->[3]
ABresult
0X0
100
111
2359 0 $bHitConditionOperator = $bHitInfo->[HIT_TBL_COND_STRING];
2360 }
2361 }
2362 }
2363 0 ▶ if ($bptErrorCode == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bptErrorCode == 0) { } 0 0 0
2364 0 my $perlFileName = $fileNameTableInfo->[2];
2365 0 our %dbline;
2366 0 local *dbline = $main::{'_<' . $perlFileName};
2367  
2368 0 ▶ $dbline{$bLine} = $bpCmd == BKPT_ENABLE ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$bpCmd == 2 ? : 0 0 0
2369 0 ▶ if ($bHitCount) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bHitCount) { } 0 0 0
elsif (not $bHitInfo && defined $bHitInfo->[2]) { } 0 0 0
2370 0 setBkPtHitInfo($bkptID, $bHitCount, $bHitConditionOperator);
2371 ▶ } elsif (!$bHitInfo
Condition0%0/3
$bHitInfo && defined $bHitInfo->[2]
!ll&&!rl&&r
000
MC/DC0%0/2
$bHitInfo && defined $bHitInfo->[2]
$bHitInfo defined $bHitInfo->[2]
Truth table0%0/3
A && B
A= $bHitInfoB= defined $bHitInfo->[2]
ABresult
0X0
100
111
2372 || !defined $bHitInfo->[HIT_TBL_EVAL_FUNC]) {
2373 0 setNullBkPtHitInfo($bkptID);
2374 } else {
2375 0 ▶ dblog("breakpoint_update -- doing nothing") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2376 }
2377 0 ▶ dblog("doing op $cmd\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2378 0 my $res = sprintf(qq(%s\n<response %s command="%s"
2379 transaction_id="%s" >),
2380 xmlHeader(),
2381 namespaceAttr(),
2382 $cmd,
2383 $transactionID);
2384 0 my $bpInfo = getBreakpointInfoString($bkptID);
2385 0 ▶ if (! defined $bpInfo || length $bpInfo == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $bpInfo or length $bpInfo == 0) { } 0 0 0
Condition0%0/3
not defined $bpInfo or length $bpInfo == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $bpInfo or length $bpInfo == 0
not defined $bpInfo length $bpInfo == 0
Truth table0%0/3
not(A) or B
A= not defined $bpInfoB= length $bpInfo == 0
ABresult
1X1
011
000
2386 0 makeErrorResponse($cmd,
2387 $transactionID,
2388 DBP_E_NoSuchBreakpoint,
2389 "Unknown breakpoint ID $bkptID.");
2390 } else {
2391 0 $res .= $bpInfo;
2392 0 $res .= "\n</response>\n";
2393 0 ▶ dblog("$cmd => $res") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2394 0 printWithLength($res);
2395 }
2396 } else {
2397 0 ▶ dblog("failed to do op $cmd (error code $bptErrorCode)\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2398 0 makeErrorResponse($cmd,
2399 $transactionID,
2400 $bptErrorCode,
2401 $bptErrorMsg);
2402 }
2403 } elsif ($cmd eq 'breakpoint_remove') {
2404 0 my $bkptID = getArg(\@cmdArgs, '-d');
2405 0 my $bptErrorCode = 0;
2406 0 my $bptErrorMsg;
2407 0 my ($bFileURINo, $bLine, $bState, $bType, $bFunction, $bExpression, $bException) = getBkPtInfo($bkptID);
2408 0 ▶ if ($bType eq 'watch') {
Branch: 3 branches
BranchTrueFalseTotal
if ($bType eq 'watch') { } 0 0 0
elsif (not defined $bFileURINo) { } 0 0 0
elsif (not getURIByNo($bFileURINo)) { } 0 0 0
2409 0 ▶ dblog("Deleting watchpoint [$bExpression]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2410 0 my $i_cnt = 0;
2411 0 foreach (@watchPoints) {
2412 0 my $val = $watchPoints[$i_cnt];
2413  
2414 # Does this one match the command argument?
2415 0 ▶ if ($val eq $bExpression) { # =~ m/^\Q$i$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq $bExpression) 0 0 0
2416 # Yes. Turn it off, and its value too.
2417 0 splice(@watchPoints, $i_cnt, 1);
2418 0 splice(@watchPointValues, $i_cnt, 1);
2419 0 last;
2420 }
2421 0 $i_cnt++;
2422 } ## end foreach (@watchPoints)
2423 0 ▶ if (--$numWatchPoints <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$numWatchPoints <= 0) { } 0 0 0
2424 0 ▶ dblog("No more watching anything [\$numWatchPoints = $numWatchPoints]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2425 0 $numWatchPoints = 0;
2426 0 $trace &= ~2;
2427 } else {
2428 0 ▶ dblog("Still watching $numWatchPoints watchPoints") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2429 }
2430 } elsif (!defined $bFileURINo) {
2431 0 $bptErrorCode = DBP_E_NoSuchBreakpoint;
2432 0 $bptErrorMsg = "Unknown breakpoint ID $bkptID.";
2433 } elsif (!getURIByNo($bFileURINo)) {
2434 0 $bptErrorCode = DBP_E_NoSuchBreakpoint;
2435 0 $bptErrorMsg = "Unknown fileURI NO $bFileURINo.";
2436 }
2437  
2438 0 ▶ if (!deleteBkPtInfo($bkptID)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not deleteBkPtInfo($bkptID)) { } 0 0 0
2439 0 $bptErrorCode = DBP_E_NoSuchBreakpoint;
2440 0 $bptErrorMsg = "Problems deleting breakpoint ID $bkptID";
2441 } else {
2442 0 remove_FileURI_LineNo_Breakpoint($bFileURINo, $bLine);
2443 }
2444 0 ▶ if ($bptErrorCode == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bptErrorCode == 0) { } 0 0 0
2445 0 my $res = sprintf(qq(%s\n<response %s command="%s"
2446 transaction_id="%s" />\n),
2447 xmlHeader(),
2448 namespaceAttr(),
2449 $cmd,
2450 $transactionID);
2451 0 ▶ dblog("$cmd => $res") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2452 0 printWithLength($res);
2453 } else {
2454 0 makeErrorResponse($cmd,
2455 $transactionID,
2456 $bptErrorCode,
2457 $bptErrorMsg);
2458 }
2459  
2460 } elsif ($cmd eq 'breakpoint_get') {
2461 0 my $bkptID = getArg(\@cmdArgs, '-d');
2462 0 my $res = sprintf(qq(%s\n<response %s command="%s"
2463 transaction_id="%s" >),
2464 xmlHeader(),
2465 namespaceAttr(),
2466 $cmd,
2467 $transactionID);
2468 0 my $bpInfo = getBreakpointInfoString($bkptID);
2469 0 ▶ if (! defined $res || length $res == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res or length $res == 0) 0 0 0
Condition0%0/3
not defined $res or length $res == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $res or length $res == 0
not defined $res length $res == 0
Truth table0%0/3
not(A) or B
A= not defined $resB= length $res == 0
ABresult
1X1
011
000
2470 0 makeErrorResponse($cmd,
2471 $transactionID,
2472 DBP_E_NoSuchBreakpoint,
2473 "Unknown breakpoint ID $bkptID.");
2474 0 next CMD;
2475 }
2476 0 $res .= $bpInfo;
2477 0 $res .= "\n</response>\n";
2478 0 ▶ dblog("$cmd => $res") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2479 0 printWithLength($res);
2480  
2481 } elsif ($cmd eq 'breakpoint_list') {
2482 0 my $res = sprintf(qq(%s\n<response %s command="%s"
2483 transaction_id="%s" >),
2484 xmlHeader(),
2485 namespaceAttr(),
2486 $cmd,
2487 $transactionID);
2488  
2489 0 for my $fileURINo (0 .. $#bkptLookupTable) {
2490 0 my $fileURIInfo = $bkptLookupTable[$fileURINo];
2491 0 ▶ next unless $fileURIInfo;
Branch: 1 branch
BranchTrueFalseTotal
unless $fileURIInfo 0 0 0
2492 0 ▶ while (my ($lineNo, $bkptID) = each %$fileURIInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$fileURIInfo) 0 0 0
2493 0 my $bpInfo = getBreakpointInfoString($bkptID, fileURI => $fileURINo, lineNo => $lineNo);
2494 0 ▶ $res .= $bpInfo if $bpInfo;
Branch: 1 branch
BranchTrueFalseTotal
if $bpInfo 0 0 0
2495 }
2496 }
2497 0 ▶ dblog("bpList: FQFnNameLookupTable: ", DB::Data::Dump::dump(%FQFnNameLookupTable)) if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2498 0 ▶ while (my ($bFunction, $val) = each %FQFnNameLookupTable) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %FQFnNameLookupTable) 0 0 0
2499 0 ▶ dblog("info($bFunction, $val): ", DB::Data::Dump::dump($val)) if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2500 0 ▶ while (my ($bType, $bkptID) = each %$val) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$val) 0 0 0
2501 0 my $bpInfo = getBreakpointInfoString($bkptID, function => $bFunction);
2502 0 ▶ $res .= $bpInfo if $bpInfo;
Branch: 1 branch
BranchTrueFalseTotal
if $bpInfo 0 0 0
2503 }
2504 }
2505 0 $res .= "\n</response>\n";
2506 0 ▶ dblog("$cmd => $res") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2507 0 printWithLength($res);
2508  
2509 } elsif ($cmd eq 'breakpoint_set') {
2510 0 my %opts;
2511 {
2512 0 local *ARGV = \@cmdArgs;
2513 0 shift @ARGV;
2514 0 getopts('c:f:h:m:n:o:r:s:t:x', \%opts);
2515 }
2516  
2517 # For now, set the filename to either $opts{f} or curr filename
2518 0 my $bHitCount = $opts{h};
2519 0 my $bFunctionName = $opts{m};
2520 0 ▶ my $bLine = $opts{n} || $currentLine;
Condition0%0/3
$opts{'n'} || $currentLine
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{'n'} || $currentLine
$opts{'n'} $currentLine
Truth table0%0/3
A || B
A= $opts{'n'}B= $currentLine
ABresult
1X1
011
000
2521 0 my $bHitConditionOperator = $opts{o};
2522 0 ▶ my $bIsTemporary = $opts{r} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$opts{'r'} ? : 0 0 0
2523 0 ▶ my $bState = $opts{s} || BKPT_REQ_ENABLED;
Condition0%0/2
$opts{'s'} || 'enabled'
l!l
00
MC/DC0%0/1
$opts{'s'} || 'enabled'
$opts{'s'}
Truth table0%0/2
A
A= $opts{'s'}
Aresult
11
00
2524 0 my $bType = $opts{t};
2525 0 my $bException = $opts{x};
2526 0 my $bCondition = "";
2527 0 ▶ if (exists $opts{f}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts{"f"}) 0 0 0
2528 0 $opts{f} =~ s@^dbgp:///file:/@file:/@;
2529 0 $opts{f} =~ s@^file:/([^/])@file://$1@;
2530 # work around broken clients
2531 0 $opts{f} =~ s@^file%3[Aa]//@file://@;
2532 $opts{f} = 'file://' . $opts{f} unless
2533 0 ▶ $opts{f} =~ m@^(?:file|dbgp)://@;
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"f"} =~ m[^(?:file|dbgp)://] 0 0 0
2534 }
2535 0 my ($bFileURINo, $bkptID, $bStateVal);
2536 0 my ($perlFileName, $bFileURI, $bFileName);
2537 0 my $bptErrorCode = 0;
2538 0 my $bptErrorMsg = undef;
2539  
2540 0 ▶ if (rindex($opts{f}, "$full_dbgp_prefix/", 0) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (rindex($opts{'f'}, "$full_dbgp_prefix/", 0) == 0) { } 0 0 0
2541 0 my ($evalIdx, $encodedName) = $opts{f} =~ m{^\Q$full_dbgp_prefix/\E(\d+)/(.*)$};
2542 0 my $evalName = decodeData($encodedName, 'urlescape');
2543 my $evalInfo = $evalTableIdx[$evalIdx] &&
2544 $evalTableIdx[$evalIdx] &&
2545 0 ▶ $evalTable{$evalTableIdx[$evalIdx]};
Condition0%0/6
$evalTableIdx[$evalIdx] && $evalTableIdx[$evalIdx] && $evalTable{$evalTableIdx[$evalIdx]}
!ll&&!rl&&r
000
$evalTableIdx[$evalIdx] and $evalTableIdx[$evalIdx]
!ll&&!rl&&r
000
MC/DC0%0/3
$evalTableIdx[$evalIdx] && $evalTableIdx[$evalIdx] && $evalTable{$evalTableIdx[$evalIdx]}
$evalTableIdx[$evalIdx] $evalTableIdx[$evalIdx] $evalTable{$evalTableIdx[$evalIdx]}
Truth table0%0/4
A and B && C
A= $evalTableIdx[$evalIdx]B= $evalTableIdx[$evalIdx]C= $evalTable{$evalTableIdx[$evalIdx]}
ABCresult
0XX0
10X0
1100
1111
2546  
2547 0 ▶ if ($evalName && $evalInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($evalName and $evalInfo) 0 0 0
Condition0%0/3
$evalName and $evalInfo
!ll&&!rl&&r
000
MC/DC0%0/2
$evalName and $evalInfo
$evalName $evalInfo
Truth table0%0/3
A and B
A= $evalNameB= $evalInfo
ABresult
0X0
100
111
2548 0 $bFileURI = $opts{f};
2549 0 $bFileName = $opts{f};
2550 0 $bFileURINo = internFileURI($bFileURI);
2551 0 $perlFileName = $evalTableIdx[$evalIdx];
2552 }
2553 } else {
2554 0 ▶ getFileInfo(defined $opts{f} ? $opts{f} : calcFileURI($currentFilename),
Branch: 1 branch
BranchTrueFalseTotal
defined $opts{'f'} ? : 0 0 0
2555 \$bFileURI,
2556 \$bFileURINo,
2557 \$bFileName,
2558 \$perlFileName);
2559 }
2560  
2561 0 ▶ if ($opts{f} =~ m@^dbgp:///perl//(?:PerlApp/|<.*>)@) {
Branch: 9 branches
BranchTrueFalseTotal
if ($opts{'f'} =~ m[^dbgp:///perl//(?:PerlApp/|<.*>)]) { } 0 0 0
elsif (defined $bException) { } 0 0 0
elsif (defined $bFunctionName) { } 0 0 0
elsif ($bType eq 'conditional') { } 0 0 0
elsif ($bType eq 'watch') { } 0 0 0
elsif (defined $bType and $bType ne 'line') { } 0 0 0
elsif (not defined $bFileName || defined $bLine) { } 0 0 0
elsif ($bLine < 0) { } 0 0 0
elsif ($bHitConditionOperator and not defined $bHitCount) { } 0 0 0
2562 0 $bptErrorCode = DBP_E_BreakpointTypeNotSupported;
2563 0 $bptErrorMsg = "Breakpoints in compiled modules are not supported.";
2564 } elsif (defined $bException) {
2565 # Don't support break on exceptions
2566 0 $bptErrorCode = DBP_E_BreakpointTypeNotSupported;
2567 0 $bptErrorMsg = "Breaking on exceptions not supported.";
2568 } elsif (defined $bFunctionName) {
2569 0 ▶ if (!defined $bType || ($bType ne 'call'
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $bType or $bType ne "call" and $bType ne "return") 0 0 0
Condition0%0/6
not defined $bType or $bType ne "call" and $bType ne "return"
l!l&&r!l&&!r
000
$bType ne "call" and $bType ne "return"
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $bType or $bType ne "call" and $bType ne "return"
not defined $bType $bType ne "call" $bType ne "return"
Truth table0%0/4
not(A) or B and C
A= not defined $bTypeB= $bType ne "call"C= $bType ne "return"
ABCresult
1XX1
0111
00X0
0100
2570 && $bType ne 'return')) {
2571 0 $bptErrorMsg = "Breaking on functions requires a breakpoint type of 'call' or 'return', got [$bType].";
2572 0 $bptErrorCode = DBP_E_InvalidOption;
2573 }
2574 } elsif ($bType eq 'conditional') {
2575 0 ▶ if (!defined $bLine) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $bLine) { } 0 0 0
2576 0 $bptErrorCode = DBP_E_InvalidOption;
2577 0 $bptErrorMsg = "Line number required for setting a conditional breakpoint in Perl.";
2578 } else {
2579 0 $bType = 'line';
2580 0 ▶ if ($cmdArgs[0] && length $cmdArgs[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdArgs[0] and length $cmdArgs[0]) { } 0 0 0
Condition0%0/3
$cmdArgs[0] and length $cmdArgs[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$cmdArgs[0] and length $cmdArgs[0]
$cmdArgs[0] length $cmdArgs[0]
Truth table0%0/3
A and B
A= $cmdArgs[0]B= length $cmdArgs[0]
ABresult
0X0
100
111
2581 0 $bCondition = $cmdArgs[0];
2582 0 ▶ dblog("Got raw condition [$bCondition]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2583 0 $bCondition = decodeData($bCondition);
2584 0 ▶ dblog("Got decoded condition [$bCondition]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2585 } else {
2586 0 $bptErrorCode = DBP_E_InvalidOption;
2587 0 $bptErrorMsg = "Condition required for setting a conditional breakpoint.";
2588 }
2589 }
2590 } elsif ($bType eq 'watch') {
2591 0 my $bptErrorCode = 0;
2592 0 my $bptErrorMsg;
2593 0 ▶ if ($cmdArgs[0] && length $cmdArgs[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdArgs[0] and length $cmdArgs[0]) { } 0 0 0
Condition0%0/3
$cmdArgs[0] and length $cmdArgs[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$cmdArgs[0] and length $cmdArgs[0]
$cmdArgs[0] length $cmdArgs[0]
Truth table0%0/3
A and B
A= $cmdArgs[0]B= length $cmdArgs[0]
ABresult
0X0
100
111
2594 0 $bCondition = $cmdArgs[0];
2595 0 ▶ dblog("Got raw condition [$bCondition]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2596 0 $bCondition = decodeData($bCondition);
2597 0 ▶ dblog("Got decoded condition [$bCondition]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2598 0 ▶ if ($bCondition) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bCondition) 0 0 0
2599 0 $evalarg = $bCondition;
2600 0 my ($val) = eval { join(' ', &eval) };
2601 0 ▶ $val = (defined $val) ? "'$val'" : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
2602 0 push @watchPoints, $bCondition;
2603 0 push @watchPointValues, $val;
2604 # We are now watching expressions.
2605 0 $trace |= 2;
2606 0 ++$numWatchPoints;
2607 }
2608 } else {
2609 0 $bptErrorCode = DBP_E_InvalidOption;
2610 0 $bptErrorMsg = "Expression required for setting a watchpoint.";
2611 }
2612 ▶ } elsif (defined $bType && $bType ne 'line') {
Condition0%0/3
defined $bType and $bType ne "line"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $bType and $bType ne "line"
defined $bType $bType ne "line"
Truth table0%0/3
A and B
A= defined $bTypeB= $bType ne "line"
ABresult
0X0
100
111
2613 0 $bptErrorMsg = "Breakpoint type of $bType not supported -- only 'line' is supported.";
2614 0 $bptErrorCode = DBP_E_BreakpointTypeNotSupported;
2615  
2616 ▶ } elsif (!defined $bFileName && !defined $bLine) {
Condition0%0/3
defined $bFileName || defined $bLine
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $bFileName || defined $bLine
defined $bFileName defined $bLine
Truth table0%0/3
A || B
A= defined $bFileNameB= defined $bLine
ABresult
1X1
011
000
2617 # Need a filename and a line no for breaking
2618 0 $bptErrorMsg = "Filename and line number required for setting a breakpoint.";
2619 0 $bptErrorCode = DBP_E_InvalidOption;
2620 } elsif ($bLine < 0) {
2621 0 $bptErrorMsg = "Negative line numbers not supported (got [$bLine])";
2622 0 $bptErrorCode = DBP_E_InvalidOption;
2623 ▶ } elsif ($bHitConditionOperator && ! defined $bHitCount) {
Condition0%0/3
$bHitConditionOperator and not defined $bHitCount
!ll&&!rl&&r
000
MC/DC0%0/2
$bHitConditionOperator and not defined $bHitCount
$bHitConditionOperator not defined $bHitCount
Truth table0%0/3
A and not(B)
A= $bHitConditionOperatorB= not defined $bHitCount
ABresult
0X0
100
111
2624 0 $bptErrorMsg = "Hit condition operator specified without a target hit count.";
2625 0 $bptErrorCode = DBP_E_InvalidOption;
2626 }
2627  
2628 # Figure out our state
2629 0 ▶ if ($bptErrorCode == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bptErrorCode == 0) 0 0 0
2630 0 ▶ if ($bState eq BKPT_REQ_ENABLED) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bState eq 'enabled') { } 0 0 0
elsif ($bState eq 'disabled') { } 0 0 0
2631 0 ▶ $bStateVal = $bIsTemporary ? BKPT_TEMPORARY : BKPT_ENABLE;
Branch: 1 branch
BranchTrueFalseTotal
$bIsTemporary ? : 0 0 0
2632 } elsif ($bState eq BKPT_REQ_DISABLED) {
2633 0 $bStateVal = BKPT_DISABLE;
2634 } else {
2635 0 $bptErrorCode = DBP_E_BreakpointStateInvalid;
2636 0 $bptErrorMsg = "Breakpoint state '$bState' not recognized.";
2637 }
2638 }
2639  
2640 0 ▶ if ($bptErrorCode != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bptErrorCode != 0) 0 0 0
2641 0 makeErrorResponse($cmd,
2642 $transactionID,
2643 $bptErrorCode,
2644 $bptErrorMsg);
2645 0 next CMD;
2646 }
2647  
2648 0 ▶ if ($bFunctionName) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bFunctionName) { } 0 0 0
2649 my @bptIDs =
2650 findAndAddFunctionBreakPoints($bFunctionName,
2651 defined $opts{f} && $perlFileName,
2652 $opts{n},
2653 0 ▶ $bCondition,
Condition0%0/3
defined $opts{'f'} && $perlFileName
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts{'f'} && $perlFileName
defined $opts{'f'} $perlFileName
Truth table0%0/3
A && B
A= defined $opts{'f'}B= $perlFileName
ABresult
0X0
100
111
2654 $bStateVal,
2655 $bIsTemporary,
2656 $bType,
2657 $bHitCount,
2658 $bHitConditionOperator);
2659 0 ▶ if (@bptIDs == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (@bptIDs == 0) { } 0 0 0
elsif (@bptIDs == 1) { } 0 0 0
2660 # No breakpoints found
2661 0 ▶ my $fname = $opts{f} || "any loaded file";
Condition0%0/2
$opts{'f'} || 'any loaded file'
l!l
00
MC/DC0%0/1
$opts{'f'} || 'any loaded file'
$opts{'f'}
Truth table0%0/2
A
A= $opts{'f'}
Aresult
11
00
2662 0 my $msg = "Currently can't find sub $bFunctionName in $fname.";
2663 0 makeErrorResponse($cmd,
2664 $transactionID,
2665 DBP_E_NoSuchBreakpoint,
2666 $msg);
2667 0 next CMD;
2668 } elsif (@bptIDs == 1) {
2669 0 $bkptID = $bptIDs[0];
2670 }
2671 } else {
2672 # None of these can fail
2673 0 ▶ if ($bType eq 'watch') {
Branch: 1 branch
BranchTrueFalseTotal
if ($bType eq 'watch') { } 0 0 0
2674 0 $bkptID = internFunctionName_watchedExpn($bCondition);
2675 } else {
2676 0 $bkptID = internFileURINo_LineNo($bFileURINo, $bLine);
2677 }
2678 0 storeBkPtInfo($bkptID, $bFileURINo, $bLine, $bStateVal, $bType, undef, $bCondition);
2679 0 ▶ if ($bHitCount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bHitCount) { } 0 0 0
2680 0 setBkPtHitInfo($bkptID, $bHitCount, $bHitConditionOperator);
2681 } else {
2682 0 setNullBkPtHitInfo($bkptID);
2683 }
2684  
2685 #todo: add pending, etc. on the dbline thing
2686 0 ▶ if (defined $perlFileName && $bStateVal != BKPT_DISABLE) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $perlFileName and $bStateVal != 1) { } 0 0 0
Condition0%0/3
defined $perlFileName and $bStateVal != 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $perlFileName and $bStateVal != 1
defined $perlFileName $bStateVal != 1
Truth table0%0/3
A and B
A= defined $perlFileNameB= $bStateVal != 1
ABresult
0X0
100
111
2687 0 our %dbline;
2688 0 local *dbline = $main::{'_<' . $perlFileName};
2689 0 ▶ if ($bLine < 1 || $bLine > $#dbline || $dbline[$bLine] == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bLine < 1 or $bLine > $#DB::dbline or $DB::dbline[$bLine] == 0) 0 0 0
Condition0%0/6
$bLine < 1 or $bLine > $#DB::dbline or $DB::dbline[$bLine] == 0
l!l&&r!l&&!r
000
$bLine < 1 or $bLine > $#DB::dbline
l!l&&r!l&&!r
000
MC/DC0%0/3
$bLine < 1 or $bLine > $#DB::dbline or $DB::dbline[$bLine] == 0
$bLine < 1 $bLine > $#DB::dbline $DB::dbline[$bLine] == 0
Truth table0%0/4
A or B or C
A= $bLine < 1B= $bLine > $#DB::dblineC= $DB::dbline[$bLine] == 0
ABCresult
1XX1
01X1
0011
0000
2690 0 ▶ my $code = (($bLine < 1 || $bLine > $#dbline)
Branch: 1 branch
BranchTrueFalseTotal
$bLine < 1 || $bLine > $#DB::dbline ? : 0 0 0
Condition0%0/3
$bLine < 1 or $bLine > $#DB::dbline
l!l&&r!l&&!r
000
MC/DC0%0/2
$bLine < 1 or $bLine > $#DB::dbline
$bLine < 1 $bLine > $#DB::dbline
Truth table0%0/3
A or B
A= $bLine < 1B= $bLine > $#DB::dbline
ABresult
1X1
011
000
2691 ? DBP_E_Unbreakable_InvalidCodeLine
2692 : DBP_E_Unbreakable_EmptyCodeLine);
2693 0 makeErrorResponse($cmd,
2694 $transactionID,
2695 $code,
2696 "Line $bLine isn't breakable");
2697 0 next CMD;
2698 }
2699 0 $dbline{$bLine} = 1;
2700 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
2701 0 dblog("Here are the breakpoints for file [$perlFileName] (ID $bkptID, fileNum $bFileURINo):\n");
2702 0 dblog((join(", ", grep ($dbline{$_}, keys %dbline)), "\n"));
2703 }
2704 } else {
2705 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
2706 0 my $str = "Curr file = |$currentFilename|, bpt set for file |$bFileName|, bStateVal = |$bStateVal|, \$bFileURI = |$bFileURI|";
2707 0 ▶ $str .= ", \$perlFileName=$perlFileName" if $perlFileName;
Branch: 1 branch
BranchTrueFalseTotal
if $perlFileName 0 0 0
2708 0 $str .= "\n";
2709 0 dblog($str);
2710 }
2711 }
2712 }
2713  
2714 0 printWithLength(sprintf
2715 (qq(%s\n<response %s command="%s"
2716 state="%s" id="%d" transaction_id="%s" />),
2717 xmlHeader(),
2718 namespaceAttr(),
2719 $cmd,
2720 $bState,
2721 $bkptID,
2722 $transactionID));
2723  
2724 } elsif ($cmd eq 'stack_depth') {
2725 0 my $stackCount = count_trace(1);
2726 0 printWithLength(sprintf
2727 (qq(%s\n<response %s command="%s"
2728 depth="%d" transaction_id="%s" />),
2729 xmlHeader(),
2730 namespaceAttr(),
2731 $cmd,
2732 $stackCount,
2733 $transactionID,
2734 ));
2735  
2736 } elsif ($cmd eq 'stack_get') {
2737 0 my $stackDepth = getArg(\@cmdArgs, '-d');
2738 0 my $numLevelsToShow;
2739 0 ▶ if (!defined $stackDepth) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $stackDepth) { } 0 0 0
elsif (not $stackDepth =~ /^\d+$/ or $stackDepth < 0) { } 0 0 0
2740 0 $numLevelsToShow = 1e9; # Get them all
2741 ▶ } elsif ($stackDepth !~ /^\d+$/ || $stackDepth < 0) {
Condition0%0/3
not $stackDepth =~ /^\d+$/ or $stackDepth < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not $stackDepth =~ /^\d+$/ or $stackDepth < 0
not $stackDepth =~ /^\d+$/ $stackDepth < 0
Truth table0%0/3
not(A) or B
A= not $stackDepth =~ /^\d+$/B= $stackDepth < 0
ABresult
1X1
011
000
2742 0 printWithLength(sprintf
2743 (qq(%s\n<response %s command="%s"
2744 transaction_id="%s" ><error code="%d" apperr="4">
2745 <message>%s</message>
2746 </error></response>),
2747 xmlHeader(),
2748 namespaceAttr(),
2749 $cmd,
2750 $transactionID,
2751 DBP_E_StackDepthInvalid,
2752 "Invalid stack depth arg of '$stackDepth'"));
2753 0 next CMD;
2754 } else {
2755 0 $numLevelsToShow = $stackDepth;
2756 }
2757 0 my $res = sprintf(qq(%s\n<response %s command="%s"
2758 transaction_id="%s" >),
2759 xmlHeader(),
2760 namespaceAttr(),
2761 $cmd,
2762 $transactionID);
2763 0 my @sub = dump_trace(0); # , $numLevelsToShow);
2764 # dblog("raw stack trace = ", DB::Data::Dump::dump(@sub), "\n") if $ldebug;
2765 0 ▶ if (@sub && $sub[0]->{line} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sub and $sub[0]{"line"} == 0) 0 0 0
Condition0%0/3
@sub and $sub[0]{"line"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
@sub and $sub[0]{"line"} == 0
@sub $sub[0]{"line"} == 0
Truth table0%0/3
A and B
A= @subB= $sub[0]{"line"} == 0
ABresult
0X0
100
111
2766 # We have no active stacks at this point
2767 0 @sub = ();
2768 }
2769 0 ▶ if (defined $stackDepth || scalar @sub == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stackDepth or scalar @sub == 0) { } 0 0 0
Condition0%0/3
defined $stackDepth or scalar @sub == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $stackDepth or scalar @sub == 0
defined $stackDepth scalar @sub == 0
Truth table0%0/3
A or B
A= defined $stackDepthB= scalar @sub == 0
ABresult
1X1
011
000
2770 0 ▶ if (defined $stackDepth) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stackDepth) { } 0 0 0
2771 0 ▶ if ($stackDepth > scalar @sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stackDepth > scalar @sub) 0 0 0
2772 0 printWithLength(sprintf
2773 (qq(%s\n<response %s command="%s"
2774 transaction_id="%s" ><error code="%d" apperr="4">
2775 <message>%s</message>
2776 </error></response>),
2777 xmlHeader(),
2778 namespaceAttr(),
2779 $cmd,
2780 $transactionID,
2781 DBP_E_StackDepthInvalid,
2782 "Invalid stack depth arg of '$stackDepth'"));
2783 0 next CMD;
2784 }
2785 0 ▶ if ($stackDepth == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stackDepth == 0) { } 0 0 0
2786 $res .= sprintf(qq(<stack level="%d"
2787 type="%s"
2788 filename="%s"
2789 lineno="%s"
2790 where="%s"/>),
2791 $stackDepth,
2792 checkForEvalStackType($sub[0]->{sub}),
2793 calcFileURI $currentFilename,
2794 $currentLine,
2795 (($#sub >= 0 && $sub[0]{sub})
2796 ? trimEvalSubNames ($sub[0]{sub})
2797 0 ▶ : 'main'),
Branch: 1 branch
BranchTrueFalseTotal
$#sub >= 0 && $sub[0]{'sub'} ? : 0 0 0
Condition0%0/3
$#sub >= 0 and $sub[0]{"sub"}
!ll&&!rl&&r
000
MC/DC0%0/2
$#sub >= 0 and $sub[0]{"sub"}
$#sub >= 0 $sub[0]{"sub"}
Truth table0%0/3
A and B
A= $#sub >= 0B= $sub[0]{"sub"}
ABresult
0X0
100
111
2798 );
2799 } else {
2800 0 my $sub2 = $sub[$stackDepth - 1];
2801 0 ▶ dblog("raw stack trace [$stackDepth] = ", DB::Data::Dump::dump($sub2), "\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2802 $res .= sprintf(qq(<stack level="%d"
2803 type="%s"
2804 filename="%s"
2805 lineno="%s"
2806 where="%s"/>),
2807 $stackDepth,
2808 checkForEvalStackType($sub[$stackDepth]->{sub}),
2809 calcFileURI $sub2->{file},
2810 $sub2->{line},
2811 ($sub[$stackDepth]->{sub}
2812 ? trimEvalSubNames ($sub[$stackDepth]{sub})
2813 0 ▶ : 'main'),
Branch: 1 branch
BranchTrueFalseTotal
$sub[$stackDepth]{'sub'} ? : 0 0 0
2814 );
2815 }
2816 } else {
2817 $res .= sprintf(qq(<stack level="%d"
2818 type="%s"
2819 filename="%s"
2820 lineno="%s"
2821 where="%s"/>),
2822 0,
2823 checkForEvalStackType($sub[0]->{sub}),
2824 calcFileURI $currentFilename,
2825 $currentLine,
2826 (($#sub >= 0 && $sub[0]{sub})
2827 ? trimEvalSubNames ($sub[0]{sub})
2828 0 ▶ : 'main'),
Branch: 1 branch
BranchTrueFalseTotal
$#sub >= 0 && $sub[0]{'sub'} ? : 0 0 0
Condition0%0/3
$#sub >= 0 and $sub[0]{"sub"}
!ll&&!rl&&r
000
MC/DC0%0/2
$#sub >= 0 and $sub[0]{"sub"}
$#sub >= 0 $sub[0]{"sub"}
Truth table0%0/3
A and B
A= $#sub >= 0B= $sub[0]{"sub"}
ABresult
0X0
100
111
2829 );
2830 }
2831 } else {
2832 # We get back a stack of callers, and need to
2833 # transform it into a stack of positions
2834 $res .= sprintf(qq(<stack level="%d"
2835 type="%s"
2836 filename="%s"
2837 lineno="%s"
2838 where="%s"/>),
2839 0,
2840 checkForEvalStackType($sub[0]->{sub}), # where we are
2841 calcFileURI $currentFilename, # and where we were called
2842 $currentLine,
2843 (($#sub >= 0 && $sub[0]{sub})
2844 ? trimEvalSubNames($sub[0]{sub})
2845 0 ▶ : 'main'),
Branch: 1 branch
BranchTrueFalseTotal
$#sub >= 0 && $sub[0]{'sub'} ? : 0 0 0
Condition0%0/3
$#sub >= 0 and $sub[0]{"sub"}
!ll&&!rl&&r
000
MC/DC0%0/2
$#sub >= 0 and $sub[0]{"sub"}
$#sub >= 0 $sub[0]{"sub"}
Truth table0%0/3
A and B
A= $#sub >= 0B= $sub[0]{"sub"}
ABresult
0X0
100
111
2846 );
2847  
2848 0 my $i;
2849 0 ▶ for ($i = 1 ; $i <= $#sub ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#sub) 0 0 0
2850 $res .= sprintf(qq(<stack level="%d"
2851 type="%s"
2852 filename="%s"
2853 lineno="%s"
2854 where="%s"/>),
2855 $i,
2856 checkForEvalStackType($sub[$i]->{sub}),
2857 calcFileURI $sub[$i - 1]->{file},
2858 $sub[$i - 1]->{line},
2859 0 trimEvalSubNames($sub[$i]{sub}),
2860 );
2861 }
2862 $res .= sprintf(qq(<stack level="%d"
2863 type="%s"
2864 filename="%s"
2865 lineno="%s"
2866 where="%s"/>),
2867 $i,
2868 checkForEvalStackType($sub[$#sub]->{sub}),
2869 calcFileURI $sub[$#sub]->{file},
2870 $sub[$#sub]->{line},
2871 0 'main');
2872 }
2873 0 $res .= "\n</response>\n";
2874 # dblog("$cmd => $res") if $ldebug;
2875 0 printWithLength($res);
2876  
2877 } elsif ($cmd eq 'context_names') {
2878 0 emitContextNames($cmd,
2879 $transactionID);
2880  
2881 } elsif ($cmd eq 'context_get') {
2882 0 my $stackDepth = getArg(\@cmdArgs, '-d');
2883 0 my $context_id = getArg(\@cmdArgs, '-c');
2884 0 ▶ $stackDepth = 0 unless defined $stackDepth;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stackDepth 0 0 0
2885 0 ▶ local $settings{max_depth}[0] = 0
Branch: 1 branch
BranchTrueFalseTotal
unless $xdebug_full_values_in_context 0 0 0
2886 unless $xdebug_full_values_in_context;
2887 0 my $currStackSize = count_trace(0); # , $numLevelsToShow;
2888 0 ▶ dblog("main->getContextProperties: \$currStackSize = $currStackSize\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
2889 0 my $namesAndValues;
2890 0 ▶ if ($context_id == FunctionArguments) {
Branch: 2 branches
BranchTrueFalseTotal
if ($context_id == 2) { } 0 0 0
elsif ($context_id == 0) { } 0 0 0
2891 0 my @savedArgs;
2892 0 my $actualStackDepth = $stackDepth + 1;
2893 0 while (1) {
2894 0 my @unused = caller($actualStackDepth);
2895 0 ▶ if (!@unused) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @unused) { } 0 0 0
elsif ($unused[3] eq '(eval)' and not $unused[4]) { } 0 0 0
2896 0 last;
2897 ▶ } elsif ($unused[3] eq '(eval)' && !$unused[4]) {
Condition0%0/3
$unused[3] eq "(eval)" and not $unused[4]
!ll&&!rl&&r
000
MC/DC0%0/2
$unused[3] eq "(eval)" and not $unused[4]
$unused[3] eq "(eval)" not $unused[4]
Truth table0%0/3
A and not(B)
A= $unused[3] eq "(eval)"B= not $unused[4]
ABresult
0X0
100
111
2898 0 $actualStackDepth++;
2899 # dblog("context_get: moving up to level $actualStackDepth");
2900 } else {
2901 # dblog("context_get: settle on caller => [@unused]");
2902 # dblog("stack depth [$actualStackDepth]: curr args are [", join(", ", @args), "]") if $ldebug;
2903 0 @savedArgs = @args;
2904 0 last;
2905 }
2906 }
2907 0 ▶ if (@savedArgs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@savedArgs) 0 0 0
2908 # Are there args? This gets around Perl's
2909 # behavior where if caller fails it doesn't
2910 # change the value of @args
2911  
2912 # dblog("caller => [@unused]");
2913 # dblog("stack depth [$stackDepth]: curr args are [", join(", ", @args), "]") if $ldebug;
2914 0 $namesAndValues = [];
2915 0 ▶ for (my $j = 0; $j < @savedArgs; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < @savedArgs) 0 0 0
2916 0 push @$namesAndValues, [sprintf('$_[%d]', $j), $savedArgs[$j], 0];
2917 }
2918 }
2919 } elsif ($context_id == LocalVars) {
2920 0 $namesAndValues = eval {
2921 0 ▶ hasPadWalker() ?
Branch: 1 branch
BranchTrueFalseTotal
hasPadWalker() ? : 0 0 0
2922 getProximityVarsViaPadWalker($pkg, $currentFilename, $currentLine, $stackDepth) :
2923 getProximityVarsViaB($pkg, $currentFilename, $currentLine, $stackDepth);
2924 };
2925 } else {
2926 0 $namesAndValues = eval { getContextProperties($context_id, $pkg); };
2927 }
2928 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
2929 0 my ($code, $error) = ($@ =~ /code:(.*):error<:<(.*?)>:>/);
2930 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
2931 0 $code = DBP_E_ParseError;
2932 0 $error = _trimExceptionInfo($@);
2933 }
2934 0 makeErrorResponse($cmd,
2935 $transactionID,
2936 $code,
2937 $error);
2938 0 next CMD;
2939 }
2940 #dblog("unsorted vars:", DB::Data::Dump::dump($namesAndValues), "\n") if $ldebug;
2941 0 my @sortedNames;
2942 0 ▶ if ($context_id != FunctionArguments) {
Branch: 1 branch
BranchTrueFalseTotal
if ($context_id != 2) { } 0 0 0
2943 @sortedNames = sort {
2944 # For some reason this doesn't work as an external fn
2945 # All the values come in undef'ed
2946 0 my ($a1, $a2) = split(//, $a->[0], 2);
2947 0 my ($b1, $b2) = split(//, $b->[0], 2);
2948 0 ▶ ($a2 cmp $b2 || $a1 cmp $b1);
Condition0%0/3
$a2 cmp $b2 || $a1 cmp $b1
l!l&&r!l&&!r
000
MC/DC0%0/2
$a2 cmp $b2 || $a1 cmp $b1
$a2 cmp $b2 $a1 cmp $b1
Truth table0%0/3
A || B
A= $a2 cmp $b2B= $a1 cmp $b1
ABresult
1X1
011
000
2949 } @$namesAndValues;
2950 } else {
2951 0 @sortedNames = @$namesAndValues;
2952 }
2953 0 ▶ if ($ldebug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug) 0 0 0
2954 0 my @names = map $_->[NV_NAME], @sortedNames;
2955 0 dblog("Found variables: @names");
2956 }
2957 # dblog("sorted vars:", DB::Data::Dump::dump(@sortedNames), "\n") if $ldebug;
2958 0 foreach my $entry (@sortedNames) {
2959 0 ▶ if ($entry->[NV_NEED_MAIN_LEVEL_EVAL]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[2]) 0 0 0
2960 0 eval {
2961 0 $entry->[NV_VALUE] = eval_term($entry->[NV_NAME]);
2962 };
2963 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
2964 0 $entry->[NV_VALUE] = _trimExceptionInfo($@);
2965 0 $entry->[NV_UNSET_FLAG] = 1;
2966 }
2967 }
2968 }
2969 # If anything had to be re-evaluated, and didn't return
2970 # a value, remove it.
2971 0 ▶ @sortedNames = grep { !($_->[NV_NEED_MAIN_LEVEL_EVAL])
Condition0%0/3
!$_->[2] || defined $_->[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
!$_->[2] || defined $_->[1]
!$_->[2] defined $_->[1]
Truth table0%0/3
not(A) || B
A= !$_->[2]B= defined $_->[1]
ABresult
1X1
011
000
2972 || defined $_->[NV_VALUE] } @sortedNames;
2973 0 ▶ if ($context_id == PunctuationVariables) {
Branch: 1 branch
BranchTrueFalseTotal
if ($context_id == 3) 0 0 0
2974 # Filter out unset values, and add the pattern-matching ones.
2975 0 @sortedNames = grep { ! defined $_->[NV_UNSET_FLAG] } @sortedNames;
2976 # And add the pattern-match vars
2977 0 $evalarg = '$#-';
2978 0 my ($numPVs) = &eval();
2979 0 ▶ for (my $pvnum = $numPVs; $pvnum > 0; $pvnum--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pvnum > 0) 0 0 0
2980 0 eval {
2981 0 my $pvname = "\$$pvnum";
2982 0 $evalarg = $pvname;
2983 0 my ($val) = &eval();
2984 0 ▶ if (length $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $val) 0 0 0
2985 0 unshift @sortedNames, [$pvname, $val, 1];
2986 }
2987 };
2988 }
2989 }
2990 0 eval { emitContextProperties($cmd, $transactionID, $context_id, \@sortedNames, $settings{max_data}[0]); };
2991 } elsif ($cmd eq 'typemap_get') {
2992 0 emitTypeMapInfo($cmd, $transactionID);
2993  
2994 ▶ } elsif ($cmd eq 'property_get' || $cmd eq 'property_value') {
Condition0%0/3
$cmd eq "property_get" or $cmd eq "property_value"
l!l&&r!l&&!r
000
MC/DC0%0/2
$cmd eq "property_get" or $cmd eq "property_value"
$cmd eq "property_get" $cmd eq "property_value"
Truth table0%0/3
A or B
A= $cmd eq "property_get"B= $cmd eq "property_value"
ABresult
1X1
011
000
2995 # First get the args, and then sanity check.
2996 0 my %opts;
2997 {
2998 0 local *ARGV = \@cmdArgs;
2999 0 shift @ARGV;
3000 0 getopts('c:d:k:m:n:p:', \%opts);
3001 }
3002 0 my $context_id = $opts{c};
3003 0 ▶ my $stackDepth = $opts{d} || 0;
Condition0%0/2
$opts{'d'} || 0
l!l
00
MC/DC0%0/1
$opts{'d'} || 0
$opts{'d'}
Truth table0%0/2
A
A= $opts{'d'}
Aresult
11
00
3004 0 my $propertyKey = $opts{k};
3005 0 ▶ my $maxDataSize = $opts{m} || $settings{max_data}[0];
Condition0%0/3
$opts{'m'} || $DB::settings{'max_data'}[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{'m'} || $DB::settings{'max_data'}[0]
$opts{'m'} $DB::settings{'max_data'}[0]
Truth table0%0/3
A || B
A= $opts{'m'}B= $DB::settings{'max_data'}[0]
ABresult
1X1
011
000
3006 0 my $property_long_name = $opts{n};
3007 0 ▶ my $pageIndex = $opts{p} || 0;
Condition0%0/2
$opts{'p'} || 0
l!l
00
MC/DC0%0/1
$opts{'p'} || 0
$opts{'p'}
Truth table0%0/2
A
A= $opts{'p'}
Aresult
11
00
3008 0 $property_long_name = nonXmlChar_Decode($property_long_name);
3009 0 ▶ if ($context_id == FunctionArguments &&
Branch: 1 branch
BranchTrueFalseTotal
if ($context_id == 2 and $property_long_name ne "\@_" and not $property_long_name =~ /^\$_\[/) 0 0 0
Condition0%0/6
$context_id == 2 and $property_long_name ne "\@_" and not $property_long_name =~ /^\$_\[/
!ll&&!rl&&r
000
$context_id == 2 and $property_long_name ne "\@_"
!ll&&!rl&&r
000
MC/DC0%0/3
$context_id == 2 and $property_long_name ne "\@_" and not $property_long_name =~ /^\$_\[/
$context_id == 2 $property_long_name ne "\@_" not $property_long_name =~ /^\$_\[/
Truth table0%0/4
A and B and not(C)
A= $context_id == 2B= $property_long_name ne "\@_"C= not $property_long_name =~ /^\$_\[/
ABCresult
0XX0
10X0
1100
1111
3010 $property_long_name ne '@_' &&
3011 $property_long_name !~ /^\$_\[/) {
3012 0 makeErrorResponse($cmd,
3013 $transactionID,
3014 DBP_E_CantGetProperty,
3015 "Property $property_long_name doesn't identify an arg");
3016 0 next CMD;
3017 }
3018 0 (my $fullName, $propertyKey) = makeFullPropertyName($property_long_name, $propertyKey);
3019 0 my $nameAndValue = [$fullName, undef, 1];
3020 # + 1 is for the eval BLOCK below
3021 0 local $evalSkipFrames = $evalSkipFrames + 1;
3022 0 local $evalStackLevel = $stackDepth;
3023 0 eval {
3024 0 $nameAndValue->[NV_VALUE] = eval_term($nameAndValue->[NV_NAME]);
3025 };
3026 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
3027 0 $nameAndValue->[NV_VALUE] = _trimExceptionInfo($@);
3028 0 $nameAndValue->[NV_UNSET_FLAG] = 1;
3029 }
3030 0 eval {
3031 0 emitEvaluatedPropertyGetInfo($cmd,
3032 $transactionID,
3033 $nameAndValue,
3034 $property_long_name,
3035 $propertyKey,
3036 $maxDataSize,
3037 $pageIndex);
3038 };
3039 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
3040 0 ▶ dblog("Error in emitEvaluatedPropertyGetInfo: [$@]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3041 0 makeErrorResponse($cmd,
3042 $transactionID,
3043 DBP_E_InternalException,
3044 "Internal error while formatting result");
3045 }
3046 } elsif ($cmd eq 'property_set') {
3047 # First get the args, and then sanity check.
3048 0 my %opts;
3049 {
3050 0 local *ARGV = \@cmdArgs;
3051 0 shift @ARGV;
3052 0 getopts('a:c:d:l:n:t:', \%opts);
3053 }
3054 0 my $context_id = $opts{c};
3055 0 ▶ my $stackDepth = $opts{d} || 0;
Condition0%0/2
$opts{'d'} || 0
l!l
00
MC/DC0%0/1
$opts{'d'} || 0
$opts{'d'}
Truth table0%0/2
A
A= $opts{'d'}
Aresult
11
00
3056 0 ▶ my $advertisedDataLength = $opts{l} || 0;
Condition0%0/2
$opts{'l'} || 0
l!l
00
MC/DC0%0/1
$opts{'l'} || 0
$opts{'l'}
Truth table0%0/2
A
A= $opts{'l'}
Aresult
11
00
3057 0 my $property_long_name = $opts{n};
3058 0 $property_long_name = nonXmlChar_Decode($property_long_name);
3059 0 my $valueType = $opts{t};
3060  
3061 0 ▶ if ($context_id == FunctionArguments) {
Branch: 1 branch
BranchTrueFalseTotal
if ($context_id == 2) 0 0 0
3062 0 makeErrorResponse($cmd,
3063 $transactionID,
3064 DBP_E_CantSetProperty,
3065 "This debugger currently doesn't modify function arguments");
3066 0 next CMD;
3067 }
3068  
3069 0 my ($actualDataLength, $currDataEncoding, $decodedData);
3070 0 ▶ if (scalar @cmdArgs) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @cmdArgs) 0 0 0
3071 0 ($actualDataLength, $currDataEncoding, $decodedData) =
3072 decodeCmdLineData($cmd, $transactionID, $advertisedDataLength, \@cmdArgs);
3073 }
3074 0 ▶ if (!defined $decodedData) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $decodedData) 0 0 0
3075 0 ▶ dblog("property_set: \$decodedData not defined\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3076 0 makeErrorResponse($cmd,
3077 $transactionID,
3078 DBP_E_CantSetProperty,
3079 "Can't decode the data");
3080 0 next CMD;
3081 }
3082 0 ▶ if ($valueType
Branch: 1 branch
BranchTrueFalseTotal
if ($valueType and $valueType eq "string" and not substr($decodedData, 0, 1) =~ /[\"\']/) 0 0 0
Condition0%0/6
$valueType and $valueType eq "string" and not substr($decodedData, 0, 1) =~ /[\"\']/
!ll&&!rl&&r
000
$valueType and $valueType eq "string"
!ll&&!rl&&r
000
MC/DC0%0/3
$valueType and $valueType eq "string" and not substr($decodedData, 0, 1) =~ /[\"\']/
$valueType $valueType eq "string" not substr($decodedData, 0, 1) =~ /[\"\']/
Truth table0%0/4
A and B and not(C)
A= $valueTypeB= $valueType eq "string"C= not substr($decodedData, 0, 1) =~ /[\"\']/
ABCresult
0XX0
10X0
1100
1111
3083 && $valueType eq 'string'
3084 && substr($decodedData, 0, 1) !~ /[\"\']/) {
3085 0 $decodedData =~ s,\\,\\\\,g;
3086 0 $decodedData =~ s,',\\',g;
3087 0 $decodedData = "\'$decodedData\'";
3088 }
3089 0 my $nameAndValue = doPropertySetInfo($cmd,
3090 $transactionID,
3091 $property_long_name);
3092 0 ▶ if (!$nameAndValue) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nameAndValue) 0 0 0
3093 # Already gave an error message
3094 0 next CMD;
3095 }
3096  
3097 0 ▶ if ($nameAndValue->[NV_NEED_MAIN_LEVEL_EVAL]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nameAndValue->[2]) 0 0 0
3098 0 $evalarg = $nameAndValue->[NV_NAME] . '=' . $decodedData;
3099 # here we don't adjust $evalSkipFrames because
3100 # modifying function arguments is not supported
3101 0 eval {
3102 0 &eval();
3103 };
3104 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
3105 # dblog("Have to deal with error [$@]\n") if $ldebug;
3106 # Fix $@;
3107 0 my ($code, $error) = ($@ =~ /code:(.*):error<:<(.*?)>:>/);
3108 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
3109 0 $code = DBP_E_CantGetProperty;
3110 0 $error = _trimExceptionInfo($@);
3111 }
3112 0 makeErrorResponse($cmd,
3113 $transactionID,
3114 207, #XXX: Invalid expression
3115 $error);
3116 } else {
3117 0 my $res = sprintf(qq(%s\n<response %s command="%s"
3118 transaction_id="%s" success="1" />),
3119 xmlHeader(),
3120 namespaceAttr(),
3121 $cmd,
3122 $transactionID);
3123 0 printWithLength($res);
3124 }
3125 }
3126  
3127 } elsif ($cmd eq 'source') {
3128 0 my %opts;
3129 {
3130 0 local *ARGV = \@cmdArgs;
3131 0 ▶ dblog("source: args={@ARGV}") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3132  
3133 0 shift @ARGV;
3134 0 getopts('b:e:f:', \%opts);
3135 }
3136 # Line 0 contains the 'require perl5db.pl thing'?
3137 0 ▶ my $beginLine = $opts{b} || 1;
Condition0%0/2
$opts{'b'} || 1
l!l
00
MC/DC0%0/1
$opts{'b'} || 1
$opts{'b'}
Truth table0%0/2
A
A= $opts{'b'}
Aresult
11
00
3138 0 ▶ $beginLine < 1 and $beginLine = 1;
Branch: 1 branch
BranchTrueFalseTotal
$beginLine < 1 and $beginLine = 1 0 0 0
3139 0 my $endLine;
3140 my $sourceString;
3141 0 my $error;
3142 0 ▶ $opts{f} = calcFileURI $currentFilename unless exists $opts{f};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"f"} 0 0 0
3143 0 ▶ if (defined &INC && $opts{f} =~ m@^dbgp:///perl//(PerlApp/|<.*?>)(.*)@) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined &INC and $opts{'f'} =~ m[^dbgp:///perl//(PerlApp/|<.*?>)(.*)]) { } 0 0 0
elsif ($opts{'f'} =~ m[^dbgp:///?perl/.*(\d+)(/\(eval\s\d+\).*)$] or $opts{'f'} =~ m[^dbgp:///?perl/.*(\d+)(/%28eval%20\d+%29.*)$]) { } 0 0 0
Condition0%0/3
defined &INC and $opts{"f"} =~ m[^dbgp:///perl//(PerlApp/|<.*?>)(.*)]
!ll&&!rl&&r
000
MC/DC0%0/2
defined &INC and $opts{"f"} =~ m[^dbgp:///perl//(PerlApp/|<.*?>)(.*)]
defined &INC $opts{"f"} =~ m[^dbgp:///perl//(PerlApp/|<.*?>)(.*)]
Truth table0%0/3
A and B
A= defined &INCB= $opts{"f"} =~ m[^dbgp:///perl//(PerlApp/|<.*?>)(.*)]
ABresult
0X0
100
111
3144 # Definitely three slashes between 'perl' and 'PerlApp'
3145 0 my $pdkUtilityName = $1;
3146 0 my @lines = split(/\n/, INC($2));
3147 0 ▶ $endLine = $opts{e} || $#lines;
Condition0%0/3
$opts{'e'} || $#lines
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{'e'} || $#lines
$opts{'e'} $#lines
Truth table0%0/3
A || B
A= $opts{'e'}B= $#lines
ABresult
1X1
011
000
3148 0 ▶ dblog("Line " . __LINE__ . ": Debugging a $pdkUtilityName module, grab source($1) and get [" . join("\n", @lines[0..2]) . "]") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3149 0 ($sourceString, $error) =
3150 _fileSource($1,
3151 $beginLine,
3152 $endLine,
3153 \@lines);
3154 # One slash or two in this next pattern?
3155 ▶ } elsif ($opts{f} =~ m@^dbgp:///?perl/.*(\d+)(/\(eval\s\d+\).*)$@ || $opts{f} =~ m@^dbgp:///?perl/.*(\d+)(/%28eval%20\d+%29.*)$@) {
Condition0%0/3
$opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/\(eval\s\d+\).*)$] or $opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/%28eval%20\d+%29.*)$]
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/\(eval\s\d+\).*)$] or $opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/%28eval%20\d+%29.*)$]
$opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/\(eval\s\d+\).*)$] $opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/%28eval%20\d+%29.*)$]
Truth table0%0/3
A or B
A= $opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/\(eval\s\d+\).*)$]B= $opts{"f"} =~ m[^dbgp:///?perl/.*(\d+)(/%28eval%20\d+%29.*)$]
ABresult
1X1
011
000
3156 0 ▶ dblog("source: it's a dbgp thing ($1/$2)") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3157 0 my $dynLocnIdx = $1;
3158 0 my $dynamicLocation;
3159 0 ▶ if (defined $evalTableIdx[$dynLocnIdx]
Branch: 1 branch
BranchTrueFalseTotal
if (defined $evalTableIdx[$dynLocnIdx] and exists $evalTable{$evalTableIdx[$dynLocnIdx]}) { } 0 0 0
Condition0%0/3
defined $evalTableIdx[$dynLocnIdx] and exists $evalTable{$evalTableIdx[$dynLocnIdx]}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $evalTableIdx[$dynLocnIdx] and exists $evalTable{$evalTableIdx[$dynLocnIdx]}
defined $evalTableIdx[$dynLocnIdx] exists $evalTable{$evalTableIdx[$dynLocnIdx]}
Truth table0%0/3
A and B
A= defined $evalTableIdx[$dynLocnIdx]B= exists $evalTable{$evalTableIdx[$dynLocnIdx]}
ABresult
0X0
100
111
3160 && exists $evalTable{$evalTableIdx[$dynLocnIdx]}) {
3161 0 ▶ dblog("source -- mapping \$dynamicLocation = $dynamicLocation to evalstring" . $evalTableIdx[$dynLocnIdx]) if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3162 0 $dynamicLocation = $evalTableIdx[$dynLocnIdx];
3163 } else {
3164 0 ▶ dblog("source -- can't resolve numeric \$dynamicLocation = $dynamicLocation") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3165 0 $error = "Can't find src for location $dynamicLocation";
3166 }
3167 # dblog("source: locn = ", $dynamicLocation) if $ldebug;
3168 0 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
3169 0 ▶ if (!exists $evalTable{$dynamicLocation}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $evalTable{$dynamicLocation}) 0 0 0
3170 0 our $dbline;
3171 0 local *dbline = $main::{"_<$dynamicLocation"};
3172 0 ▶ if ($dbline eq $dynamicLocation) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DB::dbline eq $dynamicLocation) { } 0 0 0
3173 0 ▶ if ($dynamicLocation =~ /\(eval (\d+)\)\[(.*):(\d+)\]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dynamicLocation =~ /\(eval (\d+)\)\[(.*):(\d+)\]$/) { } 0 0 0
3174 0 my ($innerEvalIdx, $parentLocation, $startingPoint) = ($1, $2, $3);
3175 0 my $etCount = scalar @evalTableIdx;
3176 0 $evalTable{$dynamicLocation} = {
3177 file => $parentLocation,
3178 startLine => $startingPoint,
3179 src => \@dbline,
3180 idx => $etCount,
3181 };
3182 0 $evalTableIdx[$etCount] = \$evalTable{$currentFilename};
3183 } else {
3184 0 ▶ dblog "get source error: Can't parse [$dynamicLocation]\n" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3185 }
3186 } else {
3187 0 ▶ dblog "get source error: Can't find a glob from [$dynamicLocation]\n" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3188 }
3189 }
3190 0 ▶ if (exists $evalTable{$dynamicLocation}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $evalTable{$dynamicLocation}) { } 0 0 0
3191 0 my @src = @{$evalTable{$dynamicLocation}{src}};
3192 0 ▶ $endLine = $opts{e} || $#src;
Condition0%0/3
$opts{'e'} || $#src
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{'e'} || $#src
$opts{'e'} $#src
Truth table0%0/3
A || B
A= $opts{'e'}B= $#src
ABresult
1X1
011
000
3193 0 ▶ $endLine < $beginLine and $endLine = $beginLine;
Branch: 1 branch
BranchTrueFalseTotal
$endLine < $beginLine and $endLine = $beginLine 0 0 0
3194 0 eval {
3195 0 $sourceString = join("",
3196 @src[$beginLine .. $endLine]
3197 );
3198 };
3199 } else {
3200 0 $error = "Can't find src for URI " . $opts{f};
3201 }
3202 }
3203 } else {
3204 0 my ($bFileURI,
3205 $bFileURINo,
3206 $bFileName,
3207 $perlFileName);
3208 # work around broken clients
3209 0 $opts{f} =~ s@^file%3[Aa]//@file://@;
3210 $opts{f} = 'file://' . $opts{f} unless
3211 0 ▶ $opts{f} =~ m@^(?:file|dbgp)://@;
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"f"} =~ m[^(?:file|dbgp)://] 0 0 0
3212 0 $endLine = $opts{e};
3213  
3214 getFileInfo($opts{f},
3215 0 \$bFileURI,
3216 \$bFileURINo,
3217 \$bFileName,
3218 \$perlFileName);
3219 0 ▶ dblog("** source -- file $currentFilename, perl name $perlFileName") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3220 0 ▶ ($sourceString, $error) =
Branch: 1 branch
BranchTrueFalseTotal
if $perlFileName 0 0 0
3221 _fileSource($perlFileName,
3222 $beginLine,
3223 $endLine,
3224 \@dbline)
3225 if $perlFileName;
3226 }
3227 0 ▶ if ($error || !$sourceString) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error or not $sourceString) 0 0 0
Condition0%0/3
$error or not $sourceString
l!l&&r!l&&!r
000
MC/DC0%0/2
$error or not $sourceString
$error not $sourceString
Truth table0%0/3
A or not(B)
A= $errorB= not $sourceString
ABresult
1X1
011
000
3228 0 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $error) { } 0 0 0
3229 0 ▶ dblog("Failed to set an error, but got no string") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3230 0 $error = "source cmd -- unknown error";
3231 } else {
3232 0 ▶ dblog("source: $error\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3233 }
3234 0 makeErrorResponse($cmd,
3235 $transactionID,
3236 DBP_E_CantOpenSource,
3237 $error);
3238 0 next CMD;
3239 };
3240 0 my ($encoding, $encVal) = figureEncoding($sourceString);
3241 0 my $res = sprintf(qq(%s\n<response %s command="%s"
3242 transaction_id="%s"
3243 success="1"
3244 encoding="%s"
3245 >%s</response>\n),
3246 xmlHeader(),
3247 namespaceAttr(),
3248 $cmd,
3249 $transactionID,
3250 $encoding,
3251 $encVal);
3252 0 printWithLength($res);
3253  
3254 ▶ } elsif ($cmd eq 'stdout' || $cmd eq 'stderr') {
Condition0%0/3
$cmd eq "stdout" or $cmd eq "stderr"
l!l&&r!l&&!r
000
MC/DC0%0/2
$cmd eq "stdout" or $cmd eq "stderr"
$cmd eq "stdout" $cmd eq "stderr"
Truth table0%0/3
A or B
A= $cmd eq "stdout"B= $cmd eq "stderr"
ABresult
1X1
011
000
3255 0 my %opts;
3256 {
3257 0 local *ARGV = \@cmdArgs;
3258 0 shift @ARGV;
3259 0 getopts('c:', \%opts);
3260 }
3261 0 ▶ my $copyType = $opts{c} || 0;
Condition0%0/2
$opts{'c'} || 0
l!l
00
MC/DC0%0/1
$opts{'c'} || 0
$opts{'c'}
Truth table0%0/2
A
A= $opts{'c'}
Aresult
11
00
3262 0 eval {
3263 0 my $redirectType;
3264 0 ▶ if ($copyType < DBGP_Redirect_Disable
Branch: 1 branch
BranchTrueFalseTotal
if ($copyType < 0 or $copyType > 2) 0 0 0
Condition0%0/3
$copyType < 0 or $copyType > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
$copyType < 0 or $copyType > 2
$copyType < 0 $copyType > 2
Truth table0%0/3
A or B
A= $copyType < 0B= $copyType > 2
ABresult
1X1
011
000
3265 || $copyType > DBGP_Redirect_Redirect) {
3266 0 makeErrorResponse($cmd,
3267 $transactionID,
3268 DBP_E_InvalidOption,
3269 "Invalid -c value of $copyType");
3270 0 next CMD;
3271 }
3272 0 ▶ if ($cmd eq 'stdout') {
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd eq 'stdout') { } 0 0 0
elsif ($cmd eq 'stderr' and not $ldebug) { } 0 0 0
3273 0 ▶ if ($tiedStdout) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tiedStdout) 0 0 0
3274 # Update the copy-type
3275 0 untie(*STDOUT);
3276 }
3277 0 ▶ if (!open ActualSTDOUT, ">&STDOUT") {
Branch: 1 branch
BranchTrueFalseTotal
unless (open ActualSTDOUT, ">&STDOUT") 0 0 0
3278 0 makeErrorResponse($cmd,
3279 $transactionID,
3280 DBP_E_InvalidOption,
3281 "Invalid -c value of $copyType");
3282 0 next CMD;
3283 }
3284 0 tie(*STDOUT, 'DB::RedirectStdOutput', *ActualSTDOUT, $OUT, $cmd, $copyType);
3285 0 $tiedStdout = 1;
3286 0 ▶ if (logName && logName == \*STDOUT) {
Branch: 1 branch
BranchTrueFalseTotal
if (logName() and logName() == \*STDOUT) 0 0 0
Condition0%0/3
logName() and logName() == \*STDOUT
!ll&&!rl&&r
000
MC/DC0%0/2
logName() and logName() == \*STDOUT
logName() logName() == \*STDOUT
Truth table0%0/3
A and B
A= logName()B= logName() == \*STDOUT
ABresult
0X0
100
111
3287 0 setLogFH(\*ActualSTDOUT);
3288 }
3289 ▶ } elsif ($cmd eq 'stderr' && !$ldebug) {
Condition0%0/3
$cmd eq "stderr" and not $ldebug
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq "stderr" and not $ldebug
$cmd eq "stderr" not $ldebug
Truth table0%0/3
A and not(B)
A= $cmd eq "stderr"B= not $ldebug
ABresult
0X0
100
111
3290 0 ▶ if ($tiedStderr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tiedStderr) 0 0 0
3291 # Update the copy-type
3292 0 untie(*STDERR);
3293 }
3294 0 ▶ if (!open ActualSTDERR, ">&STDERR") {
Branch: 1 branch
BranchTrueFalseTotal
unless (open ActualSTDERR, ">&STDERR") 0 0 0
3295 0 makeErrorResponse($cmd,
3296 $transactionID,
3297 DBP_E_InvalidOption,
3298 "Invalid -c value of $copyType");
3299 0 next CMD;
3300 }
3301 0 tie(*STDERR, 'DB::RedirectStdOutput', *ActualSTDERR, $OUT, $cmd, $copyType);
3302 0 $tiedStderr = 1;
3303 0 ▶ if (logName && logName == \*STDERR) {
Branch: 1 branch
BranchTrueFalseTotal
if (logName() and logName() == \*STDERR) 0 0 0
Condition0%0/3
logName() and logName() == \*STDERR
!ll&&!rl&&r
000
MC/DC0%0/2
logName() and logName() == \*STDERR
logName() logName() == \*STDERR
Truth table0%0/3
A and B
A= logName()B= logName() == \*STDERR
ABresult
0X0
100
111
3304 0 setLogFH(\*ActualSTDERR);
3305 }
3306 }
3307 0 my $res = sprintf(qq(%s\n<response %s command="%s"
3308 transaction_id="%s" success="1" />),
3309 xmlHeader(),
3310 namespaceAttr(),
3311 $cmd,
3312 $transactionID);
3313 {
3314 0 ▶ local $ldebug = $cmd ne 'stderr' && $ldebug;
Condition0%0/3
$cmd ne 'stderr' && $ldebug
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd ne 'stderr' && $ldebug
$cmd ne 'stderr' $ldebug
Truth table0%0/3
A && B
A= $cmd ne 'stderr'B= $ldebug
ABresult
0X0
100
111
3315 0 printWithLength($res);
3316 }
3317 };
3318 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
3319 0 makeErrorResponse($cmd,
3320 $transactionID,
3321 DBP_E_InvalidOption,
3322 "Invalid -c value of $copyType");
3323 }
3324 } elsif ($cmd eq 'stdin') {
3325  
3326 =head unsupported
3327  
3328 my %opts;
3329 {
3330 local *ARGV = \@cmdArgs;
3331 shift @ARGV;
3332 getopts('c:l:', \%opts);
3333 }
3334 if ($opts{c} == 1) {
3335 } else {
3336 dblog("stdin: opts{c} = $opts{c}\n") if $ldebug;
3337 next CMD;
3338 }
3339 my $dataLength = $opts{l}; # ignore
3340 my $encodedData = join("", @cmdArgs);
3341 my $actualData = decodeData($encodedData, 'base64');
3342 dblog "stdin: [$actualData]\n" if $ldebug;
3343  
3344 =cut
3345  
3346 0 makeErrorResponse($cmd,
3347 $transactionID,
3348 DBP_E_CommandUnimplemented,
3349 "stdin not supported via protocol");
3350 } elsif ($cmd eq 'eval') {
3351 0 my %opts;
3352 {
3353 0 local *ARGV = \@cmdArgs;
3354 0 shift @ARGV;
3355 0 getopts('l:p:', \%opts);
3356 }
3357 0 my $dataLength = $opts{l};
3358 0 ▶ my $pageIndex = $opts{p} || 0;
Condition0%0/2
$opts{'p'} || 0
l!l
00
MC/DC0%0/1
$opts{'p'} || 0
$opts{'p'}
Truth table0%0/2
A
A= $opts{'p'}
Aresult
11
00
3359 0 my ($actualDataLength, $currDataEncoding, $decodedData);
3360 0 ▶ if (scalar @cmdArgs) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @cmdArgs) 0 0 0
3361 0 ($actualDataLength, $currDataEncoding, $decodedData) =
3362 decodeCmdLineData($cmd, $transactionID, $dataLength, \@cmdArgs);
3363 }
3364 0 ▶ if (!defined $decodedData) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $decodedData) 0 0 0
3365 0 next CMD;
3366 }
3367 eval {
3368 0 local $evalSkipFrames = $evalSkipFrames + 1;
3369 0 my $res = eval_term($decodedData);
3370 emitEvalResultAsProperty($cmd,
3371 $transactionID,
3372 $decodedData,
3373 $res,
3374 0 $settings{max_data}[0],
3375 $pageIndex);
3376 0 1;
3377 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { local $evalSkipFrames = $evalSkipFrames + 1; my $res = eval_term($decodedData); &emitEvalResultAsProperty($cmd, $transactionID, $decodedData, $res, $DB::settings{"max_data"}[0], $pageIndex); 1 } } or do { my $error = $@ || ""; &makeErrorResponse($cmd, $transactionID, 206, "Error in eval: $error") } 0 0 0
3378 0 ▶ my $error = $@ || "";
Condition0%0/2
$@ || ''
l!l
00
MC/DC0%0/1
$@ || ''
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
3379  
3380 0 makeErrorResponse($cmd, $transactionID, DBP_E_PropertyEvalError, "Error in eval: $error")
3381 };
3382 } else {
3383 # Fallback
3384 0 printWithLength(sprintf
3385 (qq(%s\n<response %s command="%s"
3386 transaction_id="%s" ><error code="6" apperr="4">
3387 <message>%s command not recognized</message>
3388 </error></response>),
3389 xmlHeader(),
3390 namespaceAttr(),
3391 $cmd,
3392 $transactionID));
3393  
3394 }
3395 }
3396 } elsif ($pkg =~ /^DB::/) {
3397 0 ▶ dblog("Skipping package [$pkg]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3398 } elsif ($inPostponed) {
3399 0 ▶ dblog("Still postponed: [$pkg/$currentFilename/$currentLine]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3400 }
3401
3402 # Put the user's globals back where you found them.
3403 0 ($@, $!, $,, $/, $\, $^W) = @saved;
3404 0 db_alarm($pending_check_interval);
3405 0 ▶ $pending_check_enabled = 1 unless $skip_alarm;
Branch: 1 branch
BranchTrueFalseTotal
unless $skip_alarm 0 0 0
3406 0 return ();
3407 }
3408  
3409 # Avoid re-entrancy problems by putting newly entered files in a
3410 # queue and processing them when it's appropriate.
3411  
3412 sub postponed {
3413 0 ▶ local *dbline_arg = shift;
Subroutine postponed: not called CC=3 SCAR=24.8
Pod undocumented
3414 0 push @postponedFiles, *dbline_arg;
3415 0 ▶ if ($inPostponed || !$ready) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inPostponed or not $ready) 0 0 0
Condition0%0/3
$inPostponed or not $ready
l!l&&r!l&&!r
000
MC/DC0%0/2
$inPostponed or not $ready
$inPostponed not $ready
Truth table0%0/3
A or not(B)
A= $inPostponedB= not $ready
ABresult
1X1
011
000
3416 0 return;
3417 }
3418 0 finish_postponed();
3419 0 return 1;
3420 }
3421  
3422 sub finish_postponed {
3423 0 ▶ local $inPostponed = 1;
Subroutine finish_postponed: not called CC=7 SCAR=40.3
Pod undocumented
3424 0 ▶ while (@postponedFiles) {
Branch: 1 branch
BranchTrueFalseTotal
if (@postponedFiles) 0 0 0
3425 0 our ($dbline, %dbline);
3426 0 local *dbline = shift @postponedFiles;
3427 0 my $filename = $dbline;
3428 0 $filename =~ s/^<_//;
3429  
3430 # Get the Perl filename, canonical filename, and URI, and see
3431 # if it was set as postponed
3432 0 my $perlFileName = $filename;
3433 0 my ($bFileURI, $bFileURINo, $bFileName);
3434  
3435 0 ▶ if (exists $perlNameToFileURINo{$perlFileName}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $perlNameToFileURINo{$perlFileName}) { } 0 0 0
3436 # Why are we here -- we already know about this filename.
3437 0 $bFileURINo = $perlNameToFileURINo{$perlFileName};
3438 0 ($bFileURI, $bFileName, undef) = @{$fileNameTable[$bFileURINo]};
3439 } else {
3440 0 $bFileURI = canonicalizeURI(filenameToURI($filename, 1));
3441 0 $bFileURINo = internFileURI($bFileURI);
3442 0 local $@;
3443 0 eval {
3444 0 $bFileName = canonicalizeFName(uriToFilename($bFileURI));
3445 };
3446 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
3447 0 ▶ dblog("Called uriToFilename in " .
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3448 join("\n", dump_trace(0))) if $ldebug;
3449 0 return;
3450 }
3451 0 $perlNameToFileURINo{canonicalizeFName($perlFileName)} = $bFileURINo;
3452 0 $fileNameTable[$bFileURINo] = [$bFileURI,
3453 $bFileName,
3454 $perlFileName];
3455 }
3456  
3457 0 ▶ if (defined $bkptLookupTable[$bFileURINo]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bkptLookupTable[$bFileURINo]) 0 0 0
3458 # Set the breakpoints in %dbline now...
3459 0 foreach my $k (keys %{$bkptLookupTable[$bFileURINo]}) {
3460 0 $dbline{$k} = 1;
3461 }
3462 }
3463 }
3464 }
3465  
3466 # This routine needs to localize these globals, as function
3467 # breakpoints are not conditional. We only need to localize
3468 # $@ because the eval() destroys it.
3469  
3470 sub tryBreaking($$$) {
3471 0 ▶ return if ($signal || $single); # we're about to break anyway.
Subroutine tryBreaking: not called CC=8 SCAR=42.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $signal or $single 0 0 0
Condition0%0/3
$signal or $single
l!l&&r!l&&!r
000
MC/DC0%0/2
$signal or $single
$signal $single
Truth table0%0/3
A or B
A= $signalB= $single
ABresult
1X1
011
000
3472 0 my ($bkptEntry, $fqsubname, $callDirection) = @_;
3473 0 local $@;
3474 0 eval {
3475 0 ▶ if (exists $bkptEntry->{$callDirection}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $bkptEntry->{$callDirection}) 0 0 0
3476 # 3 because of DB::sub + tryBreaking + the eval BLOCK
3477 0 local $evalSkipFrames = $evalSkipFrames + 3;
3478 0 my $breakHere = 0;
3479 0 my $bkptInfoRef = getBkPtInfo($bkptEntry->{$callDirection});
3480 0 processPossibleBreakpoint($bkptInfoRef, "sub $fqsubname");
3481 }
3482 0 ▶ if (!$single && _checkForBreak()) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $single and _checkForBreak()) 0 0 0
Condition0%0/3
not $single and _checkForBreak()
!ll&&!rl&&r
000
MC/DC0%0/2
not $single and _checkForBreak()
not $single _checkForBreak()
Truth table0%0/3
not(A) and B
A= not $singleB= _checkForBreak()
ABresult
0X0
100
111
3483 0 $single = 1;
3484 }
3485 };
3486 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
3487 0 ▶ dblog "Error while trying to eval breakpoint($fqsubname, $callDirection): $@" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3488 }
3489 }
3490  
3491  
3492 sub sub_pp {
3493 0 ▶ local $stack_depth = $stack_depth + 1; # Protect from non-local exits
Subroutine sub_pp: not called CC=11 SCAR=48.8
Pod undocumented
3494 0 $#stack = $stack_depth;
3495 0 $stack[-1] = $single;
3496 0 $single &= 1;
3497 0 ▶ $single |= 4 if $#stack == $deep;
Branch: 1 branch
BranchTrueFalseTotal
if $#stack == $deep 0 0 0
3498 0 my $pkg = caller;
3499 0 ▶ my $inDB = ($pkg && rindex($pkg, "DB::", 0) == 0);
Condition0%0/3
$pkg && rindex($pkg, 'DB::', 0) == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$pkg && rindex($pkg, 'DB::', 0) == 0
$pkg rindex($pkg, 'DB::', 0) == 0
Truth table0%0/3
A && B
A= $pkgB= rindex($pkg, 'DB::', 0) == 0
ABresult
0X0
100
111
3500 0 my $bkptEntry = $FQFnNameLookupTable{$sub};
3501 0 ▶ tryBreaking($bkptEntry, $sub, 'call') if $bkptEntry && !$inDB;
Branch: 1 branch
BranchTrueFalseTotal
if $bkptEntry and not $inDB 0 0 0
Condition0%0/3
$bkptEntry and not $inDB
!ll&&!rl&&r
000
MC/DC0%0/2
$bkptEntry and not $inDB
$bkptEntry not $inDB
Truth table0%0/3
A and not(B)
A= $bkptEntryB= not $inDB
ABresult
0X0
100
111
3502  
3503 0 ▶ if (wantarray)
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
3504 {
3505 0 my @i = &$sub;
3506 0 $single |= $stack[$stack_depth];
3507 # it would be nicer to break on return statement inside the function
3508 0 $bkptEntry = $FQFnNameLookupTable{$sub};
3509 0 ▶ tryBreaking($bkptEntry, $sub, 'return') if $bkptEntry && !$inDB;
Branch: 1 branch
BranchTrueFalseTotal
if $bkptEntry and not $inDB 0 0 0
Condition0%0/3
$bkptEntry and not $inDB
!ll&&!rl&&r
000
MC/DC0%0/2
$bkptEntry and not $inDB
$bkptEntry not $inDB
Truth table0%0/3
A and not(B)
A= $bkptEntryB= not $inDB
ABresult
0X0
100
111
3510 0 @i;
3511 }
3512 else
3513 {
3514 0 my $i;
3515 0 ▶ if (defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) { } 0 0 0
3516 0 $i = &$sub;
3517 } else {
3518 0 &$sub;
3519 };
3520 0 $single |= $stack[$stack_depth];
3521 # it would be nicer to break on return statement inside the function
3522 0 $bkptEntry = $FQFnNameLookupTable{$sub};
3523 0 ▶ tryBreaking($bkptEntry, $sub, 'return') if $bkptEntry && !$inDB;
Branch: 1 branch
BranchTrueFalseTotal
if $bkptEntry and not $inDB 0 0 0
Condition0%0/3
$bkptEntry and not $inDB
!ll&&!rl&&r
000
MC/DC0%0/2
$bkptEntry and not $inDB
$bkptEntry not $inDB
Truth table0%0/3
A and not(B)
A= $bkptEntryB= not $inDB
ABresult
0X0
100
111
3524 0 $i;
3525 }
3526 }
3527  
3528 sub lsub_pp : lvalue {
3529 0 ▶ local $stack_depth = $stack_depth + 1; # Protect from non-local exits
Subroutine lsub_pp: not called CC=5 SCAR=34.0
Pod undocumented
3530 0 $#stack = $stack_depth;
3531 0 $stack[-1] = $single;
3532 0 $single &= 1;
3533 0 ▶ $single |= 4 if $#stack == $deep;
Branch: 1 branch
BranchTrueFalseTotal
if $#stack == $deep 0 0 0
3534 0 my $pkg = caller;
3535 0 ▶ my $inDB = ($pkg && rindex($pkg, "DB::", 0) == 0);
Condition0%0/3
$pkg && rindex($pkg, 'DB::', 0) == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$pkg && rindex($pkg, 'DB::', 0) == 0
$pkg rindex($pkg, 'DB::', 0) == 0
Truth table0%0/3
A && B
A= $pkgB= rindex($pkg, 'DB::', 0) == 0
ABresult
0X0
100
111
3536 0 my $bkptEntry = $FQFnNameLookupTable{$sub};
3537 0 ▶ tryBreaking($bkptEntry, $sub, 'call') if $bkptEntry && !$inDB;
Branch: 1 branch
BranchTrueFalseTotal
if $bkptEntry and not $inDB 0 0 0
Condition0%0/3
$bkptEntry and not $inDB
!ll&&!rl&&r
000
MC/DC0%0/2
$bkptEntry and not $inDB
$bkptEntry not $inDB
Truth table0%0/3
A and not(B)
A= $bkptEntryB= not $inDB
ABresult
0X0
100
111
3538  
3539 # breakpoint on return not supported for lvalue subs
3540 0 &$sub;
3541 }
3542  
3543 # exception handling?
3544 $SIG{'INT'} = "DB::catch";
3545  
3546 sub catch
3547 {
3548 0 ▶ $signal = 1;
Subroutine catch: not called CC=1 SCAR=6.9
Pod undocumented
3549 }
3550 #
3551 # save
3552 #
3553 # Save registers.
3554 #
3555 sub save
3556 {
3557 0 ▶ @saved = ($@, $!, $,, $/, $\, $^W);
Subroutine save: not called CC=1 SCAR=6.9
Pod undocumented
3558 0 $, = ""; $/ = "\n"; $\ = ""; $^W = 0;
3559 }
3560  
3561 sub chr_expand {
3562 0 ▶ my $s = shift;
Subroutine chr_expand: not called CC=2 SCAR=17.9
Pod undocumented
3563 0 ▶ return "" unless defined $s;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $s 0 0 0
3564 0 $s =~ s/([\x00-\x08\x0a-\x1f\x7e-\xff])/sprintf('\\x%02x', ord($1))/eg;
3565 0 $s;
3566 }
3567  
3568 # Slight modification so this routine buffers,
3569 # returning strings separated by nulls or newlines
3570  
3571 sub readline {
3572 0 ▶ local $.;
Subroutine readline: not called CC=10 SCAR=47.0
Pod undocumented
3573 # Nothing on the filehandle stack. Socket?
3574 0 ▶ if (ref $OUT and UNIVERSAL::isa($OUT, 'IO::Socket')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $OUT and UNIVERSAL::isa($OUT, "IO::Socket")) 0 0 0
Condition0%0/3
ref $OUT and UNIVERSAL::isa($OUT, "IO::Socket")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $OUT and UNIVERSAL::isa($OUT, "IO::Socket")
ref $OUT UNIVERSAL::isa($OUT, "IO::Socket")
Truth table0%0/3
A and B
A= ref $OUTB= UNIVERSAL::isa($OUT, "IO::Socket")
ABresult
0X0
100
111
3575 # Send anything we have to send.
3576 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
3577 0 $OUT->write(join ('', @_));
3578 }
3579  
3580 # Receive anything there is to receive.
3581 0 my $finalBuffer = '';
3582 0 ▶ if (@pending_commands) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pending_commands) 0 0 0
3583 0 return shift @pending_commands;
3584 }
3585 0 my $amtToRead = 2048;
3586 0 while (1) {
3587 0 my $thisBuffer;
3588 0 $IN->recv($thisBuffer, $amtToRead); # XXX "what's wrong with sysread?"
3589 # XXX Don't know. You tell me.
3590 # Check the size before removing nulls
3591 0 my $leave = (length($thisBuffer) < $amtToRead);
3592 # dblog("Read in [", chr_expand($thisBuffer), "], adding to [", chr_expand($finalBuffer), "]");
3593 # And allow for embedded newlines
3594 0 $thisBuffer =~ s/\r?\n//g;
3595 0 $finalBuffer .= $thisBuffer;
3596 0 ▶ last if $leave && (length($finalBuffer) == 0
Branch: 1 branch
BranchTrueFalseTotal
if $leave and length $finalBuffer == 0 || $finalBuffer =~ /\0$/ 0 0 0
Condition0%0/6
$leave and length $finalBuffer == 0 || $finalBuffer =~ /\0$/
!ll&&!rl&&r
000
length $finalBuffer == 0 or $finalBuffer =~ /\0$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$leave and length $finalBuffer == 0 || $finalBuffer =~ /\0$/
$leave length $finalBuffer == 0 $finalBuffer =~ /\0$/
Truth table0%0/4
A and B or C
A= $leaveB= length $finalBuffer == 0C= $finalBuffer =~ /\0$/
ABCresult
0XX0
1000
11X1
1011
3597 || $finalBuffer =~ /\0$/);
3598 }
3599 # Remove trailing null on last command
3600 0 $finalBuffer =~ s/\0$//;
3601
3602 # And if we read multiple commands in one go, hold on to them.
3603 0 ($finalBuffer, @pending_commands) = split(/[\x00\n]/, $finalBuffer);
3604 0 ▶ if ($ldebug && @pending_commands) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ldebug and @pending_commands) 0 0 0
Condition0%0/3
$ldebug and @pending_commands
!ll&&!rl&&r
000
MC/DC0%0/2
$ldebug and @pending_commands
$ldebug @pending_commands
Truth table0%0/3
A and B
A= $ldebugB= @pending_commands
ABresult
0X0
100
111
3605 0 dblog("Multiple cmds read in: <$finalBuffer>, <",
3606 join(">, <", @pending_commands), ">");
3607 }
3608 0 return $finalBuffer;
3609 } ## end if (ref $OUT and UNIVERSAL::isa...)
3610 } ## end sub readline
3611  
3612 sub _break_check_handler {
3613 0 ▶ if (!$single) {
Subroutine _break_check_handler: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
unless ($single) 0 0 0
3614 # We timed out, so move the pending-check counter up
3615 0 $pending_check_count = $pending_check_lim;
3616 0 ▶ if (_checkForBreak()) {
Branch: 1 branch
BranchTrueFalseTotal
if (_checkForBreak()) 0 0 0
3617 0 $single = 1;
3618 0 db_alarm(0);
3619 }
3620 }
3621 0 ▶ if (!$single) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $single) 0 0 0
3622 0 db_alarm($pending_check_interval);
3623 }
3624 }
3625  
3626 sub _checkForBreak {
3627 0 ▶ return if $skip_alarm;
Subroutine _checkForBreak: not called CC=11 SCAR=48.8
Branch: 1 branch
BranchTrueFalseTotal
if $skip_alarm 0 0 0
3628 0 ▶ return unless $pending_check_enabled && $OUT_selector;
Branch: 1 branch
BranchTrueFalseTotal
unless $pending_check_enabled and $OUT_selector 0 0 0
Condition0%0/3
$pending_check_enabled and $OUT_selector
!ll&&!rl&&r
000
MC/DC0%0/2
$pending_check_enabled and $OUT_selector
$pending_check_enabled $OUT_selector
Truth table0%0/3
A and B
A= $pending_check_enabledB= $OUT_selector
ABresult
0X0
100
111
3629 0 ▶ return if ++$pending_check_count < $pending_check_lim;
Branch: 1 branch
BranchTrueFalseTotal
if ++$pending_check_count < $pending_check_lim 0 0 0
3630 0 $pending_check_count = 0;
3631 # dblog("_checkForBreak: About to select...($pending_check_timeout)");
3632 0 my $have_something = $OUT_selector->can_read($pending_check_timeout);
3633 # dblog("... Done");
3634 0 ▶ return unless $have_something;
Branch: 1 branch
BranchTrueFalseTotal
unless $have_something 0 0 0
3635 0 my $cmd = &readline();
3636 # dblog("_checkForBreak: Got command [$cmd]\n");
3637 0 ▶ if ($cmd =~ /\Abreak\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\Abreak\b/) { } 0 0 0
3638 0 unshift(@pending_commands, $cmd);
3639 0 $pending_check_enabled = 0;
3640 0 return 1;
3641 } else {
3642 # Put the command back at the front, so we process it in due time.
3643 0 my $directive = $cmd;
3644 0 ▶ if (!@pending_commands
Branch: 1 branch
BranchTrueFalseTotal
if (not @pending_commands or $cmd =~ /^(\w+)\b/ and $supportedCommands{$1}) { } 0 0 0
Condition0%0/6
not @pending_commands or $cmd =~ /^(\w+)\b/ and $supportedCommands{$1}
l!l&&r!l&&!r
000
$cmd =~ /^(\w+)\b/ and $supportedCommands{$1}
!ll&&!rl&&r
000
MC/DC0%0/3
not @pending_commands or $cmd =~ /^(\w+)\b/ and $supportedCommands{$1}
not @pending_commands $cmd =~ /^(\w+)\b/ $supportedCommands{$1}
Truth table0%0/4
not(A) or B and C
A= not @pending_commandsB= $cmd =~ /^(\w+)\b/C= $supportedCommands{$1}
ABCresult
1XX1
0111
00X0
0100
3645 || ($cmd =~ /^(\w+)\b/ && $supportedCommands{$1})) {
3646 0 unshift(@pending_commands, $cmd);
3647 } else {
3648 0 ▶ dblog("_checkForBreak: Appending [$cmd] onto $pending_commands[0]\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3649 0 $pending_commands[0] .= $cmd;
3650 }
3651 }
3652 0 return 0;
3653 }
3654  
3655 sub fileAndLineIfXdebug {
3656 0 ▶ return '/' unless $xdebug_file_line_in_step;
Subroutine fileAndLineIfXdebug: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless $xdebug_file_line_in_step 0 0 0
3657 0 return sprintf '><xdebug:message filename="%s" lineno="%s" /></response',
3658 calcFileURI($currentFilename), $currentLine;
3659 }
3660  
3661 sub dump_trace {
3662  
3663 # How many levels to skip.
3664 0 ▶ my $skip = shift;
Subroutine dump_trace: not called CC=13 SCAR=52.0
Pod undocumented
3665  
3666 # How many levels to show. (1e9 is a cheap way of saying "all of them";
3667 # it's unlikely that we'll have more than a billion stack frames. If you
3668 # do, you've got an awfully big machine...)
3669 0 ▶ my $count = shift || 1e9;
Condition0%0/2
shift() || 1000000000.0
l!l
00
MC/DC0%0/1
shift() || 1000000000.0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
3670  
3671 # We increment skip because caller(1) is the first level *back* from
3672 # the current one. Add $skip to the count of frames so we have a
3673 # simple stop criterion, counting from $skip to $count+$skip.
3674 0 $skip++;
3675 0 $count += $skip;
3676  
3677 # These variables are used to capture output from caller();
3678 0 my ($p, $file, $line, $sub);
3679  
3680 0 my ($e, $r, @sub);
3681  
3682 # Do not want to trace this.
3683 0 local $trace = 0;
3684  
3685 # Start out at the skip count.
3686 # If we haven't reached the number of frames requested, and caller() is
3687 # still returning something, stay in the loop. (If we pass the requested
3688 # number of stack frames, or we run out - caller() returns nothing - we
3689 # quit.
3690 # Up the stack frame index to go back one more level each time.
3691 0 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $count and () = caller $i) 0 0 0
Condition0%0/3
$i < $count and () = caller $i
!ll&&!rl&&r
000
MC/DC0%0/2
$i < $count and () = caller $i
$i < $count () = caller $i
Truth table0%0/3
A and B
A= $i < $countB= () = caller $i
ABresult
0X0
100
111
3692 my $i = $skip ;
3693 $i < $count
3694 and ($p, $file, $line, $sub, undef, undef, $e, $r) = caller($i) ;
3695 $i++
3696 )
3697 {
3698 0 ▶ if ($p eq 'DB' || $p =~ /^DB::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p eq "DB" or $p =~ /^DB::/) 0 0 0
Condition0%0/3
$p eq "DB" or $p =~ /^DB::/
l!l&&r!l&&!r
000
MC/DC0%0/2
$p eq "DB" or $p =~ /^DB::/
$p eq "DB" $p =~ /^DB::/
Truth table0%0/3
A or B
A= $p eq "DB"B= $p =~ /^DB::/
ABresult
1X1
011
000
3699 # Don't count debugger entries
3700 0 next;
3701 }
3702  
3703 # remove trailing newline-whitespace-semicolon-end of line sequence
3704 # from the eval text, if any.
3705 0 ▶ $e =~ s/\n\s*\;\s*\Z// if $e;
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
3706  
3707 # Escape backslashed single-quotes again if necessary.
3708 0 ▶ $e =~ s/([\\\'])/\\$1/g if $e;
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
3709  
3710 # if the require flag is true, the eval text is from a require.
3711 0 ▶ if ($r) {
Branch: 3 branches
BranchTrueFalseTotal
if ($r) { } 0 0 0
elsif (defined $r) { } 0 0 0
elsif ($sub eq '(eval)') { } 0 0 0
3712 0 $sub = "require '$e'";
3713 }
3714 # if it's false, the eval text is really from an eval.
3715 elsif (defined $r) {
3716 0 $sub = "eval '$e'";
3717 }
3718  
3719 # If the sub is '(eval)', this is a block eval, meaning we don't
3720 # know what the eval'ed text actually was.
3721 elsif ($sub eq '(eval)') {
3722 0 $sub = "eval {...}";
3723 }
3724 0 ▶ if ($sub =~ /^DB::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub =~ /^DB::/) 0 0 0
3725 0 next;
3726 }
3727  
3728 # Stick the collected information into @sub as an anonymous hash.
3729 push (
3730 0 @sub,
3731 {
3732 sub => $sub,
3733 file => $file,
3734 line => $line
3735 }
3736 );
3737  
3738 # Stop processing frames if the user hit control-C.
3739 0 ▶ last if $signal;
Branch: 1 branch
BranchTrueFalseTotal
if $signal 0 0 0
3740 } ## end for ($i = $skip ; $i < ...
3741  
3742 0 @sub;
3743 } ## end sub dump_trace
3744  
3745 # equivalent to scalar dump_trace(...)
3746 sub count_trace {
3747  
3748 # How many levels to skip.
3749 0 ▶ my $skip = shift;
Subroutine count_trace: not called CC=7 SCAR=40.3
Pod undocumented
3750  
3751 # How many levels to show. (1e9 is a cheap way of saying "all of them";
3752 # it's unlikely that we'll have more than a billion stack frames. If you
3753 # do, you've got an awfully big machine...)
3754 0 ▶ my $count = shift || 1e9;
Condition0%0/2
shift() || 1000000000.0
l!l
00
MC/DC0%0/1
shift() || 1000000000.0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
3755  
3756 # We increment skip because caller(1) is the first level *back* from
3757 # the current one. Add $skip to the count of frames so we have a
3758 # simple stop criterion, counting from $skip to $count+$skip.
3759 0 $skip++;
3760 0 $count += $skip;
3761  
3762 0 my ($p, $frames);
3763  
3764 # Do not want to trace this.
3765 0 local $trace = 0;
3766  
3767 # Start out at the skip count.
3768 # If we haven't reached the number of frames requested, and caller() is
3769 # still returning something, stay in the loop. (If we pass the requested
3770 # number of stack frames, or we run out - caller() returns nothing - we
3771 # quit.
3772 # Up the stack frame index to go back one more level each time.
3773 0 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $count and ($p) = caller $i) 0 0 0
Condition0%0/3
$i < $count and ($p) = caller $i
!ll&&!rl&&r
000
MC/DC0%0/2
$i < $count and ($p) = caller $i
$i < $count ($p) = caller $i
Truth table0%0/3
A and B
A= $i < $countB= ($p) = caller $i
ABresult
0X0
100
111
3774 my $i = $skip ;
3775 $i < $count
3776 and ($p) = caller($i) ;
3777 $i++
3778 )
3779 {
3780 0 ▶ if ($p eq 'DB' || $p =~ /^DB::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p eq "DB" or $p =~ /^DB::/) 0 0 0
Condition0%0/3
$p eq "DB" or $p =~ /^DB::/
l!l&&r!l&&!r
000
MC/DC0%0/2
$p eq "DB" or $p =~ /^DB::/
$p eq "DB" $p =~ /^DB::/
Truth table0%0/3
A or B
A= $p eq "DB"B= $p =~ /^DB::/
ABresult
1X1
011
000
3781 # Don't count debugger entries
3782 0 next;
3783 }
3784  
3785 0 $frames++;
3786  
3787 # Stop processing frames if the user hit control-C.
3788 0 ▶ last if $signal;
Branch: 1 branch
BranchTrueFalseTotal
if $signal 0 0 0
3789 } ## end for ($i = $skip ; $i < ...
3790  
3791 0 $frames;
3792 }
3793  
3794 =head2 C<parse_options>
3795  
3796 Trimmed down version for processing only RemotePort=\d+
3797  
3798 =cut
3799  
3800 sub parse_options {
3801 0 ▶ local ($_) = @_;
Subroutine parse_options: not called CC=36 SCAR=71.9
Pod undocumented
3802 0 local $\ = '';
3803  
3804 0 my %xdebug_map = (
3805 send_position_after_stepping => \$xdebug_file_line_in_step,
3806 property_without_value_tag => \$xdebug_no_value_tag,
3807 nested_properties_in_context => \$xdebug_full_values_in_context,
3808 temporary_breakpoint_state => \$xdebug_temporary_breakpoint_state,
3809 );
3810  
3811 0 ▶ while (length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_) 0 0 0
3812 0 my $val_defaulted;
3813  
3814 # Clean off excess leading whitespace.
3815 0 s/^\s+//;
3816
3817 0 ▶ s/^(\w+)(\W?)// or last;
Branch: 1 branch
BranchTrueFalseTotal
s/^(\w+)(\W?)// or last 0 0 0
3818 0 my ($opt, $sep) = ($1, $2);
3819 0 my $val;
3820  
3821 0 ▶ print OUT "Info: Opt = [$opt], sep=[$sep]\n" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3822  
3823 # '?' as separator means query, but must have whitespace after it.
3824 0 ▶ if ("?" eq $sep) {
Branch: 3 branches
BranchTrueFalseTotal
if ('?' eq $sep) { } 0 0 0
elsif (not $sep =~ /\S/) { } 0 0 0
elsif ($sep eq '=') { } 0 0 0
3825 0 ▶ print(OUT "Option query `$opt?' followed by non-space `$_'\n"),
Branch: 1 branch
BranchTrueFalseTotal
if /^\S/ 0 0 0
3826 last
3827 if /^\S/;
3828 } ## end if ("?" eq $sep)
3829  
3830 # Separator is whitespace (or just a carriage return).
3831 # They're going for a default, which we assume is 1.
3832 elsif ($sep !~ /\S/) {
3833 0 $val_defaulted = 1;
3834 0 $val = "1"; # this is an evil default; make 'em set it!
3835 }
3836  
3837 # Separator is =. Trying to set a value.
3838 elsif ($sep eq "=") {
3839 # If quoted, extract a quoted string.
3840 0 ▶ if (s/ ([\"\']) ( (?: \\. | (?! \1 ) [^\\] )* ) \1 //x) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/ ([\"\']) ( (?: \\. | (?! \1 ) [^\\] )* ) \1 //x) { } 0 0 0
3841 0 my $quote = $1;
3842 0 ($val = $2) =~ s/\\([$quote\\])/$1/g;
3843 }
3844  
3845 # Not quoted. Use the whole thing. Warn about 'option='.
3846 else {
3847 0 s/^(\S*)//;
3848 0 $val = $1;
3849 0 ▶ print OUT qq(Option better cleared using $opt=""\n)
Branch: 1 branch
BranchTrueFalseTotal
unless length $val 0 0 0
3850 unless length $val;
3851 0 ▶ print OUT "Info: Val = [$val]\n" if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3852 } ## end else [ if (s/ (["']) ( (?: \\. | (?! \1 ) [^\\] )* ) \1 //x)
3853  
3854 } ## end elsif ($sep eq "=")
3855  
3856 # "Quoted" with [], <>, or {}.
3857 else { #{ to "let some poor schmuck bounce on the % key in B<vi>."
3858 0 my ($end) = "\\" . substr(")]>}$sep", index("([<{", $sep), 1); #}
3859 0 ▶ s/^(([^\\$end]|\\[\\$end])*)$end($|\s+)//
Branch: 1 branch
BranchTrueFalseTotal
s/^(([^\\$end]|\\[\\$end])*)$end($|\s+)// or print(OUT "Unclosed option value `$opt$sep${_}'\n"), last 0 0 0
3860 or print(OUT "Unclosed option value `$opt$sep$_'\n"), last;
3861 0 ($val = $1) =~ s/\\([\\$end])/$1/g;
3862 } ## end else [ if ("?" eq $sep)
3863  
3864 # Impedance-match the code above to the code below.
3865 0 my $option = $opt;
3866  
3867 # Save the option value.
3868 0 ▶ next unless length($val);
Branch: 1 branch
BranchTrueFalseTotal
unless length $val 0 0 0
3869 0 ▶ if (lc $option eq 'remoteport' && $val =~ /.*:\d+$/) {
Branch: 8 branches
BranchTrueFalseTotal
if (lc $option eq 'remoteport' and $val =~ /.*:\d+$/) { } 0 0 0
elsif ($option eq 'RemotePath' and $val =~ m[^/]) { } 0 0 0
elsif ($option eq 'Xdebug') { } 0 0 0
elsif ($option eq 'ConnectAtStart') { } 0 0 0
elsif ($option eq 'KeepRunning') { } 0 0 0
elsif ($option eq 'LogFile' and length $val) { } 0 0 0
elsif (lc $option eq 'alarm' or lc $option eq 'async') { } 0 0 0
elsif ($option eq 'RecursionCheckDepth' and $val =~ /^\d+$/) { } 0 0 0
Condition0%0/3
lc $option eq "remoteport" and $val =~ /.*:\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
lc $option eq "remoteport" and $val =~ /.*:\d+$/
lc $option eq "remoteport" $val =~ /.*:\d+$/
Truth table0%0/3
A and B
A= lc $option eq "remoteport"B= $val =~ /.*:\d+$/
ABresult
0X0
100
111
3870 0 $remoteport = $val;
3871 ▶ } elsif ($option eq 'RemotePath' && $val =~ /^\//) {
Condition0%0/3
$option eq "RemotePath" and $val =~ m[^/]
!ll&&!rl&&r
000
MC/DC0%0/2
$option eq "RemotePath" and $val =~ m[^/]
$option eq "RemotePath" $val =~ m[^/]
Truth table0%0/3
A and B
A= $option eq "RemotePath"B= $val =~ m[^/]
ABresult
0X0
100
111
3872 0 $remotepath = $val;
3873 } elsif ($option eq 'Xdebug') {
3874 0 ▶ $val = $val ? 'send_position_after_stepping,property_without_value_tag,nested_properties_in_context' : ''
Branch: 2 branches
BranchTrueFalseTotal
if $val =~ /^\d+$/ 0 0 0
$val ? : 0 0 0
3875 if $val =~ /^\d+$/;
3876 0 for my $tag (split /,/, $val) {
3877 die "Invalid Xdebug compatibility tag: '$tag'"
3878 0 ▶ unless exists $xdebug_map{$tag};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $xdebug_map{$tag} 0 0 0
3879 0 ${$xdebug_map{$tag}} = 1;
3880 }
3881 } elsif ($option eq 'ConnectAtStart') {
3882 0 $connect_at_start = !!$val;
3883 } elsif ($option eq 'KeepRunning') {
3884 0 $keep_running = !!$val;
3885 ▶ } elsif ($option eq 'LogFile' && length($val)) {
Condition0%0/3
$option eq "LogFile" and length $val
!ll&&!rl&&r
000
MC/DC0%0/2
$option eq "LogFile" and length $val
$option eq "LogFile" length $val
Truth table0%0/3
A and B
A= $option eq "LogFile"B= length $val
ABresult
0X0
100
111
3886 0 my $logThing;
3887 0 ▶ if (lc $val eq 'stdout') {
Branch: 2 branches
BranchTrueFalseTotal
if (lc $val eq 'stdout') { } 0 0 0
elsif (lc $val eq 'stderr') { } 0 0 0
3888 0 $logThing = \*STDOUT;
3889 } elsif (lc $val eq 'stderr') {
3890 0 $logThing = \*STDERR;
3891 } else {
3892 0 $logThing = $val;
3893 }
3894 0 ▶ if ($logThing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logThing) 0 0 0
3895 0 eval {
3896 0 DB::DbgrCommon::enableLogger($logThing);
3897 0 $ldebug = 1;
3898 0 $DB::DbgrProperties::ldebug = 1;
3899 0 $DB::DbgrCommon::ldebug = 1;
3900 };
3901 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
3902 # Disable this.
3903 0 print STDERR "Info: enableLogger => $@\n";
3904 }
3905 }
3906 ▶ } elsif (lc $option eq 'alarm' || lc $option eq 'async') {
Condition0%0/3
lc $option eq "alarm" or lc $option eq "async"
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $option eq "alarm" or lc $option eq "async"
lc $option eq "alarm" lc $option eq "async"
Truth table0%0/3
A or B
A= lc $option eq "alarm"B= lc $option eq "async"
ABresult
1X1
011
000
3907 # Both options mean the same
3908 0 ▶ $val = eval($val) if $val =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $val =~ /^\d+$/ 0 0 0
3909 0 ▶ $skip_alarm = 0 if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 0 0 0
3910 ▶ } elsif ($option eq 'RecursionCheckDepth' && $val =~ /^\d+$/) {
Condition0%0/3
$option eq "RecursionCheckDepth" and $val =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$option eq "RecursionCheckDepth" and $val =~ /^\d+$/
$option eq "RecursionCheckDepth" $val =~ /^\d+$/
Truth table0%0/3
A and B
A= $option eq "RecursionCheckDepth"B= $val =~ /^\d+$/
ABresult
0X0
100
111
3911 0 $deep = $val;
3912 }
3913 } ## end while (length)
3914 } ## end sub parse_options
3915  
3916 sub answerLastContinuationCommand {
3917 0 ▶ return unless defined $lastContinuationCommand;
Subroutine answerLastContinuationCommand: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lastContinuationCommand 0 0 0
3918 0 my ($status) = @_;
3919 0 ▶ printWithLength(sprintf(qq(%s\n<response %s command="%s" status="%s"
Condition0%0/4
$lastContinuationCommand || 'run'
l!l
00
$lastTranID || '0'
l!l
00
MC/DC0%0/1
$lastContinuationCommand || 'run'
$lastContinuationCommand
MC/DC0%0/1
$lastTranID || '0'
$lastTranID
Truth table0%0/2
A
A= $lastContinuationCommand
Aresult
11
00
Truth table0%0/2
A
A= $lastTranID
Aresult
11
00
3920 reason="ok" transaction_id="%s" %s>),
3921 xmlHeader(),
3922 namespaceAttr(),
3923 $lastContinuationCommand || 'run',
3924 $lastContinuationStatus = $status,
3925 $lastTranID || '0',
3926 fileAndLineIfXdebug()));
3927 }
3928  
3929 END {
3930 # avoid breakpoints if we call code outside DB
3931 0 ▶ $single = 0;
Subroutine END: not called CC=5 SCAR=34.0
3932 # Do not stop in at_exit() and destructors on exit:
3933 0 $finished = 1;
3934 0 $stopReason = STOP_REASON_STOPPING;
3935 0 ▶ if ($fall_off_end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fall_off_end) { } 0 0 0
3936 0 ▶ dblog("END block: single <= 0\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $DB::ldebug 0 0 0
3937 0 $single = 0;
3938 } else {
3939 0 ▶ dblog("END block: single <= 1\n") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $DB::ldebug 0 0 0
3940 0 ▶ if ($OUT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($OUT) 0 0 0
3941 # Send a status of stopping
3942  
3943 # Invariant:
3944 # $lastContinuationCommand and $lastTranID must be set
3945  
3946 0 answerLastContinuationCommand('stopping');
3947 }
3948 # do this after printing the response (since it might indirectly
3949 # call code outside the DB package)
3950 0 $single = 1;
3951 0 DB::fake::at_exit();
3952 }
3953 } ## end END
3954  
3955 sub end_report {
3956 0 ▶ my ($cmd, $transactionID) = @_;
Subroutine end_report: not called CC=1 SCAR=6.9
Pod undocumented
3957 0 printWithLength(sprintf
3958 (qq(%s\n<response %s command="%s"
3959 transaction_id="%s" ><error code="6" apperr="4">
3960 <message>Command '%s' not valid at end of run.</message>
3961 </error></response>),
3962 xmlHeader(),
3963 namespaceAttr(),
3964 $cmd,
3965 $transactionID,
3966 $cmd,
3967 ));
3968 }
3969  
3970 my (%ORIG_DB_SUB, %DISABLED_DB_SUB, $ORIG_DB_LSUB);
3971  
3972 BEGIN {
3973 %ORIG_DB_SUB = %DISABLED_DB_SUB = map {
3974 ($_ => *DB::sub{$_}) x !!*DB::sub{$_}
3975 } qw(CODE SCALAR ARRAY HASH);
3976 $ORIG_DB_SUB{CODE} = \&DB::sub_pp;
3977 $ORIG_DB_LSUB = \&DB::lsub_pp;
3978 *DB::sub = \&DB::sub_pp;
3979 *DB::lsub = \&DB::lsub_pp;
3980 }
3981  
3982 sub enable {
3983 0 ▶ dblog("(Re-)enabling the debugger via DB::enable()") if $ldebug;
Subroutine enable: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3984 0 ▶ die "DB::enable() called too early" unless %ORIG_DB_SUB;
Branch: 1 branch
BranchTrueFalseTotal
unless %ORIG_DB_SUB 0 0 0
3985 0 $single = 1;
3986 0 $^P = DEBUG_DEFAULT_FLAGS;
3987 0 undef *DB::sub;
3988 0 *DB::sub = $ORIG_DB_SUB{$_} for keys %ORIG_DB_SUB;
3989 0 *DB::lsub = $ORIG_DB_LSUB;
3990 }
3991  
3992 sub disable {
3993 0 ▶ dblog("Disabling the debugger via DB::disable()") if $ldebug;
Subroutine disable: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
3994 0 ▶ die "DB::disable() called too early" unless %ORIG_DB_SUB;
Branch: 1 branch
BranchTrueFalseTotal
unless %ORIG_DB_SUB 0 0 0
3995 0 $single = 0;
3996 0 $^P = DEBUG_PREPARE_FLAGS;
3997 0 undef *DB::sub;
3998 0 undef *DB::lsub;
3999 0 *DB::sub = $DISABLED_DB_SUB{$_} for keys %DISABLED_DB_SUB;
4000 }
4001  
4002 sub restore_db_sub {
4003 0 ▶ undef *DB::sub;
Subroutine restore_db_sub: not called CC=2 SCAR=17.9
Pod undocumented
4004 0 *DB::sub = $ORIG_DB_SUB{$_} for keys %ORIG_DB_SUB;
4005 0 *DB::lsub = $ORIG_DB_LSUB;
4006 }
4007  
4008 sub clobber_db_sub {
4009 0 ▶ undef *DB::sub;
Subroutine clobber_db_sub: not called CC=2 SCAR=17.9
Pod undocumented
4010 0 undef *DB::lsub;
4011 0 *DB::sub = $DISABLED_DB_SUB{$_} for keys %DISABLED_DB_SUB;
4012 }
4013  
4014 # called from XS
4015 sub setup_lexicals {
4016 0 ▶ DB::XS::setup_lexicals(\$ldebug, \@stack, \$deep, \%FQFnNameLookupTable);
Subroutine setup_lexicals: not called CC=1 SCAR=6.9
Pod undocumented
4017 }
4018  
4019 sub use_xs_sub {
4020 0 ▶ $ORIG_DB_SUB{CODE} = \&DB::XS::sub_xs;
Subroutine use_xs_sub: not called CC=5 SCAR=34.0
Pod undocumented
4021 0 ▶ $ORIG_DB_LSUB = \&DB::XS::lsub_xs if $] >= 5.016;
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.016" 0 0 0
4022 0 ▶ *DB::sub = \&DB::XS::sub_xs if defined &DB::sub;
Branch: 1 branch
BranchTrueFalseTotal
if defined &DB::sub 0 0 0
4023 0 ▶ *DB::lsub = \&DB::XS::lsub_xs if defined &DB::lsub && $] >= 5.016;
Branch: 1 branch
BranchTrueFalseTotal
if defined &DB::lsub and $] >= "5.016" 0 0 0
Condition0%0/3
defined &DB::lsub and $] >= "5.016"
!ll&&!rl&&r
000
MC/DC0%0/2
defined &DB::lsub and $] >= "5.016"
defined &DB::lsub $] >= "5.016"
Truth table0%0/3
A and B
A= defined &DB::lsubB= $] >= "5.016"
ABresult
0X0
100
111
4024 }
4025  
4026 BEGIN {
4027 $^W = $ini_warn;
4028 }
4029  
4030 =head1 C<DB::fake>
4031  
4032 Contains the C<at_exit> routine that the debugger uses to issue the
4033 C<Debugged program terminated ...> message after the program completes. See
4034 the C<END> block documentation for more details.
4035  
4036 =cut
4037  
4038 package DB::fake;
4039  
4040 sub at_exit {
4041 0 ▶ $DB::single = 1;
Subroutine at_exit: not called CC=1 SCAR=6.9
4042 0 "Debugged program terminated.";
4043 }
4044  
4045 package DB; # Do not trace this 1; below!
4046  
4047 1;
↑ Summary blib/lib/dbgp-helper/DB/Data/Dump.pm »