diff options
author | das <das> | 2007-09-13 15:28:09 (GMT) |
---|---|---|
committer | das <das> | 2007-09-13 15:28:09 (GMT) |
commit | 6727c60fc8fb34e49299e93c7c9ac1502935b9b0 (patch) | |
tree | 593d357422c91ee5b5623ed463f7d5629d99a4a5 /generic/tclExecute.c | |
parent | 31db1293d7001f8e7aeb25c06df292f43db1154e (diff) | |
download | tcl-6727c60fc8fb34e49299e93c7c9ac1502935b9b0.zip tcl-6727c60fc8fb34e49299e93c7c9ac1502935b9b0.tar.gz tcl-6727c60fc8fb34e49299e93c7c9ac1502935b9b0.tar.bz2 |
* generic/tclDTrace.d (new file): add DTrace provider for Tcl; allows
* generic/tclCompile.h: tracing of proc and command entry &
* generic/tclBasic.c: return, bytecode execution, object
* generic/tclExecute.c: allocation and more; with essentially
* generic/tclInt.h: zero cost when tracing is inactive;
* generic/tclObj.c: enable with --enable-dtrace configure
* generic/tclProc.c: arg (disabled by default, will only
* unix/Makefile.in: enable if DTrace is present).
* unix/configure.in: [Patch 1793984]
* macosx/Makefile: enable DTrace support.
* unix/configure: autoconf-2.13
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 4fd6dcc..c0deb73 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.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: tclExecute.c,v 1.94.2.21 2007/03/13 16:26:32 dgp Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.94.2.22 2007/09/13 15:28:12 das Exp $ */ #include "tclInt.h" @@ -259,6 +259,31 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 }; #endif /* TCL_COMPILE_DEBUG */ /* + * DTrace instruction probe macros. + */ + +#define TCL_DTRACE_INST_NEXT() \ + if (TCL_DTRACE_INST_DONE_ENABLED()) {\ + if (curInstName) {\ + TCL_DTRACE_INST_DONE(curInstName, stackTop - initStackTop,\ + stackPtr + stackTop);\ + }\ + curInstName = tclInstructionTable[*pc].name;\ + if (TCL_DTRACE_INST_START_ENABLED()) {\ + TCL_DTRACE_INST_START(curInstName, stackTop - initStackTop,\ + stackPtr + stackTop);\ + }\ + } else if (TCL_DTRACE_INST_START_ENABLED()) {\ + TCL_DTRACE_INST_START(tclInstructionTable[*pc].name,\ + stackTop - initStackTop, stackPtr + stackTop);\ + } +#define TCL_DTRACE_INST_LAST() \ + if (TCL_DTRACE_INST_DONE_ENABLED() && curInstName) {\ + TCL_DTRACE_INST_DONE(curInstName, stackTop - initStackTop,\ + stackPtr + stackTop);\ + } + +/* * Macro to read a string containing either a wide or an int and * decide which it is while decoding it at the same time. This * enforces the policy that integer constants between LONG_MIN and @@ -1115,6 +1140,7 @@ TclExecuteByteCode(interp, codePtr) int traceInstructions = (tclTraceExec == 3); char cmdNameBuf[21]; #endif + char *curInstName = NULL; /* * This procedure uses a stack to hold information about catch commands. @@ -1259,6 +1285,9 @@ TclExecuteByteCode(interp, codePtr) #ifdef TCL_COMPILE_STATS iPtr->stats.instructionCount[*pc]++; #endif + + TCL_DTRACE_INST_NEXT(); + switch (*pc) { case INST_DONE: if (stackTop <= initStackTop) { @@ -4035,6 +4064,7 @@ TclExecuteByteCode(interp, codePtr) */ pc += 5; + TCL_DTRACE_INST_NEXT(); #else NEXT_INST_F(5, 0, 0); #endif @@ -4390,6 +4420,7 @@ TclExecuteByteCode(interp, codePtr) */ abnormalReturn: + TCL_DTRACE_INST_LAST(); while (stackTop > initStackTop) { valuePtr = POP_OBJECT(); TclDecrRefCount(valuePtr); |