I'm trying to get the merging more reliable. One problem is that there is some
variance in which Perl files XS subroutines are assigned to. XSUBs don't
carry filenames, so NYTProf tries to find "homes" for them by scanning
%DB::sub, the debuggers subroutine->filename mapping hash, to identify
(Perl) subroutines in the same package, and hence get a filename for them.

I've added a heuristic in r1015 to deal with one case I'd found - JSON::XS
adds :lvalue to one of its XSUBs in its BOOT: section, which causes the
interpreter to autoload attributes, which results in entry in %DB::sub for
DynaLoader::BEGIN in .../JSON/XS.pm. I acn spot that because the line range
is illegal.

The problem remaining is that sometimes the XSUB Storable::bootstrap is
attributed to .../Storable.pm, and sometimes to (eval 7)[.../Storable.pm]

It all depends on the order that %DB::sub returns results when it iterates.

So I *assumed* that if I made that code skip anything that matches the
eval "filename" pattern, it would solve this:

However, it seems that this approach makes several unrelated tests fail:

Test Summary Report
-------------------
t/test11.t           (Wstat: 4096 Tests: 97 Failed: 16)
  Failed tests:  3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63
                69, 75, 81, 87, 93
  Non-zero exit status: 16
t/test22-strevala.t  (Wstat: 4096 Tests: 49 Failed: 16)
  Failed tests:  3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33
                36, 39, 42, 45, 48
  Non-zero exit status: 16
t/test51-enable.t    (Wstat: 4096 Tests: 145 Failed: 16)
  Failed tests:  3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93
                102, 111, 120, 129, 138
  Non-zero exit status: 16
t/test61-submerge.t  (Wstat: 4096 Tests: 49 Failed: 16)
  Failed tests:  3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33
                36, 39, 42, 45, 48
  Non-zero exit status: 16


I'm not sure if this is because they are all assuming golden results, and
I've just changed the ordering, or there is a more serious problem. My
assumption was that any "eval" filename that exists has a corresponding
real file to go with it, and that *that* file would get spotted later on
in the %DB::sub iteration. So I'm not sure what to do here. Skipping "eval"
filenames seems conceptually cleaner, but I don't understand *why* it causes
breakage.

Nicholas Clark

--- a/NYTProf.xs
+++ b/NYTProf.xs
@@ -2984,6 +2984,22 @@ parse_DBsub_value(pTHX_ SV *sv, STRLEN *filename_len_p, U
     return 1;
 }
 
+/* Returns a pointer to the ')' after the digits in the (?:re_)?eval prefix.
+   As the prefix length is known, this gives the length of the digits.  */
+
+static char *
+eval_prefix(char *filename, const char *prefix, STRLEN prefix_len) {
+    if (memEQ(filename, prefix, prefix_len)
+        && isdigit(filename[prefix_len])) {
+        char *s = filename + prefix_len + 1;
+
+        while (isdigit(*s))
+            ++s;
+        if (s[0] == ')' && s[1] == '[')
+            return s;
+    }
+    return NULL;
+}
 
 static void
 write_sub_line_ranges(pTHX)
@@ -3032,6 +3048,13 @@ write_sub_line_ranges(pTHX)
         first = strrchr(filename, ':');
         filename_len = (first) ? first - filename : 0;
 
+        /* skip filenames for generated evals /\A\((?:re_)?eval \d+\)\[.*]\z/
+         */
+        if (filename_len > 9 && filename[filename_len - 1] == ']'
+            && (eval_prefix(filename, "(eval ", 6) ||
+                eval_prefix(filename, "(re_eval ", 9)))
+            continue;
+
         /* get sv for package-of-subname to filename mapping */
         pkg_filename_sv = sub_pkg_filename_sv(aTHX_ sub_name, sub_name_len);
 
-- 
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