{"id":7246,"date":"2022-12-20T19:35:59","date_gmt":"2022-12-20T22:35:59","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/tcl_createtrace-man3\/"},"modified":"2022-12-20T19:35:59","modified_gmt":"2022-12-20T22:35:59","slug":"tcl_createtrace-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/tcl_createtrace-man3\/","title":{"rendered":"Tcl_CreateTrace (man3)"},"content":{"rendered":"<h1 align=\"center\">Tcl_CreateTrace<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#ARGUMENTS\">ARGUMENTS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_CreateTrace, Tcl_CreateObjTrace, Tcl_DeleteTrace \u2212 arrange for command execution to be traced<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <tcl.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_Trace <b><br \/> Tcl_CreateTrace<\/b>(<i>interp, level, proc, clientData<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_Trace <b><br \/> Tcl_CreateObjTrace<\/b>(<i>interp, level, flags, objProc, clientData, deleteProc<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DeleteTrace<\/b>(<i>interp, trace<\/i>)<\/p>\n<h2>ARGUMENTS <a name=\"ARGUMENTS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p style=\"margin-top: 1em\">Tcl_Interp <i>*interp<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\">Interpreter containing command to be traced or untraced.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>int <i>level<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Only commands at or below this nesting level will be traced unless 0 is specified. 1 means top-level commands only, 2 means top-level commands or those that are invoked 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.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>int <i>flags<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Flags governing the trace execution. See below for details.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>Tcl_CmdObjTraceProc <i>*objProc<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Procedure to call for each command that is executed. See below for details of the calling sequence.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>Tcl_CmdTraceProc <i>*proc<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Procedure to call for each command that is executed. See below for details on the calling sequence.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>ClientData <i>clientData<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Arbitrary one-word value to pass to <i>objProc<\/i> or <i>proc<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>Tcl_CmdObjTraceDeleteProc <i>*deleteProc<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Procedure to call when the trace is deleted. See below for details of the calling sequence. A NULL pointer is permissible and results in no callback when the trace is deleted.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"64%\">\n<p>Tcl_Trace <i>trace<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"9%\">\n<p>Token for trace to be removed (return value from previous call to <b>Tcl_CreateTrace<\/b>).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:91%;\">______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_CreateObjTrace<\/b> arranges for command tracing. After it is called, <i>objProc<\/i> will be invoked before the Tcl interpreter calls any command procedure when evaluating commands in <i>interp<\/i>. The return value from <b>Tcl_CreateObjTrace<\/b> is a token for the trace, which may be passed to <b>Tcl_DeleteTrace<\/b> to remove the trace. There may be many traces in effect simultaneously for the same interpreter.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>objProc<\/i> should have arguments and result that match the type, <b>Tcl_CmdObjTraceProc<\/b>:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">typedef int <b>Tcl_CmdObjTraceProc<\/b>( <b><br \/> ClientData<\/b> <i>clientData<\/i>, <b><br \/> Tcl_Interp<\/b>* <i>interp<\/i>, <br \/> int <i>level<\/i>, <br \/> const char *<i>command<\/i>, <b><br \/> Tcl_Command<\/b> <i>commandToken<\/i>, <br \/> int <i>objc<\/i>, <b><br \/> Tcl_Obj<\/b> *const <i>objv<\/i>[]);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>clientData<\/i> and <i>interp<\/i> parameters are copies of the corresponding arguments given to <b>Tcl_CreateTrace<\/b>. <i>ClientData<\/i> typically points to an application-specific data structure that describes what to do when <i>objProc<\/i> is invoked. The <i>level<\/i> parameter gives the nesting level of the command (1 for top-level commands passed to <b>Tcl_Eval<\/b> by the application, 2 for the next-level commands passed to <b>Tcl_Eval<\/b> as part of parsing or interpreting level-1 commands, and so on). The <i>command<\/i> parameter points to a string containing the text of the command, before any argument substitution. The <i>commandToken<\/i> parameter is a Tcl command token that identifies the command to be invoked. The token may be passed to <b>Tcl_GetCommandName<\/b>, <b>Tcl_GetCommandInfoFromToken<\/b>, or <b>Tcl_SetCommandInfoFromToken<\/b> to manipulate the definition of the command. The <i>objc<\/i> and <i>objv<\/i> parameters designate the final parameter count and parameter vector that will be passed to the command, and have had all substitutions performed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>objProc<\/i> callback is expected to return a standard Tcl status return code. If this code is <b>TCL_OK<\/b> (the normal case), then the Tcl interpreter will invoke the command. Any other return code is treated as if the command returned that status, and the command is <i>not<\/i> invoked.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>objProc<\/i> callback must not modify <i>objv<\/i> in any way. It is, however, permissible to change the command by calling <b>Tcl_SetCommandTokenInfo<\/b> prior to returning. Any such change takes effect immediately, and the command is invoked with the new information.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tracing will only occur for commands at nesting level less than or equal to the <i>level<\/i> parameter (i.e. the <i>level<\/i> parameter to <i>objProc<\/i> will always be less than or equal to the <i>level<\/i> parameter to <b>Tcl_CreateTrace<\/b>).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tracing has a significant effect on runtime performance because it causes the bytecode compiler to refrain from generating in-line code for Tcl commands such as <b>if<\/b> and <b>while<\/b> in order that they may be traced. If traces for the built-in commands are not required, the <i>flags<\/i> parameter may be set to the constant value <b>TCL_ALLOW_INLINE_COMPILATION<\/b>. In this case, traces on built-in commands may or may not result in trace callbacks, depending on the state of the interpreter, but run-time performance will be improved significantly. (This functionality is desirable, for example, when using <b>Tcl_CreateObjTrace<\/b> to implement an execution time profiler.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Calls to <i>objProc<\/i> will be made by the Tcl parser immediately before it calls the command procedure for the command (<i>cmdProc<\/i>). This occurs after argument parsing and substitution, so tracing for substituted commands occurs before tracing of the commands containing the substitutions. If there is a syntax error in a command, or if there is no command procedure associated with a command name, then no tracing will occur for that command. If a string passed to Tcl_Eval contains multiple commands (bracketed, or on different lines) then multiple calls to <i>objProc<\/i> will occur, one for each command.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DeleteTrace<\/b> removes a trace, so that no future calls will be made to the procedure associated with the trace. After <b>Tcl_DeleteTrace<\/b> returns, the caller should never again use the <i>trace<\/i> token.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When <b>Tcl_DeleteTrace<\/b> is called, the interpreter invokes the <i>deleteProc<\/i> that was passed as a parameter to <b>Tcl_CreateObjTrace<\/b>. The <i>deleteProc<\/i> must match the type, <b>Tcl_CmdObjTraceDeleteProc<\/b>:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">typedef void <b>Tcl_CmdObjTraceDeleteProc<\/b>( <b><br \/> ClientData<\/b> <i>clientData<\/i>);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>clientData<\/i> parameter will be the same as the <i>clientData<\/i> parameter that was originally passed to <b>Tcl_CreateObjTrace<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_CreateTrace<\/b> is an alternative interface for command tracing, <i>not recommended for new applications<\/i>. It is provided for backward compatibility with code that was developed for older versions of the Tcl interpreter. It is similar to <b>Tcl_CreateObjTrace<\/b>, except that its <i>proc<\/i> parameter should have arguments and result that match the type <b>Tcl_CmdTraceProc<\/b>:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">typedef void <b>Tcl_CmdTraceProc<\/b>( <br \/> ClientData <i>clientData<\/i>, <br \/> Tcl_Interp *<i>interp<\/i>, <br \/> int <i>level<\/i>, <br \/> char *<i>command<\/i>, <br \/> Tcl_CmdProc *<i>cmdProc<\/i>, <br \/> ClientData <i>cmdClientData<\/i>, <br \/> int <i>argc<\/i>, <br \/> const char *<i>argv<\/i>[]);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The parameters to the <i>proc<\/i> callback are similar to those of the <i>objProc<\/i> callback above. The <i>commandToken<\/i> is replaced with <i>cmdProc<\/i>, a pointer to the (string-based) command procedure that will be invoked; and <i>cmdClientData<\/i>, the client data that will be passed to the procedure. The <i>objc<\/i> parameter is replaced with an <i>argv<\/i> parameter, that gives the arguments to the command as character strings. <i>Proc<\/i> must not modify the <i>command<\/i> or <i>argv<\/i> strings.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If a trace created with <b>Tcl_CreateTrace<\/b> is in effect, inline compilation of Tcl commands such as <b>if<\/b> and <b>while<\/b> is always disabled. There is no notification when a trace created with <b>Tcl_CreateTrace<\/b> is deleted. There is no way to be notified when the trace created by <b>Tcl_CreateTrace<\/b> is deleted. There is no way for the <i>proc<\/i> associated with a call to <b>Tcl_CreateTrace<\/b> to abort execution of <i>command<\/i>.<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">command, create, delete, interpreter, trace<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_CreateTrace, Tcl_CreateObjTrace, Tcl_DeleteTrace \u2212 arrange for command execution to be traced <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3572],"class_list":["post-7246","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_createobjtrace"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7246"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7246\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}