| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## no critic: TestingAndDebugging::RequireUseStrict |
|
2
|
|
|
|
|
|
|
package Carp::Patch::ExcludePackage; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
332153
|
use 5.010001; |
|
|
1
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
|
|
#use strict 'vars'; |
|
6
|
1
|
|
|
1
|
|
7
|
no warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
74
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
686
|
use Module::Patch; |
|
|
1
|
|
|
|
|
25052
|
|
|
|
1
|
|
|
|
|
8
|
|
|
9
|
1
|
|
|
1
|
|
88
|
use base qw(Module::Patch); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
941
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
12
|
|
|
|
|
|
|
our $DATE = '2024-04-17'; # DATE |
|
13
|
|
|
|
|
|
|
our $DIST = 'Carp-Patch-ExcludePackage'; # DIST |
|
14
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our %config; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $p_ret_backtrace = sub { |
|
19
|
|
|
|
|
|
|
my ( $i, @error ) = @_; |
|
20
|
|
|
|
|
|
|
my $mess; |
|
21
|
|
|
|
|
|
|
my $err = join '', @error; |
|
22
|
|
|
|
|
|
|
$i++; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $tid_msg = ''; |
|
25
|
|
|
|
|
|
|
if ( defined &threads::tid ) { |
|
26
|
|
|
|
|
|
|
my $tid = threads->tid; |
|
27
|
|
|
|
|
|
|
$tid_msg = " thread $tid" if $tid; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %i = Carp::caller_info($i); |
|
31
|
|
|
|
|
|
|
$mess = "$err at $i{file} line $i{line}$tid_msg"; |
|
32
|
|
|
|
|
|
|
if( $. ) { |
|
33
|
|
|
|
|
|
|
# Use ${^LAST_FH} if available. |
|
34
|
|
|
|
|
|
|
if (LAST_FH) { |
|
35
|
|
|
|
|
|
|
if (${+LAST_FH}) { |
|
36
|
|
|
|
|
|
|
$mess .= sprintf ", <%s> %s %d", |
|
37
|
|
|
|
|
|
|
*${+LAST_FH}{NAME}, |
|
38
|
|
|
|
|
|
|
($/ eq "\n" ? "line" : "chunk"), $. |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else { |
|
42
|
|
|
|
|
|
|
local $@ = ''; |
|
43
|
|
|
|
|
|
|
local $SIG{__DIE__}; |
|
44
|
|
|
|
|
|
|
eval { |
|
45
|
|
|
|
|
|
|
CORE::die; |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
if($@ =~ /^Died at .*(, <.*?> (?:line|chunk) \d+).$/ ) { |
|
48
|
|
|
|
|
|
|
$mess .= $1; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
$mess .= "\.\n"; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
while ( my %i = Carp::caller_info( ++$i ) ) { |
|
55
|
|
|
|
|
|
|
if (defined $config{-exclude_pat} && $i{pack} =~ /$config{-exclude_pat}/) { |
|
56
|
|
|
|
|
|
|
$mess .= "Skipped stack trace level (package $i{pack} excluded by $config{-exclude_pat})\n" if $config{-show_excluded}; |
|
57
|
|
|
|
|
|
|
next; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
if (defined $config{-include_pat} && $i{pack} !~ /$config{-include_pat}/) { |
|
60
|
|
|
|
|
|
|
$mess .= "Skipped stack trace level (package $i{pack} not included by $config{-include_pat})\n" if $config{-show_excluded}; |
|
61
|
|
|
|
|
|
|
next; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
$mess .= "\t$i{sub_name} called at $i{file} line $i{line}$tid_msg\n"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return $mess; |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub patch_data { |
|
70
|
|
|
|
|
|
|
return { |
|
71
|
0
|
|
|
0
|
0
|
|
v => 3, |
|
72
|
|
|
|
|
|
|
config => { |
|
73
|
|
|
|
|
|
|
-exclude_pat => { |
|
74
|
|
|
|
|
|
|
schema => 're*', |
|
75
|
|
|
|
|
|
|
}, |
|
76
|
|
|
|
|
|
|
-include_pat => { |
|
77
|
|
|
|
|
|
|
schema => 're*', |
|
78
|
|
|
|
|
|
|
}, |
|
79
|
|
|
|
|
|
|
-show_excluded => { |
|
80
|
|
|
|
|
|
|
schema => 'bool*', |
|
81
|
|
|
|
|
|
|
}, |
|
82
|
|
|
|
|
|
|
}, |
|
83
|
|
|
|
|
|
|
patches => [ |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
action => 'replace', |
|
86
|
|
|
|
|
|
|
sub_name => 'ret_backtrace', |
|
87
|
|
|
|
|
|
|
code => $p_ret_backtrace, |
|
88
|
|
|
|
|
|
|
}, |
|
89
|
|
|
|
|
|
|
], |
|
90
|
|
|
|
|
|
|
-warn_target_loaded => 0, |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
# ABSTRACT: Exclude some packages from stack trace |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |