Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-06-28
06:07 • Ticket [1695203fff] info frame reports wrong line status still Open with 4... artifact: 3786b3431f user: mercurio
2007-04-05
19:16 • New ticket [1695203fff]. artifact: 9f36212cec user: dgp

[info frame] reports wrong line

Open1695203fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 19 years ago
Descriptionplain2007-04-05 19:16:10
With this script:

$ cat ~/tip280.tcl
puts "this
is
[info frame 0]
a test"

I see the [info frame] command
on line 3 of the script file.
But running the script reports:

$ ./tclsh ~/tip280.tcl
this
is
type source line 1 file /home/dgp/tip280.tcl cmd {info frame 0} level 0
a test

Instead of reporting the line
of the command, as documented,
[info frame] is reporting the
line on which the word containing
the command begins.  Those are
not always the same.
mercurioplain2007-06-28 06:07:01
Logged In: YES 
user_id=44475
Originator: NO

The same thing happens with continued lines.  Try this in tclsh85:

proc printStack {} {
    for {set i [info frame]} {$i >= 1} {incr i -1} {
        set d [info frame $i]
        switch [dict get $d type] {
            source {lappend stack "[dict get $d file] [dict get $d line]"}
            proc {lappend stack "[dict get $d proc] [dict get $d line]"}
        }
    }
    puts stderr [join $stack \n]
}

proc test {} {
        set x  \
                1

        printStack
}

test

% tclsh85 test1.tcl
test1.tcl 3
test1.tcl 20
test1.tcl 24

The line where printStack is invoked is 21, not 20.  Remove the
continued line at the beginning of test{} and the output is correct.

I'm also seeing a lot of "proc" frames that have incorrect
positive line numbers (probably due to the same line counting problem)
or line numbers that are -1.  I haven't been able to come up with a
short example that demonstrates this, but it shows up repeatably in
a debugger I'm trying to implement (using trace add exec .. enterstep).
Log in (anonymous is fine) to add a comment.