line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Confess; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
9
|
|
|
9
|
|
48942547
|
my $can_use_informative_names = "$]" >= 5.008; |
4
|
|
|
|
|
|
|
# detect -d:Confess. disable debugger features for now. we'll |
5
|
|
|
|
|
|
|
# enable them when we need them. |
6
|
9
|
50
|
33
|
|
|
96
|
if (!defined &DB::DB && $^P & 0x02) { |
7
|
0
|
|
|
|
|
0
|
$can_use_informative_names = 1; |
8
|
0
|
|
|
|
|
0
|
$^P = 0; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
*_CAN_USE_INFORMATIVE_NAMES |
11
|
9
|
50
|
|
|
|
234
|
= $can_use_informative_names ? sub () { 1 } : sub () { 0 }; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
9
|
|
|
9
|
|
228
|
use 5.006; |
|
9
|
|
|
|
|
21
|
|
15
|
9
|
|
|
9
|
|
29
|
use strict; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
156
|
|
16
|
9
|
|
|
9
|
|
28
|
use warnings; |
|
9
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
231
|
|
17
|
9
|
|
|
9
|
|
26
|
no warnings 'once'; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
437
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.009004'; |
20
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
9
|
|
35
|
use Carp (); |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
110
|
|
23
|
9
|
|
|
9
|
|
3388
|
use Symbol (); |
|
9
|
|
|
|
|
5072
|
|
|
9
|
|
|
|
|
235
|
|
24
|
9
|
|
|
|
|
564
|
use Devel::Confess::_Util qw( |
25
|
|
|
|
|
|
|
blessed |
26
|
|
|
|
|
|
|
refaddr |
27
|
|
|
|
|
|
|
weaken |
28
|
|
|
|
|
|
|
longmess |
29
|
|
|
|
|
|
|
_str_val |
30
|
|
|
|
|
|
|
_in_END |
31
|
|
|
|
|
|
|
_can_stringify |
32
|
|
|
|
|
|
|
_can |
33
|
|
|
|
|
|
|
_isa |
34
|
9
|
|
|
9
|
|
2209198
|
); |
|
9
|
|
|
|
|
16
|
|
35
|
9
|
|
|
9
|
|
35
|
use Config (); |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
1799
|
|
36
|
|
|
|
|
|
|
BEGIN { |
37
|
|
|
|
|
|
|
*_BROKEN_CLONED_DESTROY_REBLESS |
38
|
9
|
50
|
33
|
9
|
|
95
|
= ("$]" >= 5.008009 && "$]" < 5.010000) ? sub () { 1 } : sub () { 0 }; |
39
|
|
|
|
|
|
|
*_BROKEN_CLONED_GLOB_UNDEF |
40
|
9
|
50
|
33
|
|
|
81
|
= ("$]" > 5.008009 && "$]" <= 5.010000) ? sub () { 1 } : sub () { 0 }; |
41
|
|
|
|
|
|
|
*_BROKEN_SIG_DELETE |
42
|
9
|
50
|
|
|
|
27
|
= ("$]" < 5.008008) ? sub () { 1 } : sub () { 0 }; |
43
|
|
|
|
|
|
|
*_DEBUGGING |
44
|
|
|
|
|
|
|
= ( |
45
|
|
|
|
|
|
|
defined &Config::non_bincompat_options |
46
|
|
|
|
|
|
|
? (grep $_ eq 'DEBUGGING', Config::non_bincompat_options()) |
47
|
|
|
|
|
|
|
: ($Config::Config{ccflags} =~ /-DDEBUGGING\b/) |
48
|
9
|
50
|
|
|
|
130
|
) ? sub () { 1 } : sub () { 0 }; |
|
|
50
|
|
|
|
|
|
49
|
9
|
|
|
|
|
26
|
my $inf = 9**9**9; |
50
|
0
|
|
|
|
|
0
|
*_INF = sub () { $inf } |
51
|
9
|
|
|
|
|
7208
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$Carp::Internal{+__PACKAGE__}++; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
our %NoTrace; |
56
|
|
|
|
|
|
|
$NoTrace{'Throwable::Error'}++; |
57
|
|
|
|
|
|
|
$NoTrace{'Moose::Error::Default'}++; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our %OPTIONS = ( |
60
|
|
|
|
|
|
|
objects => !!1, |
61
|
|
|
|
|
|
|
builtin => undef, |
62
|
|
|
|
|
|
|
dump => !!0, |
63
|
|
|
|
|
|
|
color => !!0, |
64
|
|
|
|
|
|
|
source => 0, |
65
|
|
|
|
|
|
|
evalsource => 0, |
66
|
|
|
|
|
|
|
errors => !!1, |
67
|
|
|
|
|
|
|
warnings => !!1, |
68
|
|
|
|
|
|
|
better_names => !!1, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
our %ENABLEOPTS = ( |
71
|
|
|
|
|
|
|
dump => 3, |
72
|
|
|
|
|
|
|
source => 3, |
73
|
|
|
|
|
|
|
evalsource => 3, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
our %NUMOPTS = ( |
76
|
|
|
|
|
|
|
dump => 1, |
77
|
|
|
|
|
|
|
source => 1, |
78
|
|
|
|
|
|
|
evalsource => 1, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
our @options = sort keys %OPTIONS; |
82
|
|
|
|
|
|
|
our ($opt_match) = |
83
|
|
|
|
|
|
|
map qr/^-?(?:(no[_-]?)(?:$_)|(?:$_)(?:(\d+)|=(.*)|))$/, |
84
|
|
|
|
|
|
|
join '|', |
85
|
|
|
|
|
|
|
map { |
86
|
|
|
|
|
|
|
my $o = $_; |
87
|
|
|
|
|
|
|
$o =~ s/_/[-_]?/g; |
88
|
|
|
|
|
|
|
'('.$o.')'; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
@options; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _parse_options { |
93
|
53
|
|
|
53
|
|
2041
|
my %opts; |
94
|
|
|
|
|
|
|
my @bad; |
95
|
53
|
|
|
|
|
118
|
while (@_) { |
96
|
53
|
|
|
|
|
56
|
my $arg = shift; |
97
|
53
|
100
|
|
|
|
439
|
my @match = defined $arg ? $arg =~ $opt_match : (); |
98
|
53
|
100
|
|
|
|
102
|
if (@match) { |
99
|
47
|
|
|
|
|
46
|
my $no = shift @match; |
100
|
47
|
|
|
|
|
42
|
my $equal = pop @match; |
101
|
47
|
|
|
|
|
31
|
my $num = pop @match; |
102
|
47
|
|
|
|
|
232
|
my ($opt) = |
103
|
|
|
|
|
|
|
map $options[$_ % @options], |
104
|
|
|
|
|
|
|
grep defined $match[$_], |
105
|
|
|
|
|
|
|
0 .. $#match; |
106
|
|
|
|
|
|
|
my $value |
107
|
|
|
|
|
|
|
= defined $no ? !!0 |
108
|
|
|
|
|
|
|
: defined $equal ? $equal |
109
|
|
|
|
|
|
|
: defined $num ? $num |
110
|
|
|
|
|
|
|
: @_ && (!defined $_[0] || $_[0] =~ /^\d+$/) ? shift |
111
|
47
|
100
|
66
|
|
|
199
|
: defined $ENABLEOPTS{$opt} ? $ENABLEOPTS{$opt} |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
112
|
|
|
|
|
|
|
: !!1; |
113
|
|
|
|
|
|
|
|
114
|
47
|
100
|
|
|
|
88
|
if ($NUMOPTS{$opt}) { |
115
|
16
|
100
|
|
|
|
41
|
$value |
|
|
50
|
|
|
|
|
|
116
|
|
|
|
|
|
|
= !defined $value ? 0 |
117
|
|
|
|
|
|
|
: !$value ? _INF |
118
|
|
|
|
|
|
|
: 0+$value; |
119
|
|
|
|
|
|
|
} |
120
|
47
|
|
|
|
|
155
|
$opts{$opt} = $value; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else { |
123
|
6
|
|
|
|
|
14
|
push @bad, $arg; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
53
|
100
|
|
|
|
89
|
if (@bad) { |
127
|
5
|
|
|
|
|
13
|
local $SIG{__DIE__}; |
128
|
5
|
100
|
|
|
|
7
|
Carp::croak("invalid options: " . join(', ', map { defined $_ ? $_ : '[undef]' } @bad)); |
|
6
|
|
|
|
|
419
|
|
129
|
|
|
|
|
|
|
} |
130
|
48
|
|
|
|
|
129
|
\%opts; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
if (my $env = $ENV{DEVEL_CONFESS_OPTIONS}) { |
134
|
|
|
|
|
|
|
local $@; |
135
|
|
|
|
|
|
|
eval { |
136
|
|
|
|
|
|
|
my $options = _parse_options(grep length, split /[\s,]+/, $env); |
137
|
|
|
|
|
|
|
@OPTIONS{keys %$options} = values %$options; |
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
} or warn "DEVEL_CONFESS_OPTIONS: $@"; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
our %OLD_SIG; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub import { |
145
|
34
|
|
|
34
|
|
62870
|
my $class = shift; |
146
|
|
|
|
|
|
|
|
147
|
34
|
|
|
|
|
68
|
my $options = _parse_options(@_); |
148
|
34
|
|
|
|
|
105
|
@OPTIONS{keys %$options} = values %$options; |
149
|
|
|
|
|
|
|
|
150
|
34
|
50
|
|
|
|
83
|
if (defined $OPTIONS{builtin}) { |
151
|
0
|
|
|
|
|
0
|
require Devel::Confess::Builtin; |
152
|
0
|
0
|
|
|
|
0
|
my $do = $OPTIONS{builtin} ? 'import' : 'unimport'; |
153
|
0
|
|
|
|
|
0
|
Devel::Confess::Builtin->$do; |
154
|
|
|
|
|
|
|
} |
155
|
34
|
100
|
66
|
|
|
115
|
if ($OPTIONS{source} || $OPTIONS{evalsource}) { |
156
|
10
|
|
|
|
|
8854
|
require Devel::Confess::Source; |
157
|
10
|
|
|
|
|
45
|
Devel::Confess::Source->import; |
158
|
|
|
|
|
|
|
} |
159
|
34
|
50
|
33
|
|
|
87
|
if ($OPTIONS{color} && $^O eq 'MSWin32') { |
160
|
0
|
0
|
|
|
|
0
|
if (eval { require Win32::Console::ANSI }) { |
|
0
|
|
|
|
|
0
|
|
161
|
0
|
|
|
|
|
0
|
Win32::Console::ANSI->import; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
else { |
164
|
0
|
|
|
|
|
0
|
local $SIG{__WARN__}; |
165
|
0
|
|
|
|
|
0
|
Carp::carp |
166
|
|
|
|
|
|
|
"Devel::Confess color option requires Win32::Console::ANSI on Windows"; |
167
|
0
|
|
|
|
|
0
|
$OPTIONS{color} = 0; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
34
|
50
|
33
|
|
|
159
|
if ($OPTIONS{errors} && !$OLD_SIG{__DIE__}) { |
172
|
|
|
|
|
|
|
$OLD_SIG{__DIE__} = $SIG{__DIE__} |
173
|
34
|
100
|
100
|
|
|
123
|
if $SIG{__DIE__} && $SIG{__DIE__} ne \&_die; |
174
|
34
|
|
|
|
|
101
|
$SIG{__DIE__} = \&_die; |
175
|
|
|
|
|
|
|
} |
176
|
34
|
100
|
66
|
|
|
122
|
if ($OPTIONS{warnings} && !$OLD_SIG{__WARN__}) { |
177
|
|
|
|
|
|
|
$OLD_SIG{__WARN__} = $SIG{__WARN__} |
178
|
16
|
50
|
66
|
|
|
53
|
if $SIG{__WARN__} && $SIG{__WARN__} ne \&_warn; |
179
|
16
|
|
|
|
|
46
|
$SIG{__WARN__} = \&_warn; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# enable better names for evals and anon subs |
183
|
|
|
|
|
|
|
$^P |= 0x100 | 0x200 |
184
|
34
|
50
|
|
|
|
5298
|
if _CAN_USE_INFORMATIVE_NAMES && $OPTIONS{better_names}; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub unimport { |
188
|
27
|
|
|
27
|
|
3925
|
for my $sig ( |
189
|
|
|
|
|
|
|
[ __DIE__ => \&_die ], |
190
|
|
|
|
|
|
|
[ __WARN__ => \&_warn ], |
191
|
|
|
|
|
|
|
) { |
192
|
54
|
|
|
|
|
74
|
my ($name, $sub) = @$sig; |
193
|
54
|
100
|
|
|
|
149
|
my $now = $SIG{$name} or next; |
194
|
36
|
|
|
|
|
38
|
my $old = $OLD_SIG{$name}; |
195
|
36
|
50
|
33
|
|
|
131
|
if ($now ne $sub && $old) { |
|
|
100
|
|
|
|
|
|
196
|
0
|
|
|
|
|
0
|
local $SIG{__WARN__}; |
197
|
0
|
|
|
|
|
0
|
warn "Can't restore $name handler!\n"; |
198
|
0
|
|
|
|
|
0
|
delete $SIG{$sig}; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
elsif ($old) { |
201
|
5
|
|
|
|
|
11
|
$SIG{$name} = $old; |
202
|
5
|
|
|
|
|
12
|
delete $OLD_SIG{$name}; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
else { |
205
|
9
|
|
|
9
|
|
38
|
no warnings 'uninitialized'; # bogus warnings on perl < 5.8.8 |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
992
|
|
206
|
31
|
|
|
|
|
22
|
undef $SIG{$name} |
207
|
|
|
|
|
|
|
if _BROKEN_SIG_DELETE; |
208
|
31
|
|
|
|
|
87
|
delete $SIG{$name}; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub _find_sig { |
214
|
61
|
|
|
61
|
|
84
|
my $sig = $_[0]; |
215
|
|
|
|
|
|
|
return undef |
216
|
61
|
100
|
|
|
|
190
|
if !defined $sig; |
217
|
5
|
100
|
|
|
|
18
|
return $sig |
218
|
|
|
|
|
|
|
if ref $sig; |
219
|
|
|
|
|
|
|
return undef |
220
|
4
|
100
|
100
|
|
|
24
|
if $sig eq 'DEFAULT' || $sig eq 'IGNORE'; |
221
|
|
|
|
|
|
|
# this isn't really needed because %SIG entries are always fully qualified |
222
|
|
|
|
|
|
|
package #hide |
223
|
|
|
|
|
|
|
main; |
224
|
9
|
|
|
9
|
|
35
|
no strict 'refs'; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
3611
|
|
225
|
2
|
50
|
|
|
|
4
|
defined &{$sig} ? \&{$sig} : undef; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
7
|
|
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _warn { |
229
|
2
|
|
|
2
|
|
4
|
local $SIG{__WARN__}; |
230
|
2
|
50
|
|
|
|
5
|
return warn @_ |
231
|
|
|
|
|
|
|
if our $warn_deep; |
232
|
2
|
|
|
|
|
9
|
my @convert = _convert(@_); |
233
|
0
|
0
|
|
|
|
0
|
if (my $sig = _find_sig($OLD_SIG{__WARN__})) { |
234
|
0
|
|
|
|
|
0
|
local $warn_deep = 1; |
235
|
0
|
0
|
|
|
|
0
|
(\&$sig)->(ref $convert[0] ? $convert[0] : join('', @convert)); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
else { |
238
|
0
|
|
|
|
|
0
|
@convert = _ex_as_strings(@convert); |
239
|
0
|
0
|
|
|
|
0
|
@convert = _colorize(33, @convert) if $OPTIONS{color}; |
240
|
0
|
|
|
|
|
0
|
warn @convert; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub _die { |
245
|
63
|
|
|
63
|
|
6514
|
local $SIG{__DIE__}; |
246
|
|
|
|
|
|
|
return |
247
|
63
|
50
|
|
|
|
144
|
if our $die_deep; |
248
|
63
|
|
|
|
|
122
|
my @convert = _convert(@_); |
249
|
61
|
100
|
|
|
|
203
|
if (my $sig = _find_sig($OLD_SIG{__DIE__})) { |
250
|
3
|
|
|
|
|
4
|
local $die_deep = 1; |
251
|
3
|
50
|
|
|
|
20
|
(\&$sig)->(ref $convert[0] ? $convert[0] : join('', @convert)); |
252
|
|
|
|
|
|
|
} |
253
|
61
|
50
|
|
|
|
1499
|
@convert = _ex_as_strings(@convert) if _can_stringify; |
254
|
61
|
50
|
33
|
|
|
176
|
@convert = _colorize(31, @convert) if $OPTIONS{color} && _can_stringify; |
255
|
61
|
|
|
|
|
46
|
if (_DEBUGGING && _in_END) { |
256
|
|
|
|
|
|
|
local $SIG{__WARN__}; |
257
|
|
|
|
|
|
|
warn @convert; |
258
|
|
|
|
|
|
|
$! ||= 1; |
259
|
|
|
|
|
|
|
return; |
260
|
|
|
|
|
|
|
} |
261
|
61
|
100
|
|
|
|
825
|
die @convert unless ref $convert[0]; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub _colorize { |
265
|
0
|
|
|
0
|
|
0
|
my ($color, @convert) = @_; |
266
|
0
|
0
|
0
|
|
|
0
|
if ($OPTIONS{color} eq 'force' || -t *STDERR) { |
267
|
0
|
0
|
|
|
|
0
|
if (@convert == 1) { |
268
|
0
|
|
|
|
|
0
|
$convert[0] = s/(.*)//; |
269
|
0
|
|
|
|
|
0
|
unshift @convert, $1; |
270
|
|
|
|
|
|
|
} |
271
|
0
|
|
|
|
|
0
|
$convert[0] = "\e[${color}m$convert[0]\e[m"; |
272
|
|
|
|
|
|
|
} |
273
|
0
|
|
|
|
|
0
|
return @convert; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub _ref_formatter { |
277
|
15
|
|
|
15
|
|
1355
|
require Data::Dumper; |
278
|
15
|
|
|
0
|
|
4198
|
local $SIG{__WARN__} = sub {}; |
279
|
15
|
|
|
0
|
|
39
|
local $SIG{__DIE__} = sub {}; |
280
|
9
|
|
|
9
|
|
37
|
no warnings 'once'; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
894
|
|
281
|
15
|
|
|
|
|
14
|
local $Data::Dumper::Indent = 0; |
282
|
15
|
|
|
|
|
11
|
local $Data::Dumper::Purity = 0; |
283
|
15
|
|
|
|
|
13
|
local $Data::Dumper::Terse = 1; |
284
|
15
|
|
|
|
|
9
|
local $Data::Dumper::Useqq = 1; |
285
|
15
|
100
|
|
|
|
28
|
local $Data::Dumper::Maxdepth = $OPTIONS{dump} == _INF ? 0 : $OPTIONS{dump}; |
286
|
15
|
|
|
|
|
31
|
Data::Dumper::Dumper($_[0]); |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub _stack_trace { |
290
|
9
|
|
|
9
|
|
32
|
no warnings 'once'; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
3531
|
|
291
|
|
|
|
|
|
|
local $Carp::RefArgFormatter |
292
|
65
|
100
|
|
65
|
|
171
|
= $OPTIONS{dump} ? \&_ref_formatter : \&_str_val; |
293
|
65
|
|
|
|
|
1601
|
my $message = &longmess; |
294
|
61
|
|
|
|
|
630
|
$message =~ s/\.?$/./m; |
295
|
61
|
100
|
66
|
|
|
210
|
if ($OPTIONS{source} || $OPTIONS{evalsource}) { |
296
|
|
|
|
|
|
|
$message .= Devel::Confess::Source::source_trace(1, |
297
|
21
|
50
|
|
|
|
76
|
$OPTIONS{evalsource} ? ($OPTIONS{evalsource}, 1) : $OPTIONS{source}); |
298
|
|
|
|
|
|
|
} |
299
|
61
|
|
|
|
|
112
|
$message; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# these are package varibles to control their lifetime. they should not be |
303
|
|
|
|
|
|
|
# used externally. |
304
|
|
|
|
|
|
|
our $PACK_SUFFIX = 'A000'; |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
our %EXCEPTIONS; |
307
|
|
|
|
|
|
|
our %PACKAGES; |
308
|
|
|
|
|
|
|
our %MESSAGES; |
309
|
|
|
|
|
|
|
our %CLONED; |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub CLONE { |
312
|
|
|
|
|
|
|
my %id_map = map { |
313
|
1
|
|
|
1
|
|
7
|
my $ex = $EXCEPTIONS{$_}; |
|
1
|
|
|
|
|
2
|
|
314
|
1
|
50
|
|
|
|
7
|
defined $ex ? ($_ => refaddr($ex)) : (); |
315
|
|
|
|
|
|
|
} keys %EXCEPTIONS; |
316
|
|
|
|
|
|
|
|
317
|
1
|
|
|
|
|
3
|
%EXCEPTIONS = map {; $id_map{$_} => $EXCEPTIONS{$_}} keys %id_map; |
|
1
|
|
|
|
|
4
|
|
318
|
1
|
|
|
|
|
2
|
%PACKAGES = map {; $id_map{$_} => $PACKAGES{$_}} keys %id_map; |
|
1
|
|
|
|
|
3
|
|
319
|
1
|
|
|
|
|
2
|
%MESSAGES = map {; $id_map{$_} => $MESSAGES{$_}} keys %id_map; |
|
1
|
|
|
|
|
3
|
|
320
|
1
|
|
|
|
|
2
|
%CLONED = map {; $_ => 1 } values %id_map |
321
|
|
|
|
|
|
|
if _BROKEN_CLONED_DESTROY_REBLESS || _BROKEN_CLONED_GLOB_UNDEF; |
322
|
|
|
|
|
|
|
weaken($_) |
323
|
1
|
|
|
|
|
4
|
for values %EXCEPTIONS; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
sub _update_ex_refs { |
327
|
65
|
|
|
65
|
|
134
|
for my $id ( keys %EXCEPTIONS ) { |
328
|
|
|
|
|
|
|
next |
329
|
0
|
0
|
|
|
|
0
|
if defined $EXCEPTIONS{$id}; |
330
|
0
|
|
|
|
|
0
|
delete $EXCEPTIONS{$id}; |
331
|
0
|
|
|
|
|
0
|
delete $PACKAGES{$id}; |
332
|
0
|
|
|
|
|
0
|
delete $MESSAGES{$id}; |
333
|
0
|
|
|
|
|
0
|
delete $CLONED{$id} |
334
|
|
|
|
|
|
|
if _BROKEN_CLONED_DESTROY_REBLESS || _BROKEN_CLONED_GLOB_UNDEF; |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub _convert { |
339
|
65
|
|
|
65
|
|
86
|
_update_ex_refs; |
340
|
65
|
100
|
|
|
|
310
|
if (my $class = blessed(my $ex = $_[0])) { |
|
|
50
|
|
|
|
|
|
341
|
|
|
|
|
|
|
return @_ |
342
|
3
|
50
|
|
|
|
74
|
unless $OPTIONS{objects}; |
343
|
|
|
|
|
|
|
return @_ |
344
|
9
|
50
|
|
9
|
|
36
|
if ! do {no strict 'refs'; defined &{"Devel::Confess::_Attached::DESTROY"} }; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
2009
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
18
|
|
345
|
3
|
|
|
|
|
4
|
my $message; |
346
|
3
|
|
|
|
|
9
|
my $id = refaddr($ex); |
347
|
3
|
50
|
|
|
|
7
|
if (defined $EXCEPTIONS{$id}) { |
348
|
|
|
|
|
|
|
return @_ |
349
|
0
|
0
|
|
|
|
0
|
if _isa($ex, "Devel::Confess::_Attached"); |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
# something is going very wrong. possibly from a Safe compartment. |
352
|
|
|
|
|
|
|
# we probably broke something, but do the best we can. |
353
|
0
|
0
|
|
|
|
0
|
if ((ref $ex) =~ /^Devel::Confess::__ANON_/) { |
354
|
0
|
|
|
|
|
0
|
my $oldclass = $PACKAGES{$id}; |
355
|
0
|
|
|
|
|
0
|
$message = $MESSAGES{$id}; |
356
|
0
|
|
|
|
|
0
|
bless $ex, $oldclass; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
else { |
359
|
|
|
|
|
|
|
# give up |
360
|
0
|
|
|
|
|
0
|
return @_; |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
3
|
|
50
|
|
|
45
|
my $does = _can($ex, 'can') && ($ex->can('does') || $ex->can('DOES')) || sub () { 0 }; |
365
|
3
|
50
|
|
|
|
9
|
if ( |
366
|
|
|
|
|
|
|
grep { |
367
|
6
|
50
|
33
|
|
|
89
|
$NoTrace{$_} |
|
|
|
33
|
|
|
|
|
368
|
|
|
|
|
|
|
&& _can($ex, 'isa') |
369
|
|
|
|
|
|
|
&& $ex->isa($_) |
370
|
|
|
|
|
|
|
|| $ex->$does($_) |
371
|
|
|
|
|
|
|
} keys %NoTrace |
372
|
|
|
|
|
|
|
) { |
373
|
0
|
|
|
|
|
0
|
return @_; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
3
|
|
33
|
|
|
11
|
$message ||= _stack_trace(); |
377
|
|
|
|
|
|
|
|
378
|
3
|
|
|
|
|
11
|
weaken($EXCEPTIONS{$id} = $ex); |
379
|
3
|
|
|
|
|
6
|
$PACKAGES{$id} = $class; |
380
|
3
|
|
|
|
|
4
|
$MESSAGES{$id} = $message; |
381
|
|
|
|
|
|
|
|
382
|
3
|
|
|
|
|
8
|
my $newclass = __PACKAGE__ . '::__ANON_' . $PACK_SUFFIX++ . '__'; |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
{ |
385
|
9
|
|
|
9
|
|
40
|
no strict 'refs'; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
5974
|
|
|
3
|
|
|
|
|
5
|
|
386
|
3
|
|
|
|
|
3
|
@{$newclass . '::ISA'} = ('Devel::Confess::_Attached', $class); |
|
3
|
|
|
|
|
42
|
|
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
|
389
|
3
|
|
|
|
|
7
|
bless $ex, $newclass; |
390
|
3
|
|
|
|
|
6
|
return $ex; |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
elsif (ref($ex = $_[0])) { |
393
|
0
|
|
|
|
|
0
|
my $id = refaddr($ex); |
394
|
|
|
|
|
|
|
|
395
|
0
|
|
|
|
|
0
|
my $message = _stack_trace; |
396
|
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
0
|
weaken($EXCEPTIONS{$id} = $ex); |
398
|
0
|
|
|
|
|
0
|
$PACKAGES{$id} = undef; |
399
|
0
|
|
0
|
|
|
0
|
$MESSAGES{$id} ||= $message; |
400
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
0
|
return $ex; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
62
|
|
|
|
|
150
|
my $out = join('', @_); |
405
|
|
|
|
|
|
|
|
406
|
62
|
100
|
|
|
|
143
|
if (caller(1) eq 'Carp') { |
407
|
24
|
|
|
|
|
530
|
my $long = longmess(); |
408
|
24
|
|
|
|
|
29
|
my $long_trail = $long; |
409
|
24
|
|
|
|
|
94
|
$long_trail =~ s/.*?\n//; |
410
|
24
|
100
|
|
|
|
7581
|
$out =~ s/\Q$long\E\z|\Q$long_trail\E\z// |
411
|
|
|
|
|
|
|
or $out =~ s/(.*) at .*? line .*?\n\z/$1/; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
62
|
|
|
|
|
70
|
my $source_trace; |
415
|
|
|
|
|
|
|
$out =~ s/^(={75}\ncontext for .*^={75}\n\z)//ms |
416
|
|
|
|
|
|
|
and $source_trace = $1 |
417
|
62
|
100
|
66
|
|
|
301
|
if $OPTIONS{source} || $OPTIONS{evalsource}; |
|
|
|
66
|
|
|
|
|
418
|
62
|
|
|
|
|
97
|
my $trace = _stack_trace(); |
419
|
58
|
|
|
|
|
198
|
$trace =~ s/^(.*\n?)//; |
420
|
58
|
|
|
|
|
98
|
my $where = $1; |
421
|
58
|
|
|
|
|
51
|
my $new_source_trace; |
422
|
|
|
|
|
|
|
$trace =~ s/^(={75}\ncontext for .*^={75}\n\z)//ms |
423
|
|
|
|
|
|
|
and $new_source_trace = $1 |
424
|
58
|
100
|
33
|
|
|
304
|
if $OPTIONS{source} || $OPTIONS{evalsource}; |
|
|
|
66
|
|
|
|
|
425
|
58
|
|
|
|
|
67
|
my $find = $where; |
426
|
58
|
|
|
|
|
152
|
$find =~ s/(\.?\n?)\z//; |
427
|
58
|
50
|
|
|
|
290
|
my $trace_re = length $trace ? "(?:\Q$trace\E)?" : ''; |
428
|
58
|
100
|
|
|
|
2215
|
$out =~ s/(\Q$find\E(?: during global destruction)?(\.?\n?))$trace_re\z// |
429
|
|
|
|
|
|
|
and $where = $1; |
430
|
58
|
100
|
|
|
|
112
|
if (defined $source_trace) { |
431
|
9
|
50
|
|
|
|
13
|
if (defined $new_source_trace) { |
432
|
9
|
|
|
|
|
31
|
$new_source_trace =~ s/^={75}\n//; |
433
|
9
|
|
|
|
|
806
|
$source_trace =~ s/^(([-=])\2{74}\n)(?:\Q$new_source_trace\E)?\z/$1/ms; |
434
|
|
|
|
|
|
|
} |
435
|
9
|
|
|
|
|
20
|
$trace .= $source_trace; |
436
|
|
|
|
|
|
|
} |
437
|
58
|
100
|
|
|
|
110
|
if (defined $new_source_trace) { |
438
|
21
|
|
|
|
|
43
|
$trace .= $new_source_trace; |
439
|
|
|
|
|
|
|
} |
440
|
58
|
|
|
|
|
251
|
return ($out, $where . $trace); |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
sub _ex_as_strings { |
444
|
1
|
|
|
1
|
|
2
|
my $ex = $_[0]; |
445
|
|
|
|
|
|
|
return @_ |
446
|
1
|
50
|
|
|
|
3
|
unless ref $ex; |
447
|
1
|
|
|
|
|
2
|
my $id = refaddr($ex); |
448
|
1
|
|
|
|
|
2
|
my $class = $PACKAGES{$id}; |
449
|
1
|
|
|
|
|
2
|
my $message = $MESSAGES{$id}; |
450
|
1
|
|
|
|
|
1
|
my $out; |
451
|
1
|
50
|
|
|
|
3
|
if (blessed $ex) { |
|
|
0
|
|
|
|
|
|
452
|
1
|
|
|
|
|
2
|
my $newclass = ref $ex; |
453
|
1
|
50
|
|
|
|
9
|
bless $ex, $class if $class; |
454
|
1
|
50
|
33
|
|
|
3
|
if ($OPTIONS{dump} && !overload::OverloadedStringify($ex)) { |
455
|
0
|
|
|
|
|
0
|
$out = _ref_formatter($ex); |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
else { |
458
|
1
|
|
|
|
|
19
|
$out = "$ex"; |
459
|
|
|
|
|
|
|
} |
460
|
1
|
50
|
|
|
|
7
|
bless $ex, $newclass if $class; |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
elsif ($OPTIONS{dump}) { |
463
|
0
|
|
|
|
|
0
|
$out = _ref_formatter($ex); |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
else { |
466
|
0
|
|
|
|
|
0
|
$out = "$ex"; |
467
|
|
|
|
|
|
|
} |
468
|
1
|
|
|
|
|
4
|
return ($out, $message); |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
{ |
472
|
|
|
|
|
|
|
package #hide |
473
|
|
|
|
|
|
|
Devel::Confess::_Attached; |
474
|
|
|
|
|
|
|
use overload |
475
|
|
|
|
|
|
|
fallback => 1, |
476
|
|
|
|
|
|
|
'bool' => sub { |
477
|
|
|
|
|
|
|
package |
478
|
|
|
|
|
|
|
Devel::Confess; |
479
|
0
|
|
|
0
|
|
0
|
my $ex = $_[0]; |
480
|
0
|
|
|
|
|
0
|
my $class = $PACKAGES{refaddr($ex)}; |
481
|
0
|
|
|
|
|
0
|
my $newclass = ref $ex; |
482
|
0
|
|
|
|
|
0
|
bless $ex, $class; |
483
|
0
|
0
|
|
|
|
0
|
my $out = $ex ? !!1 : !!0; |
484
|
0
|
|
|
|
|
0
|
bless $ex, $newclass; |
485
|
0
|
|
|
|
|
0
|
return $out; |
486
|
|
|
|
|
|
|
}, |
487
|
|
|
|
|
|
|
'0+' => sub { |
488
|
|
|
|
|
|
|
package |
489
|
|
|
|
|
|
|
Devel::Confess; |
490
|
0
|
|
|
0
|
|
0
|
my $ex = $_[0]; |
491
|
0
|
|
|
|
|
0
|
my $class = $PACKAGES{refaddr($ex)}; |
492
|
0
|
|
|
|
|
0
|
my $newclass = ref $ex; |
493
|
0
|
|
|
|
|
0
|
bless $ex, $class; |
494
|
0
|
|
|
|
|
0
|
my $out = 0+sprintf '%.20g', $ex; |
495
|
0
|
|
|
|
|
0
|
bless $ex, $newclass; |
496
|
0
|
|
|
|
|
0
|
return $out; |
497
|
|
|
|
|
|
|
}, |
498
|
|
|
|
|
|
|
'""' => sub { |
499
|
|
|
|
|
|
|
package |
500
|
|
|
|
|
|
|
Devel::Confess; |
501
|
1
|
|
|
1
|
|
52
|
join('', _ex_as_strings(@_)); |
502
|
|
|
|
|
|
|
}, |
503
|
9
|
|
|
9
|
|
7513
|
; |
|
9
|
|
|
|
|
5716
|
|
|
9
|
|
|
|
|
117
|
|
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
sub DESTROY { |
506
|
|
|
|
|
|
|
package |
507
|
|
|
|
|
|
|
Devel::Confess; |
508
|
2
|
|
|
2
|
|
575
|
my $ex = $_[0]; |
509
|
2
|
|
|
|
|
4
|
my $id = refaddr($ex); |
510
|
2
|
50
|
|
|
|
7
|
my $class = delete $PACKAGES{$id} or return; |
511
|
2
|
|
|
|
|
3
|
delete $MESSAGES{$id}; |
512
|
2
|
|
|
|
|
2
|
delete $EXCEPTIONS{$id}; |
513
|
|
|
|
|
|
|
|
514
|
2
|
|
|
|
|
3
|
my $newclass = ref $ex; |
515
|
|
|
|
|
|
|
|
516
|
2
|
|
|
|
|
3
|
my $cloned; |
517
|
|
|
|
|
|
|
# delete_package is more complete, but can explode on some perls |
518
|
2
|
|
|
|
|
2
|
if (_BROKEN_CLONED_GLOB_UNDEF && delete $CLONED{$id}) { |
519
|
|
|
|
|
|
|
$cloned = 1; |
520
|
9
|
|
|
9
|
|
1195
|
no strict 'refs'; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
1293
|
|
521
|
|
|
|
|
|
|
@{"${newclass}::ISA"} = (); |
522
|
|
|
|
|
|
|
my $stash = \%{"${newclass}::"}; |
523
|
|
|
|
|
|
|
delete @{$stash}{keys %$stash}; |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
else { |
526
|
2
|
|
|
|
|
6
|
Symbol::delete_package($newclass); |
527
|
|
|
|
|
|
|
} |
528
|
|
|
|
|
|
|
|
529
|
2
|
50
|
|
|
|
87
|
if (_BROKEN_CLONED_DESTROY_REBLESS && $cloned || delete $CLONED{$id}) { |
530
|
0
|
|
0
|
|
|
0
|
my $destroy = _can($class, 'DESTROY') || return; |
531
|
0
|
|
|
|
|
0
|
goto $destroy; |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
|
534
|
2
|
|
|
|
|
5
|
bless $ex, $class; |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
# after reblessing, perl will re-dispatch to the class's own DESTROY. |
537
|
2
|
|
|
|
|
5
|
(); |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
} |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
1; |
542
|
|
|
|
|
|
|
__END__ |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=encoding utf8 |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
=head1 NAME |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
Devel::Confess - Include stack traces on all warnings and errors |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
=head1 SYNOPSIS |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
Use on the command line: |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
# Make every warning and error include a full stack trace |
555
|
|
|
|
|
|
|
perl -d:Confess script.pl |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
# Also usable as a module |
558
|
|
|
|
|
|
|
perl -MDevel::Confess script.pl |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
# display warnings in yellow and errors in red |
561
|
|
|
|
|
|
|
perl -d:Confess=color script.pl |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
# set options by environment |
564
|
|
|
|
|
|
|
export DEVEL_CONFESS_OPTIONS='color dump' |
565
|
|
|
|
|
|
|
perl -d:Confess script.pl |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
Can also be used inside a script: |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
use Devel::Confess; |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
use Devel::Confess 'color'; |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
# disable stack traces |
574
|
|
|
|
|
|
|
no Devel::Confess; |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
=head1 DESCRIPTION |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
This module is meant as a debugging aid. It can be used to make a script |
579
|
|
|
|
|
|
|
complain loudly with stack backtraces when C<warn()>ing or C<die()>ing. |
580
|
|
|
|
|
|
|
Unlike other similar modules (e.g. L<Carp::Always>), stack traces will also be |
581
|
|
|
|
|
|
|
included when exception objects are thrown. |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
The stack traces are generated using L<Carp>, and will work for all types of |
584
|
|
|
|
|
|
|
errors. L<Carp>'s C<carp> and C<croak> functions will also be made to include |
585
|
|
|
|
|
|
|
stack traces. |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
# it works for explicit die's and warn's |
588
|
|
|
|
|
|
|
$ perl -d:Confess -e 'sub f { die "arghh" }; sub g { f }; g' |
589
|
|
|
|
|
|
|
arghh at -e line 1. |
590
|
|
|
|
|
|
|
main::f() called at -e line 1 |
591
|
|
|
|
|
|
|
main::g() called at -e line 1 |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
# it works for interpreter-thrown failures |
594
|
|
|
|
|
|
|
$ perl -d:Confess -w -e 'sub f { $a = shift; @a = @$a };' \ |
595
|
|
|
|
|
|
|
-e 'sub g { f(undef) }; g' |
596
|
|
|
|
|
|
|
Use of uninitialized value $a in array dereference at -e line 1. |
597
|
|
|
|
|
|
|
main::f(undef) called at -e line 2 |
598
|
|
|
|
|
|
|
main::g() called at -e line 2 |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
Internally, this is implemented with L<$SIG{__WARN__}|perlvar/%SIG> and |
601
|
|
|
|
|
|
|
L<$SIG{__DIE__}|perlvar/%SIG> hooks. |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
Stack traces are also included if raw non-object references are thrown. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
This module is compatible with all perl versions back to 5.6.2, without |
606
|
|
|
|
|
|
|
additional prerequisites. It contains workarounds for a number of bugs in the |
607
|
|
|
|
|
|
|
perl interpreter, some of which effect comparatively simpler modules, like |
608
|
|
|
|
|
|
|
L<Carp::Always>. |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=head1 METHODS |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head2 import( @options ) |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
Enables stack traces and sets options. A list of options to enable can be |
615
|
|
|
|
|
|
|
passed in. Prefixing the options with C<no_> will disable them. |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
=over 4 |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=item C<objects> |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Enable attaching stack traces to exception objects. Enabled by default. |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=item C<builtin> |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
Load the L<Devel::Confess::Builtin> module to use built in |
626
|
|
|
|
|
|
|
stack traces on supported exception types. Disabled by default. |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=item C<dump> |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
Dumps the contents of references in arguments in stack trace, instead |
631
|
|
|
|
|
|
|
of only showing their stringified version. Also causes exceptions that are |
632
|
|
|
|
|
|
|
non-object references and objects without string overloads to be dumped if |
633
|
|
|
|
|
|
|
being displayed. Shows up to three references deep. |
634
|
|
|
|
|
|
|
Disabled by default. |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=item C<dump0>, C<dump1>, C<dump2>, etc |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
The same as the dump option, but with a different max depth to dump. A depth |
639
|
|
|
|
|
|
|
of 0 is treated as infinite. |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
=item C<color> |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
Colorizes error messages in red and warnings in yellow. Disabled by default. |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=item C<source> |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
Includes a snippet of the source for each level of the stack trace. Disabled |
648
|
|
|
|
|
|
|
by default. |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=item C<source0>, C<source1>, C<source2>, etc |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
Enables source display, but with a specified number of lines of context to show. |
653
|
|
|
|
|
|
|
Context of 0 will show the entire source of the files. |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
=item C<evalsource> |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
Similar to the source option, but only shows includes source for string evals. |
658
|
|
|
|
|
|
|
Useful for seeing the results of code generation. Disabled by default. |
659
|
|
|
|
|
|
|
Overrides the source option. |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
=item C<evalsource0>, C<evalsource1>, C<evalsource2>, etc |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
Enables eval source display, but with a specified number of lines of context to |
664
|
|
|
|
|
|
|
show. Context of 0 will show the entire source of the evals. |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=item C<better_names> |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
Use more informative names to string evals and anonymous subs in stack |
669
|
|
|
|
|
|
|
traces. Enabled by default. |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
=item C<errors> |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
Add stack traces to errors. Enabled by default. |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=item C<warnings> |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
Add stack traces to warnings. Enabled by default. |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=back |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
The default options can be changed by setting the C<DEVEL_CONFESS_OPTIONS> |
682
|
|
|
|
|
|
|
environment variable to a space separated list of options. |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=head1 CONFIGURATION |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=head2 C<%Devel::Confess::NoTrace> |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
Classes or roles added to this hash will not have stack traces |
689
|
|
|
|
|
|
|
attached to them. This is useful for exception classes that provide |
690
|
|
|
|
|
|
|
their own stack traces, or classes that don't cope well with being |
691
|
|
|
|
|
|
|
re-blessed. If L<Devel::Confess::Builtin> is loaded, it will |
692
|
|
|
|
|
|
|
automatically add its supported exception types to this hash. |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
Default Entries: |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
=over 4 |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=item L<Throwable::Error> |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
Provides a stack trace |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=item L<Moose::Error::Default> |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
Provides a stack trace |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=back |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
The idea and parts of the code and documentation are taken from L<Carp::Always>. |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
=head1 SEE ALSO |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=over 4 |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
=item * |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
L<Carp::Always> |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
=item * |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
L<Carp> |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=item * |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
L<Acme::JavaTrace> and L<Devel::SimpleTrace> |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
=item * |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
L<Carp::Always::Color> |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=item * |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
L<Carp::Source::Always> |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=item * |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
L<Carp::Always::Dump> |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
=back |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
=head1 CAVEATS |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
This module uses several ugly tricks to do its work and surely has bugs. |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
=over 4 |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
=item * |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
This module uses C<$SIG{__WARN__}> and C<$SIG{__DIE__}> to accomplish its goal, |
751
|
|
|
|
|
|
|
and thus may not play well with other modules that try to use these hooks. |
752
|
|
|
|
|
|
|
Significant effort has gone into making this work as well as possible, but |
753
|
|
|
|
|
|
|
global variables like these can never be fully encapsulated. |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
=item * |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
To provide stack traces on exception objects, this module re-blesses the |
758
|
|
|
|
|
|
|
exception objects into a generated class. While it tries to have the smallest |
759
|
|
|
|
|
|
|
effect it can, some things cannot be worked around. In particular, |
760
|
|
|
|
|
|
|
C<ref($exception)> will return a different value than may be expected. Any |
761
|
|
|
|
|
|
|
module that relies on the specific return value from C<ref> like already has |
762
|
|
|
|
|
|
|
bugs though. |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=back |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=head1 SUPPORT |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
Please report bugs via |
769
|
|
|
|
|
|
|
L<CPAN RT|http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Confess>. |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
=head1 AUTHORS |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
=over 4 |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=item * |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
Graham Knop <haarg@haarg.org> |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=back |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=over 4 |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=item * |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
Adriano Ferreira <ferreira@cpan.org> |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
=back |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=head1 COPYRIGHT |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
Copyright (c) 2005-2013 the L</AUTHORS> and L</CONTRIBUTORS> |
795
|
|
|
|
|
|
|
as listed above. |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
=head1 LICENSE |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
This library is free software and may be distributed under the same terms |
800
|
|
|
|
|
|
|
as perl itself. See L<http://dev.perl.org/licenses/>. |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
=cut |