www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15432] New: Win64: bad code offset in debug line number info

https://issues.dlang.org/show_bug.cgi?id=15432

          Issue ID: 15432
           Summary: Win64: bad code offset in debug line number info
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

This program:

//////////////
import std.stdio;

enum AnotherColor { Red, }

enum Color { red, }

int main(string[] argv)
{
    Color c = Color.red;    
    writeln(AnotherColor.Red.stringof); // line 10
    return 0;
}
//////////////

compiled with "dmd -m64 -g main.d"

generates this disassembly for main (dumpbin):

_Dmain:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: 48 83 EC 28        sub         rsp,28h
  0000000000000008: 53                 push        rbx
  0000000000000009: 48 89 4D 10        mov         qword ptr [rbp+10h],rcx
  000000000000000D: 31 C0              xor         eax,eax
  000000000000000F: 89 45 E0           mov         dword ptr [rbp-20h],eax
  0000000000000012: 48 8D 0D 00 00 00  lea         rcx,[_TMP0]
                    00
  0000000000000019: BB 03 00 00 00     mov         ebx,3
  000000000000001E: 48 89 5D F0        mov         qword ptr [rbp-10h],rbx
  0000000000000022: 48 89 4D F8        mov         qword ptr [rbp-8],rcx
  0000000000000026: 48 8D 4D F0        lea         rcx,[rbp-10h]
  000000000000002A: 48 83 EC 20        sub         rsp,20h
  000000000000002E: E8 00 00 00 00     call       
_D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv
  0000000000000033: 48 83 C4 20        add         rsp,20h
  0000000000000037: 31 C0              xor         eax,eax
  0000000000000039: 5B                 pop         rbx
  000000000000003A: 48 8D 65 00        lea         rsp,[rbp]
  000000000000003E: 5D                 pop         rbp
  000000000000003F: C3                 ret

and these line number infos ("c:\Program Files
(x86)\VisualD\cv2pdb\dumplines"):

Sym: _Dmain
File: main.d
    Off 0x0: Line 7
    Off 0xd: Line 9
    Off 0x12: Line 10
    Off 0x36: Line 12

Please note, that the code offset for line 12 is not at the beginning of an
address, so setting a breakpoint there corrupts execution (the debugger changes
the respective code byte to 0xcc).

--
Dec 10 2015