public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Richard Bunt <Richard.Bunt@arm.com>,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCHv2 8/8] gdb/fortran: Add allocatable type qualifier
Date: Tue, 02 Apr 2019 23:59:00 -0000	[thread overview]
Message-ID: <0a5035dd6ac3159dc8c886ba93fdced7000ef9f7.1554249182.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1554249182.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1554249182.git.andrew.burgess@embecosm.com>

Types in Fortran can have the 'allocatable' qualifier attached to
indicate that memory needs to be explicitly allocated by the user.
This patch extends GDB to show this qualifier when printing types.

Lots of tests results are then updated to include this new qualifier
in the expected results.

gdb/ChangeLog:

	* f-typeprint.c (f_type_print_base): Print 'allocatable' type
	qualifier.
	* gdbtypes.h (TYPE_IS_ALLOCATABLE): Define.

gdb/testsuite/ChangeLog:

	* gdb.fortran/vla-datatypes.exp: Update expected results.
	* gdb.fortran/vla-ptype.exp: Likewise.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
---
 gdb/ChangeLog                               |  7 +++++++
 gdb/f-typeprint.c                           |  3 +++
 gdb/gdbtypes.h                              |  4 ++++
 gdb/testsuite/ChangeLog                     |  7 +++++++
 gdb/testsuite/gdb.fortran/vla-datatypes.exp | 10 +++++-----
 gdb/testsuite/gdb.fortran/vla-ptype.exp     |  8 ++++----
 gdb/testsuite/gdb.fortran/vla-type.exp      | 22 +++++++++++-----------
 gdb/testsuite/gdb.fortran/vla-value.exp     |  4 ++--
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp     |  4 ++--
 9 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 66a450a65c7..a7c1a00a714 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -440,4 +440,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
 	error (_("Invalid type code (%d) in symbol table."), TYPE_CODE (type));
       break;
     }
+
+  if (TYPE_IS_ALLOCATABLE (type))
+    fprintf_filtered (stream, ", allocatable");
 }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2125ed991d0..a1535d1d0b4 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -350,6 +350,10 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
 #define TYPE_IS_REFERENCE(t) \
   (TYPE_CODE (t) == TYPE_CODE_REF || TYPE_CODE (t) == TYPE_CODE_RVALUE_REF)
 
