[Issue 16977] New: bad debug info for function default arguments

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 17 02:40:06 PST 2016


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

          Issue ID: 16977
           Summary: bad debug info for function default arguments
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Keywords: symdeb
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

When compiling this code with debug information for OMF:



void main()
{
    foo(1, 2);
}

size_t foo(int x, int y, int z = 3)
{
    return x;
}

it results in line number info displayed by the debugger like this:

     1: 
     2: void main()
00402010 55                   push        ebp  
00402011 8B EC                mov         ebp,esp  
     3: {
     4:     foo(1, 2);
00402013 6A 01                push        1  
     3: {
     4:     foo(1, 2);
00402015 6A 02                push        2  
     6: 
     7: size_t foo(int x, int y, int z = 3)
00402017 B8 03 00 00 00       mov         eax,3  
0040201C E8 07 00 00 00       call        cvdefarg at foo (0402028h)  
00402021 31 C0                xor         eax,eax  
     5: }
00402023 5D                   pop         ebp  
00402024 C3                   ret  

This has issues:

- loading the default argument inherits the location of the function
declaration, so the debugger is prematurely redirected to the source line of
the function before actually calling it. The user thinks the function is
already called, but using "step until return" will stop after returning from
the calling function instead.

- the return address on the stack is considered at line 7, i.e. at the function
declaration. This makes the call stack pretty unusable.

Compiling for COFF is even worse because there is a (gratuitious?) limitation
on increasing line numbers.

--


More information about the Digitalmars-d-bugs mailing list