aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-valprint.c
diff options
context:
space:
mode:
authorWalfred Tedeschi <walfred.tedeschi@intel.com>2016-06-21 15:15:04 +0200
committerWalfred Tedeschi <walfred.tedeschi@intel.com>2016-06-21 15:15:04 +0200
commit04d59df6f311bcc20d74ada64a5e15a4bbb40026 (patch)
tree0fd8b906cf2cd75b1a9a91842c0397ac9b05dc82 /gdb/f-valprint.c
parentbdd582dbf14f12998a0003b5aa772d7868bc3dc7 (diff)
downloadgdb-04d59df6f311bcc20d74ada64a5e15a4bbb40026.zip
gdb-04d59df6f311bcc20d74ada64a5e15a4bbb40026.tar.gz
gdb-04d59df6f311bcc20d74ada64a5e15a4bbb40026.tar.bz2
Improve user experience in printing Fortran derived types.
Output for Fortran derived classes is like: "( 9, 'abc')" with this changes the output is changed to: "( lucky_number = 9, letters = 'abc')" 2016-06-21 Walfred Tedeschi <walfred.tedeschi@intel.com> * f-valprint.c (f_val_print): Add field names for printing derived types fields. gdb/testsuite: * gdb.fortran/derived-type.exp (print q): Add fields to the output. * gdb.fortran/vla-type.exp (print twov): Fix vla tests with structs. * gdb.fortran/derived-type-function.exp: New file. * gdb.fortran/derived-type-function.f90: New file.
Diffstat (limited to 'gdb/f-valprint.c')
-rw-r--r--gdb/f-valprint.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 1264737..08215e2 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -219,6 +219,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
struct gdbarch *gdbarch = get_type_arch (type);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int i = 0; /* Number of characters printed. */
+ int printed_field = 0; /* Number of fields printed. */
struct type *elttype;
CORE_ADDR addr;
int index;
@@ -337,15 +338,32 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
struct value *field = value_field
((struct value *)original_value, index);
- val_print (value_type (field),
- value_contents_for_printing (field),
- value_embedded_offset (field),
- value_address (field), stream, recurse + 1,
- field, options, current_language);
+ struct type *field_type = check_typedef (TYPE_FIELD_TYPE (type, index));
- if (index != TYPE_NFIELDS (type) - 1)
- fputs_filtered (", ", stream);
- }
+
+ if (TYPE_CODE (field_type) != TYPE_CODE_FUNC)
+ {
+ const char *field_name;
+
+ if (printed_field > 0)
+ fputs_filtered (", ", stream);
+
+ field_name = TYPE_FIELD_NAME (type, index);
+ if (field_name != NULL)
+ {
+ fputs_filtered (field_name, stream);
+ fputs_filtered (" = ", stream);
+ }
+
+ val_print (value_type (field),
+ value_contents_for_printing (field),
+ value_embedded_offset (field),
+ value_address (field), stream, recurse + 1,
+ field, options, current_language);
+
+ ++printed_field;
+ }
+ }
fprintf_filtered (stream, " )");
break;