home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / doc / CrtTrace.3 < prev    next >
Text File  |  1993-04-01  |  5KB  |  126 lines

  1. '\"
  2. '\" Copyright (c) 1989-1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/CrtTrace.3,v 1.8 93/04/01 09:25:26 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tcl_CreateTrace tclc
  25. .BS
  26. .SH NAME
  27. Tcl_CreateTrace, Tcl_DeleteTrace \- arrange for command execution to be traced
  28. .SH SYNOPSIS
  29. .nf
  30. \fB#include <tcl.h>\fR
  31. .sp
  32. Tcl_Trace
  33. \fBTcl_CreateTrace\fR(\fIinterp, level, proc, clientData\fR)
  34. .sp
  35. \fBTcl_DeleteTrace\fR(\fIinterp, trace\fR)
  36. .SH ARGUMENTS
  37. .AS Tcl_CmdTraceProc (clientData)()
  38. .AP Tcl_Interp *interp in
  39. Interpreter containing command to be traced or untraced.
  40. .AP int level in
  41. Only commands at or below this nesting level will be traced.  1 means
  42. top-level commands only, 2 means top-level commands or those that are
  43. invoked as immediate consequences of executing top-level commands
  44. (procedure bodies, bracketed commands, etc.) and so on.
  45. .AP Tcl_CmdTraceProc *proc in
  46. Procedure to call for each command that's executed.  See below for
  47. details on the calling sequence.
  48. .AP ClientData clientData in
  49. Arbitrary one-word value to pass to \fIproc\fR.
  50. .AP Tcl_Trace trace in
  51. Token for trace to be removed (return value from previous call
  52. to \fBTcl_CreateTrace\fR).
  53. .BE
  54.  
  55. .SH DESCRIPTION
  56. .PP
  57. \fBTcl_CreateTrace\fR arranges for command tracing.  From now on, \fIproc\fR
  58. will be invoked before Tcl calls command procedures to process
  59. commands in \fIinterp\fR.  The return value from
  60. \fBTcl_CreateTrace\fR is a token for the trace,
  61. which may be passed to \fBTcl_DeleteTrace\fR to remove the trace.  There may
  62. be many traces in effect simultaneously for the same command interpreter.
  63. .PP
  64. \fIProc\fR should have arguments and result that match the
  65. type \fBTcl_CmdTraceProc\fR:
  66. .nf
  67. .sp
  68. .RS
  69. typedef void Tcl_CmdTraceProc(
  70. .RS
  71. ClientData \fIclientData\fR,
  72. Tcl_Interp *\fIinterp\fR,
  73. int \fIlevel\fR,
  74. char *\fIcommand\fR,
  75. Tcl_CmdProc *\fIcmdProc\fR,
  76. ClientData \fIcmdClientData\fR,
  77. int \fIargc\fR,
  78. char *\fIargv\fR[]));
  79. .sp
  80. .RE
  81. .RE
  82. .fi
  83. The \fIclientData\fP and \fIinterp\fP parameters are
  84. copies of the corresponding arguments given to \fBTcl_CreateTrace\fR.
  85. \fIClientData\fR typically points to an application-specific
  86. data structure that describes what to do when \fIproc\fR
  87. is invoked.  \fILevel\fR gives the nesting level of the command
  88. (1 for top-level commands passed to \fBTcl_Eval\fR by the application,
  89. 2 for the next-level commands passed to \fBTcl_Eval\fR as part of parsing
  90. or interpreting level-1 commands, and so on).  \fICommand\fR
  91. points to a string containing the text of the
  92. command, before any argument substitution.
  93. \fICmdProc\fR contains the address of the command procedure that
  94. will be called to process the command (i.e. the \fIproc\fR argument
  95. of some previous call to \fBTcl_CreateCommand\fR) and \fIcmdClientData\fR
  96. contains the associated client data for \fIcmdProc\fR (the \fIclientData\fR
  97. value passed to \fBTcl_CreateCommand\fR).  \fIArgc\fR and \fIargv\fR give
  98. the final argument information that will be passed to \fIcmdProc\fR, after
  99. command, variable, and backslash substitution.
  100. \fIProc\fR must not modify the \fIcommand\fR or \fIargv\fR strings.
  101. .PP
  102. Tracing will only occur for commands at nesting level less than
  103. or equal to the \fIlevel\fR parameter (i.e. the \fIlevel\fR
  104. parameter to \fIproc\fR will always be less than or equal to the
  105. \fIlevel\fR parameter to \fBTcl_CreateTrace\fR).
  106. .PP
  107. Calls to \fIproc\fR will be made by the Tcl parser immediately before
  108. it calls the command procedure for the command (\fIcmdProc\fR).  This
  109. occurs after argument parsing and substitution, so tracing for
  110. substituted commands occurs before tracing of the commands
  111. containing the substitutions.  If there is a syntax error in a
  112. command, or if there is no command procedure associated with a
  113. command name, then no tracing will occur for that command.  If a
  114. string passed to Tcl_Eval contains multiple commands (bracketed, or
  115. on different lines) then multiple calls to \fIproc\fR will occur,
  116. one for each command.  The \fIcommand\fR string for each of these
  117. trace calls will reflect only a single command, not the entire string
  118. passed to Tcl_Eval.
  119. .PP
  120. \fBTcl_DeleteTrace\fR removes a trace, so that no future calls will be
  121. made to the procedure associated with the trace.  After \fBTcl_DeleteTrace\fR
  122. returns, the caller should never again use the \fItrace\fR token.
  123.  
  124. .SH KEYWORDS
  125. command, create, delete, interpreter, trace
  126.