|
2013-11-12
| ||
| 12:33 | • Closed ticket [3439728fff]: Leave execution trace created in the same proc doesn... artifact: 38f6a2b0a2 user: dkf | |
|
2011-12-02
| ||
| 05:17 | • Ticket [3439728fff]: 4 changes artifact: cdc43d5a8f user: msofer | |
| 02:43 | • Ticket [3439728fff]: 4 changes artifact: 71d85bb321 user: ladayaroslav | |
|
2011-12-01
| ||
| 23:15 | • Pending ticket [3439728fff]. artifact: 44bb84d330 user: dgp | |
|
2011-11-18
| ||
| 05:16 | • New ticket [3439728fff]. artifact: 45e114d2ee user: ladayaroslav | |
Leave execution trace created in the same proc doesn't fire
Closed / Invalid3439728fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 13 years ago
Descriptionplain2011-11-18 05:16:19
Script to reproduce:
-------------
proc LTrace {args} {
puts "LTrace: $args"
#Hardcoded:
trace remove execution test leave LTrace
}
proc GTrace {args} {puts "This is global trace: $args"}
proc localproc {pname arglist body} {
set caller [lindex [info level 1] 0]
trace add execution $caller leave LTrace
puts "Active traces on $caller: [trace info execution $caller]"
proc $pname $arglist "uplevel 1 [list $body]"
return
}
proc test {a b} {
localproc lproc {} {puts "a=$a, b=$b"}
lproc
set a "A" ; set b "B"
lproc
}
#trace add execution test leave GTrace
test a 4
puts "---------"
test a 5
------------------
In tcl 8.4.19 it gives:
Active traces on test: {leave LTrace}
a=a, b=4
a=A, b=B
LTrace: {test a 4} 0 {} leave
---------
Active traces on test: {leave LTrace}
a=a, b=5
a=A, b=B
LTrace: {test a 5} 0 {} leave
But in tcl 8.6b2 and 8.5.10:
Active traces on test: {leave LTrace}
a=a, b=4
a=A, b=B
---------
Active traces on test: {leave LTrace} {leave LTrace}
a=a, b=5
a=A, b=B
LTrace: {test a 5} 0 {} leave
-----
So, LTrace isn't called first time.
Also, if I uncomment the line "#trace add execution test leave GTrace", then in all tcl versions result becomes:
---
Active traces on test: {leave LTrace} {leave GTrace}
a=a, b=4
a=A, b=B
This is global trace: {test a 4} 0 {} leave
LTrace: {test a 4} 0 {} leave
---------
Active traces on test: {leave LTrace} {leave GTrace}
a=a, b=5
a=A, b=B
This is global trace: {test a 5} 0 {} leave
LTrace: {test a 5} 0 {} leave
dgpplain2011-12-01 23:15:19
Isn't this covered in the changes file? 2007-06-21 (feature change)[1740962] leave traces created during execution of traced command do not fire (sofer)
ladayaroslavplain2011-12-02 02:43:16
Ok, but if it's so, then why uncommenting a line: 'trace add execution test leave GTrace' makes LTrace active?
msoferplain2011-12-02 05:17:00
The real issue is: when a command call occurs, are there any execution traces active in the interpreter or for that specific command?
1. if not, then *that* command call will ignore leave traces until it returns
2. if yes, leave traces will be called - whatever they are when the command is done. That is, a *change* during execution will be taken into account, but creation of traces on an untraced-at-invocation command will not.
Even more confusing: if instead of uncommenting that line you replace it with
trace add execution test enter GTrace
then ... the leave trace fires too! The important thing is: was the command traced on invocation or not?
The docs are possibly unclear about this (granted, somewhat confusing) behaviour. Suggestions?
dkf Closed ticket [3439728fff].
[History diff]2013-11-12 12:33:43
Log in (anonymous is fine) to add a comment.