www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13519] New: Debugging issues when main()-containing module


          Issue ID: 13519
           Summary: Debugging issues when main()-containing module not
                    listed first in DMD commandline
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: erikas.aubade gmail.com

It appears that, when compiling for x86_64 on linux, if invoked with a module
besides the one containing main() first on the command line, DMD slightly
messes up something with debug info, making it not possible to read some
variables at runtime.

I've managed to make the problem work with the following setup, requiring two
files; main.d and afunc.d.


module main;
import afunc;

void main() {
    size_t count;

     while(true) {
        count = inc(count);


module afunc;

auto inc (size_t var) {
    return ++var;

Compiling it with the following command:

$ dmd -m64 -g -ofbadsymbols afunc.d main.d

Load it in gdb with the following:

$ gdb ./badsymbols

then, in gdb, enter the following commands:

) break main.d:8
) run

here, it should run momentarily, then hit the breakpoint.

) print count

will give the error:
'Could not find the frame base for "D main".'

However, if you compile with this command instead:

$ dmd -m64 -g -ofgoodsymbols main.d afunc.d

then repeat the procedure, print count will show
'$1 = 0'
as expected.

Sep 22 2014