summaryrefslogtreecommitdiffstats
path: root/generic/tclTrace.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-06-09 20:12:53 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-06-09 20:12:53 (GMT)
commita4338c631ef67bfe928e7764ab1fc89d0a3a2e62 (patch)
treec9cb6877f88fcbfad1512aa0fd12c16dc9738a77 /generic/tclTrace.c
parentc17b51664c1993d118f7a0611afc339d8e84d1c3 (diff)
downloadtcl-a4338c631ef67bfe928e7764ab1fc89d0a3a2e62.zip
tcl-a4338c631ef67bfe928e7764ab1fc89d0a3a2e62.tar.gz
tcl-a4338c631ef67bfe928e7764ab1fc89d0a3a2e62.tar.bz2
* generic/tclBasic.c: Split TEOv in two, by separating a
processor for non-TCL_OK returns. Also spli TEOvI in a full version that handles non-existing and traced commands, and a separate shorter version for the regular case. * generic/tclBasic.c: Moved the generation of command strings for * generic/tclTrace.c: traces: previously in Tcl_EvalObjv(), now in TclCheck[Interp|Execution]Traces(). Also insured that the strings are properly nul terminated at the correct length [Bug 1693986] * generic/tclBasic.c: Extend usage of TclLimitReady() and * generic/tclExecute.c: (new) TclLimitExceeded() macros. * generic/tclInt.h: * generic/tclInterp.c: * generic/tclInt.h: New TclCleanupCommandMacro for core usage. * generic/tclBasic.c: * generic/tclExecute.c: * generic/tclObj.c:
Diffstat (limited to 'generic/tclTrace.c')
-rw-r--r--generic/tclTrace.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/generic/tclTrace.c b/generic/tclTrace.c
index a575f04..7d6b667 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.37 2007/05/07 19:45:33 dgp Exp $
+ * RCS: @(#) $Id: tclTrace.c,v 1.38 2007/06/09 20:12:55 msofer Exp $
*/
#include "tclInt.h"
@@ -1396,7 +1396,8 @@ int
TclCheckExecutionTraces(
Tcl_Interp *interp, /* The current interpreter. */
CONST char *command, /* Pointer to beginning of the current command
- * string. */
+ * string. If NULL, the string will be
+ * generated from (objc,objv) */
int numChars, /* The number of characters in 'command' which
* are part of the command string. */
Command *cmdPtr, /* Points to command's Command struct. */
@@ -1412,11 +1413,24 @@ TclCheckExecutionTraces(
int traceCode = TCL_OK;
TraceCommandInfo* tcmdPtr;
Tcl_InterpState state = NULL;
+ Tcl_Obj *commandPtr = NULL;
- if (command == NULL || cmdPtr->tracePtr == NULL) {
+ if (cmdPtr->tracePtr == NULL) {
return traceCode;
}
+ /*
+ * Insure that we have a nul-terminated command string
+ */
+
+ if (!command) {
+ commandPtr = Tcl_NewListObj(objc, objv);
+ command = Tcl_GetStringFromObj(commandPtr, &numChars);
+ } else if ((numChars != -1) && (command[numChars] != '\0')) {
+ commandPtr = Tcl_NewStringObj(command, numChars);
+ command = TclGetString(commandPtr);
+ }
+
curLevel = iPtr->varFramePtr->level;
active.nextPtr = iPtr->activeCmdTracePtr;
@@ -1467,6 +1481,10 @@ TclCheckExecutionTraces(
if (state) {
(void) Tcl_RestoreInterpState(interp, state);
}
+
+ if (commandPtr) {
+ Tcl_DecrRefCount(commandPtr);
+ }
return(traceCode);
}
@@ -1497,7 +1515,8 @@ int
TclCheckInterpTraces(
Tcl_Interp *interp, /* The current interpreter. */
CONST char *command, /* Pointer to beginning of the current command
- * string. */
+ * string. If NULL, the string will be
+ * generated from (objc,objv) */
int numChars, /* The number of characters in 'command' which
* are part of the command string. */
Command *cmdPtr, /* Points to command's Command struct. */
@@ -1512,12 +1531,25 @@ TclCheckInterpTraces(
int curLevel;
int traceCode = TCL_OK;
Tcl_InterpState state = NULL;
+ Tcl_Obj *commandPtr = NULL;
- if (command == NULL || iPtr->tracePtr == NULL
+ if ((iPtr->tracePtr == NULL)
|| (iPtr->flags & INTERP_TRACE_IN_PROGRESS)) {
return(traceCode);
}
+ /*
+ * Insure that we have a nul-terminated command string
+ */
+
+ if (!command) {
+ commandPtr = Tcl_NewListObj(objc, objv);
+ command = Tcl_GetStringFromObj(commandPtr, &numChars);
+ } else if ((numChars != -1) && (command[numChars] != '\0')) {
+ commandPtr = Tcl_NewStringObj(command, numChars);
+ command = TclGetString(commandPtr);
+ }
+
curLevel = iPtr->numLevels;
active.nextPtr = iPtr->activeInterpTracePtr;
@@ -1615,6 +1647,10 @@ TclCheckInterpTraces(
Tcl_DiscardInterpState(state);
}
}
+
+ if (commandPtr) {
+ Tcl_DecrRefCount(commandPtr);
+ }
return(traceCode);
}