diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 18 | ||||
-rw-r--r-- | tests/trace.test | 38 |
3 files changed, 59 insertions, 2 deletions
@@ -1,5 +1,10 @@ 2003-09-23 Don Porter <dgp@users.sourceforge.net> + * generic/tclCmdMZ.c (): Fixed [Bug 807243] where + * tests/trace.test (trace-31,32.*): the introspection results + of both [trace info command] and [trace info execution] were getting + co-mingled. + * library/init.tcl (auto_load, auto_import): Expanded Eric Melski's 2000-01-28 fix for [Bug 218871] to all potentially troubled uses of [info commands] on input data, where glob-special characters could diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index ca1abef..a3dc03a 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.6 2003/07/16 08:24:20 dkf Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.7 2003/09/24 02:17:10 dgp Exp $ */ #include "tclInt.h" @@ -3350,6 +3350,7 @@ TclTraceExecutionObjCmd(interp, optionIndex, objc, objv) resultListPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); while ((clientData = Tcl_CommandTraceInfo(interp, name, 0, TraceCommandProc, clientData)) != NULL) { + int numOps = 0; TraceCommandInfo *tcmdPtr = (TraceCommandInfo *) clientData; @@ -3363,6 +3364,7 @@ TclTraceExecutionObjCmd(interp, optionIndex, objc, objv) */ elemObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); + Tcl_IncrRefCount(elemObjPtr); if (tcmdPtr->flags & TCL_TRACE_ENTER_EXEC) { Tcl_ListObjAppendElement(NULL, elemObjPtr, Tcl_NewStringObj("enter",5)); @@ -3379,7 +3381,13 @@ TclTraceExecutionObjCmd(interp, optionIndex, objc, objv) Tcl_ListObjAppendElement(NULL, elemObjPtr, Tcl_NewStringObj("leavestep",9)); } + Tcl_ListObjLength(NULL, elemObjPtr, &numOps); + if (0 == numOps) { + Tcl_DecrRefCount(elemObjPtr); + continue; + } Tcl_ListObjAppendElement(NULL, eachTraceObjPtr, elemObjPtr); + Tcl_DecrRefCount(elemObjPtr); elemObjPtr = NULL; Tcl_ListObjAppendElement(NULL, eachTraceObjPtr, @@ -3545,6 +3553,7 @@ TclTraceCommandObjCmd(interp, optionIndex, objc, objv) resultListPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); while ((clientData = Tcl_CommandTraceInfo(interp, name, 0, TraceCommandProc, clientData)) != NULL) { + int numOps = 0; TraceCommandInfo *tcmdPtr = (TraceCommandInfo *) clientData; @@ -3558,6 +3567,7 @@ TclTraceCommandObjCmd(interp, optionIndex, objc, objv) */ elemObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); + Tcl_IncrRefCount(elemObjPtr); if (tcmdPtr->flags & TCL_TRACE_RENAME) { Tcl_ListObjAppendElement(NULL, elemObjPtr, Tcl_NewStringObj("rename",6)); @@ -3566,7 +3576,13 @@ TclTraceCommandObjCmd(interp, optionIndex, objc, objv) Tcl_ListObjAppendElement(NULL, elemObjPtr, Tcl_NewStringObj("delete",6)); } + Tcl_ListObjLength(NULL, elemObjPtr, &numOps); + if (0 == numOps) { + Tcl_DecrRefCount(elemObjPtr); + continue; + } Tcl_ListObjAppendElement(NULL, eachTraceObjPtr, elemObjPtr); + Tcl_DecrRefCount(elemObjPtr); elemObjPtr = Tcl_NewStringObj(tcmdPtr->command, -1); Tcl_ListObjAppendElement(NULL, eachTraceObjPtr, elemObjPtr); diff --git a/tests/trace.test b/tests/trace.test index cedb7ba..4e010e9 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -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: trace.test,v 1.26.2.1 2003/03/27 13:11:17 dkf Exp $ +# RCS: @(#) $Id: trace.test,v 1.26.2.2 2003/09/24 02:17:10 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -2093,6 +2093,42 @@ test trace-28.10 {exec trace info nonsense} { list [catch {trace remove execution} res] $res } {1 {wrong # args: should be "trace remove execution name opList command"}} +# Missing test number to keep in sync with the 8.5 branch +# (want to backport those tests?) + +test trace-31.1 {command and execution traces shared struct} { + # Tcl Bug 807243 + proc foo {} {} + trace add command foo delete foo + trace add execution foo enter foo + set result [trace info command foo] + trace remove command foo delete foo + trace remove execution foo enter foo + rename foo {} + set result +} [list [list delete foo]] +test trace-31.2 {command and execution traces shared struct} { + # Tcl Bug 807243 + proc foo {} {} + trace add command foo delete foo + trace add execution foo enter foo + set result [trace info execution foo] + trace remove command foo delete foo + trace remove execution foo enter foo + rename foo {} + set result +} [list [list enter foo]] + +test trace-32.1 {mystery memory corruption} knownBug { + # Tcl Bug 811483 + proc foo {} {} + trace add command foo delete foo + trace add execution foo enter foo + set result [trace info command foo] + rename foo {} + set result +} [list [list delete foo]] + # Delete procedures when done, so we don't clash with other tests # (e.g. foobar will clash with 'unknown' tests). catch {rename foobar {}} |