r1215/r1217 make the warning "isn't a cop" mandatory:

------------------------------------------------------------------------
r1215 | [email protected] | 2010-05-06 23:39:37 +0100 (Thu, 06 May 2010) | 2 
lines

Added CXt_LOOP to cx_block_type and the ability to show the int value for 
unknown types.

------------------------------------------------------------------------

Index: NYTProf.xs
===================================================================
--- NYTProf.xs  (revision 1214)
+++ NYTProf.xs  (revision 1215)
@@ -966,6 +966,7 @@
 
 static const char *
 cx_block_type(PERL_CONTEXT *cx) {
+    char buf[20];
     switch (CxTYPE(cx)) {
     case CXt_NULL:              return "CXt_NULL";
     case CXt_SUB:               return "CXt_SUB";
@@ -979,6 +980,9 @@
 #ifdef CXt_GIVEN
     case CXt_GIVEN:             return "CXt_GIVEN";
 #endif
+#ifdef CXt_LOOP
+    case CXt_LOOP:              return "CXt_LOOP";
+#endif
 #ifdef CXt_LOOP_FOR
     case CXt_LOOP_FOR:          return "CXt_LOOP_FOR";
 #endif
@@ -992,7 +996,11 @@
     case CXt_LOOP_LAZYIV:       return "CXt_LOOP_LAZYIV";
 #endif
     }
-    return "CXt_???";
+    /* short-lived and not thread safe but we only use this for tracing
+     * and it should never be reached anyway
+     */
+    sprintf(buf, "CXt_%d", CxTYPE(cx));
+    return buf;
 }
 
 
@@ -1077,8 +1085,12 @@
                     OutCopFILE((COP*)o));
             return (COP*)o;
         }
+        if (CxTYPE(cx) == CXt_LOOP) {
+            return NULL;
+        }
         /* should never get here but we do */
-        if (trace_level >= trace) {
+        if (trace_level >= trace || 1) {
+            warn("not a cop");
             logwarn("\tstart_cop_of_context %s op '%s' isn't a cop\n",
                 cx_block_type(cx), OP_NAME(o));
             if (trace_level >  trace)



This warning gets hit a lot on 5.12.0 and later, for example:

        start_cop_of_context CXt_LOOP_PLAIN op 'enter' isn't a cop


        start_cop_of_context CXt_LOOP_LAZYIV op 'gvsv' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'concat' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'const' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'concat' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'entereval' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'unstack' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'iter' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'and' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'leaveloop' isn't a cop
        start_cop_of_context CXt_LOOP_LAZYIV op 'const' isn't a cop


(and CXt_LOOP_FOR, but not CXt_LOOP_LAZYSV)


The analagous change to r1215/r1217 is:

diff --git a/NYTProf.xs b/NYTProf.xs
index 3bb4880..a386d83 100644
--- a/NYTProf.xs
+++ b/NYTProf.xs
@@ -1090,6 +1090,12 @@ start_cop_of_context(pTHX_ PERL_CONTEXT *cx)
         if (CxTYPE(cx) == CXt_LOOP)
             return NULL;
 #endif
+#if defined (CXt_LOOP_PLAIN) && defined (CXt_LOOP_FOR) && defined(CXt_LOOP_LAZY
+            /* This is Perl 5.11.0 or later */
+        if (CxTYPE(cx) == CXt_LOOP_PLAIN || CxTYPE(cx) == CXt_LOOP_FOR
+        || CxTYPE(cx) == CXt_LOOP_LAZYIV || CxTYPE(cx) == CXt_LOOP_LAZYSV)
+            return NULL;
+#endif
         /* should never get here but we do */
         if (trace_level >= trace || 1) {
             logwarn("\tstart_cop_of_context %s op '%s' isn't a cop\n",



Is this correct? I don't really understand what that part of the code is
doing.

Certainly, something needs to change before a production release is cut.

Nicholas Clark

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