PERL_OP_ENTRY(tmp_name, file, line, stash); \
}
+# define LOADING_FILE_PROBE(name) \
+ if (PERL_LOADING_FILE_ENABLED()) { \
+ const char *tmp_name = name; \
+ PERL_LOADING_FILE(tmp_name); \
+ }
+
+# define LOADED_FILE_PROBE(name) \
+ if (PERL_LOADED_FILE_ENABLED()) { \
+ const char *tmp_name = name; \
+ PERL_LOADED_FILE(tmp_name); \
+ }
+
# else
# define ENTRY_PROBE(func, file, line, stash) \
PERL_OP_ENTRY(name); \
}
+# define LOADING_FILE_PROBE(name) \
+ if (PERL_LOADING_FILE_ENABLED()) { \
+ PERL_LOADING_FILE(name); \
+ }
+
+# define LOADED_FILE_PROBE(name) \
+ if (PERL_LOADED_FILE_ENABLED()) { \
+ PERL_LOADED_FILE(name); \
+ }
+
# endif
# define PHASE_CHANGE_PROBE(new_phase, old_phase) \
# define RETURN_PROBE(func, file, line, stash)
# define PHASE_CHANGE_PROBE(new_phase, old_phase)
# define OP_ENTRY_PROBE(name)
+# define LOADING_FILE_PROBE(name)
+# define LOADED_FILE_PROBE(name)
#endif
probe phase__change(const char *, const char *);
probe op__entry(const char *);
+
+ probe loading__file(const char *);
+ probe loaded__file(const char *);
};
/*
=item 5.18.0
-The C<op-entry> probe was added.
+The C<op-entry>, C<loading-file>, and C<loaded-file> probes weree added.
=back
printf("About to execute opcode %s\n", copyinstr(arg0));
}
+=item loading-file(FILENAME)
+
+Fires when Perl is about to load an individual file, whether from
+C<use>, C<require>, or C<do>. This probe fires before the file is
+read from disk. The filename argument is converted to local filesystem
+paths instead of providing C<Module::Name>-style names.
+
+ :*perl*:loading-file {
+ printf("About to load %s\n", copyinstr(arg0));
+ }
+
+=item loaded-file(FILENAME)
+
+Fires when Perl has successfully loaded an individual file, whether
+from C<use>, C<require>, or C<do>. This probe fires after the file
+is read from disk and its contentss evaluated. The filename argument
+is converted to local filesystem paths instead of providing
+C<Module::Name>-style names.
+
+ :*perl*:loaded-file {
+ printf("Successfully loaded %s\n", copyinstr(arg0));
+ }
+
=back
=head1 EXAMPLES
Exporter::Heavy::_rebuild_cache 5039
Exporter::import 14578
+=item
+
=back
=head1 REFERENCES
}
}
+ LOADING_FILE_PROBE(unixname);
+
/* prepare to compile file */
if (path_is_absolute(name)) {
/* Restore encoding. */
PL_encoding = encoding;
+ LOADED_FILE_PROBE(unixname);
+
return op;
}
use warnings;
use IPC::Open2;
-plan(tests => 7);
+plan(tests => 9);
dtrace_like(
'1',
'basic op probe',
);
+dtrace_like(<< 'PERL_SCRIPT',
+ use strict;
+ require HTTP::Tiny;
+ do "run/dtrace.pl";
+PERL_SCRIPT
+ << 'D_SCRIPT',
+ loading-file { printf("loading-file <%s>\n", copyinstr(arg0)) }
+ loaded-file { printf("loaded-file <%s>\n", copyinstr(arg0)) }
+D_SCRIPT
+ [
+ # the original test made sure that each file generated a loading-file then a loaded-file,
+ # but that had a race condition when the kernel would push the perl process onto a different
+ # CPU, so the DTrace output would appear out of order
+ qr{loading-file <strict\.pm>.*loading-file <HTTP/Tiny\.pm>.*loading-file <run/dtrace\.pl>}s,
+ qr{loaded-file <strict\.pm>.*loaded-file <HTTP/Tiny\.pm>.*loaded-file <run/dtrace\.pl>}s,
+ ],
+ 'loading-file, loaded-file probes',
+);
+
sub dtrace_like {
my $perl = shift;
my $probes = shift;