⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crttrace.3

📁 tcl是工具命令语言
💻 3
字号:
'\"'\" Copyright (c) 1989-1993 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\" Copyright (c) 2002 by Kevin B. Kenny.  All rights reserved.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: CrtTrace.3,v 1.6 2002/08/05 03:24:39 dgp Exp $'\" .so man.macros.TH Tcl_CreateTrace 3 "" Tcl "Tcl Library Procedures".BS.SH NAMETcl_CreateTrace, Tcl_CreateObjTrace, Tcl_DeleteTrace \- arrange for command execution to be traced.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.spTcl_Trace\fBTcl_CreateTrace\fR(\fIinterp, level, proc, clientData\fR).spTcl_Trace\fBTcl_CreateObjTrace\fR(\fIinterp, level, flags, objProc, clientData, deleteProc\fR).sp\fBTcl_DeleteTrace\fR(\fIinterp, trace\fR).SH ARGUMENTS.AS Tcl_CmdObjTraceDeleteProc (clientData)().AP Tcl_Interp *interp inInterpreter containing command to be traced or untraced..AP int level inOnly commands at or below this nesting level will be traced unless0 is specified.  1 meanstop-level commands only, 2 means top-level commands or those that areinvoked as immediate consequences of executing top-level commands(procedure bodies, bracketed commands, etc.) and so on.A value of 0 means that commands at any level are traced..AP int flags inFlags governing the trace execution.  See below for details..AP Tcl_CmdObjTraceProc *objProc inProcedure to call for each command that's executed.  See below fordetails of the calling sequence..AP Tcl_CmdTraceProc *proc inProcedure to call for each command that's executed.  See below fordetails on the calling sequence..AP ClientData clientData inArbitrary one-word value to pass to \fIobjProc\fR or \fIproc\fR..AP Tcl_CmdObjTraceDeleteProc *deleteProcProcedure to call when the trace is deleted.  See below for details ofthe calling sequence.  A null pointer is permissible and results in nocallback when the trace is deleted..AP Tcl_Trace trace inToken for trace to be removed (return value from previous callto \fBTcl_CreateTrace\fR)..BE.SH DESCRIPTION.PP\fBTcl_CreateObjTrace\fR arranges for command tracing.  After it iscalled, \fIobjProc\fR will be invoked before the Tcl interpreter callsany command procedure when evaluating commands in \fIinterp\fR.The return value from \fBTcl_CreateObjTrace\fR is a token for the trace,which may be passed to \fBTcl_DeleteTrace\fR to remove the trace.There may be many traces in effect simultaneously for the sameinterpreter..PP\fIobjProc\fR should have arguments and result that match the type,\fBTcl_CmdObjTraceProc\fR:.CStypedef int \fBTcl_CmdObjTraceProc\fR(     \fBClientData\fR \fIclientData\fR,    \fBTcl_Interp\fR* \fIinterp\fR,    int \fIlevel\fR,    CONST char* \fIcommand\fR,    \fBTcl_Command\fR \fIcommandToken\fR,    int \fIobjc\fR,    \fBTcl_Obj\fR *CONST \fIobjv\fR[] );.CEThe \fIclientData\fR and \fIinterp\fR parameters are copies of thecorresponding arguments given to \fBTcl_CreateTrace\fR.\fIClientData\fR typically points to an application-specific datastructure that describes what to do when \fIobjProc\fR is invoked.  The\fIlevel\fR parameter gives the nesting level of the command (1 fortop-level commands passed to \fBTcl_Eval\fR by the application, 2 forthe next-level commands passed to \fBTcl_Eval\fR as part of parsing orinterpreting level-1 commands, and so on). The \fIcommand\fR parameterpoints to a string containing the text of the command, before anyargument substitution.  The \fIcommandToken\fR parameter is a Tclcommand token that identifies the command to be invoked.  The tokenmay be passed to \fBTcl_GetCommandName\fR,\fBTcl_GetCommandTokenInfo\fR, or \fBTcl_SetCommandTokenInfo\fR tomanipulate the definition of the command. The \fIobjc\fR and \fIobjv\fRparameters designate the final parameter count and parameter vectorthat will be passed to the command, and have had all substitutionsperformed..PPThe \fIobjProc\fR callback is expected to return a standard Tcl statusreturn code.  If this code is \fBTCL_OK\fR (the normal case), thenthe Tcl interpreter will invoke the command.  Any other return codeis treated as if the command returned that status, and the command is\fInot\fR invoked..PPThe \fIobjProc\fR callback must not modify \fIobjv\fR in any way.  Itis, however, permissible to change the command by calling\fBTcl_SetCommandTokenInfo\fR prior to returning.  Any such changetakes effect immediately, and the command is invoked with the newinformation..PPTracing will only occur for commands at nesting level less thanor equal to the \fIlevel\fR parameter (i.e. the \fIlevel\fRparameter to \fIobjProc\fR will always be less than or equal to the\fIlevel\fR parameter to \fBTcl_CreateTrace\fR)..PPTracing has a significant effect on runtime performance because itcauses the bytecode compiler to refrain from generating in-line codefor Tcl commands such as \fBif\fR and \fBwhile\fR in order that theymay be traced.  If traces for the built-in commands are not required,the \fIflags\fR parameter may be set to the constant value\fBTCL_ALLOW_INLINE_COMPILATION\fR.  In this case, traces on built-incommands may or may not result in trace callbacks, depending on thestate of the interpreter, but run-time performance will be improvedsignificantly.  (This functionality is desirable, for example, whenusing \fBTcl_CreateObjTrace\fR to implement an execution timeprofiler.).PPCalls to \fIobjProc\fR will be made by the Tcl parser immediately beforeit calls the command procedure for the command (\fIcmdProc\fR).  Thisoccurs after argument parsing and substitution, so tracing forsubstituted commands occurs before tracing of the commandscontaining the substitutions.  If there is a syntax error in acommand, or if there is no command procedure associated with acommand name, then no tracing will occur for that command.  If astring passed to Tcl_Eval contains multiple commands (bracketed, oron different lines) then multiple calls to \fIobjProc\fR will occur,one for each command..PP\fBTcl_DeleteTrace\fR removes a trace, so that no future calls will bemade to the procedure associated with the trace.  After \fBTcl_DeleteTrace\fRreturns, the caller should never again use the \fItrace\fR token..PPWhen \fBTcl_DeleteTrace\fR is called, the interpreter invokes the\fIdeleteProc\fR that was passed as a parameter to\fBTcl_CreateObjTrace\fR.  The \fIdeleteProc\fR must match the type,\fBTcl_CmdObjTraceDeleteProc\fR:.CStypedef void \fBTcl_CmdObjTraceDeleteProc\fR(     \fBClientData\fR \fIclientData\fR);.CEThe \fIclientData\fR parameter will be the same as the\fIclientData\fR parameter that was originally passed to\fBTcl_CreateObjTrace\fR..PP\fBTcl_CreateTrace\fR is an alternative interface for command tracing,\fInot recommended for new applications\fR.  It is provided for backwardcompatibility with code that was developed for older versions of theTcl interpreter.  It is similar to \fBTcl_CreateObjTrace\fR, exceptthat its \fIproc\fR parameter should have arguments and result thatmatch the type \fBTcl_CmdTraceProc\fR:.CStypedef void Tcl_CmdTraceProc(	ClientData \fIclientData\fR,	Tcl_Interp *\fIinterp\fR,	int \fIlevel\fR,	char *\fIcommand\fR,	Tcl_CmdProc *\fIcmdProc\fR,	ClientData \fIcmdClientData\fR,	int \fIargc\fR,	CONST char *\fIargv\fR[]);.CEThe parameters to the \fIproc\fR callback are similar to those of the\fIobjProc\fR callback above. The \fIcommandToken\fR isreplaced with \fIcmdProc\fR, a pointer to the (string-based) commandprocedure that will be invoked; and \fIcmdClientData\fR, the clientdata that will be passed to the procedure.  The \fIobjc\fR parameteris replaced with an \fIargv\fR parameter, that gives the arguments tothe command as character strings.\fIProc\fR must not modify the \fIcommand\fR or \fIargv\fR strings..PPIf a trace created with \fBTcl_CreateTrace\fR is in effect, inlinecompilation of Tcl commands such as \fBif\fR and \fBwhile\fR is alwaysdisabled.  There is no notification when a trace created with\fBTcl_CreateTrace\fR is deleted.There is no way to be notified when the trace created by\fBTcl_CreateTrace\fR is deleted.  There is no way for the \fIproc\fRassociated with a call to \fBTcl_CreateTrace\fR to abort execution of\fIcommand\fR..SH KEYWORDScommand, create, delete, interpreter, trace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -