Ticket UUID: | 3439728 | |||
Title: | Leave execution trace created in the same proc doesn't fire | |||
Type: | Bug | Version: | obsolete: 8.5.10 | |
Submitter: | ladayaroslav | Created on: | 2011-11-18 05:16:19 | |
Subsystem: | 46. Traces | Assigned To: | aku | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2013-11-12 12:33:43 | |
Resolution: | Invalid | Closed By: | dkf | |
Closed on: | 2013-11-12 12:33:43 | |||
Description: |
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 | |||
User Comments: |
msofer added on 2011-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? ladayaroslav added on 2011-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? dgp added on 2011-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) |