diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclTrace.c | 19 | ||||
-rw-r--r-- | tests/trace.test | 33 |
3 files changed, 58 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2012-02-06 Miguel Sofer <msofer@users.sf.net> + + * generic/tclTrace.c: Fix for [Bug 3484621]: insure that + * tests/trace.test: execution traces on bytecoded commands bump + the interp's compile epoch. + 2012-02-02 Jan Nijtmans <nijtmans@users.sf.net> * generic/tclUniData.c: [Frq 3464401] Support Unicode 6.1 diff --git a/generic/tclTrace.c b/generic/tclTrace.c index 28e6934..ad81c58 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -1124,6 +1124,16 @@ Tcl_TraceCommand( if (tracePtr->flags & TCL_TRACE_ANY_EXEC) { cmdPtr->flags |= CMD_HAS_EXEC_TRACES; } + + /* + * Bug 3484621: up the interp's epoch if this is a BC'ed command + */ + + if (cmdPtr->compileProc != NULL) { + Interp *iPtr = (Interp *) interp; + iPtr->compileEpoch++; + } + return TCL_OK; } @@ -1226,6 +1236,15 @@ Tcl_UntraceCommand( */ cmdPtr->flags &= ~CMD_HAS_EXEC_TRACES; + + /* + * Bug 3484621: up the interp's epoch if this is a BC'ed command + */ + + if (cmdPtr->compileProc != NULL) { + Interp *iPtr = (Interp *) interp; + iPtr->compileEpoch++; + } } } diff --git a/tests/trace.test b/tests/trace.test index c2a760d..3297258 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -2558,6 +2558,39 @@ set base { } runbase {{- *} {-* *} {- *} {- *}} $base +test trace-39 {bug #3484621: tracing Bc'ed commands} -setup { + set ::traceLog 0 + set ::traceCalls 0 + set ::bar [list 0 1 2 3] + set res {} + proc dotrace args { + incr ::traceLog + } + proc foo {} { + incr ::traceCalls + # choose a BC'ed command that is 'unlikely' to interfere with tcltest's + # internals + lset ::bar 1 2 + } +} -body { + foo + lappend res $::traceLog + + trace add execution lset enter dotrace + foo + lappend res $::traceLog + + trace remove execution lset enter dotrace + foo + lappend res $::traceLog + + list $::traceCalls | {*}$res +} -cleanup { + unset ::traceLog ::traceCalls ::bar res + rename dotrace {} + rename foo {} +} -result {3 | 0 1 1} + # Delete procedures when done, so we don't clash with other tests |