diff options
author | Tom Tromey <tromey@redhat.com> | 2012-01-16 19:44:16 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-01-16 19:44:16 +0000 |
commit | cafec441901459c36ad92f1cd9eef648534ea53b (patch) | |
tree | 4cd1a43ea2f36c655c39948c0b0e163874bb2e24 /gdb/dwarf2read.c | |
parent | 983af33b2623508a921372f02abee87aad9c8915 (diff) | |
download | gdb-cafec441901459c36ad92f1cd9eef648534ea53b.zip gdb-cafec441901459c36ad92f1cd9eef648534ea53b.tar.gz gdb-cafec441901459c36ad92f1cd9eef648534ea53b.tar.bz2 |
gdb
PR python/13281:
* gdbtypes.h (TYPE_FLAG_ENUM): New macro.
(struct main_type) <flag_flag_enum>: New field.
* dwarf2read.c (process_enumeration_scope): Detect "flag" enums.
* NEWS: Add entries.
* c-valprint.c (c_val_print) <TYPE_CODE_ENUM>: Handle "flag"
enums.
* python/lib/gdb/printing.py (_EnumInstance): New class.
(FlagEnumerationPrinter): Likewise.
gdb/doc
* gdb.texinfo (gdb.printing): Document FlagEnumerationPrinter.
gdb/testsuite
* gdb.base/printcmds.c (enum flag_enum): New.
(three): New global.
* gdb.base/printcmds.exp (test_print_enums): Add test for flag
enum printing.
* gdb.python/py-pp-maint.py (build_pretty_printer): Instantiate
FlagEnumerationPrinter.
* gdb.python/py-pp-maint.exp: Add tests for FlagEnumerationPrinter.
* gdb.python/py-pp-maint.c (enum flag_enum): New.
(fval): New global.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 42dbac3..afb4337 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -7913,6 +7913,8 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) int num_fields = 0; int unsigned_enum = 1; char *name; + int flag_enum = 1; + ULONGEST mask = 0; child_die = die->child; while (child_die && child_die->tag) @@ -7928,7 +7930,14 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) { sym = new_symbol (child_die, this_type, cu); if (SYMBOL_VALUE (sym) < 0) - unsigned_enum = 0; + { + unsigned_enum = 0; + flag_enum = 0; + } + else if ((mask & SYMBOL_VALUE (sym)) != 0) + flag_enum = 0; + else + mask |= SYMBOL_VALUE (sym); if ((num_fields % DW_FIELD_ALLOC_CHUNK) == 0) { @@ -7961,6 +7970,8 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) } if (unsigned_enum) TYPE_UNSIGNED (this_type) = 1; + if (flag_enum) + TYPE_FLAG_ENUM (this_type) = 1; } /* If we are reading an enum from a .debug_types unit, and the enum |