Revision: 1376
Author: [email protected]
Date: Sat Oct  2 14:19:06 2010
Log: Improve handling of Class::MOP/Moose generated methods.
A useful step in the right direction.
Also avoids filename length problems caused by old behaviour that would prepend the cwd
to non-absolute names that didn't seem to be evals.

http://code.google.com/p/perl-devel-nytprof/source/detail?r=1376

Modified:
 /trunk/Changes
 /trunk/NYTProf.xs

=======================================
--- /trunk/Changes      Wed Sep 29 14:05:42 2010
+++ /trunk/Changes      Sat Oct  2 14:19:06 2010
@@ -8,9 +8,10 @@

 =head2 Changes in Devel::NYTProf 4.06 (svn XXX) XXX

+  Improved handling of Class::MOP/Moose generated methods.
   Added note to the docs re profiling applications that use Coro.
   Clarified usecputime=1 docs.
-  Updates tests for new functionality in Sub::Name 0.06.
+  Updated tests for new functionality in Sub::Name 0.06.

 =head2 Changes in Devel::NYTProf 4.05 (svn 1359) 15th Sept 2010

=======================================
--- /trunk/NYTProf.xs   Thu Sep 30 03:17:28 2010
+++ /trunk/NYTProf.xs   Sat Oct  2 14:19:06 2010
@@ -340,6 +340,8 @@
 static SV *DB_INIT_cv;
 static SV *DB_END_cv;
 static SV *DB_fin_cv;
+static char *class_mop_evaltag     = " defined at ";
+static int   class_mop_evaltag_len = 12;

static unsigned int ticks_per_sec = 0; /* 0 forces error if not set */

@@ -887,6 +889,22 @@
             found->eval_line_num = 1;
         }
     }
+
+    /* detect Class::MOP #line evals */
+    /* See _add_line_directive() in Class::MOP::Method::Generated */
+    if (!found->eval_fid) {
+ char *tag = ninstr(file_name, file_name+file_name_len, class_mop_evaltag, class_mop_evaltag+class_mop_evaltag_len);
+        if (tag) {
+            char *definer = tag + class_mop_evaltag_len;
+            int len       = file_name_len - (definer - file_name);
+ found->eval_fid = get_file_id(aTHX_ definer, len, created_via); + found->eval_line_num = 1; /* XXX pity Class::MOP doesn't include the line here */
+            if (trace_level >= 1)
+ logwarn("Class::MOP eval for '%.*s' (fid %u:%u) from '%.*s'\n",
+                    len, definer, found->eval_fid, found->eval_line_num,
+                    (int)file_name_len, file_name);
+        }
+    }

     /* is the file is an autosplit, e.g., has a file_name like
      * "../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/errno.al)"
@@ -930,8 +948,7 @@
     found->key_abs = NULL;
     if (!found->eval_fid &&
         !(file_name[0] == '-'
-         && (file_name_len==1
-             || (file_name[1] == 'e' && file_name_len==2))) &&
+ && (file_name_len==1 || (file_name[1]=='e' && file_name_len==2))) &&
 #ifdef WIN32
         /* XXX should we check for UNC names too? */
(file_name_len < 3 || !isALPHA(file_name[0]) || file_name[1] != ':' ||
@@ -939,8 +956,7 @@
 #else
         *file_name != '/'
 #endif
-        )
-    {
+    ) {
         char file_name_abs[MAXPATHLEN * 2];
         /* Note that the current directory may have changed
             * between loading the file and profiling it.

--
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]

Reply via email to