Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-12-07
21:01 • Closed ticket [403430ffff]: Tcl_CreateTrace() callback - a proposed 'enhance... artifact: 30d1c819bf user: msofer
03:16 • Pending ticket [403430ffff]. artifact: a725f29392 user: msofer
2001-05-22
05:38 • Ticket [403430ffff]: 5 changes artifact: 13b8cb3814 user: msofer
2001-02-22
07:06 • Ticket [403430ffff]: 1 change artifact: acf9660307 user: dgp
2001-01-26
17:21 • Ticket [403430ffff]: 4 changes artifact: 93511ec2f8 user: dkf
07:18 • Add attachment None to ticket [403430ffff] artifact: 56456b8da3 user: daknol
00:18 • New ticket [403430ffff] Tcl_CreateTrace() callback - a proposed 'enhancement... artifact: 417b2e7afc user: daknol

Tcl_CreateTrace() callback - a proposed 'enhancement'

Closed / Rejected403430ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2001-01-26 00:18:44
this is a patch for which i didn't see any related PR, so i'm not entirely certain if this patch will be a popular one or not...

as mentioned in patch#103420, my company's tools typically register a callback with Tcl_CreateTrace() so that we can automatically generate a command  "history log" or "replay script" of a tool's usage.  one of the problems we've had with the tcl trace involves the 'level' argument that gets passed to our trace callback function.  specifically, bracketed commands whose results are passed as arguments to another command is the issue.  

consider two tcl commands, 'a' and 'b', where the results of 'b' are commonly passed as an argument to 'a'.  ie, "a [ b ]".  with today's implementation, a tcl trace callback will be invoked twice, once with the 'command' argument equal to "b", and then again with 'command' equal to "a [ b ]".  the 'level' argument in both invocations is the *same* value, which presents a problem for me.  if the 'level' provided in the first invocation was 'X', i would expect the second invocation to be 'X-1'.  otherwise, i have no way of telling that the first invocation is merely being evaluated as another command's argument.

since the bracketed command cannot be distinguished from a regular command, our resulting command log is faulty in that it will first print 'b' and then print 'a [ b ]'.  

the fix for this involves wrapping an increment/decrement of iPtr->numLevels before/after a call to a bracketed command.  i'm not convinced the patch i've provided below is the absolute cleanest or best way to achieve our goal, but it seems to work just fine for us.

it'd be nice to see this patch encorporated into a future release of tcl, but i also realize there may be some argument to the contrary that i haven't seen yet...
dkfplain2001-01-26 17:21:10
This might break other code - we ought to consult with the rest of the community on this...
dgp Ticket [403430ffff]: 1 change [History diff]2001-02-22 07:06:13
msoferplain2001-05-22 05:38:38
Logged In: YES 
user_id=148712

Related to: bug #219362, patch #403420
msoferplain2001-12-07 03:16:50
Logged In: YES 
user_id=148712

This doesn't fit with tcl's way of seeing things: it is NOT
a who is calling b in the example.

The way it works and is documented is: b's result as an
argument to a. The level count is correct, the log's output
corresponds to the real evaluation order.
msofer Closed ticket [403430ffff]. [History diff]2001-12-07 21:01:27
Log in (anonymous is fine) to add a comment.

Attachments: