Revision: 1387
Author: [email protected]
Date: Sat Oct 30 05:54:27 2010
Log: Make stmt and leave trace messages more informative.
Add some (very limited) support for CxMULTICALL.

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

Modified:
 /trunk/NYTProf.xs

=======================================
--- /trunk/NYTProf.xs   Tue Oct 12 07:58:02 2010
+++ /trunk/NYTProf.xs   Sat Oct 30 05:54:27 2010
@@ -1411,7 +1411,7 @@
             NYTP_write_time_line(out, elapsed, overflow, last_executed_fid,
                                  last_executed_line);

-        if (trace_level >= 5)
+ if (trace_level >= 5) /* previous fid:line and how much time we spent there */
             logwarn("\...@%d:%-4d %2ld ticks (%u, %u)\n",
                 last_executed_fid, last_executed_line,
                 elapsed, last_block_line, last_sub_line);
@@ -1459,8 +1459,8 @@
last_executed_fid = get_file_id(aTHX_ file, strlen(file), NYTP_FIDf_VIA_STMT);
     }

-    if (trace_level >= 7)
- logwarn(" @%d:%-4d %s\n", last_executed_fid, last_executed_line,
+    if (trace_level >= 7)   /* show the fid:line we're about to execute */
+ logwarn("\...@%d:%-4d... %s\n", last_executed_fid, last_executed_line,
             (profile_blocks) ? "looking for block and sub lines" : "");

     if (profile_blocks) {
@@ -1492,11 +1492,10 @@


 static void
-DB_leave(pTHX_ OP *op)
-{
-    int saved_errno = errno;
-    unsigned int prev_last_executed_fid  = last_executed_fid;
-    unsigned int prev_last_executed_line = last_executed_line;
+DB_leave(pTHX_ OP *op, OP *prev_op)
+{
+    int saved_errno, is_multicall;
+    unsigned int prev_last_executed_fid, prev_last_executed_line;

     /* Called _after_ ops that indicate we've completed a statement
      * and are returning into the middle of some outer statement.
@@ -1513,6 +1512,20 @@
         return;
 #endif

+    saved_errno = errno;
+    prev_last_executed_fid  = last_executed_fid;
+    prev_last_executed_line = last_executed_line;
+
+#ifdef CxMULTICALL
+    /* pp_return, pp_leavesub and pp_leavesublv
+     * return a NULL op when returning from a MULTICALL.
+     * See Lightweight Callbacks in perlcall.
+     */
+    is_multicall = (!op && CxMULTICALL(&cxstack[cxstack_ix]));
+#else
+    is_multicall = 0;
+#endif
+
     /* measure and output end time of previous statement
      * (earlier than it would have been done)
      * and switch back to measuring the 'calling' statement
@@ -1533,11 +1546,11 @@
     }

     if (trace_level >= 5) {
- logwarn("\tleft %u:%u back to %s at %u:%u (b%u s%u) - discounting next statement%s\n", + logwarn("\tleft %u:%u via %s back to %s at %u:%u (b%u s%u) - discounting next statement%s\n",
             prev_last_executed_fid, prev_last_executed_line,
-            OP_NAME_safe(op),
+            OP_NAME_safe(prev_op), OP_NAME_safe(op),
last_executed_fid, last_executed_line, last_block_line, last_sub_line,
-            (op) ? "" : ", LEAVING PERL"
+            (op || is_multicall) ? "" : ", LEAVING PERL"
         );
     }

@@ -2708,8 +2721,9 @@
 static OP *
pp_leave_profiler(pTHX) /* handles OP_LEAVESUB, OP_LEAVEEVAL, etc */
 {
+    OP *prev_op = PL_op;
     OP *op = run_original_op(PL_op->op_type);
-    DB_leave(aTHX_ op);
+    DB_leave(aTHX_ op, prev_op);
     return op;
 }

@@ -2724,7 +2738,7 @@
 static OP *
pp_exit_profiler(pTHX) /* handles OP_EXIT, OP_EXEC, etc */
 {
- DB_leave(aTHX_ NULL); /* call DB_leave *before* run_original_op() */ + DB_leave(aTHX_ NULL, PL_op); /* call DB_leave *before* run_original_op() */
     if (PL_op->op_type == OP_EXEC)
finish_profile(aTHX); /* this is the last chance we'll get */
     return run_original_op(PL_op->op_type);

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