Author: tim.bunce
Date: Tue Jun  2 14:58:58 2009
New Revision: 746

Modified:
    trunk/Changes
    trunk/NYTProf.xs

Log:
Fixed enable_profile() after fork thanks to delamonpansie
   http://code.google.com/p/perl-devel-nytprof/issues/detail?id=15
Also moved some comments re autosplit to a better place.


Modified: trunk/Changes
==============================================================================
--- trunk/Changes       (original)
+++ trunk/Changes       Tue Jun  2 14:58:58 2009
@@ -7,6 +7,8 @@
  =head2 Changes in Devel::NYTProf 2.10 (svn rXXX) XXX

    Fixed call count for XSubs that was one too high.
+  Fixed enable_profile() after fork thanks to delamonpansie
+    http://code.google.com/p/perl-devel-nytprof/issues/detail?id=15

    Added nytprofcg utility to generate callgrind data for
      viewing via Kcachegrind, thanks to Chia-liang Kao.

Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs    (original)
+++ trunk/NYTProf.xs    Tue Jun  2 14:58:58 2009
@@ -1212,13 +1212,14 @@
          found->eval_line_num = atoi(end+1);
      }

+    /* is the file is an autosplit, e.g., has a file_name like
+     * "../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/errno.al)"
+     */
      if (   ')' == file_name[file_name_len-1] && strstr(file_name, "  
(autosplit ")) {
-        /* flag as autosplit */
          found->fid_flags |= NYTP_FIDf_IS_AUTOSPLIT;
      }

-    /* if the file is an autosplit, with a file_name like
-     * "../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/errno.al)"
+    /* if the file is an autosplit
       * then we want it to have the same fid as the file it was split from.
       * Thankfully that file will almost certainly be in the fid hash,
       * so we can find it and copy the details.
@@ -1983,13 +1984,15 @@
      if (sub_callers_hv)
          hv_clear(sub_callers_hv);

-    /* any data that was unflushed in the parent when it forked
-     * is now duplicated unflushed in this child process.
-     * We need to be a little devious to prevent it getting flushed.
-     */
-    NYTP_close(out, 1); /* 1: discard output, to stop it being flushed to  
disk */
+    if (out) {
+        /* any data that was unflushed in the parent when it forked
+        * is now duplicated unflushed in this child process.
+        * We need to be a little devious to prevent it getting flushed.
+        */
+        NYTP_close(out, 1); /* 1: discard output, to stop it being flushed  
to disk */

-    open_output_file(aTHX_ PROF_output_file);
+        open_output_file(aTHX_ PROF_output_file);
+    }

      return 1;                                     /* have forked */
  }
@@ -2408,6 +2411,8 @@
          warn("NYTProf enable_profile (previously %s) to %s",
              prev_is_profiling ? "enabled" : "disabled",
              (file && *file) ? file : PROF_output_file);
+
+    reinit_if_forked(aTHX);

      if (file && *file && strNE(file, PROF_output_file)) {
          /* caller wants output to go to a new file */

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