Thread overview
[Issue 3657] New: No lexical scope for local variables in debug info
Dec 29, 2009
Rainer Schuetze
Dec 29, 2009
Rainer Schuetze
Dec 29, 2009
Rainer Schuetze
Jan 19, 2012
Walter Bright
Jan 19, 2012
Rainer Schuetze
Jan 20, 2012
Walter Bright
Jan 20, 2012
Rainer Schuetze
Jan 21, 2012
Rainer Schuetze
Jan 21, 2012
Walter Bright
December 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3657

           Summary: No lexical scope for local variables in debug info
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: r.sagitario@gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario@gmx.de> 2009-12-29 02:47:59 PST ---
Consider

import std.stdio;

void main()
{
   for(int i = 0; i < 10; i++)
      writefln("1 - %d", i);

   for(int i = 0; i < 10; i++)
      writefln("2 - %d", i);
}

This declares two different variables "i", but the debugger only shows the value of the first variable, even while stepping through the second loop. (The list of local variables does show two variables "i".)

This is caused by DMD not emitting any life time info of local variables.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3657



--- Comment #1 from Rainer Schuetze <r.sagitario@gmx.de> 2009-12-29 02:57:56 PST ---
Created an attachment (id=536)
add lexical scope to local symbols in codeview debug info

The patch consists of two parts:
1. modify the parser to remember the end of scope statements.
2. transfer the life-time info to the debug info.

The latter is straight forward, but the second part is a bit complicated.

As scoping information is lost in the code generation, only the line of declaration and the end of the enclosing scope is remembered by the symbol. The life-time of the variable in terms of code byte offset and length is then reconstructed from the line number info. This is only implemented for CodeView information, as I don't know anything about the other formats.

Another complication: optlink removes the corresponding debug entries, so I had to use pseudo-symbols to get this info to cv2pdb and convert them back there. This might confuse other tools, so maybe this feature should be enabled by some command line switch only.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3657


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
           Priority|P2                          |P3


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3657


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2012-01-18 20:55:44 PST ---
Want to do a pull request for this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3657



--- Comment #3 from Rainer Schuetze <r.sagitario@gmx.de> 2012-01-19 13:42:22 PST ---
I'd like to if there is a chance to avoid the ugly workaround regarding optlink: Will it be a large issue to add support for S_BLOCK32/S_END debug entries to optlink?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3657



--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2012-01-19 17:56:43 PST ---
That would be a great deal of work, mainly because the optlink codeview code is a giant inscrutable mess.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3657



--- Comment #5 from Rainer Schuetze <r.sagitario@gmx.de> 2012-01-20 00:31:22 PST ---
So you are fine with the workaround to emit symbols to be translated back to the block statements? This will create strange symbols "@sblk" and "@send" if you happen to work with the debug info without using cv2pdb.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3657



--- Comment #7 from Rainer Schuetze <r.sagitario@gmx.de> 2012-01-21 13:49:51 PST ---
So I guess we are kind of stuck. Is it really much worse than all the temporaries generated as local variables by dmd?

Do you see another possibility to pass variable life time information to the debugger?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3657



--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2012-01-21 13:56:03 PST ---
Maybe we should defer this then until the linker can be improved.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------