Handle DW_AT_encoding on DW_TAG_enumeration_type
A user pointed out a problem when printing certain values from an Ada
enumeration type. Investigation showed that the problem was that some
enumeration constants were emitted using DW_FORM_data1, and were
incorrectly sign-extended by gdb.
First, this is yet another instance of a general problem with DWARF.
See https://sourceware.org/bugzilla/show_bug.cgi?id=32680 for the
analysis.
Meanwhile, it turns out that GCC implements an extension to handle
this scenario. In particular, in non-strict mode, it will emit
DW_AT_encoding using either DW_ATE_signed or DW_ATE_unsigned. This
was done back in 2017 by Pierre-Marie, in support of Ada -- but then
somehow nothing was ever implemented on the gdb side. For this see
GCC commit
f76f096e ("DWARF: add DW_AT_encoding attributes for
DW_TAG_enumeration_type DIEs").
This patch adds the missing code to gdb. The included test case shows
the bug that was originally reported. I've also included the snippet
from Pierre-Marie's commit message for good measure.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680
Approved-By: Andrew Burgess <aburgess@redhat.com>