]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle __XVL fields in Ada type printing
authorTom Tromey <tromey@adacore.com>
Wed, 4 Nov 2020 16:17:58 +0000 (09:17 -0700)
committerTom Tromey <tromey@adacore.com>
Wed, 4 Nov 2020 16:17:58 +0000 (09:17 -0700)
Sometimes the Ada compiler will emit an "__XVL" name for a field.  The
Ada compiler describes:

--  Second, the variable-length fields themselves are represented by
--  replacing the type by a special access type. The designated type of
--  this access type is the original variable-length type, and the fact
--  that this field has been transformed in this way is signalled by
--  encoding the field name as:

--    field___XVL

Currently gdb describes such fields as having "access" type, but this
is inaccurate.  This patch changes gdb to avoid printing "access" in
this case.

gdb/ChangeLog
2020-11-04  Tom Tromey  <tromey@adacore.com>

* ada-typeprint.c (ada_print_type): Handle __XVL fields.

gdb/testsuite/ChangeLog
2020-11-04  Tom Tromey  <tromey@adacore.com>

* gdb.ada/funcall_ref.exp: Update.
* gdb.ada/var_rec_arr.exp: Update.

gdb/ChangeLog
gdb/ada-typeprint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/funcall_ref.exp
gdb/testsuite/gdb.ada/var_rec_arr.exp

index 478da8238f5064ff4ebadaa2f85453f748d83857..c03eacc904fd2ea0f663cabc68dafcfa72d8ab4e 100644 (file)
@@ -1,3 +1,7 @@
+2020-11-04  Tom Tromey  <tromey@adacore.com>
+
+       * ada-typeprint.c (ada_print_type): Handle __XVL fields.
+
 2020-11-04  Tom Tromey  <tromey@adacore.com>
 
        * ada-typeprint.c (ada_print_type): Handle __T types.
index 0892c7c3dcd9dd7be230e44115daa82cd1f7151e..5388247957be8c269f5f3dff58673e086689d3f0 100644 (file)
@@ -1006,7 +1006,11 @@ ada_print_type (struct type *type0, const char *varstring,
        break;
       case TYPE_CODE_PTR:
       case TYPE_CODE_TYPEDEF:
-       fprintf_filtered (stream, "access ");
+       /* An __XVL field is not truly a pointer, so don't print
+          "access" in this case.  */
+       if (type->code () != TYPE_CODE_PTR
+           || strstr (varstring, "___XVL") == nullptr)
+         fprintf_filtered (stream, "access ");
        ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level,
                        flags);
        break;
index 6927735324f61c4bca9da807459a670cc1452d8b..06ca3e7137412d3d8a40a1ffd5ae9061e14fee6e 100644 (file)
@@ -1,3 +1,8 @@
+2020-11-04  Tom Tromey  <tromey@adacore.com>
+
+       * gdb.ada/funcall_ref.exp: Update.
+       * gdb.ada/var_rec_arr.exp: Update.
+
 2020-11-04  Tom Tromey  <tromey@adacore.com>
 
        * gdb.ada/rec_ptype.exp: New file.
index 1768c1d480a4f3d5c69b8f73c5c8323dcad087cd..d3c6e54c8e0f2456e6d47f99a996f153ddf08189 100644 (file)
@@ -41,7 +41,7 @@ foreach_with_prefix scenario {all minimal} {
     # references).
     set pass_re [multi_line "type = <ref> record" \
                     "    n: natural;" \
-                    "    s: access array \\(1 \\.\\. n\\) of character;" \
+                    "    s: array \\(1 \\.\\. n\\) of character;" \
                     "end record"]
     # With DWARF we get debuginfo that could in theory show "1..n" for
     # the range:
index c2ad97b31e2df6a58c4fefb7f6a4a4a8969febc7..da906dc5d8cfaf9d03e8867a88093d0da1411f26 100644 (file)
@@ -58,21 +58,9 @@ foreach_with_prefix scenario {all minimal} {
     gdb_test "print a2(3)" \
        " = \\(i => 0, s => \"\"\\)"
 
-    # Note that the "access" is only printed when the gnat encodings
-    # are used.  This is due to how the encodings work -- the type
-    # doesn't actually have the "access", and so here the DWARF
-    # encoding is more correct.
-    if {$scenario == "all"} {
-       set ex [multi_line "type = record" \
-                   "    i: pck\\.small_type;" \
-                   "    s: access array \\((<>|1 \\.\\. i)\\) of character;" \
-                   "end record"]
-    } else {
-       set ex [multi_line "type = record" \
-                   "    i: pck\\.small_type;" \
-                   "    s: array \\((<>|1 \\.\\. i)\\) of character;" \
-                   "end record"]
-    }
-
-    gdb_test "ptype a1(1)" $ex
+    gdb_test "ptype a1(1)" \
+       [multi_line "type = record" \
+            "    i: pck\\.small_type;" \
+            "    s: array \\((<>|1 \\.\\. i)\\) of character;" \
+            "end record"]
 }