+/* * True if this type is allocatable.  */
+#define TYPE_IS_ALLOCATABLE(t) \
+  (get_dyn_prop (DYN_PROP_ALLOCATED, t) != NULL)
+
 /* * Instruction-space delimited type.  This is for Harvard architectures
    which have separate instruction and data address spaces (and perhaps
    others).
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index afe67742bc4..bb5ed276c22 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -55,15 +55,15 @@ gdb_test "print l" " = \\.TRUE\\." "charactervla allocated"
 
 gdb_breakpoint [gdb_get_line_number "vlas-initialized"]
 gdb_continue_to_breakpoint "vlas-initialized"
-gdb_test "ptype intvla" "type = $int \\\(11,22,33\\\)" \
+gdb_test "ptype intvla" "type = $int, allocatable \\\(11,22,33\\\)" \
   "ptype intvla"
-gdb_test "ptype realvla" "type = $real \\\(11,22,33\\\)" \
+gdb_test "ptype realvla" "type = $real, allocatable \\\(11,22,33\\\)" \
   "ptype realvla"
-gdb_test "ptype complexvla" "type = $complex \\\(11,22,33\\\)" \
+gdb_test "ptype complexvla" "type = $complex, allocatable \\\(11,22,33\\\)" \
   "ptype complexvla"
-gdb_test "ptype logicalvla" "type = $logical \\\(11,22,33\\\)" \
+gdb_test "ptype logicalvla" "type = $logical, allocatable \\\(11,22,33\\\)" \
   "ptype logicalvla"
-gdb_test "ptype charactervla" "type = character\\\*1 \\\(11,22,33\\\)" \
+gdb_test "ptype charactervla" "type = character\\\*1, allocatable \\\(11,22,33\\\)" \
   "ptype charactervla"
 
 gdb_test "print intvla(5,5,5)" " = 1" "print intvla(5,5,5) (1st)"
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index a40ad917da5..0f4abb63757 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -43,24 +43,24 @@ gdb_test "ptype vla2(5, 45, 20)" \
 
 gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
 gdb_continue_to_breakpoint "vla1-allocated"
-gdb_test "ptype vla1" "type = $real \\\(10,10,10\\\)" \
+gdb_test "ptype vla1" "type = $real, allocatable \\\(10,10,10\\\)" \
   "ptype vla1 allocated"
 
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
 gdb_continue_to_breakpoint "vla2-allocated"
-gdb_test "ptype vla2" "type = $real \\\(7,42:50,13:35\\\)" \
+gdb_test "ptype vla2" "type = $real, allocatable \\\(7,42:50,13:35\\\)" \
   "ptype vla2 allocated"
 
 gdb_breakpoint [gdb_get_line_number "vla1-filled"]
 gdb_continue_to_breakpoint "vla1-filled"
-gdb_test "ptype vla1" "type = $real \\\(10,10,10\\\)" \
+gdb_test "ptype vla1" "type = $real, allocatable \\\(10,10,10\\\)" \
   "ptype vla1 filled"
 gdb_test "ptype vla1(3, 6, 9)" "type = $real" \
   "ptype vla1(3, 6, 9)"
 
 gdb_breakpoint [gdb_get_line_number "vla2-filled"]
 gdb_continue_to_breakpoint "vla2-filled"
-gdb_test "ptype vla2" "type = $real \\\(7,42:50,13:35\\\)" \
+gdb_test "ptype vla2" "type = $real, allocatable \\\(7,42:50,13:35\\\)" \
   "ptype vla2 filled"
 gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
   "ptype vla2(5, 45, 20) filled"
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 407a447a851..951f118194a 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -46,7 +46,7 @@ gdb_test "print onev%ivla(1, 2, 3)" " = 123"
 gdb_test "print onev%ivla(3, 2, 1)" " = 321"
 gdb_test "ptype onev" \
          [multi_line "type = Type one" \
-                     "\\s+$int :: ivla\\\(11,22,33\\\)" \
+                     "\\s+$int, allocatable :: ivla\\\(11,22,33\\\)" \
                      "End Type one" ]
 
 # Check type with two VLA's inside
@@ -57,8 +57,8 @@ gdb_test "print twov%ivla1(1, 2, 3)" " = 123"
 gdb_test "print twov%ivla1(3, 2, 1)" " = 321"
 gdb_test "ptype twov" \
          [multi_line "type = Type two" \
-                     "\\s+$int :: ivla1\\\(5,12,99\\\)" \
-                     "\\s+$int :: ivla2\\\(9,12\\\)" \
+                     "\\s+$int, allocatable :: ivla1\\\(5,12,99\\\)" \
+                     "\\s+$int, allocatable :: ivla2\\\(9,12\\\)" \
                      "End Type two" ]
 gdb_test "print twov" " = \\\( ivla1 = \\\(\\\( \\\( 1, 1, 1, 1, 1\\\)\
  \\\( 1, 1, 321, 1, 1\\\)\
@@ -74,7 +74,7 @@ gdb_test "print threev%ivar" " = 3"
 gdb_test "ptype threev" \
          [multi_line "type = Type three" \
                      "\\s+$int :: ivar" \
-                     "\\s+$int :: ivla\\\(20\\\)" \
+                     "\\s+$int, allocatable :: ivla\\\(20\\\)" \
                      "End Type three" ]
 
 # Check type with attribute at end of type
@@ -87,7 +87,7 @@ gdb_test "print fourv%ivla(12)" "no such vector element"
 gdb_test "print fourv%ivar" " = 3"
 gdb_test "ptype fourv" \
          [multi_line "type = Type four" \
-                     "\\s+$int :: ivla\\\(10\\\)" \
+                     "\\s+$int, allocatable :: ivla\\\(10\\\)" \
                      "\\s+$int :: ivar" \
                      "End Type four" ]
 
@@ -103,7 +103,7 @@ gdb_test "ptype fivev" \
                      "End Type five" ]
 gdb_test "ptype fivev%tone" \
          [multi_line "type = Type one" \
-                     "    $int :: ivla\\(10,10,10\\)" \
+                     "    $int, allocatable :: ivla\\(10,10,10\\)" \
                      "End Type one" ]
 
 # Check array of types containing a VLA
@@ -120,7 +120,7 @@ gdb_test "ptype fivearr(1)" \
                      "End Type five" ]
 gdb_test "ptype fivearr(1)%tone" \
          [multi_line "type = Type one" \
-                     "    $int :: ivla\\(2,4,6\\)" \
+                     "    $int, allocatable :: ivla\\(2,4,6\\)" \
                      "End Type one" ]
 gdb_test "ptype fivearr(2)" \
          [multi_line "type = Type five" \
@@ -128,7 +128,7 @@ gdb_test "ptype fivearr(2)" \
                      "End Type five" ]
 gdb_test "ptype fivearr(2)%tone" \
          [multi_line "type = Type one" \
-                     "    $int :: ivla\\(12,14,16\\)" \
+                     "    $int, allocatable :: ivla\\(12,14,16\\)" \
                      "End Type one" ]
 
 # Check allocation status of dynamic array and it's dynamic members
@@ -141,7 +141,7 @@ gdb_test "ptype fivedynarr(2)" \
          "ptype fivedynarr(2), tone is not allocated"
 gdb_test "ptype fivedynarr(2)%tone" \
          [multi_line "type = Type one" \
-                     "    $int :: ivla\\(<not allocated>\\)" \
+                     "    $int, allocatable :: ivla\\(<not allocated>\\)" \
                      "End Type one" ] \
          "ptype fivedynarr(2)%tone, not allocated"
 
@@ -159,7 +159,7 @@ gdb_test "ptype fivedynarr(1)" \
                      "End Type five" ]
 gdb_test "ptype fivedynarr(1)%tone" \
          [multi_line "type = Type one" \
-                     "    $int :: ivla\\(2,4,6\\)" \
+                     "    $int, allocatable :: ivla\\(2,4,6\\)" \
                      "End Type one" ]
 gdb_test "ptype fivedynarr(2)" \
          [multi_line "type = Type five" \
@@ -167,5 +167,5 @@ gdb_test "ptype fivedynarr(2)" \
                      "End Type five" ]
 gdb_test "ptype fivedynarr(2)%tone" \
          [multi_line "type = Type one" \
-                     "    $int :: ivla\\(12,14,16\\)" \
+                     "    $int, allocatable :: ivla\\(12,14,16\\)" \
                      "End Type one" ]
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 507137bed21..be397fd95fb 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
 gdb_continue_to_breakpoint "vla1-init"
 gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
 gdb_test "print &vla1" \
-  " = \\\(PTR TO -> \\\( $real \\\(<not allocated>\\\) \\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real, allocatable \\\(<not allocated>\\\) \\\)\\\) $hex" \
   "print non-allocated &vla1"
 gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
   "print member in non-allocated vla1 (1)"
@@ -56,7 +56,7 @@ with_timeout_factor 15 {
 	"step over value assignment of vla1"
 }
 gdb_test "print &vla1" \
-  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \
   "print allocated &vla1"
 gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
 gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index bf65bf914cf..0759ccbaebe 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -77,10 +77,10 @@ mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
 mi_gdb_test "510-data-evaluate-expression vla1" \
   "510\\^done,value=\"\\(.*\\)\"" "evaluate allocated vla"
 
-mi_create_varobj_checked vla1_allocated vla1 "$real \\\(5\\\)" \
+mi_create_varobj_checked vla1_allocated vla1 "$real, allocatable \\\(5\\\)" \
   "create local variable vla1_allocated"
 mi_gdb_test "511-var-info-type vla1_allocated" \
-  "511\\^done,type=\"$real \\\(5\\\)\"" \
+  "511\\^done,type=\"$real, allocatable \\\(5\\\)\"" \
   "info type variable vla1_allocated"
 mi_gdb_test "512-var-show-format vla1_allocated" \
   "512\\^done,format=\"natural\"" \
-- 
2.14.5

  parent reply	other threads:[~2019-04-02 23:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 23:58 [PATCHv2 0/8] Series of Fortran type printing patches Andrew Burgess
2019-03-18 12:52 ` [PATCH " Andrew Burgess
2019-03-18 12:52   ` [PATCH 2/8] gdb/fortran: Handle internal function calls Andrew Burgess
2019-03-19 19:52     ` Tom Tromey
2019-03-18 12:52   ` [PATCH 4/8] gdb/fortran: better types for components of complex numbers Andrew Burgess
2019-03-19 20:18     ` Tom Tromey
2019-03-18 12:52   ` [PATCH 3/8] gdb/fortran: Additional builtin procedures Andrew Burgess
2019-03-19 20:06     ` Tom Tromey
2019-03-18 12:52   ` [PATCH 8/8] gdb/fortran: Add allocatable type qualifier Andrew Burgess
2019-03-18 12:52   ` [PATCH 6/8] gdb/fortran: print function arguments when printing function type Andrew Burgess
2019-03-18 12:52   ` [PATCH 7/8] gdb/fortran: Update rules for printing whitespace in types Andrew Burgess
2019-03-18 12:52   ` [PATCH 5/8] gdb/fortran: Print 'void' type in lower case Andrew Burgess
2019-03-18 12:52   ` [PATCH 1/8] gdb: Add $_cimag and $_creal internal functions Andrew Burgess
2019-03-18 17:20     ` Eli Zaretskii
2019-03-29 22:41       ` Andrew Burgess
2019-03-30  7:15         ` Eli Zaretskii
2019-03-19 19:47     ` Tom Tromey
2019-04-12 20:24     ` New FAIL on gdb.base/complex-parts.exp - unix/-m32 (was: Re: [PATCH 1/8] gdb: Add $_cimag and $_creal internal functions) Sergio Durigan Junior
2019-04-13  0:02       ` Andrew Burgess
2019-04-16 18:30         ` New FAIL on gdb.base/complex-parts.exp - unix/-m32 Tom Tromey
2019-04-17  0:03           ` Andrew Burgess
2019-03-19 20:27   ` [PATCH 0/8] Series of Fortran type printing patches Tom Tromey
2019-04-02 23:58   ` [PATCHv2 3/8] gdb/fortran: Additional builtin procedures Andrew Burgess
2019-04-02 23:58   ` [PATCHv2 1/8] gdb: Remove an unbalanced stray double quote from a comment Andrew Burgess
2019-04-02 23:58   ` [PATCHv2 2/8] gdb/fortran: Introduce fortran-operator.def file Andrew Burgess
2019-04-02 23:59   ` Andrew Burgess [this message]
2019-04-02 23:59   ` [PATCHv2 4/8] gdb/fortran: better types for components of complex numbers Andrew Burgess
2019-05-03  0:21     ` Regression on gdb.fortran/complex.exp on unix/-m32 (was: Re: [PATCHv2 4/8] gdb/fortran: better types for components of complex numbers) Sergio Durigan Junior
2019-04-02 23:59   ` [PATCHv2 6/8] gdb/fortran: print function arguments when printing function type Andrew Burgess
2019-04-02 23:59   ` [PATCHv2 7/8] gdb/fortran: Update rules for printing whitespace in types Andrew Burgess
2019-04-02 23:59   ` [PATCHv2 5/8] gdb/fortran: Print 'void' type in lower case Andrew Burgess
2019-04-23 22:16 ` [PATCHv2 0/8] Series of Fortran type printing patches Andrew Burgess
2019-04-24 19:19   ` Tom Tromey
2019-04-30 12:37     ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0a5035dd6ac3159dc8c886ba93fdced7000ef9f7.1554249182.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=Richard.Bunt@arm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).