Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Epoch does not increase when adding a trace

Closed / Fixed3484621fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2012-02-05 12:44:01
Different bytecode depending if there is a trace execution on a (bytecode) inlined command.

Testcase:
proc putargs {args} {puts $args}
proc test1 {t} {if {[string equal $t "test"]} {puts "foo"}}
test1 -; #compile
trace add execution ::string enter putargs
proc test2 {t} [info body test1]; # create a second proc with the same body
test2 -; # compile
tcl::unsupported::disassemble proc test1
tcl::unsupported::disassemble proc test2
johannes-kuhn Ticket [3484621fff]: 2 changes [History diff]2012-02-05 19:46:06
johannes-kuhnplain2012-02-05 20:08:59
<schelte> Johannes13, I would think the most important issue is that command tracing doesn't work if the trace is defined after the code has been executed before. You don't seem to mention that very clearly.
dkfplain2012-02-06 21:37:27
Ugh, tracing a compiled command should indeed cause the epoch to bump. Yuck (as that causes a lot of cost) but probably unavoidable.
msoferplain2012-02-06 22:26:42
Is this a bug in the trace, or a bug in unsupported::disassemble? I do not see a trace malfunction:

% proc putargs {args} {puts $args}
% proc test1 {t} {if {[string equal $t "test"]} {puts "foo"}}
% test1 -; #compile
% test1 test
foo
% trace add execution ::string enter putargs
% test1 test
{string trim {test1 test}} enter
foo
sebresplain2012-02-06 22:44:43
to Miguel:
the bug is probably by "epoch", cause the trace "string equal" should be displayed.
The output "{string trim {test1 test}} enter" you see, it's an another trace (possible from "history" command of tclsh). 
Just create after trace "test2" like this:
% proc test2 {t} {if {[string equal $t "test"]} {puts "foo"}}
% test2 -
{string trim {test2 -}} enter
!!!!!!!!!!!!
{string equal - test} enter
!!!!!!!!!!!!
msoferplain2012-02-06 22:52:24
Indeed - thanks. Upping prio
msoferplain2012-02-06 23:47:03
allow_comments - 1

Fixed in core-8-5-branch and trunk
Log in (anonymous is fine) to add a comment.