Would it be OK for me to apply the following patch?
It moves the call to normalize_eval_seqn() after the callback runs.
With this change, it's possible to write a program to output a byte-for-byte
identical file via the callback interface.
Without it, it's not, because the callback gets passed the normalised
subroutine names, rather than the originals.
No tests fail with it, but I wasn't sure if there was an architectural reason
why the callback should have the normalised name.
Nicholas Clark
diff --git a/NYTProf.xs b/NYTProf.xs
index a100d30..5c9b9a5 100644
--- a/NYTProf.xs
+++ b/NYTProf.xs
@@ -3737,7 +3737,7 @@ read_nv()
}
-static SV *
+static void
normalize_eval_seqn(pTHX_ SV *sv) {
/* in-place-edit any eval sequence numbers to 0 */
int found = 0;
@@ -3747,7 +3747,7 @@ normalize_eval_seqn(pTHX_ SV *sv) {
char *dst = start;
if (len < 5)
- return sv;
+ return;
/* effectively does $sv =~ s/(?<!$assert) \s \d+/eval 0/xg;
* where $assert is qr/\((?:re_)?eval/ so it only matches '(eval ' and
'(re_eval '
@@ -3778,8 +3778,6 @@ normalize_eval_seqn(pTHX_ SV *sv) {
if (trace_level >= 5)
logwarn("edited it to: %s\n", start);
}
-
- return sv;
}
@@ -4102,8 +4100,6 @@ load_profile_data_from_stream(SV *cb)
unsigned int file_mtime = read_int();
filename_sv = read_str(aTHX_ NULL);
- if (eval_file_num)
- normalize_eval_seqn(aTHX_ filename_sv);
if (cb) {
PUSHMARK(SP);
@@ -4126,6 +4122,9 @@ load_profile_data_from_stream(SV *cb)
break;
}
+ if (eval_file_num)
+ normalize_eval_seqn(aTHX_ filename_sv);
+
if (trace_level >= 2) {
logwarn("Fid %2u is %s (eval %u:%u) 0x%x sz%u mt%u\n",
file_num, SvPV_nolen(filename_sv), eval_file_num,
eval_line_num,
@@ -4231,7 +4230,7 @@ load_profile_data_from_stream(SV *cb)
AV *av;
SV *sv;
unsigned int fid = read_int();
- SV *subname_sv = normalize_eval_seqn(aTHX_ read_str(aTHX_
tmp_str1_sv));
+ SV *subname_sv = read_str(aTHX_ tmp_str1_sv);
unsigned int first_line = read_int();
unsigned int last_line = read_int();
int skip_subinfo_store = 0;
@@ -4258,6 +4257,8 @@ load_profile_data_from_stream(SV *cb)
break;
}
+ normalize_eval_seqn(aTHX_ subname_sv);
+
subname_pv = SvPV(subname_sv, subname_len);
if (trace_level >= 2)
logwarn("Sub %s fid %u lines %u..%u\n",
@@ -4306,7 +4307,7 @@ load_profile_data_from_stream(SV *cb)
int len;
unsigned int fid = read_int();
unsigned int line = read_int();
- SV *caller_subname_sv = normalize_eval_seqn(aTHX_
read_str(aTHX_ tmp_str2_sv));
+ SV *caller_subname_sv = read_str(aTHX_ tmp_str2_sv);
unsigned int count = read_int();
NV incl_time = read_nv();
NV excl_time = read_nv();
@@ -4314,7 +4315,7 @@ load_profile_data_from_stream(SV *cb)
NV scpu_time = read_nv();
NV reci_time = read_nv();
UV rec_depth = read_int();
- SV *called_subname_sv = normalize_eval_seqn(aTHX_
read_str(aTHX_ tmp_str1_sv));
+ SV *called_subname_sv = read_str(aTHX_ tmp_str1_sv);
if (cb) {
PUSHMARK(SP);
@@ -4340,6 +4341,9 @@ load_profile_data_from_stream(SV *cb)
break;
}
+ normalize_eval_seqn(aTHX_ caller_subname_sv);
+ normalize_eval_seqn(aTHX_ called_subname_sv);
+
if (trace_level >= 3)
logwarn("Sub %s called by %s %u:%u: count %d, incl
%"NVff", excl %"NVff", ucpu %"NVff" scpu %"NVff"\n",
SvPV_nolen(called_subname_sv),
SvPV_nolen(caller_subname_sv), fid, line,
--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]