www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4839] New: CodeView: Segment end address is wrong

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4839

           Summary: CodeView: Segment end address is wrong
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: aldonunez1 gmail.com



---
In the debug info for a program, the end address for each segment that a file
contributes to is set to the starting address of the last line in the segment,
not the very last address in the segment. 

The end address of segments that a whole compiland contributes to is set
correctly, though. 

This applies to the sstSrcModule record type. In the following example, the
executable base is 402000h:


  Name: 'd.obj'
  Section count: 1
  File count: 7

    Start offset: 00000010
    End offset: 00004185

    Name: 'F:\dmd.2.045\dmd2\windows\bin\..\..\src\phobos\std\format.d'
    ...

      Start offset: 00003e64
      End offset: 00004182    (*should be 4185)
      Line count: 57
      Line 0: 00003e64, 2175
      Line 1: 00003e6e, 2180
      ...
      Line 55: 0000415a, 2124
      Line 56: 00004182, 2131
  ...

    Name: 'd.d'
    Segment count: 1

      Start offset: 00000010
      End offset: 00000236    (*should be 23c)
      Line count: 51
      Line 0: 00000010, 20
      Line 1: 0000001f, 22
      ...
      Line 49: 00000222, 92
      Line 50: 00000236, 93

This compiland contributes to section 2 between offsets 10h and 4185h. Here's
one example of the problem. At the end of the compiland contribution, there's
the pair of instructions below. Instead of the segment contribution saying that
it goes all the way to the end of the ret instruction, it says it goes to the
beginning of the leave:

[offset 4182]
0x00004d82      0x00406182      0xc9            leave   esp,ebp
0x00004d83      0x00406183      0xc2,0x04,0x00  ret     0x4

The same thing happens for a function in a segment contribution in the middle
of the compiland contribution:

[offset 236]
0x00000e36      0x00402236      0x5f            pop     edi
0x00000e37      0x00402237      0x5e            pop     esi
0x00000e38      0x00402238      0x5b            pop     ebx
0x00000e39      0x00402239      0xc9            leave   esp,ebp
0x00000e3a      0x0040223a      0xc2,0x04,0x00  ret     0x4

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4839




---
When debugging in source code view, you reach the return statement of a
function. Then you step over to try to return to the caller. Instead, we're put
into disassembly to step thru the epilogue of the function.

This seems to be a problem in the linker. I couldn't find where in the compiler
this wrong information is set. I suspect that when the linker makes the
sstSrcModule record, it uses the offset of the last line, instead of the offset
of the last byte of the function it's in.

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