Tcl Source Code

Artifact [9b917c8c34]
Login

Artifact 9b917c8c34a63d52bae0c158ccd94892bec6ae6b:

Attachment "traceinst.patch" to ticket [3059758fff] added by ferrieux 2010-09-20 04:03:24.
Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.494
diff -u -p -r1.494 tclExecute.c
--- generic/tclExecute.c	1 Sep 2010 20:35:33 -0000	1.494
+++ generic/tclExecute.c	18 Sep 2010 15:39:50 -0000
@@ -199,6 +199,7 @@ typedef struct BottomData {
 #define NR_DATA_DIG() \
     do {						\
 	pc = BP->pc;					\
+	pcBeg = pc;					\
 	codePtr = BP->codePtr;				\
 	cleanup = BP->cleanup;				\
 	TAUX.esPtr = iPtr->execEnvPtr->execStackPtr;	\
@@ -362,8 +363,8 @@ VarHashCreateVar(
     while (TAUX.traceInstructions) {				\
 	fprintf(stdout, "%2d: %2d (%u) %s ", iPtr->numLevels,	\
 		(int) CURR_DEPTH,				\
-		(unsigned) (pc - codePtr->codeStart),		\
-		GetOpcodeName(pc));				\
+		(unsigned) (pcBeg - codePtr->codeStart),		\
+		GetOpcodeName(pcBeg));				\
 	printf a;						\
 	break;							\
     }
@@ -376,8 +377,8 @@ VarHashCreateVar(
     while (TAUX.traceInstructions) {				\
 	fprintf(stdout, "%2d: %2d (%u) %s ", iPtr->numLevels,	\
 		(int) CURR_DEPTH,				\
-		(unsigned) (pc - codePtr->codeStart),		\
-		GetOpcodeName(pc));				\
+		(unsigned) (pcBeg - codePtr->codeStart),		\
+		GetOpcodeName(pcBeg));				\
 	printf a;						\
 	TclPrintObject(stdout, objPtr, 30);			\
 	fprintf(stdout, "\n");					\
@@ -1971,6 +1972,8 @@ TclExecuteByteCode(
 				 * stack. */
     const unsigned char *pc = NULL;
 				/* The current program counter. */
+    const unsigned char *pcBeg = NULL;
+				/* The beginning of currently executed INST. */
 
     /*
      * Transfer variables - needed only between opcodes, but not while
@@ -2223,6 +2226,8 @@ TclExecuteByteCode(
 
     TCL_DTRACE_INST_NEXT();
 
+    pcBeg = pc;
+
     /*
      * These two instructions account for 26% of all instructions (according
      * to measurements on tclbench by Ben Vitale
@@ -6262,13 +6267,13 @@ TclExecuteByteCode(
 
     processExceptionReturn:
 #if TCL_COMPILE_DEBUG
-	switch (*pc) {
+	switch (*pcBeg) {
 	case INST_INVOKE_STK1:
-	    opnd = TclGetUInt1AtPtr(pc+1);
+	    opnd = TclGetUInt1AtPtr(pcBeg+1);
 	    TRACE(("%u => ... after \"%.20s\": ", opnd, cmdNameBuf));
 	    break;
 	case INST_INVOKE_STK4:
-	    opnd = TclGetUInt4AtPtr(pc+1);
+	    opnd = TclGetUInt4AtPtr(pcBeg+1);
 	    TRACE(("%u => ... after \"%.20s\": ", opnd, cmdNameBuf));
 	    break;
 	case INST_EVAL_STK: