Author: tim.bunce
Date: Sat Jun 13 15:10:12 2009
New Revision: 769
Modified:
trunk/Changes
trunk/NYTProf.xs
Log:
Fixed suprious "Unable to determine line number" warnings
when using options like -p, -n, -Mfoo.
Modified: trunk/Changes
==============================================================================
--- trunk/Changes (original)
+++ trunk/Changes Sat Jun 13 15:10:12 2009
@@ -11,6 +11,8 @@
http://code.google.com/p/perl-devel-nytprof/issues/detail?id=15
Fixed to use correct scripts during test and so avoid permissions
issues, thanks to David Golden.
+ Fixed suprious "Unable to determine line number" warnings
+ when using options like -p, -n, -Mfoo.
Changed enable_profile() to discard the time spent since
profile was disabled.
Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs (original)
+++ trunk/NYTProf.xs Sat Jun 13 15:10:12 2009
@@ -1753,10 +1753,25 @@
if (!cop)
cop = PL_curcop_nytprof;
last_executed_line = CopLINE(cop);
- if (!last_executed_line) { /* i.e. finish_profile
called by END */
- /* XXX maybe code due to command line options, like -Mblib */
- if (op)
- warn("Unable to determine line number in %s",
OutCopFILE(cop));
+ if (!last_executed_line) {
+ /* XXX command line options, like -n, -p, -Mfoo etc can cause
this
+ * as perl effectively treats those as 'line 0' so we try not
to warn
+ * in that case (there's probably a better way to detect this)
+ */
+ /* for -n/-p flags we can use strEQ(CopLABEL(cop),"LINE")
+ * but that's doesn't work for -Mfoo.
+ * XXX We could probably check for various stack pointers
+ * being (nearly?) empty as a good indicator of being at the
+ * outermost level of perl.
+ */
+ int is_preamble = (strEQ(CopSTASHPV(cop),"main"));
+
+ /* op is used a a flag as it's null when called via
finish_profile called by END */
+ if (!is_preamble && op) {
+ warn("Unable to determine line number in %s",
OutCopFILE(cop)); */
+ if (trace_level > 5)
+ do_op_dump(1, PerlIO_stderr(), cop);
+ }
last_executed_line = 1; /* don't want zero line
numbers in data */
}
}
@@ -3372,7 +3387,7 @@
if (SvOK(*svp)) { /* should never happen, perhaps file is
corrupt */
AV *old_av = (AV *)SvRV(*av_fetch(fid_fileinfo_av,
file_num, 1));
SV *old_name = *av_fetch(old_av, 0, 1);
- warn("Fid %d redefined from %s to %s", file_num,
+ warn("Fid %d redefined from %s to %s\n", file_num,
SvPV_nolen(old_name), SvPV_nolen(filename_sv));
}
sv_setsv(*svp, rv);
@@ -3383,7 +3398,7 @@
/* this eval fid refers to the fid that contained the
eval */
SV *eval_fi = *av_fetch(fid_fileinfo_av,
eval_file_num, 1);
if (!SvROK(eval_fi)) { /* should never happen */
- warn("Eval '%s' (fid %d) has unknown invoking
fid %d",
+ warn("Eval '%s' (fid %d) has unknown invoking
fid %d\n",
SvPV_nolen(filename_sv), file_num,
eval_file_num);
/* so make it look like a real file instead of an
eval */
av_store(av, NYTP_FIDi_EVAL_FI, &PL_sv_undef);
--~--~---------~--~----~------------~-------~--~----~
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]
-~----------~----~----~----~------~----~------~--~---