Bug 16063 - Debuggers need more information about enum types in C++
Debuggers need more information about enum types in C++
Status: NEW
Product: gcc
Classification: Unclassified
Component: debug
3.4.0
: P2 enhancement
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-06-18 16:12 UTC by jcownie
Modified: 2014-03-23 11:22 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 4.0.0
Known to fail:
Last reconfirmed: 2006-01-29 17:57:23


Attachments
Test case with embedded description. (1.99 KB, text/plain)
2004-06-18 16:14 UTC, jcownie
Details
Patch against 3.4.0 (460 bytes, patch)
2004-06-18 16:27 UTC, jcownie
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jcownie 2004-06-18 16:12:55 UTC
The debug information emitted for enumerated types does not allow a debugger
to unambiguously determine the "underlying type" of the enumeration.

A debugger therefore does not have enough information to allow it to perform
overload resolution when asked to evaluate a function call with an enum type
as an actual argument.

One can view this either as a bug (the compiler is emitting an unsigned value
using DW_FORM_sdata), or as requiring an enhancement.

I believe the simplest solution would be to have the compiler be explicit about 
the representation of the enum type by emitting a DW_AT_encoding with the
DW_TAG_enumeration, so that the debugger is explicitly told whether the 
underlying type of the enumeration is signed or unsigned.

See the (about to be attached) test case for detailed information.
Comment 1 jcownie 2004-06-18 16:14:46 UTC
Created attachment 6565 [details]
Test case with embedded description.
Comment 2 Andrew Pinski 2004-06-18 16:22:52 UTC
Confirmed, I should note that ICC 6.0 does not do this also.
Comment 3 jcownie 2004-06-18 16:27:08 UTC
Created attachment 6566 [details]
Patch against 3.4.0

This simple patch does everything we need, I believe.
Comment 4 jcownie 2004-06-18 16:31:13 UTC
Subject: Re:  Debuggers need more information about enum types in C++ 


> Confirmed, I should note that ICC 6.0 does not do this also.

Right, it's an extension to the DWARF standard to require this. 

I have submitted changes to add this to DWARF to the DWARF2 maliing
lists, but have yet to receive feedback.

I have also submitted it as a bug report to Intel against their latest
compiler ;-)

I imagine their fix may take longer than yours if you're happy with
the (one line of code) patch which I just submitted.

Comment 5 Tom Tromey 2012-06-29 13:50:49 UTC
DWARF 4 allows this:

The enumeration type entry may have a DW_AT_type attribute which refers to the underlying
data type used to implement the enumeration.

I think this is definitely needed for "enum class", where the base
type can be specified by the user.
However, emitting it unconditionally wouldn't hurt.
Comment 6 Mark Wielaard 2014-03-23 11:22:24 UTC
Posted a patch:
http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01198.html