Author: tim.bunce
Date: Sun Mar 8 07:48:47 2009
New Revision: 704
Modified:
trunk/NYTProf.xs
Log:
Add special case for NTP_write with length 0 as fwrite with len==0 is
problematic (http://www.opengroup.org/platform/resolutions/bwg98-007.html)
When using compression this code isn't executed, and the compression code
handles len==0 properly, which is why we've not encountered this before.
Use gv_fetchfile_flags if available.
Fix line count in save src log message.
Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs (original)
+++ trunk/NYTProf.xs Sun Mar 8 07:48:47 2009
@@ -676,10 +676,14 @@
size_t result = 0;
#endif
if (FILE_STATE(ofile) == NYTP_FILE_STDIO) {
+ /* fwrite with len==0 is problematic */
+ /* http://www.opengroup.org/platform/resolutions/bwg98-007.html */
+ if (len == 0)
+ return len;
if (fwrite(buffer, 1, len, ofile->file) < 1) {
dTHX;
- croak("fwrite error %d: %s", errno,
- strerror(errno));
+ croak("fwrite error %d writing %ld bytes to fd%d: %s",
+ errno, (long)len, fileno(ofile->file), strerror(errno));
}
return len;
}
@@ -1257,7 +1261,11 @@
|| (profile_opts & NYTP_OPTf_SAVESRC)
) {
/* source only available if PERLDB_LINE or PERLDB_SAVESRC is true
*/
+#ifdef gv_fetchfile_flags
+ src_av = GvAV(gv_fetchfile_flags(found->key, found->key_len, 0));
+#else
src_av = GvAV(gv_fetchfile(found->key));
+#endif
if (!src_av && trace_level >= 3)
warn("No source available for fid %d%s\n",
found->id, use_db_sub ? "" : ", set use_db_sub=1 option");
@@ -1278,7 +1286,7 @@
I32 lines = av_len(src_av);
int line;
if (trace_level >= 4)
- warn("fid %d has %ld src lines", found->id, (long)lines+1);
+ warn("fid %d has %ld src lines", found->id, (long)lines);
for (line = 1; line <= lines; ++line) { /* lines start at 1 */
SV **svp = av_fetch(src_av, line, 0);
STRLEN len = 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]
-~----------~----~----~----~------~----~------~--~---