Bug 4014 – CodeView debug type info not linked in from library

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-03-27T01:33:12Z
Last change time
2017-08-16T13:22:30Z
Keywords
pull, symdeb, wrong-code
Assigned to
No Owner
Creator
Rainer Schuetze
Blocks
4044

Comments

Comment #0 by r.sagitario — 2010-03-27T01:33:12Z
If a class is defined in a library, the debug info describing that class is not linked into an executable, if it does not reference the init-property. Example: ---- module lib; struct struc_lib { int a, b; } ---- dmd -g -lib lib ---- module test; import lib; void main() { struc_lib slib; } ---- dmd -g test lib.lib ---- This produces incomplete debug info for struc_lib. Using struc_lib slib = struc_lib.init; helps.
Comment #1 by r.sagitario — 2010-03-27T01:38:36Z
This is caused the implicite "-multiobj" flag being set when compiling into a library. The debug type info is then in the module that contains the init-struct for the class/struct. If never referenced (e.g. if initialization is inlined), it will not show up in the executable. A workaround is to not use -multiobj for libraries if they are compiled with debug info, but this can add some link dependencies. Index: mars.c =================================================================== --- mars.c (revision 419) +++ mars.c (working copy) @@ -806,7 +806,9 @@ global.params.objname = NULL; // Haven't investigated handling these options with multiobj - if (!global.params.cov && !global.params.trace) + // multiobj causes class/struct debug info to be attached to init-data, + // but this will not be linked into the executable, so this info is lost + if (!global.params.cov && !global.params.trace && !global.params.symdebug) global.params.multiobj = 1; } else if (global.params.run)
Comment #2 by bugzilla — 2011-02-07T15:41:02Z
Comment #3 by bugzilla — 2011-02-13T11:41:55Z
Rainer Schuetze writes on the mailing list: trying to create a branch with as little changes to the master branch as possible, I noticed that this patch causes problems when creating DLLs (it still wants _Dmain to be defined). This is happening because the patch puts full modules into a library instead of single functions when also adding debug symbols, so any reference into rt.dmain2 drags in the standard console application startup. My patches to create a shared version of the runtime library split this module, so the issue did not show up before. I'd say the patch to 4014 should be reverted until this is sorted out. A minor improvement could be that prohibiting multiobj generation should be limited to debug builds in addition to adding debug symbols (which could also happen for release builds).
Comment #4 by r.sagitario — 2011-09-20T23:44:42Z
Comment #5 by bugzilla — 2012-09-12T13:35:43Z
I just don't like the idea of duplicating the symbolic debug info. In reading this bug report, it seems the primary issue is that symdeb info is only generated for the module with the .init data. A better solution may be to have a module generated with only symdeb info for a class, and a single global defined. Then, other modules can reference that single global, thereby pulling in the symdeb data.
Comment #6 by r.sagitario — 2014-10-07T08:09:31Z
Comment #7 by github-bugzilla — 2017-06-23T08:50:05Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9d2eeda0383fa55a8dea58f4d6960bb110e77c56 fix issue 4014 - add option to add debug info for all referenced types https://github.com/dlang/dmd/commit/8aeca3c24e742eff8a5a72c27ea6ebd61a167582 Merge pull request #6908 from rainers/cv_symdebref fix issue 4014 - add option to add debug info for all referenced types
Comment #8 by github-bugzilla — 2017-08-07T13:16:51Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9d2eeda0383fa55a8dea58f4d6960bb110e77c56 fix issue 4014 - add option to add debug info for all referenced types https://github.com/dlang/dmd/commit/8aeca3c24e742eff8a5a72c27ea6ebd61a167582 Merge pull request #6908 from rainers/cv_symdebref
Comment #9 by github-bugzilla — 2017-08-16T13:22:30Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9d2eeda0383fa55a8dea58f4d6960bb110e77c56 fix issue 4014 - add option to add debug info for all referenced types https://github.com/dlang/dmd/commit/8aeca3c24e742eff8a5a72c27ea6ebd61a167582 Merge pull request #6908 from rainers/cv_symdebref