diff options
author | Tom Tromey <tom@tromey.com> | 2020-03-13 17:39:52 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-03-13 18:03:41 -0600 |
commit | 40f3ce189e3c16398f2e56442e6d8db5573587ee (patch) | |
tree | e07611d04348489594254787c7592199cf43c9ea /gdb | |
parent | 2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9 (diff) | |
download | fsf-binutils-gdb-40f3ce189e3c16398f2e56442e6d8db5573587ee.zip fsf-binutils-gdb-40f3ce189e3c16398f2e56442e6d8db5573587ee.tar.gz fsf-binutils-gdb-40f3ce189e3c16398f2e56442e6d8db5573587ee.tar.bz2 |
Fix generic_val_print_enum for value-based printing
This removes a call to val_print_scalar_formatted from
generic_val_print_enum, preferring to do the work in the callers.
This lets generic_value_print use the value-based API.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_val_print): Update.
(generic_value_print): Update.
* valprint.c (generic_val_print_enum): Don't call
val_print_scalar_formatted.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/valprint.c | 30 |
2 files changed, 22 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 322d4c7..f812cd7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2020-03-13 Tom Tromey <tom@tromey.com> + * valprint.c (generic_val_print): Update. + (generic_value_print): Update. + * valprint.c (generic_val_print_enum): Don't call + val_print_scalar_formatted. + +2020-03-13 Tom Tromey <tom@tromey.com> + * valprint.c (generic_value_print): Call generic_value_print_ptr. * valprint.c (generic_value_print_ptr): New function. diff --git a/gdb/valprint.c b/gdb/valprint.c index 0063bb5..9362bda 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -721,19 +721,13 @@ generic_val_print_enum (struct type *type, struct gdbarch *gdbarch = get_type_arch (type); int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); - if (options->format) - { - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - } - else - { - const gdb_byte *valaddr = value_contents_for_printing (original_value); + gdb_assert (!options->format); - val = unpack_long (type, valaddr + embedded_offset * unit_size); + const gdb_byte *valaddr = value_contents_for_printing (original_value); - generic_val_print_enum_1 (type, val, stream); - } + val = unpack_long (type, valaddr + embedded_offset * unit_size); + + generic_val_print_enum_1 (type, val, stream); } /* generic_val_print helper for TYPE_CODE_FLAGS. */ @@ -977,8 +971,12 @@ generic_val_print (struct type *type, break; case TYPE_CODE_ENUM: - generic_val_print_enum (type, embedded_offset, stream, - original_value, options); + if (options->format) + val_print_scalar_formatted (type, embedded_offset, + original_value, options, 0, stream); + else + generic_val_print_enum (type, embedded_offset, stream, + original_value, options); break; case TYPE_CODE_FLAGS: @@ -1086,8 +1084,10 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_ENUM: - generic_val_print_enum (type, 0, stream, - val, options); + if (options->format) + value_print_scalar_formatted (val, options, 0, stream); + else + generic_val_print_enum (type, 0, stream, val, options); break; case TYPE_CODE_FLAGS: |