diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-04-18 06:46:47 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-04-18 06:46:47 +0000 |
commit | 14e75d8ea4fe9ed4dbf292ae4a9745e33e2ff353 (patch) | |
tree | 1f75ad6039b21a8ce73b1577f8cd74c7bc23193d /gdb/python | |
parent | dcc0705263d4af11b3bb1953d29a0ad99de7b647 (diff) | |
download | gdb-14e75d8ea4fe9ed4dbf292ae4a9745e33e2ff353.zip gdb-14e75d8ea4fe9ed4dbf292ae4a9745e33e2ff353.tar.gz gdb-14e75d8ea4fe9ed4dbf292ae4a9745e33e2ff353.tar.bz2 |
gdb/
PR symtab/7259:
* ada-exp.y (convert_char_literal): Use TYPE_FIELD_ENUMVAL.
* ada-lang.c (ada_discrete_type_high_bound)
(ada_discrete_type_low_bound): Use TYPE_FIELD_ENUMVAL for
TYPE_CODE_ENUM.
(ada_identical_enum_types_p): Use TYPE_FIELD_ENUMVAL.
(pos_atr, value_val_atr): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
* ada-typeprint.c (print_enum_type): Change variable lastval to LONGEST.
Use TYPE_FIELD_ENUMVAL.
* ada-valprint.c (print_optional_low_bound, ada_print_scalar)
(ada_val_print_1): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
* c-typeprint.c (c_type_print_base): Move variable lastval to inner
block, change it to LONGEST. Use TYPE_FIELD_ENUMVAL for
TYPE_CODE_ENUM.
* coffread.c (coff_read_enum_type): Use SET_FIELD_ENUMVAL.
* dwarf2read.c (process_enumeration_scope): Likewise.
* gdb-gdb.py (TypeFlagsPrinter): Use field.enumval instead of
field.bitpos.
(class StructMainTypePrettyPrinter): Support also
FIELD_LOC_KIND_ENUMVAL.
* gdbtypes.c (get_discrete_bounds): Use TYPE_FIELD_ENUMVAL for
TYPE_CODE_ENUM.
(recursive_dump_type): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
(copy_type_recursive): Support also FIELD_LOC_KIND_ENUMVAL.
* gdbtypes.h (enum field_loc_kind): New FIELD_LOC_KIND_ENUMVAL.
(struct main_type.flds_bnds.fields.loc): Adjust bitpos comment. New
field enumval.
(struct main_type.flds_bnds.bields): Adjust loc_kind and bitsize to
accommodate enumval.
(struct call_site): Adjust loc_kind to accommodate enumval.
(FIELD_ENUMVAL, FIELD_ENUMVAL_LVAL, SET_FIELD_ENUMVAL)
(TYPE_FIELD_ENUMVAL): New macros.
* m2-typeprint.c (m2_enum): Use TYPE_FIELD_ENUMVAL.
* mdebugread.c (parse_symbol): Use TYPE_FIELD_ENUMVAL for
TYPE_CODE_ENUM.
* p-typeprint.c (pascal_type_print_base): Likewise.
* python/lib/gdb/printing.py (class FlagEnumerationPrinter): Use
enumval.
* python/lib/gdb/types.py (make_enum_dict): Likewise.
* python/py-type.c (convert_field): New variable addrstring. Use
TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
(check_types_equal): Support also FIELD_LOC_KIND_ENUMVAL.
* stabsread.c (read_enum_type): Use SET_FIELD_ENUMVAL.
* typepint.c (print_type_scalar): Use TYPE_FIELD_ENUMVAL for
TYPE_CODE_ENUM.
* valprint.c (generic_val_print): Likewise.
gdb/testsuite/
PR symtab/7259:
* gdb.base/enumval.c: New test case.
* gdb.base/enumval.exp: New test case.
* gdb.python/py-type.exp (test_enums): Use field.enumval instead of
field.bitpos.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/printing.py | 4 | ||||
-rw-r--r-- | gdb/python/lib/gdb/types.py | 4 | ||||
-rw-r--r-- | gdb/python/py-type.c | 20 |
3 files changed, 22 insertions, 6 deletions
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index 0f399d0..b4e798d 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -247,10 +247,10 @@ class FlagEnumerationPrinter(PrettyPrinter): flags = gdb.lookup_type(self.name) self.enumerators = [] for field in flags.fields(): - self.enumerators.append((field.name, field.bitpos)) + self.enumerators.append((field.name, field.enumval)) # Sorting the enumerators by value usually does the right # thing. - self.enumerators.sort(key = lambda x: x.bitpos) + self.enumerators.sort(key = lambda x: x.enumval) if self.enabled: return _EnumInstance(self.enumerators, val) diff --git a/gdb/python/lib/gdb/types.py b/gdb/python/lib/gdb/types.py index aca84f3..66c9528 100644 --- a/gdb/python/lib/gdb/types.py +++ b/gdb/python/lib/gdb/types.py @@ -86,8 +86,8 @@ def make_enum_dict(enum_type): raise TypeError("not an enum type") enum_dict = {} for field in enum_type.fields(): - # The enum's value is stored in "bitpos". - enum_dict[field.name] = field.bitpos + # The enum's value is stored in "enumval". + enum_dict[field.name] = field.enumval return enum_dict diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index d47d4c8..23808af 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -167,11 +167,23 @@ convert_field (struct type *type, int field) if (!field_is_static (&TYPE_FIELD (type, field))) { - arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field)); + const char *attrstring; + + if (TYPE_CODE (type) == TYPE_CODE_ENUM) + { + arg = gdb_py_long_from_longest (TYPE_FIELD_ENUMVAL (type, field)); + attrstring = "enumval"; + } + else + { + arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field)); + attrstring = "bitpos"; + } + if (!arg) goto fail; - if (PyObject_SetAttrString (result, "bitpos", arg) < 0) + if (PyObject_SetAttrString (result, attrstring, arg) < 0) goto failarg; } @@ -1018,6 +1030,10 @@ check_types_equal (struct type *type1, struct type *type2, if (FIELD_BITPOS (*field1) != FIELD_BITPOS (*field2)) return Py_NE; break; + case FIELD_LOC_KIND_ENUMVAL: + if (FIELD_ENUMVAL (*field1) != FIELD_ENUMVAL (*field2)) + return Py_NE; + break; case FIELD_LOC_KIND_PHYSADDR: if (FIELD_STATIC_PHYSADDR (*field1) != FIELD_STATIC_PHYSADDR (*field2)) |