Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Devel/StackTrace/Frame.pm |
Statements | Executed 33 statements in 518µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 23µs | 23µs | BEGIN@10 | Devel::StackTrace::Frame::
1 | 1 | 1 | 12µs | 21µs | BEGIN@6 | Devel::StackTrace::Frame::
1 | 1 | 1 | 7µs | 10µs | BEGIN@7 | Devel::StackTrace::Frame::
1 | 1 | 1 | 6µs | 14µs | BEGIN@11 | Devel::StackTrace::Frame::
0 | 0 | 0 | 0s | 0s | __ANON__[:17] | Devel::StackTrace::Frame::
0 | 0 | 0 | 0s | 0s | args | Devel::StackTrace::Frame::
0 | 0 | 0 | 0s | 0s | as_string | Devel::StackTrace::Frame::
0 | 0 | 0 | 0s | 0s | new | Devel::StackTrace::Frame::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Devel::StackTrace::Frame; | ||||
2 | { | ||||
3 | 2 | 900ns | $Devel::StackTrace::Frame::VERSION = '1.30'; | ||
4 | } | ||||
5 | |||||
6 | 2 | 18µs | 2 | 30µs | # spent 21µs (12+9) within Devel::StackTrace::Frame::BEGIN@6 which was called:
# once (12µs+9µs) by Devel::StackTrace::BEGIN@11 at line 6 # spent 21µs making 1 call to Devel::StackTrace::Frame::BEGIN@6
# spent 9µs making 1 call to strict::import |
7 | 2 | 22µs | 2 | 13µs | # spent 10µs (7+3) within Devel::StackTrace::Frame::BEGIN@7 which was called:
# once (7µs+3µs) by Devel::StackTrace::BEGIN@11 at line 7 # spent 10µs making 1 call to Devel::StackTrace::Frame::BEGIN@7
# spent 3µs making 1 call to warnings::import |
8 | |||||
9 | # Create accessor routines | ||||
10 | # spent 23µs within Devel::StackTrace::Frame::BEGIN@10 which was called:
# once (23µs+0s) by Devel::StackTrace::BEGIN@11 at line 19 | ||||
11 | 2 | 50µs | 2 | 23µs | # spent 14µs (6+8) within Devel::StackTrace::Frame::BEGIN@11 which was called:
# once (6µs+8µs) by Devel::StackTrace::BEGIN@11 at line 11 # spent 14µs making 1 call to Devel::StackTrace::Frame::BEGIN@11
# spent 8µs making 1 call to strict::unimport |
12 | 1 | 4µs | foreach my $f ( | ||
13 | qw( package filename line subroutine hasargs | ||||
14 | wantarray evaltext is_require hints bitmask args ) | ||||
15 | ) { | ||||
16 | 11 | 2µs | next if $f eq 'args'; | ||
17 | 10 | 18µs | *{$f} = sub { my $s = shift; return $s->{$f} }; | ||
18 | } | ||||
19 | 1 | 397µs | 1 | 23µs | } # spent 23µs making 1 call to Devel::StackTrace::Frame::BEGIN@10 |
20 | |||||
21 | { | ||||
22 | 2 | 2µs | my @fields = ( | ||
23 | qw( package filename line subroutine hasargs wantarray | ||||
24 | evaltext is_require hints bitmask ) | ||||
25 | ); | ||||
26 | |||||
27 | sub new { | ||||
28 | my $proto = shift; | ||||
29 | my $class = ref $proto || $proto; | ||||
30 | |||||
31 | my $self = bless {}, $class; | ||||
32 | |||||
33 | @{$self}{@fields} = @{ shift() }; | ||||
34 | |||||
35 | # fixup unix-style paths on win32 | ||||
36 | $self->{filename} = File::Spec->canonpath( $self->{filename} ); | ||||
37 | |||||
38 | $self->{args} = shift; | ||||
39 | |||||
40 | $self->{respect_overload} = shift; | ||||
41 | |||||
42 | $self->{max_arg_length} = shift; | ||||
43 | |||||
44 | $self->{message} = shift; | ||||
45 | |||||
46 | $self->{indent} = shift; | ||||
47 | |||||
48 | return $self; | ||||
49 | } | ||||
50 | } | ||||
51 | |||||
52 | sub args { | ||||
53 | my $self = shift; | ||||
54 | |||||
55 | return @{ $self->{args} }; | ||||
56 | } | ||||
57 | |||||
58 | sub as_string { | ||||
59 | my $self = shift; | ||||
60 | my $first = shift; | ||||
61 | my $p = shift; | ||||
62 | |||||
63 | my $sub = $self->subroutine; | ||||
64 | |||||
65 | # This code stolen straight from Carp.pm and then tweaked. All | ||||
66 | # errors are probably my fault -dave | ||||
67 | if ($first) { | ||||
68 | $sub | ||||
69 | = defined $self->{message} | ||||
70 | ? $self->{message} | ||||
71 | : 'Trace begun'; | ||||
72 | } | ||||
73 | else { | ||||
74 | |||||
75 | # Build a string, $sub, which names the sub-routine called. | ||||
76 | # This may also be "require ...", "eval '...' or "eval {...}" | ||||
77 | if ( my $eval = $self->evaltext ) { | ||||
78 | if ( $self->is_require ) { | ||||
79 | $sub = "require $eval"; | ||||
80 | } | ||||
81 | else { | ||||
82 | $eval =~ s/([\\\'])/\\$1/g; | ||||
83 | $sub = "eval '$eval'"; | ||||
84 | } | ||||
85 | } | ||||
86 | elsif ( $sub eq '(eval)' ) { | ||||
87 | $sub = 'eval {...}'; | ||||
88 | } | ||||
89 | |||||
90 | # if there are any arguments in the sub-routine call, format | ||||
91 | # them according to the format variables defined earlier in | ||||
92 | # this file and join them onto the $sub sub-routine string | ||||
93 | # | ||||
94 | # We copy them because they're going to be modified. | ||||
95 | # | ||||
96 | if ( my @a = $self->args ) { | ||||
97 | for (@a) { | ||||
98 | |||||
99 | # set args to the string "undef" if undefined | ||||
100 | $_ = "undef", next unless defined $_; | ||||
101 | |||||
102 | # hack! | ||||
103 | $_ = $self->Devel::StackTrace::_ref_to_string($_) | ||||
104 | if ref $_; | ||||
105 | |||||
106 | local $SIG{__DIE__}; | ||||
107 | local $@; | ||||
108 | |||||
109 | eval { | ||||
110 | my $max_arg_length | ||||
111 | = exists $p->{max_arg_length} | ||||
112 | ? $p->{max_arg_length} | ||||
113 | : $self->{max_arg_length}; | ||||
114 | |||||
115 | if ( $max_arg_length | ||||
116 | && length $_ > $max_arg_length ) { | ||||
117 | substr( $_, $max_arg_length ) = '...'; | ||||
118 | } | ||||
119 | |||||
120 | s/'/\\'/g; | ||||
121 | |||||
122 | # 'quote' arg unless it looks like a number | ||||
123 | $_ = "'$_'" unless /^-?[\d.]+$/; | ||||
124 | |||||
125 | # print control/high ASCII chars as 'M-<char>' or '^<char>' | ||||
126 | s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg; | ||||
127 | s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg; | ||||
128 | }; | ||||
129 | |||||
130 | if ( my $e = $@ ) { | ||||
131 | $_ = $e =~ /malformed utf-8/i ? '(bad utf-8)' : '?'; | ||||
132 | } | ||||
133 | } | ||||
134 | |||||
135 | # append ('all', 'the', 'arguments') to the $sub string | ||||
136 | $sub .= '(' . join( ', ', @a ) . ')'; | ||||
137 | $sub .= ' called'; | ||||
138 | } | ||||
139 | } | ||||
140 | |||||
141 | # If the user opted into indentation (a la Carp::confess), pre-add a tab | ||||
142 | my $tab = $self->{indent} && !$first ? "\t" : q{}; | ||||
143 | |||||
144 | return "${tab}$sub at " . $self->filename . ' line ' . $self->line; | ||||
145 | } | ||||
146 | |||||
147 | 1 | 3µs | 1; | ||
148 | |||||
149 | # ABSTRACT: A single frame in a stack trace | ||||
150 | |||||
151 | __END__ |