Tcl Source Code

View Ticket
Login
Ticket UUID: 1695203
Title: [info frame] reports wrong line
Type: Bug Created on: 2007-04-05 19:16:10
Submitter: dgp Assigned to: andreas_kupries
Subsystem: 45. Parsing and Eval Severity:
Priority: 5 Medium Last modified: 2007-06-28 06:07:01
Status: Open Closed by:
Resolution: None Closed on:
Version: obsolete: 8.5a6
Description:
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.
User Comments:
mercurio added on 2007-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).