← Index
NYTProf Performance Profile   « line view »
For /usr/sbin/pkg_info
  Run on Fri Aug 4 10:12:01 2017
Reported on Fri Aug 4 10:12:17 2017

Filename/usr/libdata/perl5/OpenBSD/Error.pm
StatementsExecuted 50 statements in 4.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111327µs335µsOpenBSD::State::::BEGIN@17 OpenBSD::State::BEGIN@17
11147µs47µsOpenBSD::Handler::::reset OpenBSD::Handler::reset
44240µs40µsOpenBSD::Auto::::cache OpenBSD::Auto::cache
11118µs111µsOpenBSD::Error::::BEGIN@72 OpenBSD::Error::BEGIN@72
11117µs33µsOpenBSD::State::::BEGIN@18.5 OpenBSD::State::BEGIN@18.5
11116µs52µsOpenBSD::Auto::::BEGIN@29 OpenBSD::Auto::BEGIN@29
11114µs207µsOpenBSD::Error::::try OpenBSD::Error::try
22211µs11µsOpenBSD::Handler::::register OpenBSD::Handler::register
11110µs120µsOpenBSD::Auto::::__ANON__[:28] OpenBSD::Auto::__ANON__[:28]
1114µs4µsOpenBSD::Error::::dienow OpenBSD::Error::dienow
1113µs3µsOpenBSD::Error::::catchall OpenBSD::Error::catchall
0000s0sOpenBSD::Error::::Copy OpenBSD::Error::Copy
0000s0sOpenBSD::Error::::Unlink OpenBSD::Error::Unlink
0000s0sOpenBSD::Error::::catch OpenBSD::Error::catch
0000s0sOpenBSD::Error::catch::::exec OpenBSD::Error::catch::exec
0000s0sOpenBSD::Error::catchall::::execOpenBSD::Error::catchall::exec
0000s0sOpenBSD::Error::::child_error OpenBSD::Error::child_error
0000s0sOpenBSD::Error::::fillup_names OpenBSD::Error::fillup_names
0000s0sOpenBSD::Error::::find_signal OpenBSD::Error::find_signal
0000s0sOpenBSD::Error::::rethrow OpenBSD::Error::rethrow
0000s0sOpenBSD::Error::::rmtree OpenBSD::Error::rmtree
0000s0sOpenBSD::Error::::throw OpenBSD::Error::throw
0000s0sOpenBSD::Handler::::__ANON__[:50] OpenBSD::Handler::__ANON__[:50]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ex:ts=8 sw=4:
2# $OpenBSD: Error.pm,v 1.32 2017/04/18 15:12:00 espie Exp $
3#
4# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
5#
6# Permission to use, copy, modify, and distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9#
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
172100µs2342µs
# spent 335µs (327+8) within OpenBSD::State::BEGIN@17 which was called: # once (327µs+8µs) by OpenBSD::State::BEGIN@88 at line 17
use strict;
# spent 335µs making 1 call to OpenBSD::State::BEGIN@17 # spent 8µs making 1 call to strict::import
182422µs250µs
# spent 33µs (17+16) within OpenBSD::State::BEGIN@18.5 which was called: # once (17µs+16µs) by OpenBSD::State::BEGIN@88 at line 18
use warnings;
# spent 33µs making 1 call to OpenBSD::State::BEGIN@18.5 # spent 16µs making 1 call to warnings::import
19
20package OpenBSD::Auto;
21sub cache(*&)
22
# spent 40µs within OpenBSD::Auto::cache which was called 4 times, avg 10µs/call: # once (13µs+0s) by main::BEGIN@22 at line 137 of OpenBSD/State.pm # once (13µs+0s) by OpenBSD::PackageRepository::BEGIN@30 at line 54 of OpenBSD/PackageLocation.pm # once (7µs+0s) by main::BEGIN@22 at line 366 of OpenBSD/State.pm # once (7µs+0s) by OpenBSD::PackageRepository::BEGIN@30 at line 68 of OpenBSD/PackageLocation.pm
{
2345µs my ($sym, $code) = @_;
2444µs my $callpkg = caller;
25
# spent 120µs (10+110) within OpenBSD::Auto::__ANON__[/usr/libdata/perl5/OpenBSD/Error.pm:28] which was called: # once (10µs+110µs) by OpenBSD::PackageRepository::parse at line 118 of OpenBSD/PackageRepository.pm
my $actual = sub {
2611µs my $self = shift;
2718µs1110µs return $self->{$sym} //= &$code($self);
# spent 110µs making 1 call to OpenBSD::State::__ANON__[OpenBSD/State.pm:137]
28410µs };
292543µs287µs
# spent 52µs (16+35) within OpenBSD::Auto::BEGIN@29 which was called: # once (16µs+35µs) by OpenBSD::State::BEGIN@88 at line 29
no strict 'refs';
# spent 52µs making 1 call to OpenBSD::Auto::BEGIN@29 # spent 35µs making 1 call to strict::unimport
30432µs *{$callpkg."::$sym"} = $actual;
31}
32
33package OpenBSD::Handler;
34
35117µsmy $list = [];
36
37sub register
38
# spent 11µs within OpenBSD::Handler::register which was called 2 times, avg 5µs/call: # once (6µs+0s) by OpenBSD::PackageLocation::BEGIN@24 at line 44 of OpenBSD/Temp.pm # once (5µs+0s) by OpenBSD::PackageLocator::BEGIN@24 at line 91 of OpenBSD/PackageRepository.pm
{
3922µs my ($class, $code) = @_;
40213µs push(@$list, $code);
41}
42
43my $handler = sub {
44 my $sig = shift;
45 for my $c (@$list) {
46 &$c($sig);
47 }
48 $SIG{$sig} = 'DEFAULT';
49 kill $sig, $$;
5016µs};
51
52sub reset
53
# spent 47µs within OpenBSD::Handler::reset which was called: # once (47µs+0s) by OpenBSD::State::BEGIN@88 at line 61
{
54129µs $SIG{'INT'} = $handler;
5513µs $SIG{'QUIT'} = $handler;
5614µs $SIG{'HUP'} = $handler;
5715µs $SIG{'KILL'} = $handler;
58116µs $SIG{'TERM'} = $handler;
59}
60
6115µs147µs__PACKAGE__->reset;
# spent 47µs making 1 call to OpenBSD::Handler::reset
62
63package OpenBSD::Error;
6411µsrequire Exporter;
65113µsour @ISA=qw(Exporter);
6614µsour @EXPORT=qw(Copy Unlink try throw catch catchall rethrow);
67
68our ($FileName, $Line, $FullMessage);
69
7011µsmy @signal_name = ();
71
7222.97ms2204µs
# spent 111µs (18+93) within OpenBSD::Error::BEGIN@72 which was called: # once (18µs+93µs) by OpenBSD::State::BEGIN@88 at line 72
use Carp;
# spent 111µs making 1 call to OpenBSD::Error::BEGIN@72 # spent 93µs making 1 call to Exporter::import
73
74sub fillup_names
75{
76 {
77 # XXX force autoload
78 package verylocal;
79
80 require POSIX;
81 POSIX->import(qw(signal_h));
82 }
83
84 for my $sym (keys %POSIX::) {
85 next unless $sym =~ /^SIG([A-Z].*)/;
86 my $i = eval "&POSIX::$sym()";
87 next unless defined $i;
88 $signal_name[$i] = $1;
89 }
90 # extra BSD signals
91 $signal_name[5] = 'TRAP';
92 $signal_name[7] = 'IOT';
93 $signal_name[10] = 'BUS';
94 $signal_name[12] = 'SYS';
95 $signal_name[16] = 'URG';
96 $signal_name[23] = 'IO';
97 $signal_name[24] = 'XCPU';
98 $signal_name[25] = 'XFSZ';
99 $signal_name[26] = 'VTALRM';
100 $signal_name[27] = 'PROF';
101 $signal_name[28] = 'WINCH';
102 $signal_name[29] = 'INFO';
103}
104
105sub find_signal
106{
107 my $number = shift;
108
109 if (@signal_name == 0) {
110 fillup_names();
111 }
112
113 return $signal_name[$number] || $number;
114}
115
116sub child_error
117{
118 my $error = shift // $?;
119
120 my $extra = "";
121
122 if ($error & 128) {
123 $extra = " (core dumped)";
124 }
125 if ($error & 127) {
126 return "killed by signal ". find_signal($error & 127).$extra;
127 } else {
128 return "exit(". ($error >> 8) . ")$extra";
129 }
130}
131
132sub Copy
133{
134 require File::Copy;
135
136 my $r = File::Copy::copy(@_);
137 if (!$r) {
138 print "copy(", join(',', @_),") failed: $!\n";
139 }
140 return $r;
141}
142
143sub Unlink
144{
145 my $verbose = shift;
146 my $r = unlink @_;
147 if ($r != @_) {
148 print "rm @_ failed: removed only $r targets, $!\n";
149 } elsif ($verbose) {
150 print "rm @_\n";
151 }
152 return $r;
153}
154
155sub dienow
156
# spent 4µs within OpenBSD::Error::dienow which was called: # once (4µs+0s) by OpenBSD::Error::try at line 176
{
15711µs my ($error, $handler) = @_;
15814µs if ($error) {
159 if ($error =~ m/^(.*?)(?:\s+at\s+(.*)\s+line\s+(\d+)\.?)?$/o) {
160 local $_ = $1;
161 $FileName = $2;
162 $Line = $3;
163 $FullMessage = $error;
164
165 $handler->exec($error, '', $1, $2, $3);
166 } else {
167 die "Fatal error: can't parse $error";
168 }
169 }
170}
171
172sub try(&@)
173
# spent 207µs (14+193) within OpenBSD::Error::try which was called: # once (14µs+193µs) by OpenBSD::State::do_options at line 271 of OpenBSD/State.pm
{
17411µs my ($try, $catch) = @_;
17524µs1190µs eval { &$try };
# spent 190µs making 1 call to OpenBSD::State::__ANON__[OpenBSD/State.pm:269]
17617µs14µs dienow($@, $catch);
# spent 4µs making 1 call to OpenBSD::Error::dienow
177}
178
179sub throw
180{
181 croak @_;
182
183}
184
185sub rethrow
186{
187 my $e = shift;
188 die $e if $e;
189}
190
191sub catch(&)
192{
193 bless $_[0], "OpenBSD::Error::catch";
194}
195
196sub catchall(&)
197
# spent 3µs within OpenBSD::Error::catchall which was called: # once (3µs+0s) by OpenBSD::State::do_options at line 271 of OpenBSD/State.pm
{
19816µs bless $_[0], "OpenBSD::Error::catchall";
199}
200
201sub rmtree
202{
203 my $class = shift;
204 require File::Path;
205 require Cwd;
206
207 # XXX make sure we live somewhere
208 Cwd::getcwd() || chdir('/');
209
210 File::Path::rmtree(@_);
211}
212
213package OpenBSD::Error::catch;
214sub exec
215{
216 my ($self, $full, $e) = @_;
217 if ($e) {
218 &$self;
219 } else {
220 die $full;
221 }
222}
223
224package OpenBSD::Error::catchall;
225sub exec
226{
227 my ($self, $full, $e) = @_;
228 &$self;
229}
230
231114µs1;