Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 45e114d2ee509f663b7244ede65e5d2d8e02eb4b
Ticket: 3439728fffffffffffffffffffffffffffffffff
Leave execution trace created in the same proc doesn't fire
User & Date: ladayaroslav on 2011-11-18 05:16:19
Changes

  1. assignee changed to: "dgp"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    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 
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "ladayaroslav"
  10. subsystem changed to: "46. Traces"
  11. title changed to:
    Leave execution trace created in the same proc doesn't fire
    
  12. type changed to: "Bug"