Author: tim.bunce
Date: Tue Jan 20 05:00:55 2009
New Revision: 672
Modified:
trunk/NYTProf.xs
trunk/t/test22-strevala.rdt
trunk/t/test61-submerge.rdt
Log:
Fix core dump at trace level >= 4.
Make option zero available via env var (it's useful for diff'ing trace
output).
When merging sub info (e.g., due to eval seqn number being normalized to 0)
store the details of the lowest fid seen. This is needed to make the tests
pass between different versions of perl with different hash key orders.
Update effected tests.
Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs (original)
+++ trunk/NYTProf.xs Tue Jan 20 05:00:55 2009
@@ -1253,7 +1253,7 @@
if (trace_level >= 4) {
if (found)
warn("fid %d: %.*s\n", found->id, found->key_len,
found->key);
- else warn("fid -: %.*s HAS NO FID\n", 0, entry.key_len,
entry.key);
+ else warn("fid -: %.*s HAS NO FID\n", entry.key_len,
entry.key);
}
return (found) ? found->id : 0;
@@ -1797,6 +1797,9 @@
PL_perldb |= PERLDBf_SAVESRC | PERLDBf_SAVESRC_NOSUBS;
}
}
+ else if (strEQ(option, "zero")) {
+ profile_zero = atoi(value);
+ }
else {
struct NYTP_int_options_t *opt_p = options;
const struct NYTP_int_options_t *const opt_end
@@ -2844,9 +2847,13 @@
* 1: start_line - may be undef if not known and not known to be xs
* 2: end_line - ditto
*/
- sv_setuv(*av_fetch(av, NYTP_SIi_CALL_COUNT, 1), 0);
- sv_setnv(*av_fetch(av, NYTP_SIi_INCL_RTIME, 1), 0);
- sv_setnv(*av_fetch(av, NYTP_SIi_EXCL_RTIME, 1), 0);
+ sv_setsv(*av_fetch(av, NYTP_SIi_SUB_NAME, 1),
newSVsv(subname_sv));
+ sv_setuv(*av_fetch(av, NYTP_SIi_CALL_COUNT, 1), 0); /* call
count */
+ sv_setnv(*av_fetch(av, NYTP_SIi_INCL_RTIME, 1), 0.0); /* incl_time
*/
+ sv_setnv(*av_fetch(av, NYTP_SIi_EXCL_RTIME, 1), 0.0); /* excl_time
*/
+ sv_setsv(*av_fetch(av, NYTP_SIi_PROFILE, 1), &PL_sv_undef); /*
ref to profile */
+ sv_setuv(*av_fetch(av, NYTP_SIi_REC_DEPTH, 1), 0); /* rec_depth
*/
+ sv_setnv(*av_fetch(av, NYTP_SIi_RECI_RTIME, 1), 0.0); /* reci_time
*/
sv_setsv(sv, rv);
}
return (AV *)SvRV(sv);
@@ -3248,6 +3255,7 @@
unsigned int fid = read_int();
unsigned int first_line = read_int();
unsigned int last_line = read_int();
+ int skip_subinfo_store = 0;
SV *subname_sv = normalize_eval_seqn(aTHX_ read_str(aTHX_
tmp_str_sv));
STRLEN subname_len;
char *subname_pv;
@@ -3271,28 +3279,32 @@
if (trace_level >= 2)
warn("Sub %s fid %u lines %u..%u\n",
subname_pv, fid, first_line, last_line);
+
av = lookup_subinfo_av(aTHX_ subname_sv, sub_subinfo_hv);
if (SvOK(*av_fetch(av, NYTP_SIi_FID, 1))) {
- /* should only happen for anon subs in string evals */
- /* so we warn for other cases */
+ /* We've already seen this subroutine name.
+ * Should only happen for anon subs in string evals so
we warn
+ * for other cases.
+ */
if (!instr(subname_pv, "__ANON__[(eval"))
warn("Sub %s already defined!", subname_pv);
- /* XXX we simply discard fid etc here,
- * though the fileinfo NYTP_FIDi_SUBS_DEFINED hash
does get
- * an entry for the sub from each fid (ie eval) that
defines it
+
+ /* We could always discard the
fid+first_line+last_line here,
+ * because we already have them stored, but for
consistency
+ * (and for the stability of the tests) we'll prefer
the lowest fid
+ */
+ if (fid > SvUV(*av_fetch(av, NYTP_SIi_FID, 1)))
+ skip_subinfo_store = 1;
+
+ /* Finally, note that the fileinfo
NYTP_FIDi_SUBS_DEFINED hash,
+ * updated below, does get an entry for the sub *from
each fid*
+ * (ie string eval) that defines the subroutine.
*/
}
- else {
+ if (!skip_subinfo_store) {
sv_setuv(*av_fetch(av, NYTP_SIi_FID, 1), fid);
sv_setuv(*av_fetch(av, NYTP_SIi_FIRST_LINE, 1),
first_line);
sv_setuv(*av_fetch(av, NYTP_SIi_LAST_LINE, 1),
last_line);
- sv_setuv(*av_fetch(av, NYTP_SIi_CALL_COUNT, 1), 0);
/* call count */
- sv_setnv(*av_fetch(av, NYTP_SIi_INCL_RTIME, 1), 0.0);
/* incl_time */
- sv_setnv(*av_fetch(av, NYTP_SIi_EXCL_RTIME, 1), 0.0);
/* excl_time */
- sv_setsv(*av_fetch(av, NYTP_SIi_SUB_NAME, 1),
subname_sv);
- sv_setsv(*av_fetch(av, NYTP_SIi_PROFILE, 1),
&PL_sv_undef); /* ref to profile */
- sv_setuv(*av_fetch(av, NYTP_SIi_REC_DEPTH, 1), 0);
/* rec_depth */
- sv_setnv(*av_fetch(av, NYTP_SIi_RECI_RTIME, 1), 0.0);
/* reci_time */
}
/* add sub to NYTP_FIDi_SUBS_DEFINED hash */
Modified: trunk/t/test22-strevala.rdt
==============================================================================
--- trunk/t/test22-strevala.rdt (original)
+++ trunk/t/test22-strevala.rdt Tue Jan 20 05:00:55 2009
@@ -73,7 +73,7 @@
profile_modes fid_block_time block
profile_modes fid_line_time line
profile_modes fid_sub_time sub
-sub_subinfo main::__ANON__[(eval 0)[(eval 0)[test22-strevala.p:12]:2]:1]
[
7 1 1 2 0 0 0 0 ]
+sub_subinfo main::__ANON__[(eval 0)[(eval 0)[test22-strevala.p:12]:2]:1]
[
6 1 1 2 0 0 0 0 ]
sub_subinfo main::__ANON__[(eval 0)[(eval 0)[test22-strevala.p:12]:2]:1]
called_by 5 2 [ 2 0 0 0 0 0 0 ]
sub_subinfo main::__ANON__[(eval 0)[test22-strevala.p:6]:1] [ 2 1 1 1 0 0
0 0 ]
sub_subinfo main::__ANON__[(eval 0)[test22-strevala.p:6]:1] called_by
1 6
[ 1 0 0 0 0 0 0 ]
Modified: trunk/t/test61-submerge.rdt
==============================================================================
--- trunk/t/test61-submerge.rdt (original)
+++ trunk/t/test61-submerge.rdt Tue Jan 20 05:00:55 2009
@@ -46,7 +46,7 @@
profile_modes fid_block_time block
profile_modes fid_line_time line
profile_modes fid_sub_time sub
-sub_subinfo main::__ANON__[(eval 0)[test61-submerge.p:8]:1] [ 3 1 1 3 0 0
0 0 ]
+sub_subinfo main::__ANON__[(eval 0)[test61-submerge.p:8]:1] [ 2 1 1 3 0 0
0 0 ]
sub_subinfo main::__ANON__[(eval 0)[test61-submerge.p:8]:1] called_by
1 8
[ 3 0 0 0 0 0 0 ]
sub_subinfo main::foo [ 1 4 4 3 0 0 0 0 ]
sub_subinfo main::foo called_by 2 1 [ 1 0 0 0 0 0 0
]
--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---