Variables with enumerator type show up in the debugger as their base types. Even though the enumerator type itself is written to the object file (at least for CodeView debug info), it is not referred to by the variables type.
compiling:
module test;
enum E { kEnum1, kEnum2 }
E e = E.kEnum1;
with "dmd -c -g test.d" and running the object file through obj2asm produces
----8<-----
...
S_GDATA32 off = x0000, seg = x0000, typ = x0074 _D4test1eE4test1E
segidx = 5 offset = 004e, lcfd = ec10, fd = 1, td = 8, targdisp = x0000
...
---->8-----
mapping test.e to type 74h (int).
Comment #1 by r.sagitario — 2010-06-23T00:18:10Z
Created attachment 674
Recoverer enumerator type for debug info
The type information is lost in toCType, but as the code generator probably relies on working with the base type, it seems dangerous to change it. Here's a patch that tunnels a reference to the D symbol through to the debug information output stage. This fix patches only the CodeView implementation.
The patch is for dmd2, svn rev 556.
Comment #2 by aldonunez1 — 2011-04-28T01:03:55Z
I think I have a simpler fix.
If we write a mostly blank LF_ENUM record with only the right name and the forward reference flag (128) in the property field, the linker merges it with the full LF_ENUM record written by EnumDeclaration::toDebug/cv4_Denum.
Only one LF_ENUM record for each enum will appear in the debug info, and all references will be right.
Comment #3 by aldonunez1 — 2011-04-28T01:05:28Z
Created attachment 951
Write a forward reference LF_ENUM record.
I believe this patch also fixes the bug and is simpler.
Comment #4 by aldonunez1 — 2011-04-28T01:10:24Z
Created attachment 952
Write a forward reference LF_ENUM record.
Let's try this again. I didn't mean for the patch to be in UTF-16.
Comment #5 by r.sagitario — 2017-01-14T09:11:38Z
*** Issue 16700 has been marked as a duplicate of this issue. ***
Comment #6 by r.sagitario — 2019-08-20T21:53:42Z
Patch by Aldo looks good, should give it a try translating it to the current backend.
Comment #7 by dlang-bot — 2019-08-21T06:53:29Z
@rainers created dlang/dmd pull request #10328 "fix Issue 4372, 982 - CodeView: type of enumerator values reduced to …" fixing this issue:
- fix Issue 4372, 982 - CodeView: type of enumerator values reduced to base type in debug info
write a forward reference to the enum definition, it is emitted elsewhere
https://github.com/dlang/dmd/pull/10328
Comment #8 by dlang-bot — 2019-08-23T01:46:38Z
dlang/dmd pull request #10328 "fix Issue 4372, 982 - CodeView: type of enumerator values reduced to …" was merged into master:
- f4e4b7e6ff66ec4d0d2774f309731c03392327cc by Rainer Schuetze:
fix Issue 4372, 982 - CodeView: type of enumerator values reduced to base type in debug info
write a forward reference to the enum definition, it is emitted elsewhere
https://github.com/dlang/dmd/pull/10328