#5234 info frame gives mismatching line number with info body

current: 8.5.14
Jerry Li

See the following example:
% proc test {} {
puts "line 2: [info frame 0]"
# line 3 \
line 4
puts "line 5: [info frame 0]"
% test
line 2: type proc line 2 cmd {info frame 0} proc ::test level 0
line 5: type proc line 5 cmd {info frame 0} proc ::test level 0
% info body test

puts "line 2: [info frame 0]"
# line 3 line 4
puts "line 5: [info frame 0]"

The second 'info frame' gives line 5 which is reasonable.
But it is in line 4 of the string returned by 'info body' (because '\' is removed and line 3 and line 4 are joined together.)
Is it possible make the line numbers consistent between 'info frame' and 'info body'?


  • Don Porter

    Don Porter - 2013-04-29
    • assigned_to: nobody --> andreas_kupries
  • Don Porter

    Don Porter - 2013-04-29

    passing to the [info frame] maintainer.

    My comment: Since Tcl eliminates the escaped
    newlines, you have to make a choice. Have the
    reported line number agree with the lines as stored
    in the file, or agree with the value reported from
    [info body]. I think the existing choice is a reasonable
    guess about which is more useful.

    The other way out would be changes deep in the
    parser to make Tcl stop stripping out the escaped
    newlines. This is on the list of things to consider
    for Tcl 9, but is likely too disruptive to consider before

  • Donal K. Fellows

    I'm not convinced it is a bug at all at the moment. Put the code into a file to [source] and the line numbers can easily stop matching at all. (That's because they are line numbers *within the file* and not [info body].)

    IMO, [info frame] is pretty strange.

  • Donal K. Fellows

    • milestone: --> current: 8.5.14
    • labels: --> 17. Commands I-L
  • Jerry Li

    Jerry Li - 2013-04-29

    Thanks for your replies:)
    I was just trying to write a script for debugging general tcl scripts in command line mode. I use trace, info frame and info body. I expect that user can debug a proc (stop at the proc entry, step in/out/over, run to a specified line number..)
    Actually my script works well except that the proc body contains '\' at the end of a line. In this scenario, info body gives a line number that doesn't match info body, then my script tells the user an 'incorrect' line number.

  • Andreas Kupries

    Andreas Kupries - 2013-04-29

    [I seem to repeat things others have said in previous comments].

    Your wish is complementary to the work work of 2009-08-25 (see changelog).

    Basically, before the ref'd change info frame behaved as you wanted, matching the info body, but then the line number was not matching to the actual location in the _file_ the code came from. After the change the line number points to the correct line in the file, but is now not matching info body.

    The issue is indeed that some stage of the parsing process of Tcl eliminates continuation lines and joining lines, and making this visible. At which point external script (in the file), and internal representation (as shown by info body) differ.

    There is no way to satisfy both with regard to line numbers. [info frame], as a debugging tool sides to match with the external representation, that which you have open in your editor.

    I would stay with that, as the more common use case.

  • Andreas Kupries

    Andreas Kupries - 2013-04-29
    • status: open --> open-wont-fix

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks