Codeview handles anonymous enums by using placeholder names.
Anonymous enums in C++ now receive a placeholder name in CodeView debug info, preventing null pointer dereferences.
This change ensures that anonymous enum types are handled correctly during CodeView debug information generation. Previously, enums lacking a name would result in a null pointer dereference when write_lf_enum attempted to emit their type information. The fix assigns a consistent placeholder name, similar to that used for anonymous structures and unions, thereby preventing the crash and ensuring valid debug output.
In Details
When processing anonymous enum DIEs in dwarf2codeview.cc, get_name returns NULL because DW_AT_name is absent. write_lf_enum then dereferences this null pointer when emitting the CodeView type information. This commit introduces the use of a placeholder name for such anonymous enums, aligning with the behavior for anonymous structures and unions, thus preventing a crash and ensuring that these types are represented in the debug output.
- DIE
- Debugging Information Entry. A structured record within DWARF or CodeView debug data that describes a program element like a variable, type, or function.
- DW_AT_name
- An attribute within a DWARF DIE that specifies the name of the entity the DIE represents.
- CodeView
- A proprietary debug information format developed by Microsoft, commonly used with the Visual C++ compiler and on Windows platforms. GCC supports generating CodeView debug info.