| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
### |
|
2
|
|
|
|
|
|
|
### Copyright (c) 2019 - 2025 Curtis Leach. All rights reserved. |
|
3
|
|
|
|
|
|
|
### |
|
4
|
|
|
|
|
|
|
### A crazy extension module for Fred::Fish::DBUG. |
|
5
|
|
|
|
|
|
|
### |
|
6
|
|
|
|
|
|
|
### Module: Fred::Fish::DBUG::SignalKiller |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Fred::Fish::DBUG::SignalKiller - A crazy extension module for Fred::Fish::DBUG. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Fred::Fish::DBUG::SignalKiller; |
|
15
|
|
|
|
|
|
|
or |
|
16
|
|
|
|
|
|
|
require Fred::Fish::DBUG::SignalKiller; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
All this module does is redirect Perl's core die method to a custom function. |
|
21
|
|
|
|
|
|
|
So that whenever B is called, it bypasses Perl's B function in favor |
|
22
|
|
|
|
|
|
|
of the one defined here by L. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
You only need to use this module if you wish to tell Perl to basically ignore |
|
25
|
|
|
|
|
|
|
all calls to B. By running: |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
DBUG_TRAP_SIGNAL ("__DIE__", DBUG_SIG_ACTION_LOG, @funcs); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
After sourcing in this module, and making the above call to DBUG_TRAP_SIGNAL, |
|
30
|
|
|
|
|
|
|
any calls to B or B will log this request to B, call the |
|
31
|
|
|
|
|
|
|
provided custom functions, and then return control to your program as if the |
|
32
|
|
|
|
|
|
|
call to B or B were just like any other function you called. |
|
33
|
|
|
|
|
|
|
Basically causing your code to ignore B or B logic. Breaking |
|
34
|
|
|
|
|
|
|
a lot of logic in many, many modules that depend on it. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Needless to say this isn't really recomended. But if you really, really want |
|
37
|
|
|
|
|
|
|
to do this, just source in this module and then use the DBUG_SIG_ACTION_LOG |
|
38
|
|
|
|
|
|
|
action for B will work this way. Otherwise if you don't source in this |
|
39
|
|
|
|
|
|
|
module it will behave exactly the same as DBUG_SIG_ACTION_DIE instead. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
I repeat again, you really, really don't want to use this module. But if you |
|
42
|
|
|
|
|
|
|
do, it's your funeral. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 WHAT ABOUT THE OTHER ACTIONS FOR DIE? |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
All the other actions for B work the same whether you source in this module |
|
47
|
|
|
|
|
|
|
or not. So why bother. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 WHAT ABOUT THE OTHER SIGNALS? |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
All the other signals work the same whether you source in this module or not. |
|
52
|
|
|
|
|
|
|
Except if you use DBUG_SIG_ACTION_DIE to trigger a call to B and you've |
|
53
|
|
|
|
|
|
|
told B to use DBUG_SIG_ACTION_LOG. In that case please reread the |
|
54
|
|
|
|
|
|
|
DESCRIPTION for what's going to happen. It's not pretty. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
package Fred::Fish::DBUG::SignalKiller; |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
2
|
|
2727
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
72
|
|
|
62
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
124
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
2
|
|
|
2
|
|
49
|
use vars qw( @ISA @EXPORT @EXPORT_OK $VERSION ); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
151
|
|
|
65
|
2
|
|
|
2
|
|
10
|
use Exporter; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
93
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# The module whose behaviour we want to modify |
|
68
|
|
|
|
|
|
|
# so that we can sabotage everything else! |
|
69
|
2
|
|
|
2
|
|
30
|
use Fred::Fish::DBUG::Signal 2.10; |
|
|
2
|
|
|
|
|
48
|
|
|
|
2
|
|
|
|
|
244
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$VERSION = "2.10"; |
|
72
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
|
73
|
|
|
|
|
|
|
@EXPORT = qw( ); |
|
74
|
|
|
|
|
|
|
@EXPORT_OK = qw( ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ---------------------------------------------------------- |
|
78
|
|
|
|
|
|
|
# Redirectiong Perl's die/croak commands to this custom code. |
|
79
|
|
|
|
|
|
|
# Needed so that we can implement: |
|
80
|
|
|
|
|
|
|
# DBUG_TRAP_SIGNAL ("__DIE__", DBUG_SIG_ACTION_LOG, @funcs); |
|
81
|
|
|
|
|
|
|
# ---------------------------------------------------------- |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
BEGIN |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
2
|
|
|
2
|
|
17
|
*CORE::GLOBAL::die = \&_custom_fish_die; |
|
86
|
2
|
|
|
|
|
615
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# ---------------------------------------------------------- |
|
91
|
|
|
|
|
|
|
# The replacement to Perl's core die routine ... |
|
92
|
|
|
|
|
|
|
# ---------------------------------------------------------- |
|
93
|
|
|
|
|
|
|
sub _custom_fish_die |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
|
|
|
|
|
|
# Did someone request that die be trapped by Fred::Fish::DBUG::Signal? |
|
96
|
|
|
|
|
|
|
# It detects if someone reset $SIG{__DIE__} outside that module |
|
97
|
|
|
|
|
|
|
# and it will never return DBUG_SIG_ACTION_LOG in that case! |
|
98
|
|
|
|
|
|
|
|
|
99
|
8
|
|
|
8
|
|
862
|
my $action = DBUG_FIND_CURRENT_TRAPS ("__DIE__"); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Let's get the DBUG function to call ... |
|
102
|
8
|
|
|
|
|
21
|
my $func; |
|
103
|
8
|
100
|
|
|
|
34
|
if ( $action == DBUG_SIG_ACTION_LOG ) { |
|
104
|
3
|
|
50
|
|
|
47
|
$func = $SIG{__DIE__} || ""; |
|
105
|
3
|
50
|
|
|
|
40
|
if ( ref ( $func ) eq "CODE" ) { |
|
|
|
50
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
; # We have a good $func CODE value ... |
|
107
|
|
|
|
|
|
|
} elsif ( $func =~ m/^(.+)::([^:]+)$/ ) { |
|
108
|
3
|
|
|
|
|
67
|
$func = ${1}->can ($2); |
|
109
|
3
|
50
|
|
|
|
16
|
$action = 0 unless ( ref ( $func ) eq "CODE" ); |
|
110
|
|
|
|
|
|
|
} else { |
|
111
|
0
|
|
|
|
|
0
|
$action = 0; # Should never happen ... |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# We use "goto" so that any line numbers printed in fish will report |
|
116
|
|
|
|
|
|
|
# where it died instead of this custom function. |
|
117
|
8
|
100
|
|
|
|
28
|
if ( $action == DBUG_SIG_ACTION_LOG ) { |
|
118
|
|
|
|
|
|
|
# Tell the DBUG module this module has been sourced in! |
|
119
|
3
|
|
|
|
|
16
|
Fred::Fish::DBUG::Signal::_dbug_enable_signal_suicide (); |
|
120
|
|
|
|
|
|
|
|
|
121
|
3
|
|
|
|
|
14
|
my $msg = join ("", @_); |
|
122
|
3
|
|
|
|
|
11
|
@_ = ( $msg ); |
|
123
|
3
|
|
|
|
|
34
|
goto &$func; # Returns to the caller, not to this code !!! |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# If we get here, we're back to using Perl's core die function ... |
|
127
|
5
|
|
|
|
|
120
|
goto &CORE::die; # Will Auto-call $SIG{__DIE__}->(@_) if set ... |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return; # Never gets here! |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
134
|
|
|
|
|
|
|
# End of Fred::Fish::DBUG::SignalKiller ... |
|
135
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L - The controlling module for this set of modules. The one |
|
140
|
|
|
|
|
|
|
you should be using. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L - The live version of the B module. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L - The stub version of the B module. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L - Allows you to trap and log STDOUT/STDERR to B. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L - Handles the trapping and logging all signals to |
|
149
|
|
|
|
|
|
|
B. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L - A L wrapper to redirect test results to |
|
152
|
|
|
|
|
|
|
B. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L - Sample code demonstrating using the B |
|
155
|
|
|
|
|
|
|
module. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright (c) 2019 - 2025 Curtis Leach. All rights reserved. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
162
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# ============================================================== |
|
167
|
|
|
|
|
|
|
#required if module is included w/ require command; |
|
168
|
|
|
|
|
|
|
1; |