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