[Issue 13519] New: Debugging issues when main()-containing module not listed first in DMD commandline

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Sep 22 01:29:51 PDT 2014


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

          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 at puremagic.com
          Reporter: erikas.aubade at 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.

main.d:

module main;
import afunc;

void main() {
    size_t count;

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


afunc.d:

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.

--


More information about the Digitalmars-d-bugs mailing list