line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Phylo::Util::StackTrace; |
2
|
57
|
|
|
57
|
|
313
|
use strict; |
|
57
|
|
|
|
|
99
|
|
|
57
|
|
|
|
|
1486
|
|
3
|
57
|
|
|
57
|
|
257
|
use warnings; |
|
57
|
|
|
|
|
92
|
|
|
57
|
|
|
|
|
18695
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Bio::Phylo::Util::StackTrace - Stack traces for exceptions |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Bio::Phylo::Util::StackTrace; |
12
|
|
|
|
|
|
|
my $trace = Bio::Phylo::Util::StackTrace->new; |
13
|
|
|
|
|
|
|
print $trace->as_string; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This is a simple stack trace object that is used by |
18
|
|
|
|
|
|
|
L<Bio::Phylo::Util::Exceptions>. At the moment of its instantiation, |
19
|
|
|
|
|
|
|
it creates a full list of all frames in the call stack (except those |
20
|
|
|
|
|
|
|
originating from with the exceptions class). These can subsequently |
21
|
|
|
|
|
|
|
be stringified by calling as_string(). |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
(If you have no idea what any of this means, don't worry: this class |
24
|
|
|
|
|
|
|
is mostly for internal usage. You can probably ignore this safely.) |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 CONSTRUCTOR |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item new() |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Stack trace object constructor. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Type : Constructor |
37
|
|
|
|
|
|
|
Title : new |
38
|
|
|
|
|
|
|
Usage : my $trace = Bio::Phylo::Util::StackTrace->new |
39
|
|
|
|
|
|
|
Function: Instantiates a Bio::Phylo::Util::StackTrace |
40
|
|
|
|
|
|
|
object. |
41
|
|
|
|
|
|
|
Returns : A Bio::Phylo::Util::StackTrace. |
42
|
|
|
|
|
|
|
Args : None |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
47
|
176
|
|
|
176
|
1
|
372
|
my $class = shift; |
48
|
176
|
|
|
|
|
342
|
my $self = []; |
49
|
176
|
|
|
|
|
280
|
my $i = 0; |
50
|
176
|
|
|
|
|
266
|
my $j = 0; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package DB; # to get @_ stack from previous frames, see perldoc -f caller |
53
|
176
|
|
|
|
|
1689
|
while ( my @frame = caller($i) ) { |
54
|
2566
|
|
|
|
|
3665
|
my $package = $frame[0]; |
55
|
2566
|
100
|
|
|
|
3626
|
if ( not Bio::Phylo::Util::StackTrace::_skip_me($package) ) { |
56
|
2214
|
|
|
|
|
3363
|
my @args = @DB::args; |
57
|
2214
|
|
|
|
|
6923
|
$self->[ $j++ ] = [ @frame, @args ]; |
58
|
|
|
|
|
|
|
} |
59
|
2566
|
|
|
|
|
13261
|
$i++; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package Bio::Phylo::Util::StackTrace; |
63
|
176
|
|
|
|
|
515
|
shift @$self; # to remove "throw" frame |
64
|
176
|
|
|
|
|
3128
|
return bless $self, $class; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _skip_me { |
68
|
2566
|
|
|
2566
|
|
3024
|
my $class = shift; |
69
|
2566
|
|
|
|
|
2860
|
my $skip = 0; |
70
|
2566
|
100
|
|
|
|
9461
|
if ( $class->isa('Bio::Phylo::Util::Exceptions') ) { |
71
|
352
|
|
|
|
|
525
|
$skip++; |
72
|
|
|
|
|
|
|
} |
73
|
2566
|
50
|
|
|
|
7564
|
if ( $class->isa('Bio::Phylo::Util::ExceptionFactory') ) { |
74
|
0
|
|
|
|
|
0
|
$skip++; |
75
|
|
|
|
|
|
|
} |
76
|
2566
|
|
|
|
|
4535
|
return $skip; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 SERIALIZERS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item as_string() |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Creates a string representation of the stack trace |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Type : Serializer |
90
|
|
|
|
|
|
|
Title : as_string |
91
|
|
|
|
|
|
|
Usage : print $trace->as_string |
92
|
|
|
|
|
|
|
Function: Creates a string representation of the stack trace |
93
|
|
|
|
|
|
|
Returns : String |
94
|
|
|
|
|
|
|
Args : None |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=begin comment |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
fields in frame: |
101
|
|
|
|
|
|
|
[ |
102
|
|
|
|
|
|
|
0 'main', |
103
|
|
|
|
|
|
|
+1 '/Users/rvosa/Desktop/exceptions.pl', |
104
|
|
|
|
|
|
|
+2 102, |
105
|
|
|
|
|
|
|
+3 'Object::this_dies', |
106
|
|
|
|
|
|
|
4 1, |
107
|
|
|
|
|
|
|
5 undef, |
108
|
|
|
|
|
|
|
6 undef, |
109
|
|
|
|
|
|
|
7 undef, |
110
|
|
|
|
|
|
|
8 2, |
111
|
|
|
|
|
|
|
9 'UUUUUUUUUUUU', |
112
|
|
|
|
|
|
|
+10 bless( {}, 'Object' ), |
113
|
|
|
|
|
|
|
+11 'very', |
114
|
|
|
|
|
|
|
+12 'violently' |
115
|
|
|
|
|
|
|
], |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=end comment |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub as_string { |
122
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
123
|
0
|
|
|
|
|
|
my $string = ""; |
124
|
0
|
|
|
|
|
|
for my $frame (@$self) { |
125
|
0
|
|
|
|
|
|
my $method = $frame->[3]; |
126
|
0
|
|
|
|
|
|
my @args; |
127
|
0
|
|
|
|
|
|
for my $i ( 10 .. $#{$frame} ) { |
|
0
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
push @args, $frame->[$i]; |
129
|
|
|
|
|
|
|
} |
130
|
0
|
|
|
|
|
|
my $file = $frame->[1]; |
131
|
0
|
|
|
|
|
|
my $line = $frame->[2]; |
132
|
|
|
|
|
|
|
$string .= |
133
|
|
|
|
|
|
|
$method . "(" |
134
|
0
|
|
|
|
|
|
. join( ', ', map { "'$_'" } grep { $_ } @args ) |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
. ") called at $file line $line\n"; |
136
|
|
|
|
|
|
|
} |
137
|
0
|
|
|
|
|
|
return $string; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SEE ALSO |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> |
147
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=over |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item L<Bio::Phylo::Util::Exceptions> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The stack trace object is used internally by the exception classes. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item L<Bio::Phylo::Manual> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 CITATION |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
166
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
167
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
168
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |