| 1 | package Sepia::Debug; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # use Sepia; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Carp (); # old Carp doesn't export shortmess. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Text::Abbrev; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use vars qw($pack $file $line $sub $level | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | $STOPDIE $STOPWARN); | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | sub define_shortcut; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | *define_shortcut = *Sepia::define_shortcut; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | ## Just leave it on -- with $DB::trace = 0, there doesn't seem | ||||||||||||||||||||||||||||||||||||||||||
| 14 | ## to be a performance penalty! | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ## Flags we use are (see PERLDBf_* in perl.h): | ||||||||||||||||||||||||||||||||||||||||||
| 17 | ## 0x1 Debugging sub enter/exit (call DB::sub if defined) | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ## 0x2 per-line debugging (keep line numbers) | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ## 0x8 "preserve more data" (call DB::postponed??) | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ## 0x10 keep line ranges for sub definitions in %DB::sub | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ## 0x100 give evals informative names | ||||||||||||||||||||||||||||||||||||||||||
| 22 | ## 0x200 give anon subs informative names | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ## 0x400 save source lines in %{"_<$filename"} | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | $^P = 0x01 | 0x02 | 0x10 | 0x100 | 0x200; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | $STOPDIE = 1; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | $STOPWARN = 0; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | sub peek_my | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peek_my: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | eval q{ require PadWalker }; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | +{ } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | } else { | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | *peek_my = \&PadWalker::peek_my; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | goto &peek_my; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # set debugging level | ||||||||||||||||||||||||||||||||||||||||||
| 41 | sub repl_debug | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_debug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | debug(@_); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub repl_backtrace | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_backtrace: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | for (my $i = 0; ; ++$i) { | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($pack, $file, $line, $sub) = caller($i); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | last unless $pack; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $Sepia::SIGGED && do { $Sepia::SIGGED--; last }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | # XXX: 4 is the magic number... | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | print($i == $level+4 ? "*" : ' ', " [$i]\t$sub ($file:$line)\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # return value from die | ||||||||||||||||||||||||||||||||||||||||||
| 58 | sub repl_return | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_return: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($Sepia::WANTARRAY) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | @Sepia::REPL_RESULT = $Sepia::REPL{eval}->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $Sepia::REPL_RESULT[0] = $Sepia::REPL{eval}->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | last repl; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | use vars qw($DIE_TO @DIE_RETURN $DIE_LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | $DIE_LEVEL = 0; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | sub xreturn | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xreturn: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | eval q{ use Scope::Upper ':all' }; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | print "xreturn requires Sub::Uplevel.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | *xreturn = eval <<'EOS'; | |||||||||||||||||||||||||||||||||||||||||
| 79 | sub { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | my $exp = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 81 | $exp = '""' unless defined $exp; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | my $ctx = CALLER($level+4); # XXX: ok? | ||||||||||||||||||||||||||||||||||||||||||
| 83 | local $Sepia::WANTARRAY = want_at $ctx; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | my @res = eval_in_env($exp, peek_my($level + 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 85 | print STDERR "unwind(@res)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 86 | unwind @res, SUB UP $ctx; | ||||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | EOS | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | goto &xreturn; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | sub repl_xreturn | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_xreturn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | print STDERR "XRETURN(@_)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | xreturn(shift); # XXX: doesn't return. Problem? | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | print STDERR "XRETURN: XXX\n"; | |||||||||||||||||||||||||||||||||||||||||
| 98 | # ($DB::DIE_TO, $DB::DIE_RETURN[0]) = split ' ', $_[0], 2; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | # $DB::DIE_RETURN[0] = $Sepia::REPL{eval}->($DB::DIE_RETURN[0]); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | # last SEPIA_DB_SUB; | ||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | # { package DB; | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # no strict; | ||||||||||||||||||||||||||||||||||||||||||
| 105 | sub sub | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sub: not called CC=5 SCAR=29.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | ▶ | no strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | local $DIE_LEVEL = $DIE_LEVEL + 1; | |||||||||||||||||||||||||||||||||||||||||
| 109 | ## Set up a dynamic catch target | ||||||||||||||||||||||||||||||||||||||||||
| 110 | SEPIA_DB_SUB: { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return &$DB::sub; | |||||||||||||||||||||||||||||||||||||||||
| 112 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 113 | # we're dying! | ||||||||||||||||||||||||||||||||||||||||||
| 114 | last SEPIA_DB_SUB | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if $DIE_LEVEL > 1 && defined $DIE_TO | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$DIE_LEVEL > 1 and defined $DIE_TO and not $DB::sub =~ /(?:^|::)\Q$DIE_TO\E$/
$DIE_LEVEL > 1 and defined $DIE_TO
MC/DC0%0/3
$DIE_LEVEL > 1 and defined $DIE_TO and not $DB::sub =~ /(?:^|::)\Q$DIE_TO\E$/
$DIE_LEVEL > 1
defined $DIE_TO
not $DB::sub =~ /(?:^|::)\Q$DIE_TO\E$/
Truth table0%0/4
A and B and not(C)
A= $DIE_LEVEL > 1B= defined $DIE_TOC= not $DB::sub =~ /(?:^|::)\Q$DIE_TO\E$/
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | && $DB::sub !~ /(?:^|::)\Q$DIE_TO\E$/; | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | undef $DIE_TO; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | wantarray ? @DIE_RETURN : $DIE_RETURN[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | sub repl_dbsub | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_dbsub: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if ($arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | *DB::sub = \⊂ | |||||||||||||||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | undef &DB::sub; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | sub repl_lsbreak | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_lsbreak: not called CC=6 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | for my $file (sort grep /^_</ && *{"::$_"}{HASH}, keys %::) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
/^_</ && *{"::$_";}{'HASH'}
MC/DC0%0/1
/^_</ && *{"::$_";}{'HASH'}
/^_</
Truth table0%0/2
A
A= /^_</
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $Sepia::SIGGED && do { $Sepia::SIGGED--; last }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my ($name) = $file =~ /^_<(.*)/; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my @pts = keys %{"::$file"}; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | next unless @pts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | print "$name:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | for (sort { $a <=> $b } @pts) { | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | print "\t$_\t${$file}{$_}\n" | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | # evaluate EXPR in environment ENV | ||||||||||||||||||||||||||||||||||||||||||
| 148 | sub eval_in_env | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eval_in_env: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my ($expr, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | local $Sepia::ENV = $env; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | for (keys %$env) { | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | next unless /^([\$\@%])(.+)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $str .= "local *$2 = \$Sepia::ENV->{'$_'}; "; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $str = "do { no strict; package $Sepia::PACKAGE; $str $expr }"; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | return $Sepia::WANTARRAY ? eval $str : scalar eval $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | sub tie_class | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tie_class: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $sig = substr shift, 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | return $sig eq '$' ? 'Tie::StdScalar' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | : $sig eq '@' ? 'Tie::StdArray' | ||||||||||||||||||||||||||||||||||||||||||
| 167 | : $sig eq '%' ? 'Tie::StdHash' | ||||||||||||||||||||||||||||||||||||||||||
| 168 | : die "Sorry, can't tie $sig\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | ## XXX: this is a better approach (the local/tie business is vile), | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ## but it segfaults and I'm not sure why. | ||||||||||||||||||||||||||||||||||||||||||
| 173 | sub eval_in_env2 | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eval_in_env2: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my ($expr, $env, $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | local $Sepia::ENV = $env; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my @vars = grep /^([\$\@%])(.+)/, keys %$env; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $body = 'sub { my ('.join(',', @vars).');'; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | for (@vars) { | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $body .= "Devel::LexAlias::lexalias(\$Sepia::ENV, '$_', \\$_);" | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $body .= "$expr }"; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | print STDERR "---\n$body\n---\n"; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $body = eval $body; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $@ || $body->(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # evaluate EXP LEV levels up the stack | ||||||||||||||||||||||||||||||||||||||||||
| 189 | # | ||||||||||||||||||||||||||||||||||||||||||
| 190 | # NOTE: We need to act like &repl_eval here and consider e.g. $WANTARRAY | ||||||||||||||||||||||||||||||||||||||||||
| 191 | sub repl_upeval | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_upeval: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | # if ($Sepia::WANTARRAY) { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return eval_in_env(shift, peek_my(4+$level)); | |||||||||||||||||||||||||||||||||||||||||
| 195 | # } else { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # return scalar eval_in_env(shift, peek_my(4+$level)); | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | # inspect lexicals at level N, or current level | ||||||||||||||||||||||||||||||||||||||||||
| 201 | sub repl_inspect | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_inspect: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $i = shift; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($i =~ /\d/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $i = 0+$i; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $i = $level + 3; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $sub = (caller $i)[3]; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ($sub) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $h = peek_my($i+1); | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | print "[$i] $sub:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | for (sort keys %$h) { | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | local @Sepia::res = $h->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | print "\t$_ = ", $Sepia::PRINTER{$Sepia::PRINTER}->(), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | sub debug | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $new = Sepia::as_boolean(shift, $DB::trace); | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | print "debug ", $new ? "ON" : "OFF"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ($new == $DB::trace) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | print " (unchanged)\n" | |||||||||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $DB::trace = $new; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | sub breakpoint_file | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
breakpoint_file: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | return \%{$main::{"_<$file"}} if exists $main::{"_<$file"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ($file !~ /^\//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ($file) = grep /^_<.*\/\Q$file\E$/, keys %main::; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return \%{$main::{$file}} if $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | sub breakpoint | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
breakpoint: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my ($file, $line, $cond) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $h = breakpoint_file $file; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if (defined $h) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $h->{$line} = $cond || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cond || 1
MC/DC0%0/1
$cond || 1
$cond
Truth table0%0/2
A
A= $cond
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | return $cond ? "$file\:$line if $cond" : "$file\:$line"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | sub repl_break | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_break: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $arg =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $arg =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($f, $l, $cond) = $arg =~ /^(.+?):(\d+)\s*(.*)/; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $cond = 1 unless $cond =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $f ||= $file; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$f ||= $Sepia::Debug::file
MC/DC0%0/2
$f ||= $Sepia::Debug::file
$f
$Sepia::Debug::file
Truth table0%0/3
A ||= B
A= $fB= $Sepia::Debug::file
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $l ||= $line; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$l ||= $Sepia::Debug::line
MC/DC0%0/2
$l ||= $Sepia::Debug::line
$l
$Sepia::Debug::line
Truth table0%0/3
A ||= B
A= $lB= $Sepia::Debug::line
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | return unless defined $f && defined $l; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $f and defined $l
MC/DC0%0/2
defined $f and defined $l
defined $f
defined $l
Truth table0%0/3
A and B
A= defined $fB= defined $l
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $bp = breakpoint($f, $l, $cond); | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | print "break $bp\n" if $bp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | sub update_location | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_location: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | # XXX: magic numberage. | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ($pack, $file, $line, $sub) = caller($level + shift); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | sub show_location | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_location: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | print "_<$file:$line>\n" if defined $file && defined $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Sepia::Debug::file and defined $Sepia::Debug::line
MC/DC0%0/2
defined $Sepia::Debug::file and defined $Sepia::Debug::line
defined $Sepia::Debug::file
defined $Sepia::Debug::line
Truth table0%0/3
A and B
A= defined $Sepia::Debug::fileB= defined $Sepia::Debug::line
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | sub repl_list | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_list: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my @lines = eval shift; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | @lines = $line - 5 .. $line + 5 unless @lines; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | printf '%-6d%s', $_, ${"::_<$file"}[$_-1] for @lines; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | sub repl_delete | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_delete: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ($f, $l) = split /:/, shift; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $f ||= $file; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$f ||= $Sepia::Debug::file
MC/DC0%0/2
$f ||= $Sepia::Debug::file
$f
$Sepia::Debug::file
Truth table0%0/3
A ||= B
A= $fB= $Sepia::Debug::file
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | $l ||= $line; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$l ||= $Sepia::Debug::line
MC/DC0%0/2
$l ||= $Sepia::Debug::line
$l
$Sepia::Debug::line
Truth table0%0/3
A ||= B
A= $lB= $Sepia::Debug::line
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $h = breakpoint_file $f; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | delete $h->{$l} if defined $h; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | sub repl_finish | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_finish: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | # XXX: doesn't handle recursion, but oh, well... | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $sub = (caller $level + 4)[3]; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if (exists $DB::sub{$sub}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ($file, $start, $end) = $DB::sub{$sub} =~ /(.*):(\d+)-(\d+)/; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | print STDERR "finish($sub): will stop at $file:$end\n"; | |||||||||||||||||||||||||||||||||||||||||
| 302 | # XXX: $end doesn't always work, since it may not have an | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # executable statement on it. | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | breakpoint($file, $end-1, 'finish'); | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | last repl; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | print STDERR "yikes: @{[keys %DB::sub]}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | sub repl_toplevel | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl_toplevel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | local $STOPDIE; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | die(bless [], __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | sub add_repl_commands | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_repl_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | define_shortcut 'delete', \&repl_delete, | |||||||||||||||||||||||||||||||||||||||||
| 320 | 'Delete current breakpoint.'; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | define_shortcut 'debug', \&repl_debug, | |||||||||||||||||||||||||||||||||||||||||
| 322 | 'debug [0|1]', 'Enable or disable debugging.'; | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | define_shortcut 'break', \&repl_break, | |||||||||||||||||||||||||||||||||||||||||
| 324 | 'break [F:N [E]]', | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 'Break at file F, line N (or at current position) if E is true.'; | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | define_shortcut 'lsbreak', \&repl_lsbreak, | |||||||||||||||||||||||||||||||||||||||||
| 327 | 'List breakpoints.'; | ||||||||||||||||||||||||||||||||||||||||||
| 328 | # define_shortcut 'dbsub', \&repl_dbsub, '(Un)install DB::sub.'; | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | %Sepia::RK = abbrev keys %Sepia::REPL; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | sub add_debug_repl_commands | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_debug_repl_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | define_shortcut quit => \&repl_toplevel, | |||||||||||||||||||||||||||||||||||||||||
| 335 | 'quit', 'Quit the debugger, returning to the top level.'; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | define_shortcut toplevel => \&repl_toplevel, | |||||||||||||||||||||||||||||||||||||||||
| 337 | 'toplevel', 'Return to the top level.'; | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | define_shortcut up => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $level += shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | update_location(4); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | show_location; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | }, 'up [N]', 'Move up N stack frames.'; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | define_shortcut down => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | $level -= shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $level = 0 if $level < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | update_location(4); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | show_location; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | }, 'down [N]', 'Move down N stack frames.'; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | define_shortcut continue => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $level = 0; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $DB::single = 0; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | last repl; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | }, 'Yep.'; | |||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | define_shortcut next => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | my $n = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $DB::single = 0; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | breakpoint $file, $line + $n, 'next'; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | last repl; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | }, 'next [N]', 'Advance N lines, skipping subroutines.'; | |||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | define_shortcut step => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | $DB::single = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | last repl; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | }, 'step [N]', 'Step N statements forward, entering subroutines.'; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | define_shortcut finish => \&repl_finish, | |||||||||||||||||||||||||||||||||||||||||
| 368 | 'finish', 'Finish the current subroutine.'; | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | define_shortcut list => \&repl_list, | |||||||||||||||||||||||||||||||||||||||||
| 371 | 'list EXPR', 'List source lines of current file.'; | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | define_shortcut backtrace => \&repl_backtrace, 'show backtrace'; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | define_shortcut inspect => \&repl_inspect, | |||||||||||||||||||||||||||||||||||||||||
| 374 | 'inspect [N]', 'inspect lexicals in frame N (or current)'; | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | define_shortcut return => \&repl_return, 'return EXPR', 'return EXPR'; | |||||||||||||||||||||||||||||||||||||||||
| 376 | # define_shortcut xreturn => \&repl_xreturn, 'xreturn EXPR', | ||||||||||||||||||||||||||||||||||||||||||
| 377 | # 'return EXPR from the current sub.'; | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | define_shortcut eval => \&repl_upeval, | |||||||||||||||||||||||||||||||||||||||||
| 379 | 'eval EXPR', 'evaluate EXPR in current frame'; # DANGER! | ||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | sub repl | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | show_location; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | local %Sepia::REPL = %Sepia::REPL; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | local %Sepia::REPL_DOC = %Sepia::REPL_DOC; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | add_debug_repl_commands; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | map { define_shortcut @$_ } @_; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | local %Sepia::RK = abbrev keys %Sepia::REPL; | |||||||||||||||||||||||||||||||||||||||||
| 390 | # local $Sepia::REPL_LEVEL = $Sepia::REPL_LEVEL + 1; | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | local $Sepia::PS1 = "*$Sepia::REPL_LEVEL*> "; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | Sepia::repl(); | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | sub DB::DB | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DB: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return if $Sepia::ISEVAL; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | local $level = 0; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | local ($pack, $file, $line, $sub) = caller($level); | |||||||||||||||||||||||||||||||||||||||||
| 400 | ## Don't do anything if we're inside an eval request, even if in | ||||||||||||||||||||||||||||||||||||||||||
| 401 | ## single-step mode. | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | return unless $DB::single || exists $main::{"_<$file"}{$line}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$DB::single or exists $main::main::{"_<$Sepia::Debug::file"}{$Sepia::Debug::line}
MC/DC0%0/2
$DB::single or exists $main::main::{"_<$Sepia::Debug::file"}{$Sepia::Debug::line}
$DB::single
exists $main::main::{"_<$Sepia::Debug::file"}{$Sepia::Debug::line}
Truth table0%0/3
A or B
A= $DB::singleB= exists $main::main::{"_<$Sepia::Debug::file"}{$Sepia::Debug::line}
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($DB::single) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | return unless --$DB::single == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $cond = $main::{"_<$file"}{$line}; | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ($cond eq 'next') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | delete $main::{"_<$file"}{$line}; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } elsif ($cond eq 'finish') { | ||||||||||||||||||||||||||||||||||||||||||
| 410 | # remove temporary breakpoint and take one more step. | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | delete $main::{"_<$file"}{$line}; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $DB::single = 1; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | return unless $Sepia::REPL{eval}->($cond); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | repl(); | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | my $MSG = "('\\C-c' to exit, ',h' for help)"; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | sub die | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
die: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | ## Protect us against people doing weird things. | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ($STOPDIE && !$SIG{__DIE__}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Sepia::Debug::STOPDIE and not $SIG{"__DIE__"}
MC/DC0%0/2
$Sepia::Debug::STOPDIE and not $SIG{"__DIE__"}
$Sepia::Debug::STOPDIE
not $SIG{"__DIE__"}
Truth table0%0/3
A and not(B)
A= $Sepia::Debug::STOPDIEB= not $SIG{"__DIE__"}
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my @dieargs = @_; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | local $level = 0; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | local ($pack, $file, $line, $sub) = caller($level); | |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my $tmp = "@_"; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | $tmp .= "\n" unless $tmp =~ /\n\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | print "$tmp\tin $sub\nDied $MSG\n"; | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $trace = $DB::trace; | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $DB::trace = 1; | |||||||||||||||||||||||||||||||||||||||||
| 435 | repl( | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | [die => sub { local $STOPDIE=0; CORE::die @dieargs }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 'Continue dying.'], | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | [quit => sub { local $STOPDIE=0; CORE::die @dieargs }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | 'Continue dying.']); | |||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $DB::trace = $trace; | |||||||||||||||||||||||||||||||||||||||||
| 441 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | CORE::die(Carp::shortmess @_); | |||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | sub warn | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warn: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | ## Again, this is above our pay grade: | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | if ($STOPWARN && $SIG{__WARN__} eq 'Sepia::sig_warn') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Sepia::Debug::STOPWARN and $SIG{"__WARN__"} eq "Sepia::sig_warn"
MC/DC0%0/2
$Sepia::Debug::STOPWARN and $SIG{"__WARN__"} eq "Sepia::sig_warn"
$Sepia::Debug::STOPWARN
$SIG{"__WARN__"} eq "Sepia::sig_warn"
Truth table0%0/3
A and B
A= $Sepia::Debug::STOPWARNB= $SIG{"__WARN__"} eq "Sepia::sig_warn"
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my @dieargs = @_; | |||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $trace = $DB::trace; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $DB::trace = 1; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | local $level = 0; | |||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | local ($pack, $file, $line, $sub) = caller($level); | |||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | print "@_\n\tin $sub\nWarned $MSG\n"; | |||||||||||||||||||||||||||||||||||||||||
| 457 | repl( | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | [warn => sub { local $STOPWARN=0; CORE::warn @dieargs }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 'Continue warning.'], | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | [quit => sub { local $STOPWARN=0; CORE::warn @dieargs }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | 'Continue warning.']); | |||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $DB::trace = $trace; | |||||||||||||||||||||||||||||||||||||||||
| 463 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 464 | ## Avoid showing up in location information. | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | CORE::warn(Carp::shortmess @_); | |||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | sub oops | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oops: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $sig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if ($STOPDIE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $trace = $DB::trace; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $DB::trace = 1; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | local $level = 0; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | local ($pack, $file, $line, $sub) = caller($level); | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | print "@_\n\tin $sub\nCaught signal $sig\n"; | |||||||||||||||||||||||||||||||||||||||||
| 478 | repl( | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | [die => sub { local $STOPDIE=0; CORE::die "Caught signal $sig; exiting." }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 'Just die.'], | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | [quit => sub { local $STOPWARN=0; CORE::die "Caught signal $sig; exiting." }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | 'Just die.']); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $DB::trace = $trace; | |||||||||||||||||||||||||||||||||||||||||
| 484 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | Carp::confess "Caught signal $sig: continue at your own risk."; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||