diff options
author | dgp <dgp@users.sourceforge.net> | 2005-06-21 18:32:52 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-06-21 18:32:52 (GMT) |
commit | 7f3ff45a57343745a50fb144bb29f676e93bd10b (patch) | |
tree | 7a5d98729f8ed233523f770f0a4d43624c466024 /generic/tclTrace.c | |
parent | f068619a503f4d64f3d88a3209a68aef34498fa9 (diff) | |
download | tcl-7f3ff45a57343745a50fb144bb29f676e93bd10b.zip tcl-7f3ff45a57343745a50fb144bb29f676e93bd10b.tar.gz tcl-7f3ff45a57343745a50fb144bb29f676e93bd10b.tar.bz2 |
* generic/tclBasic.c: Added missing walk of the list of active traces
* generic/tclTrace.c: to cleanup references to traces being deleted.
* generic/tclInt.h: [Bug 1201035] Made the walk of the active trace
* tests/trace.test (trace-34.*): list aware of the direction of trace
scanning, so the proper correction can be made. [Bug 1224585]
Diffstat (limited to 'generic/tclTrace.c')
-rw-r--r-- | generic/tclTrace.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/generic/tclTrace.c b/generic/tclTrace.c index d482a6b..c3aaa82 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTrace.c,v 1.24 2005/06/14 13:46:03 dkf Exp $ + * RCS: @(#) $Id: tclTrace.c,v 1.25 2005/06/21 18:33:05 dgp Exp $ */ #include "tclInt.h" @@ -1176,7 +1176,11 @@ Tcl_UntraceCommand(interp, cmdName, flags, proc, clientData) for (activePtr = iPtr->activeCmdTracePtr; activePtr != NULL; activePtr = activePtr->nextPtr) { if (activePtr->nextTracePtr == tracePtr) { - activePtr->nextTracePtr = tracePtr->nextPtr; + if (activePtr->reverseScan) { + activePtr->nextTracePtr = prevPtr; + } else { + activePtr->nextTracePtr = tracePtr->nextPtr; + } } } if (prevPtr == NULL) { @@ -1395,6 +1399,7 @@ TclCheckExecutionTraces(interp, command, numChars, cmdPtr, code, tracePtr = active.nextTracePtr) { if (traceFlags & TCL_TRACE_LEAVE_EXEC) { /* execute the trace command in order of creation for "leave" */ + active.reverseScan = 1; active.nextTracePtr = NULL; tracePtr = cmdPtr->tracePtr; while (tracePtr->nextPtr != lastTracePtr) { @@ -1402,6 +1407,7 @@ TclCheckExecutionTraces(interp, command, numChars, cmdPtr, code, tracePtr = tracePtr->nextPtr; } } else { + active.reverseScan = 0; active.nextTracePtr = tracePtr->nextPtr; } tcmdPtr = (TraceCommandInfo*)tracePtr->clientData; @@ -1418,7 +1424,9 @@ TclCheckExecutionTraces(interp, command, numChars, cmdPtr, code, ckfree((char*)tcmdPtr); } } - lastTracePtr = tracePtr; + if (active.nextTracePtr) { + lastTracePtr = active.nextTracePtr->nextPtr; + } } iPtr->activeCmdTracePtr = active.nextPtr; if (state) { @@ -1493,6 +1501,7 @@ TclCheckInterpTraces(interp, command, numChars, cmdPtr, code, * Tcl_CreateObjTrace creates one more linked list of traces * which results in one more reversal of trace invocation. */ + active.reverseScan = 1; active.nextTracePtr = NULL; tracePtr = iPtr->tracePtr; while (tracePtr->nextPtr != lastTracePtr) { @@ -1500,6 +1509,7 @@ TclCheckInterpTraces(interp, command, numChars, cmdPtr, code, tracePtr = tracePtr->nextPtr; } } else { + active.reverseScan = 0; active.nextTracePtr = tracePtr->nextPtr; } if (tracePtr->level > 0 && curLevel > tracePtr->level) { @@ -1547,7 +1557,9 @@ TclCheckInterpTraces(interp, command, numChars, cmdPtr, code, tracePtr->flags &= ~TCL_TRACE_EXEC_IN_PROGRESS; Tcl_Release((ClientData) tracePtr); } - lastTracePtr = tracePtr; + if (active.nextTracePtr) { + lastTracePtr = active.nextTracePtr->nextPtr; + } } iPtr->activeInterpTracePtr = active.nextPtr; if (state) { @@ -2219,15 +2231,18 @@ Tcl_DeleteTrace(interp, trace) * Tcl_CreateTrace). */ { Interp *iPtr = (Interp *) interp; - Trace *tracePtr = (Trace *) trace; + Trace *prevPtr, *tracePtr = (Trace *) trace; register Trace **tracePtr2 = &(iPtr->tracePtr); + ActiveInterpTrace *activePtr; /* * Locate the trace entry in the interpreter's trace list, * and remove it from the list. */ + prevPtr = NULL; while ((*tracePtr2) != NULL && (*tracePtr2) != tracePtr) { + prevPtr = *tracePtr2; tracePtr2 = &((*tracePtr2)->nextPtr); } if (*tracePtr2 == NULL) { @@ -2236,6 +2251,23 @@ Tcl_DeleteTrace(interp, trace) (*tracePtr2) = (*tracePtr2)->nextPtr; /* + * The code below makes it possible to delete traces while traces + * are active: it makes sure that the deleted trace won't be + * processed by TclCheckInterpTraces. + */ + + for (activePtr = iPtr->activeInterpTracePtr; activePtr != NULL; + activePtr = activePtr->nextPtr) { + if (activePtr->nextTracePtr == tracePtr) { + if (activePtr->reverseScan) { + activePtr->nextTracePtr = prevPtr; + } else { + activePtr->nextTracePtr = tracePtr->nextPtr; + } + } + } + + /* * If the trace forbids bytecode compilation, change the interpreter's * state. If bytecode compilation is now permitted, flag the fact and * advance the compilation epoch so that procs will be recompiled to |