| Filename | /usr/lib/x86_64-linux-gnu/perl-base/DynaLoader.pm |
| Statements | Executed 58 statements in 1.21ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 77µs | 77µs | DynaLoader::dl_load_file (xsub) |
| 1 | 1 | 1 | 32µs | 151µs | DynaLoader::bootstrap |
| 2 | 2 | 1 | 14µs | 14µs | DynaLoader::CORE:subst (opcode) |
| 1 | 1 | 1 | 9µs | 11µs | Want::BEGIN@3 |
| 1 | 1 | 1 | 8µs | 71µs | DynaLoader::BEGIN@27 |
| 1 | 1 | 1 | 7µs | 7µs | DynaLoader::CORE:ftdir (opcode) |
| 1 | 1 | 1 | 5µs | 12µs | DynaLoader::BEGIN@31 |
| 1 | 1 | 1 | 5µs | 9µs | DynaLoader::BEGIN@109 |
| 1 | 1 | 1 | 2µs | 2µs | DynaLoader::CORE:ftsize (opcode) |
| 1 | 1 | 1 | 2µs | 2µs | DynaLoader::CORE:ftfile (opcode) |
| 1 | 1 | 1 | 2µs | 2µs | DynaLoader::dl_install_xsub (xsub) |
| 1 | 1 | 1 | 2µs | 2µs | DynaLoader::BEGIN@19 |
| 1 | 1 | 1 | 900ns | 900ns | DynaLoader::dl_find_symbol (xsub) |
| 1 | 1 | 1 | 500ns | 500ns | DynaLoader::dl_load_flags |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::bootstrap_inherit |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::croak |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::dl_expandspec |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::dl_find_symbol_anywhere |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::dl_findfile |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # Generated from DynaLoader_pm.PL, this file is unique for every OS | ||||
| 2 | |||||
| 3 | 2 | 32µs | 2 | 12µs | # spent 11µs (9+2) within Want::BEGIN@3 which was called:
# once (9µs+2µs) by Contextual::Return::BEGIN@361 at line 3 # spent 11µs making 1 call to Want::BEGIN@3
# spent 2µs making 1 call to strict::import |
| 4 | |||||
| 5 | package DynaLoader; | ||||
| 6 | |||||
| 7 | # And Gandalf said: 'Many folk like to know beforehand what is to | ||||
| 8 | # be set on the table; but those who have laboured to prepare the | ||||
| 9 | # feast like to keep their secret; for wonder makes the words of | ||||
| 10 | # praise louder.' | ||||
| 11 | |||||
| 12 | # (Quote from Tolkien suggested by Anno Siegel.) | ||||
| 13 | # | ||||
| 14 | # See pod text at end of file for documentation. | ||||
| 15 | # See also ext/DynaLoader/README in source tree for other information. | ||||
| 16 | # | ||||
| 17 | # Tim.Bunce@ig.co.uk, August 1994 | ||||
| 18 | |||||
| 19 | # spent 2µs within DynaLoader::BEGIN@19 which was called:
# once (2µs+0s) by Contextual::Return::BEGIN@361 at line 21 | ||||
| 20 | 1 | 2µs | our $VERSION = '1.52'; | ||
| 21 | 1 | 26µs | 1 | 2µs | } # spent 2µs making 1 call to DynaLoader::BEGIN@19 |
| 22 | |||||
| 23 | # Note: in almost any other piece of code "our" would have been a better | ||||
| 24 | # option than "use vars", but DynaLoader's bootstrap files need the | ||||
| 25 | # side effect of the variable being declared in any scope whose current | ||||
| 26 | # package is DynaLoader, not just the current lexical one. | ||||
| 27 | 1 | 7µs | 1 | 63µs | # spent 71µs (8+63) within DynaLoader::BEGIN@27 which was called:
# once (8µs+63µs) by Contextual::Return::BEGIN@361 at line 29 # spent 63µs making 1 call to vars::import |
| 28 | $dl_debug @dl_librefs @dl_modules @dl_shared_objects | ||||
| 29 | 1 | 14µs | 1 | 71µs | $dl_dlext $dl_so $dlsrc @args $module @dirs $file $bscode); # spent 71µs making 1 call to DynaLoader::BEGIN@27 |
| 30 | |||||
| 31 | 2 | 187µs | 2 | 18µs | # spent 12µs (5+7) within DynaLoader::BEGIN@31 which was called:
# once (5µs+7µs) by Contextual::Return::BEGIN@361 at line 31 # spent 12µs making 1 call to DynaLoader::BEGIN@31
# spent 7µs making 1 call to Config::import |
| 32 | |||||
| 33 | # enable debug/trace messages from DynaLoader perl code | ||||
| 34 | 1 | 800ns | $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug; | ||
| 35 | |||||
| 36 | # | ||||
| 37 | # Flags to alter dl_load_file behaviour. Assigned bits: | ||||
| 38 | # 0x01 make symbols available for linking later dl_load_file's. | ||||
| 39 | # (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL)) | ||||
| 40 | # (ignored under VMS; effect is built-in to image linking) | ||||
| 41 | # (ignored under Android; the linker always uses RTLD_LOCAL) | ||||
| 42 | # | ||||
| 43 | # This is called as a class method $module->dl_load_flags. The | ||||
| 44 | # definition here will be inherited and result on "default" loading | ||||
| 45 | # behaviour unless a sub-class of DynaLoader defines its own version. | ||||
| 46 | # | ||||
| 47 | |||||
| 48 | 1 | 1µs | # spent 500ns within DynaLoader::dl_load_flags which was called:
# once (500ns+0s) by DynaLoader::bootstrap at line 199 | ||
| 49 | |||||
| 50 | 1 | 7µs | 3 | 4µs | ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)}; # spent 4µs making 3 calls to Config::FETCH, avg 1µs/call |
| 51 | |||||
| 52 | # Some systems need special handling to expand file specifications | ||||
| 53 | # (VMS support by Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU>) | ||||
| 54 | # See dl_expandspec() for more details. Should be harmless but | ||||
| 55 | # inefficient to define on systems that don't need it. | ||||
| 56 | 1 | 300ns | my $do_expand = 0; | ||
| 57 | |||||
| 58 | 1 | 800ns | @dl_require_symbols = (); # names of symbols we need | ||
| 59 | 1 | 100ns | @dl_library_path = (); # path to look for files | ||
| 60 | |||||
| 61 | #XSLoader.pm may have added elements before we were required | ||||
| 62 | #@dl_shared_objects = (); # shared objects for symbols we have | ||||
| 63 | #@dl_librefs = (); # things we have loaded | ||||
| 64 | #@dl_modules = (); # Modules we have loaded | ||||
| 65 | |||||
| 66 | # Initialise @dl_library_path with the 'standard' library path | ||||
| 67 | # for this platform as determined by Configure. | ||||
| 68 | |||||
| 69 | 1 | 2µs | 1 | 600ns | push(@dl_library_path, split(' ', $Config::Config{libpth})); # spent 600ns making 1 call to Config::FETCH |
| 70 | |||||
| 71 | 1 | 900ns | 1 | 700ns | my $ldlibpthname = $Config::Config{ldlibpthname}; # spent 700ns making 1 call to Config::FETCH |
| 72 | 1 | 1µs | 1 | 400ns | my $ldlibpthname_defined = defined $Config::Config{ldlibpthname}; # spent 400ns making 1 call to Config::FETCH |
| 73 | 1 | 800ns | 1 | 700ns | my $pthsep = $Config::Config{path_sep}; # spent 700ns making 1 call to Config::FETCH |
| 74 | |||||
| 75 | # Add to @dl_library_path any extra directories we can gather from environment | ||||
| 76 | # during runtime. | ||||
| 77 | |||||
| 78 | 1 | 500ns | if ($ldlibpthname_defined && | ||
| 79 | exists $ENV{$ldlibpthname}) { | ||||
| 80 | push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname})); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | # E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH. | ||||
| 84 | |||||
| 85 | 1 | 200ns | if ($ldlibpthname_defined && | ||
| 86 | $ldlibpthname ne 'LD_LIBRARY_PATH' && | ||||
| 87 | exists $ENV{LD_LIBRARY_PATH}) { | ||||
| 88 | push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH})); | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||||
| 92 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||||
| 93 | 1 | 500ns | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||
| 94 | !defined(&dl_error); | ||||
| 95 | |||||
| 96 | 1 | 100ns | if ($dl_debug) { | ||
| 97 | print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n"; | ||||
| 98 | print STDERR "DynaLoader not linked into this perl\n" | ||||
| 99 | unless defined(&boot_DynaLoader); | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | 1 | 11µs | 1; # End of main code | ||
| 103 | |||||
| 104 | sub croak { require Carp; Carp::croak(@_) } | ||||
| 105 | |||||
| 106 | sub bootstrap_inherit { | ||||
| 107 | my $module = $_[0]; | ||||
| 108 | |||||
| 109 | 2 | 762µs | 2 | 14µs | # spent 9µs (5+5) within DynaLoader::BEGIN@109 which was called:
# once (5µs+5µs) by Contextual::Return::BEGIN@361 at line 109 # spent 9µs making 1 call to DynaLoader::BEGIN@109
# spent 5µs making 1 call to strict::unimport |
| 110 | local *isa = *{"$module\::ISA"}; | ||||
| 111 | local @isa = (@isa, 'DynaLoader'); | ||||
| 112 | # Cannot goto due to delocalization. Will report errors on a wrong line? | ||||
| 113 | bootstrap(@_); | ||||
| 114 | } | ||||
| 115 | |||||
| 116 | # spent 151µs (32+119) within DynaLoader::bootstrap which was called:
# once (32µs+119µs) by Contextual::Return::BEGIN@361 at line 17 of Want.pm | ||||
| 117 | # use local vars to enable $module.bs script to edit values | ||||
| 118 | 1 | 500ns | local(@args) = @_; | ||
| 119 | 1 | 200ns | local($module) = $args[0]; | ||
| 120 | 1 | 300ns | local(@dirs, $file); | ||
| 121 | |||||
| 122 | 1 | 100ns | unless ($module) { | ||
| 123 | require Carp; | ||||
| 124 | Carp::confess("Usage: DynaLoader::bootstrap(module)"); | ||||
| 125 | } | ||||
| 126 | |||||
| 127 | # A common error on platforms which don't support dynamic loading. | ||||
| 128 | # Since it's fatal and potentially confusing we give a detailed message. | ||||
| 129 | 1 | 200ns | croak("Can't load module $module, dynamic loading not available in this perl.\n". | ||
| 130 | " (You may need to build a new perl executable which either supports\n". | ||||
| 131 | " dynamic loading or has the $module module statically linked into it.)\n") | ||||
| 132 | unless defined(&dl_load_file); | ||||
| 133 | |||||
| 134 | |||||
| 135 | 1 | 900ns | my @modparts = split(/::/,$module); | ||
| 136 | 1 | 300ns | my $modfname = $modparts[-1]; | ||
| 137 | 1 | 200ns | my $modfname_orig = $modfname; # For .bs file search | ||
| 138 | |||||
| 139 | # Some systems have restrictions on files names for DLL's etc. | ||||
| 140 | # mod2fname returns appropriate file base name (typically truncated) | ||||
| 141 | # It may also edit @modparts if required. | ||||
| 142 | 1 | 100ns | $modfname = &mod2fname(\@modparts) if defined &mod2fname; | ||
| 143 | |||||
| 144 | 1 | 500ns | my $modpname = join('/',@modparts); | ||
| 145 | |||||
| 146 | 1 | 100ns | print STDERR "DynaLoader::bootstrap for $module ", | ||
| 147 | "(auto/$modpname/$modfname.$dl_dlext)\n" | ||||
| 148 | if $dl_debug; | ||||
| 149 | |||||
| 150 | 1 | 100ns | my $dir; | ||
| 151 | 1 | 400ns | foreach (@INC) { | ||
| 152 | |||||
| 153 | 1 | 500ns | $dir = "$_/auto/$modpname"; | ||
| 154 | |||||
| 155 | 1 | 10µs | 1 | 7µs | next unless -d $dir; # skip over uninteresting directories # spent 7µs making 1 call to DynaLoader::CORE:ftdir |
| 156 | |||||
| 157 | # check for common cases to avoid autoload of dl_findfile | ||||
| 158 | 1 | 400ns | my $try = "$dir/$modfname.$dl_dlext"; | ||
| 159 | 1 | 6µs | 1 | 2µs | last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try); # spent 2µs making 1 call to DynaLoader::CORE:ftfile |
| 160 | |||||
| 161 | # no luck here, save dir for possible later dl_findfile search | ||||
| 162 | push @dirs, $dir; | ||||
| 163 | } | ||||
| 164 | # last resort, let dl_findfile have a go in all known locations | ||||
| 165 | 1 | 200ns | $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file; | ||
| 166 | |||||
| 167 | 1 | 100ns | croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)") | ||
| 168 | unless $file; # wording similar to error from 'require' | ||||
| 169 | |||||
| 170 | |||||
| 171 | 1 | 200ns | my $bootname = "boot_$module"; | ||
| 172 | 1 | 2µs | 1 | 600ns | $bootname =~ s/\W/_/g; # spent 600ns making 1 call to DynaLoader::CORE:subst |
| 173 | 1 | 300ns | @dl_require_symbols = ($bootname); | ||
| 174 | |||||
| 175 | # Execute optional '.bootstrap' perl script for this module. | ||||
| 176 | # The .bs file can be used to configure @dl_resolve_using etc to | ||||
| 177 | # match the needs of the individual module on this architecture. | ||||
| 178 | # N.B. The .bs file does not following the naming convention used | ||||
| 179 | # by mod2fname. | ||||
| 180 | 1 | 200ns | my $bs = "$dir/$modfname_orig"; | ||
| 181 | 1 | 15µs | 1 | 14µs | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library # spent 14µs making 1 call to DynaLoader::CORE:subst |
| 182 | 1 | 4µs | 1 | 2µs | if (-s $bs) { # only read file if it's not empty # spent 2µs making 1 call to DynaLoader::CORE:ftsize |
| 183 | print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | ||||
| 184 | eval { local @INC = ('.'); do $bs; }; | ||||
| 185 | warn "$bs: $@\n" if $@; | ||||
| 186 | } | ||||
| 187 | |||||
| 188 | 1 | 100ns | my $boot_symbol_ref; | ||
| 189 | |||||
| 190 | |||||
| 191 | |||||
| 192 | # Many dynamic extension loading problems will appear to come from | ||||
| 193 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
| 194 | # Often these errors are actually occurring in the initialisation | ||||
| 195 | # C code of the extension XS file. Perl reports the error as being | ||||
| 196 | # in this perl code simply because this was the last perl code | ||||
| 197 | # it executed. | ||||
| 198 | |||||
| 199 | 1 | 2µs | 1 | 500ns | my $flags = $module->dl_load_flags; # spent 500ns making 1 call to DynaLoader::dl_load_flags |
| 200 | |||||
| 201 | 1 | 81µs | 1 | 77µs | my $libref = dl_load_file($file, $flags) or # spent 77µs making 1 call to DynaLoader::dl_load_file |
| 202 | croak("Can't load '$file' for module $module: ".dl_error()); | ||||
| 203 | |||||
| 204 | 1 | 300ns | push(@dl_librefs,$libref); # record loaded object | ||
| 205 | |||||
| 206 | 1 | 3µs | 1 | 900ns | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or # spent 900ns making 1 call to DynaLoader::dl_find_symbol |
| 207 | croak("Can't find '$bootname' symbol in $file\n"); | ||||
| 208 | |||||
| 209 | 1 | 300ns | push(@dl_modules, $module); # record loaded module | ||
| 210 | |||||
| 211 | 1 | 5µs | 1 | 2µs | boot: # spent 2µs making 1 call to DynaLoader::dl_install_xsub |
| 212 | my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file); | ||||
| 213 | |||||
| 214 | # See comment block above | ||||
| 215 | |||||
| 216 | 1 | 200ns | push(@dl_shared_objects, $file); # record files loaded | ||
| 217 | |||||
| 218 | 1 | 17µs | 1 | 11µs | &$xs(@args); # spent 11µs making 1 call to Want::bootstrap |
| 219 | } | ||||
| 220 | |||||
| 221 | sub dl_findfile { | ||||
| 222 | # This function does not automatically consider the architecture | ||||
| 223 | # or the perl library auto directories. | ||||
| 224 | my (@args) = @_; | ||||
| 225 | my (@dirs, $dir); # which directories to search | ||||
| 226 | my (@found); # full paths to real files we have found | ||||
| 227 | #my $dl_ext= 'so'; # $Config::Config{'dlext'} suffix for perl extensions | ||||
| 228 | #my $dl_so = 'so'; # $Config::Config{'so'} suffix for shared libraries | ||||
| 229 | |||||
| 230 | print STDERR "dl_findfile(@args)\n" if $dl_debug; | ||||
| 231 | |||||
| 232 | # accumulate directories but process files as they appear | ||||
| 233 | arg: foreach(@args) { | ||||
| 234 | # Special fast case: full filepath requires no search | ||||
| 235 | |||||
| 236 | |||||
| 237 | if (m:/: && -f $_) { | ||||
| 238 | push(@found,$_); | ||||
| 239 | last arg unless wantarray; | ||||
| 240 | next; | ||||
| 241 | } | ||||
| 242 | |||||
| 243 | |||||
| 244 | # Deal with directories first: | ||||
| 245 | # Using a -L prefix is the preferred option (faster and more robust) | ||||
| 246 | if ( s{^-L}{} ) { push(@dirs, $_); next; } | ||||
| 247 | |||||
| 248 | # Otherwise we try to try to spot directories by a heuristic | ||||
| 249 | # (this is a more complicated issue than it first appears) | ||||
| 250 | if (m:/: && -d $_) { push(@dirs, $_); next; } | ||||
| 251 | |||||
| 252 | |||||
| 253 | |||||
| 254 | # Only files should get this far... | ||||
| 255 | my(@names, $name); # what filenames to look for | ||||
| 256 | if ( s{^-l}{} ) { # convert -lname to appropriate library name | ||||
| 257 | push(@names, "lib$_.$dl_so", "lib$_.a"); | ||||
| 258 | } else { # Umm, a bare name. Try various alternatives: | ||||
| 259 | # these should be ordered with the most likely first | ||||
| 260 | push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o; | ||||
| 261 | push(@names,"$_.$dl_so") unless m/\.$dl_so$/o; | ||||
| 262 | |||||
| 263 | push(@names,"lib$_.$dl_so") unless m:/:; | ||||
| 264 | push(@names, $_); | ||||
| 265 | } | ||||
| 266 | my $dirsep = '/'; | ||||
| 267 | foreach $dir (@dirs, @dl_library_path) { | ||||
| 268 | next unless -d $dir; | ||||
| 269 | |||||
| 270 | foreach $name (@names) { | ||||
| 271 | my($file) = "$dir$dirsep$name"; | ||||
| 272 | print STDERR " checking in $dir for $name\n" if $dl_debug; | ||||
| 273 | if ($do_expand && ($file = dl_expandspec($file))) { | ||||
| 274 | push @found, $file; | ||||
| 275 | next arg; # no need to look any further | ||||
| 276 | } | ||||
| 277 | elsif (-f $file) { | ||||
| 278 | push(@found, $file); | ||||
| 279 | next arg; # no need to look any further | ||||
| 280 | } | ||||
| 281 | |||||
| 282 | } | ||||
| 283 | } | ||||
| 284 | } | ||||
| 285 | if ($dl_debug) { | ||||
| 286 | foreach(@dirs) { | ||||
| 287 | print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_; | ||||
| 288 | } | ||||
| 289 | print STDERR "dl_findfile found: @found\n"; | ||||
| 290 | } | ||||
| 291 | return $found[0] unless wantarray; | ||||
| 292 | @found; | ||||
| 293 | } | ||||
| 294 | |||||
| 295 | sub dl_expandspec { | ||||
| 296 | my($spec) = @_; | ||||
| 297 | # Optional function invoked if DynaLoader.pm sets $do_expand. | ||||
| 298 | # Most systems do not require or use this function. | ||||
| 299 | # Some systems may implement it in the dl_*.xs file in which case | ||||
| 300 | # this Perl version should be excluded at build time. | ||||
| 301 | |||||
| 302 | # This function is designed to deal with systems which treat some | ||||
| 303 | # 'filenames' in a special way. For example VMS 'Logical Names' | ||||
| 304 | # (something like unix environment variables - but different). | ||||
| 305 | # This function should recognise such names and expand them into | ||||
| 306 | # full file paths. | ||||
| 307 | # Must return undef if $spec is invalid or file does not exist. | ||||
| 308 | |||||
| 309 | my $file = $spec; # default output to input | ||||
| 310 | |||||
| 311 | return undef unless -f $file; | ||||
| 312 | print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug; | ||||
| 313 | $file; | ||||
| 314 | } | ||||
| 315 | |||||
| 316 | sub dl_find_symbol_anywhere | ||||
| 317 | { | ||||
| 318 | my $sym = shift; | ||||
| 319 | my $libref; | ||||
| 320 | foreach $libref (@dl_librefs) { | ||||
| 321 | my $symref = dl_find_symbol($libref,$sym,1); | ||||
| 322 | return $symref if $symref; | ||||
| 323 | } | ||||
| 324 | return undef; | ||||
| 325 | } | ||||
| 326 | |||||
| 327 | __END__ | ||||
# spent 7µs within DynaLoader::CORE:ftdir which was called:
# once (7µs+0s) by DynaLoader::bootstrap at line 155 | |||||
# spent 2µs within DynaLoader::CORE:ftfile which was called:
# once (2µs+0s) by DynaLoader::bootstrap at line 159 | |||||
# spent 2µs within DynaLoader::CORE:ftsize which was called:
# once (2µs+0s) by DynaLoader::bootstrap at line 182 | |||||
sub DynaLoader::CORE:subst; # opcode | |||||
# spent 900ns within DynaLoader::dl_find_symbol which was called:
# once (900ns+0s) by DynaLoader::bootstrap at line 206 | |||||
# spent 2µs within DynaLoader::dl_install_xsub which was called:
# once (2µs+0s) by DynaLoader::bootstrap at line 211 | |||||
# spent 77µs within DynaLoader::dl_load_file which was called:
# once (77µs+0s) by DynaLoader::bootstrap at line 201 |