Fortran, typeprint: Take level of details into account when printing elements of...
authorBernhard Heckel <bernhard.heckel@intel.com>
Wed, 25 May 2016 06:47:17 +0000 (08:47 +0200)
committerBernhard Heckel <bernhard.heckel@intel.com>
Wed, 25 May 2016 06:47:17 +0000 (08:47 +0200)
According to the typeprint's description, elements of a structure
should not be printed when show is < 1.
This variable is also used to distinguish the level of details
between "ptype" and "whatis" expressions.

Before:
(gdb) whatis t1v
type = Type t1
    integer(kind=4) :: t1_i
    real(kind=4) :: t1_r
End Type t1

After:
(gdb) whatis t1v
type = Type t1

2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
* f-typeprint.c (f_type_print_base): Don't print fields when show < 0.

gdb/testsuite/Changelog:
* gdb.fortran/whatis_type.exp: Adapt expected output.

gdb/ChangeLog
gdb/f-typeprint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/whatis_type.exp

index cba01ef14df36b36643e0fc93563df7f29f045eb..a4989ddf9af3c925296f0a377be0d92afebc55e0 100644 (file)
@@ -1,3 +1,7 @@
+2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>
+
+       * f-typeprint.c (f_type_print_base): Don't print fields when show < 0.
+
 2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>
 
        * f-typeprint.c (f_type_print_base): Take print level into account.
index 1990e1bb15f80622abb3ec93e237c34972609e5f..f38a3a0af495fe2e9757b42f821708bdac73f225 100644 (file)
@@ -364,19 +364,24 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
       else
        fprintfi_filtered (level, stream, "Type ");
       fputs_filtered (TYPE_TAG_NAME (type), stream);
-      fputs_filtered ("\n", stream);
-      for (index = 0; index < TYPE_NFIELDS (type); index++)
+      /* According to the definition,
+         we only print structure elements in case show > 0.  */
+      if (show > 0)
        {
-         f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show,
-                            level + 4);
-         fputs_filtered (" :: ", stream);
-         fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
-         f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
-                                      stream, 0, 0, 0, 0);
          fputs_filtered ("\n", stream);
-       } 
-      fprintfi_filtered (level, stream, "End Type ");
-      fputs_filtered (TYPE_TAG_NAME (type), stream);
+         for (index = 0; index < TYPE_NFIELDS (type); index++)
+           {
+             f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show,
+                                level + 4);
+             fputs_filtered (" :: ", stream);
+             fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
+             f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
+                                          stream, 0, 0, 0, 0);
+             fputs_filtered ("\n", stream);
+           }
+         fprintfi_filtered (level, stream, "End Type ");
+         fputs_filtered (TYPE_TAG_NAME (type), stream);
+       }
       break;
 
     case TYPE_CODE_MODULE:
index 2b0519261b10b625a7c3f3fe385ed0d65b1363ff..712ee2f0228781b65000fb12ae87cbcb6f7ef71a 100644 (file)
@@ -1,3 +1,7 @@
+2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>
+
+       * gdb.fortran/whatis_type.exp: Adapt expected output.
+
 2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>
 
        * gdb.fortran/print_type.exp: Fix expected output.
index 7265923447874417d88bdbef3eea5dcd3bb7a529..0b7a1b71a6825162535d43b46ccdf85425c329b6 100644 (file)
@@ -38,18 +38,8 @@ gdb_continue_to_breakpoint "bp1"
 set t1_i "$int :: t1_i"
 set t1_r "$real :: t1_r"
 
-gdb_test "whatis t1" \
-  [multi_line "type = Type t1" \
-                 "    $t1_i" \
-                 "    $t1_r" \
-                 "End Type t1"] \
-  "whatis t1"
-gdb_test "whatis t1v" \
-  [multi_line "type = Type t1" \
-                 "    $t1_i" \
-                 "    $t1_r" \
-                 "End Type t1"] \
-  "whatis t1v"
+gdb_test "whatis t1" "type = Type t1"
+gdb_test "whatis t1v" "type = Type t1"
 
 gdb_test "ptype t1" \
   [multi_line "type = Type t1" \