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