Revision: 1361
Author: [email protected]
Date: Thu Sep 16 09:51:26 2010
Log: Add signed int i/o. Support signed tick counts for statements.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1361
Modified:
/trunk/Changes
/trunk/FileHandle.h
/trunk/FileHandle.xs
/trunk/NYTProf.xs
=======================================
--- /trunk/Changes Wed Sep 15 02:53:22 2010
+++ /trunk/Changes Thu Sep 16 09:51:26 2010
@@ -12,8 +12,7 @@
Fixed handling of negative values for subroutine line ranges
(that may be added to %DB::sub by buggy software).
Fixed handling of negative times from unstable clocks
- that caused spikes in statement times. (Currently negative
- times cause warnings. In future they'll be handled.)
+ that caused spikes in statement times.
Fixed risk of bad line numbers hanging report generation.
=head2 Changes in Devel::NYTProf 4.04 (svn 1332) 9th July 2010
=======================================
--- /trunk/FileHandle.h Wed Sep 15 02:42:26 2010
+++ /trunk/FileHandle.h Thu Sep 16 09:51:26 2010
@@ -118,5 +118,6 @@
* On the read-side we've not got that far yet (and there's less need).
*/
U32 read_u32(NYTP_file ifile);
+I32 read_i32(NYTP_file ifile);
NV read_nv(NYTP_file ifile);
=======================================
--- /trunk/FileHandle.xs Wed Sep 15 04:57:10 2010
+++ /trunk/FileHandle.xs Thu Sep 16 09:51:26 2010
@@ -695,8 +695,15 @@
}
return NYTP_write(file, buffer, p - buffer);
}
+
+static size_t
+output_tag_i32(NYTP_file file, unsigned char tag, I32 i)
+{
+ return output_tag_u32(file, tag, *( (U32*) &i ) );
+}
#define output_u32(fh, i) output_tag_u32((fh), NYTP_TAG_NO_TAG, (i))
+#define output_i32(fh, i) output_tag_i32((fh), NYTP_TAG_NO_TAG, (i))
/**
@@ -744,6 +751,12 @@
return newint;
}
+I32
+read_i32(NYTP_file ifile) {
+ U32 u = read_u32(ifile);
+ return *( (I32*)&u );
+}
+
static size_t
output_str(NYTP_file file, const char *str, I32 len) { /* negative len
signifies utf8 */
@@ -1019,16 +1032,13 @@
size_t total;
size_t retval;
- if (overflow) /* XXX temp - needs protocol change to add new tag
*/
+ if (overflow) {
+ /* XXX needs protocol change to output a new time-overflow tag */
fprintf(stderr, "profile time overflow of %lu seconds
discarded!\n",
(unsigned long)overflow);
-
- if (elapsed < 0) { /* XXX temp - needs support for signed ints */
- fprintf(stderr, "Negative ticks %ld recorded as 0\n",
(long)elapsed);
- elapsed = 0;
}
- total = retval = output_tag_u32(ofile, tag, elapsed);
+ total = retval = output_tag_i32(ofile, tag, elapsed);
if (retval < 1)
return retval;
=======================================
--- /trunk/NYTProf.xs Wed Sep 15 02:42:26 2010
+++ /trunk/NYTProf.xs Thu Sep 16 09:51:26 2010
@@ -3681,13 +3681,13 @@
NV seconds;
unsigned int eval_file_num = 0;
unsigned int eval_line_num = 0;
- unsigned int ticks;
+ I32 ticks;
unsigned int file_num;
unsigned int line_num;
va_start(args, tag);
- ticks = va_arg(args, unsigned int);
+ ticks = va_arg(args, I32);
file_num = va_arg(args, unsigned int);
line_num = va_arg(args, unsigned int);
@@ -3705,8 +3705,8 @@
const char *new_file_name = "";
if (file_num != state->last_file_num && SvROK(fid_info_rvav))
new_file_name = SvPV_nolen(*av_fetch((AV
*)SvRV(fid_info_rvav), NYTP_FIDi_FILENAME, 1));
- logwarn("Read %d:%-4d %2u ticks%s %s\n",
- file_num, line_num, ticks, trace_note, new_file_name);
+ logwarn("Read %d:%-4d %2ld ticks%s %s\n",
+ file_num, line_num, (long)ticks, trace_note,
new_file_name);
}
add_entry(aTHX_ state->fid_line_time_av, file_num, line_num,
@@ -4186,8 +4186,8 @@
{STR_WITH_LEN("VERSION"), "uu"},
{STR_WITH_LEN("ATTRIBUTE"), "33"},
{STR_WITH_LEN("COMMENT"), "3"},
- {STR_WITH_LEN("TIME_BLOCK"), "uuuuu"},
- {STR_WITH_LEN("TIME_LINE"), "uuu"},
+ {STR_WITH_LEN("TIME_BLOCK"), "iuuuu"},
+ {STR_WITH_LEN("TIME_LINE"), "iuu"},
{STR_WITH_LEN("DISCOUNT"), ""},
{STR_WITH_LEN("NEW_FID"), "uuuuuuS"},
{STR_WITH_LEN("SRC_LINE"), "uuS"},
@@ -4245,6 +4245,14 @@
XPUSHs(cb_args[i++]);
break;
}
+ case 'i':
+ {
+ I32 i32 = va_arg(args, I32);
+
+ sv_setuv(cb_args[i], i32);
+ XPUSHs(cb_args[i++]);
+ break;
+ }
case 'n':
{
NV n = va_arg(args, NV);
@@ -4405,7 +4413,7 @@
case NYTP_TAG_TIME_LINE: /*FALLTHRU*/
case NYTP_TAG_TIME_BLOCK:
{
- unsigned int ticks = read_u32(in);
+ I32 ticks = read_i32(in);
unsigned int file_num = read_u32(in);
unsigned int line_num = read_u32(in);
unsigned int block_line_num = 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]