Revision: 957 Author: tim.bunce Date: Thu Dec 17 16:01:26 2009 Log: Added some notes & comments re handling of xsubs and opcodes that call back into perl
http://code.google.com/p/perl-devel-nytprof/source/detail?r=957 Modified: /trunk/HACKING /trunk/NYTProf.xs ======================================= --- /trunk/HACKING Sun Jul 12 14:55:24 2009 +++ /trunk/HACKING Thu Dec 17 16:01:26 2009 @@ -364,3 +364,20 @@ The pseudo-sub "main::BEGIN" doesn't appear to be 'called' in NYTProf data. Perhaps it should. + +To stress-test NYTProf using perl's own test suite, set env vars: + NYTPROF='file=/tmp/nytprof.out:addpid=1:nameanonsubs=0:nameevals=0' + PERL5OPT='-d:NYTProf' +and hack t/TEST to not delete the PERL5OPT env var. + +The findcaller option doesn't notice if the caller is an opcode. +Opcodes that call subs (like subst calling utf8::SWASHGET) probably shouldn't +appear as the caller in the call-tree because, while strictly accurate, it's +probably less useful from the users perspective. +Fixing that part is easy but handling incl/excl time needs more thought. + +In the subroutine prologue that currently lists where the sub was called from, +for xsubs & opcodes, add a list of subs that it called (typically none). +That would be handy because currently calls from xsubs & opcodes appear in the +reports at the line of the last _perl_ statement executed, and not in the fake +'stub' that we add to the end of the package source. ======================================= --- /trunk/NYTProf.xs Thu Dec 17 05:46:32 2009 +++ /trunk/NYTProf.xs Thu Dec 17 16:01:26 2009 @@ -2615,6 +2615,12 @@ subr_entry->called_is_xs = "sop"; } + /* These refer to the last perl statement executed, so aren't + * strictly correct where an opcode or xsub is making the call, + * but they're still more useful than nothing. + * In reports the references line shows calls made by the + * opcode or xsub that's called at that line. + */ file = OutCopFILE(prev_cop); subr_entry->caller_fid = (file == last_executed_fileptr) ? last_executed_fid @@ -2695,8 +2701,22 @@ found_caller_by = (profile_findcaller) ? "" : "(calculated)"; } else { - subr_entry->caller_subpkg_pv = caller_subr_entry->called_subpkg_pv; - subr_entry->caller_subnam_sv = SvREFCNT_inc(caller_subr_entry->called_subnam_sv); + subr_entry_t *caller_se = caller_subr_entry; + int caller_is_op = caller_se->called_is_xs && strEQ(caller_se->called_is_xs,"sop"); + /* if the caller is an op then use the caller of that op as our caller. + * that makes more sense from the users perspective (and is consistent + * with the findcaller=1 option). + * XXX disabled for now because (I'm pretty sure) it needs a corresponding + * change in incr_sub_inclusive_time otherwise the incl/excl times are distorted. + */ + if (0 && caller_is_op) { + subr_entry->caller_subpkg_pv = caller_se->caller_subpkg_pv; + subr_entry->caller_subnam_sv = SvREFCNT_inc(caller_se->caller_subnam_sv); + } + else { + subr_entry->caller_subpkg_pv = caller_se->called_subpkg_pv; + subr_entry->caller_subnam_sv = SvREFCNT_inc(caller_se->called_subnam_sv); + } found_caller_by = "(inherited)"; } -- 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]
