public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH V4 1/6] Fortran: Testsuite, fix differences in type naming.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
                   ` (2 preceding siblings ...)
  2016-09-07  6:38 ` [PATCH V4 6/6] Fortran: Testsuite, add cyclic pointers Bernhard Heckel
@ 2016-09-07  6:38 ` Bernhard Heckel
  2016-09-21 15:57   ` Yao Qi
  2016-09-07  6:38 ` [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer Bernhard Heckel
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

Continued on 0c13f7e559afe5f973a59311b0e401296c48d96c
(fortran: Testsuite, fix different type naming across compilers).

2016-06-08  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Testsuite/Changelog:
	* gdb.fortran/vla-value.exp: Use type names defined in libfortran.
	* gdb.mi/mi-var-child-f.exp: Likewise.
	* gdb.mi/mi-vla-fortran.exp: Likewise.

---
 gdb/testsuite/gdb.fortran/vla-value.exp | 12 ++++++++----
 gdb/testsuite/gdb.mi/mi-var-child-f.exp |  7 +++----
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 18 +++++++++++-------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 0945181..275f738 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib "fortran.exp"
 
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
      {debug f90 quiet}] } {
@@ -25,12 +26,15 @@ if ![runto_main] {
     return -1
 }
 
+# Depending on the compiler being used, the type names can be printed differently.
+set real [fortran_real4]
+
 # Try to access values in non allocated VLA
 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\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real \\\(<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)"
@@ -51,7 +55,7 @@ with_timeout_factor 15 {
 	"step over value assignment of vla1"
 }
 gdb_test "print &vla1" \
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real \\\(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)"
@@ -71,7 +75,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
 # Try to access values in undefined pointer to VLA (dangling)
 gdb_test "print pvla" " = <not associated>" "print undefined pvla"
 gdb_test "print &pvla" \
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\)\\\)\\\) $hex" \
   "print non-associated &pvla"
 gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
   "print undefined pvla(1,3,8)"
@@ -80,7 +84,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated
 gdb_breakpoint [gdb_get_line_number "pvla-associated"]
 gdb_continue_to_breakpoint "pvla-associated"
 gdb_test "print &pvla" \
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
   "print associated &pvla"
 gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
 gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index f3ed7c2..bc44c6b 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -17,6 +17,7 @@
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
+load_lib "fortran.exp"
 
 if { [skip_fortran_tests] } { return -1 }
 
@@ -40,10 +41,8 @@ mi_runto MAIN__
 mi_create_varobj "array" "array" "create local variable array"
 
 
-# Depending on the compiler version being used, the name of the 4-byte integer
-# and real types can be printed differently.  For instance, gfortran-4.1 uses
-# "int4" whereas gfortran-4.3 uses "integer(kind=4)".
-set int4 "(int4|integer\\(kind=4\\))"
+# Depending on the compiler being used, the type names can be printed differently.
+set int4 [fortran_int4]
 
 set children [list [list "array.-1" "-1" 2 "$int4 \\(2\\)"] \
 		  [list "array.0" "0" 2 "$int4 \\(2\\)"] \
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index 333b71a..1779ec0 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -18,6 +18,7 @@
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
+load_lib "fortran.exp"
 
 gdb_exit
 if [mi_gdb_start] {
@@ -32,6 +33,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
      return -1
 }
 
+# Depending on the compiler being used, the type names can be printed differently.
+set real [fortran_real4]
+
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
@@ -58,7 +62,7 @@ mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
   "503\\^done,value=\"\\\[0\\\]\"" \
   "eval variable vla1_not_allocated"
 mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
-    "real\\\(kind=4\\\)" "get children of vla1_not_allocated"
+    "$real" "get children of vla1_not_allocated"
 
 
 
@@ -71,10 +75,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\\\(kind=4\\\) \\\(5\\\)" \
+mi_create_varobj_checked vla1_allocated vla1 "$real \\\(5\\\)" \
   "create local variable vla1_allocated"
 mi_gdb_test "511-var-info-type vla1_allocated" \
-  "511\\^done,type=\"real\\\(kind=4\\\) \\\(5\\\)\"" \
+  "511\\^done,type=\"$real \\\(5\\\)\"" \
   "info type variable vla1_allocated"
 mi_gdb_test "512-var-show-format vla1_allocated" \
   "512\\^done,format=\"natural\"" \
@@ -83,7 +87,7 @@ mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
   "513\\^done,value=\"\\\[5\\\]\"" \
   "eval variable vla1_allocated"
 mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
-    "real\\\(kind=4\\\)" "get children of vla1_allocated"
+    "$real" "get children of vla1_allocated"
 
 
 set bp_lineno [gdb_get_line_number "vla1-filled"]
@@ -148,7 +152,7 @@ gdb_expect {
 	    "583\\^done,value=\"\\\[0\\\]\"" \
 	    "eval variable pvla2_not_associated"
 	mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
-	    "real\\\(kind=4\\\)" "get children of pvla2_not_associated"
+	    "$real" "get children of pvla2_not_associated"
     }
     -re "580\\^error,msg=\"value contents too large \\(\[0-9\]+ bytes\\).*${mi_gdb_prompt}$" {
 	# Undefined behaviour in gfortran.
@@ -173,9 +177,9 @@ mi_gdb_test "590-data-evaluate-expression pvla2" \
   "evaluate associated vla"
 
 mi_create_varobj_checked pvla2_associated pvla2 \
-  "real\\\(kind=4\\\) \\\(5,2\\\)" "create local variable pvla2_associated"
+  "$real \\\(5,2\\\)" "create local variable pvla2_associated"
 mi_gdb_test "591-var-info-type pvla2_associated" \
-  "591\\^done,type=\"real\\\(kind=4\\\) \\\(5,2\\\)\"" \
+  "591\\^done,type=\"$real \\\(5,2\\\)\"" \
   "info type variable pvla2_associated"
 mi_gdb_test "592-var-show-format pvla2_associated" \
   "592\\^done,format=\"natural\"" \
-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH V4 6/6] Fortran: Testsuite, add cyclic pointers.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
  2016-09-07  6:38 ` [PATCH V4 5/6] Resolve dynamic " Bernhard Heckel
  2016-09-07  6:38 ` [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types Bernhard Heckel
@ 2016-09-07  6:38 ` Bernhard Heckel
  2016-10-13 14:08   ` Yao Qi
  2016-09-07  6:38 ` [PATCH V4 1/6] Fortran: Testsuite, fix differences in type naming Bernhard Heckel
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

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

gdb/testsuite/Changelog:
	* pointers.f90: Add cylic pointers.
	* pointers.exp: Add print of cyclic pointers.

---
 gdb/testsuite/gdb.fortran/pointers.exp | 20 ++++++++++++++++++++
 gdb/testsuite/gdb.fortran/pointers.f90 | 12 ++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp
index c19d7e0..67cf999 100644
--- a/gdb/testsuite/gdb.fortran/pointers.exp
+++ b/gdb/testsuite/gdb.fortran/pointers.exp
@@ -57,6 +57,24 @@ gdb_test_multiple "print intap" $test {
 gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
 gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
 gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
+set test "print cyclicp1, not associated"
+gdb_test_multiple "print cyclicp1" $test {
+  -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" {
+    pass $test
+  }
+  -re "= \\( i = -?\\d+, p = <not associated> \\)\r\n$gdb_prompt $" {
+    pass $test
+  }
+}
+set test "print cyclicp1%p, not associated"
+gdb_test_multiple "print cyclicp1%p" $test {
+  -re "= \\(PTR TO -> \\( Type typewithpointer \\)\\) 0x0\r\n$gdb_prompt $" {
+    pass $test
+  }
+  -re "= \\(PTR TO -> \\( Type typewithpointer \\)\\) <not associated>\r\n$gdb_prompt $" {
+    pass $test
+  }
+}
 
 
 gdb_breakpoint [gdb_get_line_number "Before value assignment"]
@@ -118,6 +136,8 @@ gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
     pass $test_name
   }
 }
+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)"
+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer \\)\\) $hex\( <.*>\)?"
 gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
 gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
 gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\)\\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
index 000193c..6240c87 100644
--- a/gdb/testsuite/gdb.fortran/pointers.f90
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
@@ -20,6 +20,11 @@ program pointers
     integer, allocatable :: ivla2 (:, :)
   end type two
 
+  type :: typeWithPointer
+    integer i
+    type(typeWithPointer), pointer:: p
+  end type typeWithPointer
+
   type :: twoPtr
     type (two), pointer :: p
   end type twoPtr
@@ -34,6 +39,7 @@ program pointers
   real, target    :: realv
   type(two), target  :: twov
   type(twoPtr) :: arrayOfPtr (3)
+  type(typeWithPointer), target:: cyclicp1,cyclicp2
 
   logical, pointer :: logp
   complex, pointer :: comp
@@ -57,6 +63,8 @@ program pointers
   nullify (arrayOfPtr(1)%p)
   nullify (arrayOfPtr(2)%p)
   nullify (arrayOfPtr(3)%p)
+  nullify (cyclicp1%p)
+  nullify (cyclicp2%p)
 
   logp => logv    ! Before pointer assignment
   comp => comv
@@ -68,6 +76,10 @@ program pointers
   realp => realv
   twop => twov
   arrayOfPtr(2)%p => twov
+  cyclicp1%i = 1
+  cyclicp1%p => cyclicp2
+  cyclicp2%i = 2
+  cyclicp2%p => cyclicp1
 
   logv = associated(logp)     ! Before value assignment
   comv = cmplx(1,2)
-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
                   ` (3 preceding siblings ...)
  2016-09-07  6:38 ` [PATCH V4 1/6] Fortran: Testsuite, fix differences in type naming Bernhard Heckel
@ 2016-09-07  6:38 ` Bernhard Heckel
  2016-10-05 10:10   ` Yao Qi
  2016-09-07  6:38 ` [PATCH V4 4/6] Fortran: Typeprint, fix dangling types Bernhard Heckel
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

Before continuing with language specific type printing
we have to resolve the target type of a pointer
as we might wanna print more details of the target
like the dimension of an array. We have to resolve it here
as we don't have any address information later on.

2016-07-08  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* typeprint.c (whatis_exp): Resolve dynamic target type
	  of pointers.

gdb/Testsuite/Changelog:
	* gdb.cp/vla-cxx.cc: Added pointer to dynamic type.
	* gdb.cp/vla-cxx.exp: Test pointer to dynamic type.

---
 gdb/testsuite/gdb.cp/vla-cxx.cc  |  9 +++++++++
 gdb/testsuite/gdb.cp/vla-cxx.exp |  5 +++++
 gdb/typeprint.c                  | 19 +++++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc
index a1fd510..5f8f8ab 100644
--- a/gdb/testsuite/gdb.cp/vla-cxx.cc
+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc
@@ -15,6 +15,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+extern "C" {
+#include <stddef.h>
+}
+
 struct container;
 
 struct element
@@ -40,11 +44,16 @@ int main(int argc, char **argv)
   typedef typeof (vla) &vlareftypedef;
   vlareftypedef vlaref2 (vla);
   container c;
+  typeof (vla) *ptr = NULL;
+
+  // Before pointer assignment
+  ptr = &vla;
 
   for (int i = 0; i < z; ++i)
     vla[i] = 5 + 2 * i;
 
   // vlas_filled
   vla[0] = 2 * vla[0];
+
   return vla[2];
 }
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp
index f6224dc..babdfb7 100644
--- a/gdb/testsuite/gdb.cp/vla-cxx.exp
+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
@@ -23,6 +23,10 @@ if ![runto_main] {
     return -1
 }
 
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
+gdb_continue_to_breakpoint "Before pointer assignment"
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
+
 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
 gdb_continue_to_breakpoint "vlas_filled"
 
@@ -33,3 +37,4 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
 # bug being tested, it's better not to depend on the exact spelling.
 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index e77513e..e3d84c7 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -485,6 +485,25 @@ whatis_exp (char *exp, int show)
       printf_filtered (" */\n");    
     }
 
+  /* Resolve any dynamic target type, as we might print
+     additional information about the target.
+     For example, in Fortran and C we are printing the dimension of the
+     dynamic array the pointer is pointing to.  */
+  if (TYPE_CODE (type) == TYPE_CODE_PTR
+      && is_dynamic_type (type) == 1)
+    {
+      CORE_ADDR addr;
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
+	addr = value_address (val);
+      else
+	addr = value_as_address (val);
+
+      if (addr != 0
+	  && type_not_associated (type) == 0)
+	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
+							NULL, addr);
+    }
+
   LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags);
   printf_filtered ("\n");
 
-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH V4 4/6] Fortran: Typeprint, fix dangling types.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
                   ` (4 preceding siblings ...)
  2016-09-07  6:38 ` [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer Bernhard Heckel
@ 2016-09-07  6:38 ` Bernhard Heckel
  2016-10-13 13:53   ` Yao Qi
  2016-09-14 12:55 ` [PING][PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
  2016-09-21  9:49 ` [ping 2] [PATCH " Bernhard Heckel
  7 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

Show the type of not-allocated and/or not-associated types
as this is known.  For array types and pointer to array types
we are going to print the number of ranks.

2016-06-30  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/ChangeLog:
	* f-typeprint.c (f_print_type): Don't bypass dangling types.
	  (f_type_print_varspec_suffix): Add print_rank parameter.
	  (f_type_print_varspec_suffix): Print ranks of array types
	  in case they dangling.
	  (f_type_print_base): Add print_rank parameter.

gdb/Testsuite/ChangeLog:
	* gdb.fortran/pointers.f90: New.
	* gdb.fortran/print_type.exp: New.
	* gdb.fortran/vla-ptype.exp: Adapt expected results.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.mi/mi-vla-fortran.exp: Likewise.

---
 gdb/f-typeprint.c                        |  93 ++++++++++++++--------------
 gdb/testsuite/gdb.fortran/pointers.f90   |  80 +++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/vla-ptype.exp  |  12 ++--
 gdb/testsuite/gdb.fortran/vla-type.exp   |   7 ++-
 gdb/testsuite/gdb.fortran/vla-value.exp  |   4 +-
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp  |   9 +--
 7 files changed, 247 insertions(+), 58 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
 create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp

diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 920c21f..13ab284 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -37,7 +37,7 @@ static void f_type_print_args (struct type *, struct ui_file *);
 #endif
 
 static void f_type_print_varspec_suffix (struct type *, struct ui_file *, int,
-					 int, int, int);
+					 int, int, int, int);
 
 void f_type_print_varspec_prefix (struct type *, struct ui_file *,
 				  int, int);
@@ -54,18 +54,6 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
   enum type_code code;
   int demangled_args;
 
-  if (type_not_associated (type))
-    {
-      val_print_not_associated (stream);
-      return;
-    }
-
-  if (type_not_allocated (type))
-    {
-      val_print_not_allocated (stream);
-      return;
-    }
-
   f_type_print_base (type, stream, show, level);
   code = TYPE_CODE (type);
   if ((varstring != NULL && *varstring != '\0')
@@ -87,7 +75,7 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
          so don't print an additional pair of ()'s.  */
 
       demangled_args = varstring[strlen (varstring) - 1] == ')'; 
-      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0);
+      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0, 0);
    }
 }
 
@@ -157,7 +145,7 @@ f_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
 static void
 f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
 			     int show, int passed_a_ptr, int demangled_args,
-			     int arrayprint_recurse_level)
+			     int arrayprint_recurse_level, int print_rank_only)
 {
   int upper_bound, lower_bound;
 
@@ -181,34 +169,50 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
 	fprintf_filtered (stream, "(");
 
       if (type_not_associated (type))
-        val_print_not_associated (stream);
+	print_rank_only = 1;
       else if (type_not_allocated (type))
-        val_print_not_allocated (stream);
+	print_rank_only = 1;
+      else if ((TYPE_ASSOCIATED_PROP (type)
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type)))
+	      || (TYPE_ALLOCATED_PROP (type)
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
+	      || (TYPE_DATA_LOCATION (type)
+		  && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
+	/* This case exist when we ptype a typename which has the
+	   dynamic properties but cannot be resolved as there is
+	   no object.  */
+	print_rank_only = 1;
+
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
+	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+				     0, 0, arrayprint_recurse_level,
+				     print_rank_only);
+
+      if (print_rank_only == 1)
+	fprintf_filtered (stream, ":");
       else
-        {
-          if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
-            f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
-                                        0, 0, arrayprint_recurse_level);
-
-          lower_bound = f77_get_lowerbound (type);
-          if (lower_bound != 1)	/* Not the default.  */
-            fprintf_filtered (stream, "%d:", lower_bound);
-
-          /* Make sure that, if we have an assumed size array, we
-             print out a warning and print the upperbound as '*'.  */
-
-          if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
-            fprintf_filtered (stream, "*");
-          else
-            {
-              upper_bound = f77_get_upperbound (type);
-              fprintf_filtered (stream, "%d", upper_bound);
-            }
-
-          if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
-            f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
-                                        0, 0, arrayprint_recurse_level);
-        }
+	{
+	  lower_bound = f77_get_lowerbound (type);
+	  if (lower_bound != 1)	/* Not the default.  */
+	    fprintf_filtered (stream, "%d:", lower_bound);
+
+	  /* Make sure that, if we have an assumed size array, we
+	       print out a warning and print the upperbound as '*'.  */
+
+	  if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
+	    fprintf_filtered (stream, "*");
+	  else
+	    {
+	      upper_bound = f77_get_upperbound (type);
+	      fprintf_filtered (stream, "%d", upper_bound);
+	    }
+	}
+
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
+	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+				     0, 0, arrayprint_recurse_level,
+				     print_rank_only);
+
       if (arrayprint_recurse_level == 1)
 	fprintf_filtered (stream, ")");
       else
@@ -219,13 +223,14 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
-				   arrayprint_recurse_level);
+				   arrayprint_recurse_level, 0);
       fprintf_filtered (stream, ")");
       break;
 
     case TYPE_CODE_FUNC:
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
-				   passed_a_ptr, 0, arrayprint_recurse_level);
+				   passed_a_ptr, 0, arrayprint_recurse_level,
+				   0);
       if (passed_a_ptr)
 	fprintf_filtered (stream, ")");
 
@@ -376,7 +381,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
 	      fputs_filtered (" :: ", stream);
 	      fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
 	      f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
-					   stream, show - 1, 0, 0, 0);
+					   stream, show - 1, 0, 0, 0, 0);
 	      fputs_filtered ("\n", stream);
 	    }
 	  fprintfi_filtered (level, stream, "End Type ");
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
new file mode 100644
index 0000000..9ebbaa9
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
@@ -0,0 +1,80 @@
+! Copyright 2016 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+program pointers
+
+  type :: two
+    integer, allocatable :: ivla1 (:)
+    integer, allocatable :: ivla2 (:, :)
+  end type two
+
+  logical, target :: logv
+  complex, target :: comv
+  character, target :: charv
+  character (len=3), target :: chara
+  integer, target :: intv
+  integer, target, dimension (10,2) :: inta
+  real, target    :: realv
+  type(two), target  :: twov
+
+  logical, pointer :: logp
+  complex, pointer :: comp
+  character, pointer:: charp
+  character (len=3), pointer:: charap
+  integer, pointer :: intp
+  integer, pointer, dimension (:,:) :: intap
+  real, pointer :: realp
+  type(two), pointer :: twop
+
+  nullify (logp)
+  nullify (comp)
+  nullify (charp)
+  nullify (charap)
+  nullify (intp)
+  nullify (intap)
+  nullify (realp)
+  nullify (twop)
+
+  logp => logv    ! Before pointer assignment
+  comp => comv
+  charp => charv
+  charap => chara
+  intp => intv
+  intap => inta
+  realp => realv
+  twop => twov
+
+  logv = associated(logp)     ! Before value assignment
+  comv = cmplx(1,2)
+  charv = "a"
+  chara = "abc"
+  intv = 10
+  inta(:,:) = 1
+  inta(3,1) = 3
+  realv = 3.14
+
+  allocate (twov%ivla1(3))
+  allocate (twov%ivla2(2,2))
+  twov%ivla1(1) = 11
+  twov%ivla1(2) = 12
+  twov%ivla1(3) = 13
+  twov%ivla2(1,1) = 211
+  twov%ivla2(2,1) = 221
+  twov%ivla2(1,2) = 212
+  twov%ivla2(2,2) = 222
+
+  intv = intv + 1 ! After value assignment
+
+end program pointers
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
new file mode 100755
index 0000000..45b4968
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -0,0 +1,100 @@
+# Copyright 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile "pointers.f90"
+load_lib fortran.exp
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+    {debug f90 quiet}] } {
+    return -1
+}
+
+
+if ![runto_main] {
+    untested "could not run to main"
+    return -1
+}
+
+# Depending on the compiler being used, the type names can be printed differently.
+set logical [fortran_logical4]
+set real [fortran_real4]
+set int [fortran_int4]
+set complex [fortran_complex4]
+
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
+gdb_continue_to_breakpoint "Before pointer assignment"
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)" "ptype logp, not associated"
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)" "ptype comp, not associated"
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)" "ptype charp, not associated"
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)" "ptype charap, not associated"
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)" "ptype intp, not associated"
+set test "ptype intap, not associated"
+gdb_test_multiple "ptype intap" $test {
+    -re "type = PTR TO -> \\( $int \\(:,:\\)\\)\r\n$gdb_prompt $" {
+        pass $test
+    }
+    -re "type = $int \\(:,:\\)\r\n$gdb_prompt $" {
+        pass $test
+    }
+}
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)" "ptype realp, not associated"
+gdb_test "ptype twop" \
+    [multi_line "type = PTR TO -> \\( Type two" \
+                "    $int :: ivla1\\(:\\)" \
+                "    $int :: ivla2\\(:,:\\)" \
+                "End Type two \\)"] \
+    "ptype twop, not associated"
+gdb_test "ptype two" \
+    [multi_line "type = Type two" \
+                "    $int :: ivla1\\(:\\)" \
+                "    $int :: ivla2\\(:,:\\)" \
+                "End Type two"]
+
+
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
+gdb_continue_to_breakpoint "Before value assignment"
+gdb_test "ptype twop" \
+    [multi_line "type = PTR TO -> \\( Type two" \
+                "    $int :: ivla1\\(:\\)" \
+                "    $int :: ivla2\\(:,:\\)" \
+                "End Type two \\)"]
+
+
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
+gdb_continue_to_breakpoint "After value assignment"
+gdb_test "ptype logv" "type = $logical"
+gdb_test "ptype comv" "type = $complex"
+gdb_test "ptype charv" "type = character\\*1"
+gdb_test "ptype chara" "type = character\\*3"
+gdb_test "ptype intv" "type = $int"
+gdb_test "ptype inta" "type = $int \\(10,2\\)"
+gdb_test "ptype realv" "type = $real"
+
+
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
+set test "ptype intap"
+gdb_test_multiple $test $test {
+    -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
+        pass $test
+    }
+    -re "type = PTR TO -> \\( $int \\(10,2\\)\\)\r\n$gdb_prompt $" {
+        pass $test
+    }
+}
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 175661f..aa5c64a 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -32,9 +32,9 @@ set real [fortran_real4]
 # Check the ptype of various VLA states and pointer to VLA's.
 gdb_breakpoint [gdb_get_line_number "vla1-init"]
 gdb_continue_to_breakpoint "vla1-init"
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
+gdb_test "ptype vla1" "type = $real \\(:,:,:\\)" "ptype vla1 not initialized"
+gdb_test "ptype vla2" "type = $real \\(:,:,:\\)" "ptype vla2 not initialized"
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla not initialized"
 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
   "ptype vla1(3, 6, 9) not initialized"
 gdb_test "ptype vla2(5, 45, 20)" \
@@ -81,20 +81,20 @@ gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
 
 gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
 gdb_continue_to_breakpoint "pvla-deassociated"
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla deassociated"
 gdb_test "ptype pvla(5, 45, 20)" \
   "no such vector element \\\(vector not associated\\\)" \
   "ptype pvla(5, 45, 20) not associated"
 
 gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
 gdb_continue_to_breakpoint "vla1-deallocated"
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
+gdb_test "ptype vla1" "type = $real \\(:,:,:\\)" "ptype vla1 not allocated"
 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
   "ptype vla1(3, 6, 9) not allocated"
 
 gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
 gdb_continue_to_breakpoint "vla2-deallocated"
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
+gdb_test "ptype vla2" "type = $real \\(:,:,:\\)" "ptype vla2 not allocated"
 gdb_test "ptype vla2(5, 45, 20)" \
   "no such vector element \\\(vector not allocated\\\)" \
   "ptype vla2(5, 45, 20) not allocated"
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 401782b..dddcf39 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -132,7 +132,10 @@ gdb_test "ptype fivearr(2)%tone" \
                      "End Type one" ]
 
 # Check allocation status of dynamic array and it's dynamic members
-gdb_test "ptype fivedynarr" "type = <not allocated>"
+gdb_test "ptype fivedynarr" \
+         [multi_line "type = Type five" \
+                     "    Type one :: tone" \
+                     "End Type five \\(:\\)" ]
 gdb_test "next" ""
 gdb_test "ptype fivedynarr(2)" \
          [multi_line "type = Type five" \
@@ -141,7 +144,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 :: ivla\\(:,:,:\\)" \
                      "End Type one" ] \
          "ptype fivedynarr(2)%tone, not allocated"
 
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 275f738..38bc55a 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -34,7 +34,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 \\\(:,:,:\\\)\\\)\\\) $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)"
@@ -75,7 +75,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
 # Try to access values in undefined pointer to VLA (dangling)
 gdb_test "print pvla" " = <not associated>" "print undefined pvla"
 gdb_test "print &pvla" \
-  " = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\)\\\)\\\) $hex" \
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
   "print non-associated &pvla"
 gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
   "print undefined pvla(1,3,8)"
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index 1779ec0..05e73c3 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -17,6 +17,7 @@
 # Array (VLA).
 
 load_lib mi-support.exp
+load_lib fortran.exp
 set MIFLAGS "-i=mi"
 load_lib "fortran.exp"
 
@@ -50,10 +51,10 @@ mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
 mi_gdb_test "500-data-evaluate-expression vla1" \
   "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
 
-mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
+mi_create_varobj_checked vla1_not_allocated vla1 "$real \\(:\\)" \
   "create local variable vla1_not_allocated"
 mi_gdb_test "501-var-info-type vla1_not_allocated" \
-  "501\\^done,type=\"<not allocated>\"" \
+  "501\\^done,type=\"$real \\(:\\)\"" \
   "info type variable vla1_not_allocated"
 mi_gdb_test "502-var-show-format vla1_not_allocated" \
   "502\\^done,format=\"natural\"" \
@@ -140,10 +141,10 @@ gdb_expect {
     -re "580\\^done,value=\"<not associated>\".*${mi_gdb_prompt}$" {
 	pass $test
 
-	mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
+	mi_create_varobj_checked pvla2_not_associated pvla2 "$real \\(:,:\\)" \
 	    "create local variable pvla2_not_associated"
 	mi_gdb_test "581-var-info-type pvla2_not_associated" \
-	    "581\\^done,type=\"<not associated>\"" \
+	    "581\\^done,type=\"$real \\(:,:\\)\"" \
 	    "info type variable pvla2_not_associated"
 	mi_gdb_test "582-var-show-format pvla2_not_associated" \
 	    "582\\^done,format=\"natural\"" \
-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
  2016-09-07  6:38 ` [PATCH V4 5/6] Resolve dynamic " Bernhard Heckel
@ 2016-09-07  6:38 ` Bernhard Heckel
  2016-10-05  8:44   ` Yao Qi
  2016-09-07  6:38 ` [PATCH V4 6/6] Fortran: Testsuite, add cyclic pointers Bernhard Heckel
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

In Fortran a pointer may have a dynamic associated property.

2016-07-08  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* gdbtypes.c (resolve_dynamic_types_internal): Resolve pointer types.
	  (resolve_dynamic_pointer): New.

---
 gdb/gdbtypes.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index ec5c17a..b53e649 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1806,7 +1806,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
   type = check_typedef (type);
 
   /* We only want to recognize references at the outermost level.  */
-  if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
+  if (top_level &&
+      (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR))
     type = check_typedef (TYPE_TARGET_TYPE (type));
 
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
@@ -2105,6 +2106,28 @@ resolve_dynamic_struct (struct type *type,
   return resolved_type;
 }
 
+/* Worker for pointer types.  */
+
+static struct type *
+resolve_dynamic_pointer (struct type *type,
+			 struct property_addr_info *addr_stack)
+{
+  struct dynamic_prop *prop;
+  CORE_ADDR value;
+
+  type = copy_type (type);
+
+  /* Resolve associated property.  */
+  prop = TYPE_ASSOCIATED_PROP (type);
+  if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
+    {
+      TYPE_DYN_PROP_ADDR (prop) = value;
+      TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
+    }
+
+  return type;
+}
+
 /* Worker for resolved_dynamic_type.  */
 
 static struct type *
@@ -2153,6 +2176,10 @@ resolve_dynamic_type_internal (struct type *type,
 	    break;
 	  }
 
+        case TYPE_CODE_PTR:
+ 	  resolved_type = resolve_dynamic_pointer (type, addr_stack);
+ 	  break;
+
 	case TYPE_CODE_ARRAY:
 	  resolved_type = resolve_dynamic_array (type, addr_stack);
 	  break;
-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
@ 2016-09-07  6:38 ` Bernhard Heckel
  2016-09-07 14:24   ` Eli Zaretskii
  2016-10-13 14:07   ` Yao Qi
  2016-09-07  6:38 ` [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types Bernhard Heckel
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

When dereferencing pointers to dynamic target types,
resolve the target type.

2016-06-30  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* NEWS: Added entry.
	* c-valprint.c (c_print_val): Resolve dynamic target types.
	* valops.c (value_ind): Resolve dynamic target types.
	* valprint.c (check_printable): Don't shortcut not associated
	  pointers.

gdb/Testsuite/Changelog:
	* pointers.f90: Added pointer to dynamic types.
	* gdb.fortran/pointers.exp: New.

---
 gdb/NEWS                               |   2 +
 gdb/c-valprint.c                       |  22 ++++++
 gdb/testsuite/gdb.cp/vla-cxx.exp       |   4 ++
 gdb/testsuite/gdb.fortran/pointers.exp | 123 +++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/pointers.f90 |  17 +++++
 gdb/valops.c                           |  16 ++++-
 gdb/valprint.c                         |   6 --
 7 files changed, 182 insertions(+), 8 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/pointers.exp

diff --git a/gdb/NEWS b/gdb/NEWS
index 3823f20..37e4ca7 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,8 @@
 
 *** Changes since GDB 7.11
 
+* Fortran: Support pointers to dynamic types.
+
 * GDB now supports a negative repeat count in the 'x' command to examine
   memory backward from the given address.  For example:
 
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 2cb418d..120163f 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -645,6 +645,28 @@ c_value_print (struct value *val, struct ui_file *stream,
       else
 	{
 	  /* normal case */
+	  if (TYPE_CODE (type) == TYPE_CODE_PTR
+	      && 1 == is_dynamic_type (type))
+	    {
+	      CORE_ADDR addr;
+	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
+		addr = value_address (val);
+	      else
+		addr = value_as_address (val);
+
+	      /* We resolve the target-type only when the
+	         pointer is associated.  */
+	      if ((addr != 0)
+		  && (0 == type_not_associated (type)))
+		  TYPE_TARGET_TYPE (type) =
+		      resolve_dynamic_type (TYPE_TARGET_TYPE (type),
+					    NULL, addr);
+	    }
+	  else
+	    {
+	      /* Do nothing. References are already resolved from the beginning,
+	         only pointers are resolved when we actual need the target.  */
+	    }
 	  fprintf_filtered (stream, "(");
 	  type_print (value_type (val), "", stream, -1);
 	  fprintf_filtered (stream, ") ");
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp
index babdfb7..543d9eb 100644
--- a/gdb/testsuite/gdb.cp/vla-cxx.exp
+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
@@ -26,6 +26,8 @@ if ![runto_main] {
 gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
 gdb_continue_to_breakpoint "Before pointer assignment"
 gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment"
+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment"
 
 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
 gdb_continue_to_breakpoint "vlas_filled"
@@ -38,3 +40,5 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
 gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
+gdb_test "print *ptr" " = \\{5, 7, 9\\}"
diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp
new file mode 100644
index 0000000..c19d7e0
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/pointers.exp
@@ -0,0 +1,123 @@
+# Copyright 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile "pointers.f90"
+load_lib fortran.exp
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+    {debug f90 quiet}] } {
+    return -1
+}
+
+if ![runto_main] {
+    untested "could not run to main"
+    return -1
+}
+
+# Depending on the compiler being used, the type names can be printed differently.
+set logical [fortran_logical4]
+set real [fortran_real4]
+set int [fortran_int4]
+set complex [fortran_complex4]
+
+
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
+gdb_continue_to_breakpoint "Before pointer assignment"
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) 0x0" "print logp, not associated"
+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) 0x0" "print comp, not associated"
+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "print charp, not associated"
+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" "print charap, not associated"
+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
+gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" "print intp, not associated"
+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated"
+set test "print intap, not associated"
+gdb_test_multiple "print intap" $test {
+  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
+    pass $test
+  }
+  -re " = <not associated>\r\n$gdb_prompt $" {
+    pass $test
+  }
+}
+gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
+
+
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
+gdb_continue_to_breakpoint "Before value assignment"
+gdb_test "print *(twop)%ivla2" "= <not allocated>"
+
+
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
+gdb_continue_to_breakpoint "After value assignment"
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"
+gdb_test "print *logp" "= \\.TRUE\\."
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"
+gdb_test "print *comp" "= \\(1,2\\)"
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?"
+gdb_test "print *charp" "= 'a'"
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?"
+gdb_test "print *charap" "= 'abc'"
+gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"
+gdb_test "print *intp" "= 10"
+set test_name "print intap, associated"
+gdb_test_multiple "print intap" $test_name {
+  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
+    pass $test_name
+  }
+  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
+    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
+    pass $test_name
+  }
+}
+set test_name "print intvlap, associated"
+gdb_test_multiple "print intvlap" $test_name {
+  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
+    pass $test_name
+  }
+  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
+    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
+    pass $test_name
+  }
+}
+gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) $hex\( <.*>\)?"
+gdb_test "print *realp" "= 3\\.14000\\d+"
+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two \\)\\) $hex\( <.*>\)?"
+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)"
+set test_name "print arrayOfPtr(3)%p"
+gdb_test_multiple $test_name $test_name {
+  -re "= \\(PTR TO -> \\( Type two \\)\\) <not associated>\r\n$gdb_prompt $" {
+    pass $test_name
+  }
+  -re "= \\(PTR TO -> \\( Type two \\)\\) 0x0\r\n$gdb_prompt $" {
+    pass $test_name
+  }
+}
+set test_name "print *(arrayOfPtr(3)%p), associated"
+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
+  -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" {
+    pass $test_name
+  }
+  -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" {
+    pass $test_name
+  }
+}
+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\)\\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
index 9ebbaa9..000193c 100644
--- a/gdb/testsuite/gdb.fortran/pointers.f90
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
@@ -20,14 +20,20 @@ program pointers
     integer, allocatable :: ivla2 (:, :)
   end type two
 
+  type :: twoPtr
+    type (two), pointer :: p
+  end type twoPtr
+
   logical, target :: logv
   complex, target :: comv
   character, target :: charv
   character (len=3), target :: chara
   integer, target :: intv
   integer, target, dimension (10,2) :: inta
+  integer, target, allocatable, dimension (:) :: intvla
   real, target    :: realv
   type(two), target  :: twov
+  type(twoPtr) :: arrayOfPtr (3)
 
   logical, pointer :: logp
   complex, pointer :: comp
@@ -35,6 +41,7 @@ program pointers
   character (len=3), pointer:: charap
   integer, pointer :: intp
   integer, pointer, dimension (:,:) :: intap
+  integer, pointer, dimension (:) :: intvlap
   real, pointer :: realp
   type(two), pointer :: twop
 
@@ -44,8 +51,12 @@ program pointers
   nullify (charap)
   nullify (intp)
   nullify (intap)
+  nullify (intvlap)
   nullify (realp)
   nullify (twop)
+  nullify (arrayOfPtr(1)%p)
+  nullify (arrayOfPtr(2)%p)
+  nullify (arrayOfPtr(3)%p)
 
   logp => logv    ! Before pointer assignment
   comp => comv
@@ -53,8 +64,10 @@ program pointers
   charap => chara
   intp => intv
   intap => inta
+  intvlap => intvla
   realp => realv
   twop => twov
+  arrayOfPtr(2)%p => twov
 
   logv = associated(logp)     ! Before value assignment
   comv = cmplx(1,2)
@@ -63,6 +76,10 @@ program pointers
   intv = 10
   inta(:,:) = 1
   inta(3,1) = 3
+  allocate (intvla(10))
+  intvla(:) = 2
+  intvla(4) = 4
+  intvlap => intvla
   realv = 3.14
 
   allocate (twov%ivla1(3))
diff --git a/gdb/valops.c b/gdb/valops.c
index 40392e8..6f38560 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1562,6 +1562,19 @@ value_ind (struct value *arg1)
   if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
     {
       struct type *enc_type;
+      CORE_ADDR addr;
+
+      if (type_not_associated (base_type))
+        error (_("Attempt to take contents of a not associated pointer."));
+
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
+	addr = value_address (arg1);
+      else
+	addr = value_as_address (arg1);
+
+      if (addr != 0)
+	TYPE_TARGET_TYPE (base_type) =
+	    resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr);
 
       /* We may be pointing to something embedded in a larger object.
          Get the real type of the enclosing object.  */
@@ -1577,8 +1590,7 @@ value_ind (struct value *arg1)
       else
 	/* Retrieve the enclosing object pointed to.  */
 	arg2 = value_at_lazy (enc_type, 
-			      (value_as_address (arg1)
-			       - value_pointed_to_offset (arg1)));
+			      (addr - value_pointed_to_offset (arg1)));
 
       enc_type = value_type (arg2);
       return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 6896da2..f592278 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1141,12 +1141,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
       return 0;
     }
 
-  if (type_not_associated (value_type (val)))
-    {
-      val_print_not_associated (stream);
-      return 0;
-    }
-
   if (type_not_allocated (value_type (val)))
     {
       val_print_not_allocated (stream);
-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH V4 0/6] Fortran: Resolve target types of pointers.
@ 2016-09-07  6:38 Bernhard Heckel
  2016-09-07  6:38 ` [PATCH V4 5/6] Resolve dynamic " Bernhard Heckel
                   ` (7 more replies)
  0 siblings, 8 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-07  6:38 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches, Bernhard Heckel

Addressed in V4:
- Fix indentation in f-typeprint.

Addressed in V3:
- Don't resolve target types of pointers when resolving pointer types.
- Address pointers to dynamic types in C99 as well.
- Resolve dynamic target types of pointers when actual needed.
- Fix some type naming in Fortran testcases.
Addressed in V2:
- The type of the pointer should be known regardless it is 
  associated with target or not, [PATCH V2 1/5].
- Removed [PATCH V1 1/3], moved tests to [PATCH V2 2/5].
- Added tests to print derefenced pointers, [PATCH V2 2/5].
- Fix address print of not allocated arrays/pointer to 
  not allocated types, [PATCH V2 4/5]

Bernhard Heckel (6):
  Fortran: Testsuite, fix differences in type naming.
  Fortran: Resolve dynamic properties of pointer types.
  Typeprint: Resolve any dynamic target type of a pointer.
  Fortran: Typeprint, fix dangling types.
  Resolve dynamic target types of pointers.
  Fortran: Testsuite, add cyclic pointers.

 gdb/NEWS                                 |   2 +
 gdb/c-valprint.c                         |  22 +++++
 gdb/f-typeprint.c                        |  93 ++++++++++----------
 gdb/gdbtypes.c                           |  29 ++++++-
 gdb/testsuite/gdb.cp/vla-cxx.cc          |   9 ++
 gdb/testsuite/gdb.cp/vla-cxx.exp         |   9 ++
 gdb/testsuite/gdb.fortran/pointers.exp   | 143 +++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/pointers.f90   | 109 +++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++++
 gdb/testsuite/gdb.fortran/vla-ptype.exp  |  12 +--
 gdb/testsuite/gdb.fortran/vla-type.exp   |   7 +-
 gdb/testsuite/gdb.fortran/vla-value.exp  |  12 ++-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp  |   7 +-
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp  |  27 +++---
 gdb/typeprint.c                          |  19 ++++
 gdb/valops.c                             |  16 +++-
 gdb/valprint.c                           |   6 --
 17 files changed, 542 insertions(+), 80 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/pointers.exp
 create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
 create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp

-- 
2.7.1.339.g0233b80

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-09-07  6:38 ` [PATCH V4 5/6] Resolve dynamic " Bernhard Heckel
@ 2016-09-07 14:24   ` Eli Zaretskii
  2016-10-13 14:07   ` Yao Qi
  1 sibling, 0 replies; 33+ messages in thread
From: Eli Zaretskii @ 2016-09-07 14:24 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches, bernhard.heckel

> From: Bernhard Heckel <bernhard.heckel@intel.com>
> Cc: gdb-patches@sourceware.org, Bernhard Heckel <bernhard.heckel@intel.com>
> Date: Wed,  7 Sep 2016 08:38:14 +0200
> 
> When dereferencing pointers to dynamic target types,
> resolve the target type.
> 
> 2016-06-30  Bernhard Heckel  <bernhard.heckel@intel.com>
> 
> gdb/Changelog:
> 	* NEWS: Added entry.
> 	* c-valprint.c (c_print_val): Resolve dynamic target types.
> 	* valops.c (value_ind): Resolve dynamic target types.
> 	* valprint.c (check_printable): Don't shortcut not associated
> 	  pointers.
> 
> gdb/Testsuite/Changelog:
> 	* pointers.f90: Added pointer to dynamic types.
> 	* gdb.fortran/pointers.exp: New.

OK for the NEWS part.

Thanks.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PING][PATCH V4 0/6] Fortran: Resolve target types of pointers.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
                   ` (5 preceding siblings ...)
  2016-09-07  6:38 ` [PATCH V4 4/6] Fortran: Typeprint, fix dangling types Bernhard Heckel
@ 2016-09-14 12:55 ` Bernhard Heckel
  2016-09-28 12:45   ` Bernhard Heckel
  2016-09-21  9:49 ` [ping 2] [PATCH " Bernhard Heckel
  7 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-14 12:55 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches

On 07/09/2016 08:38, Bernhard Heckel wrote:
> Addressed in V4:
> - Fix indentation in f-typeprint.
>
> Addressed in V3:
> - Don't resolve target types of pointers when resolving pointer types.
> - Address pointers to dynamic types in C99 as well.
> - Resolve dynamic target types of pointers when actual needed.
> - Fix some type naming in Fortran testcases.
> Addressed in V2:
> - The type of the pointer should be known regardless it is
>    associated with target or not, [PATCH V2 1/5].
> - Removed [PATCH V1 1/3], moved tests to [PATCH V2 2/5].
> - Added tests to print derefenced pointers, [PATCH V2 2/5].
> - Fix address print of not allocated arrays/pointer to
>    not allocated types, [PATCH V2 4/5]
>
> Bernhard Heckel (6):
>    Fortran: Testsuite, fix differences in type naming.
>    Fortran: Resolve dynamic properties of pointer types.
>    Typeprint: Resolve any dynamic target type of a pointer.
>    Fortran: Typeprint, fix dangling types.
>    Resolve dynamic target types of pointers.
>    Fortran: Testsuite, add cyclic pointers.
>
>   gdb/NEWS                                 |   2 +
>   gdb/c-valprint.c                         |  22 +++++
>   gdb/f-typeprint.c                        |  93 ++++++++++----------
>   gdb/gdbtypes.c                           |  29 ++++++-
>   gdb/testsuite/gdb.cp/vla-cxx.cc          |   9 ++
>   gdb/testsuite/gdb.cp/vla-cxx.exp         |   9 ++
>   gdb/testsuite/gdb.fortran/pointers.exp   | 143 +++++++++++++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/pointers.f90   | 109 +++++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/vla-ptype.exp  |  12 +--
>   gdb/testsuite/gdb.fortran/vla-type.exp   |   7 +-
>   gdb/testsuite/gdb.fortran/vla-value.exp  |  12 ++-
>   gdb/testsuite/gdb.mi/mi-var-child-f.exp  |   7 +-
>   gdb/testsuite/gdb.mi/mi-vla-fortran.exp  |  27 +++---
>   gdb/typeprint.c                          |  19 ++++
>   gdb/valops.c                             |  16 +++-
>   gdb/valprint.c                           |   6 --
>   17 files changed, 542 insertions(+), 80 deletions(-)
>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.exp
>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
>   create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp
>

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [ping 2] [PATCH V4 0/6] Fortran: Resolve target types of pointers.
  2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
                   ` (6 preceding siblings ...)
  2016-09-14 12:55 ` [PING][PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
@ 2016-09-21  9:49 ` Bernhard Heckel
  7 siblings, 0 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-21  9:49 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches

On 07/09/2016 08:38, Bernhard Heckel wrote:
> Addressed in V4:
> - Fix indentation in f-typeprint.
>
> Addressed in V3:
> - Don't resolve target types of pointers when resolving pointer types.
> - Address pointers to dynamic types in C99 as well.
> - Resolve dynamic target types of pointers when actual needed.
> - Fix some type naming in Fortran testcases.
> Addressed in V2:
> - The type of the pointer should be known regardless it is
>    associated with target or not, [PATCH V2 1/5].
> - Removed [PATCH V1 1/3], moved tests to [PATCH V2 2/5].
> - Added tests to print derefenced pointers, [PATCH V2 2/5].
> - Fix address print of not allocated arrays/pointer to
>    not allocated types, [PATCH V2 4/5]
>
> Bernhard Heckel (6):
>    Fortran: Testsuite, fix differences in type naming.
>    Fortran: Resolve dynamic properties of pointer types.
>    Typeprint: Resolve any dynamic target type of a pointer.
>    Fortran: Typeprint, fix dangling types.
>    Resolve dynamic target types of pointers.
>    Fortran: Testsuite, add cyclic pointers.
>
>   gdb/NEWS                                 |   2 +
>   gdb/c-valprint.c                         |  22 +++++
>   gdb/f-typeprint.c                        |  93 ++++++++++----------
>   gdb/gdbtypes.c                           |  29 ++++++-
>   gdb/testsuite/gdb.cp/vla-cxx.cc          |   9 ++
>   gdb/testsuite/gdb.cp/vla-cxx.exp         |   9 ++
>   gdb/testsuite/gdb.fortran/pointers.exp   | 143 +++++++++++++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/pointers.f90   | 109 +++++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/vla-ptype.exp  |  12 +--
>   gdb/testsuite/gdb.fortran/vla-type.exp   |   7 +-
>   gdb/testsuite/gdb.fortran/vla-value.exp  |  12 ++-
>   gdb/testsuite/gdb.mi/mi-var-child-f.exp  |   7 +-
>   gdb/testsuite/gdb.mi/mi-vla-fortran.exp  |  27 +++---
>   gdb/typeprint.c                          |  19 ++++
>   gdb/valops.c                             |  16 +++-
>   gdb/valprint.c                           |   6 --
>   17 files changed, 542 insertions(+), 80 deletions(-)
>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.exp
>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
>   create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp
>

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 1/6] Fortran: Testsuite, fix differences in type naming.
  2016-09-07  6:38 ` [PATCH V4 1/6] Fortran: Testsuite, fix differences in type naming Bernhard Heckel
@ 2016-09-21 15:57   ` Yao Qi
  0 siblings, 0 replies; 33+ messages in thread
From: Yao Qi @ 2016-09-21 15:57 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

> 2016-06-08  Bernhard Heckel  <bernhard.heckel@intel.com>
>
> gdb/Testsuite/Changelog:
> 	* gdb.fortran/vla-value.exp: Use type names defined in
> 	libfortran.

Use type names defined in fortran.exp

> 	* gdb.mi/mi-var-child-f.exp: Likewise.
> 	* gdb.mi/mi-vla-fortran.exp: Likewise.
>
> ---

>  
> +# Depending on the compiler being used, the type names can be printed
> differently.

This line is too long.

> +set real [fortran_real4]

Otherwise, patch is good to me.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PING][PATCH V4 0/6] Fortran: Resolve target types of pointers.
  2016-09-14 12:55 ` [PING][PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
@ 2016-09-28 12:45   ` Bernhard Heckel
  2016-10-05  6:03     ` [ping 2][PATCH " Bernhard Heckel
  0 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-09-28 12:45 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches

Ping for Patches V4 2..6/6

Patch V4 1/6 was already reviewed by Yao
News was reviewed by Eli


On 14/09/2016 14:55, Bernhard Heckel wrote:
> On 07/09/2016 08:38, Bernhard Heckel wrote:
>> Addressed in V4:
>> - Fix indentation in f-typeprint.
>>
>> Addressed in V3:
>> - Don't resolve target types of pointers when resolving pointer types.
>> - Address pointers to dynamic types in C99 as well.
>> - Resolve dynamic target types of pointers when actual needed.
>> - Fix some type naming in Fortran testcases.
>> Addressed in V2:
>> - The type of the pointer should be known regardless it is
>>    associated with target or not, [PATCH V2 1/5].
>> - Removed [PATCH V1 1/3], moved tests to [PATCH V2 2/5].
>> - Added tests to print derefenced pointers, [PATCH V2 2/5].
>> - Fix address print of not allocated arrays/pointer to
>>    not allocated types, [PATCH V2 4/5]
>>
>> Bernhard Heckel (6):
>>    Fortran: Testsuite, fix differences in type naming.
>>    Fortran: Resolve dynamic properties of pointer types.
>>    Typeprint: Resolve any dynamic target type of a pointer.
>>    Fortran: Typeprint, fix dangling types.
>>    Resolve dynamic target types of pointers.
>>    Fortran: Testsuite, add cyclic pointers.
>>
>>   gdb/NEWS                                 |   2 +
>>   gdb/c-valprint.c                         |  22 +++++
>>   gdb/f-typeprint.c                        |  93 ++++++++++----------
>>   gdb/gdbtypes.c                           |  29 ++++++-
>>   gdb/testsuite/gdb.cp/vla-cxx.cc          |   9 ++
>>   gdb/testsuite/gdb.cp/vla-cxx.exp         |   9 ++
>>   gdb/testsuite/gdb.fortran/pointers.exp   | 143 
>> +++++++++++++++++++++++++++++++
>>   gdb/testsuite/gdb.fortran/pointers.f90   | 109 +++++++++++++++++++++++
>>   gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++++
>>   gdb/testsuite/gdb.fortran/vla-ptype.exp  |  12 +--
>>   gdb/testsuite/gdb.fortran/vla-type.exp   |   7 +-
>>   gdb/testsuite/gdb.fortran/vla-value.exp  |  12 ++-
>>   gdb/testsuite/gdb.mi/mi-var-child-f.exp  |   7 +-
>>   gdb/testsuite/gdb.mi/mi-vla-fortran.exp  |  27 +++---
>>   gdb/typeprint.c                          |  19 ++++
>>   gdb/valops.c                             |  16 +++-
>>   gdb/valprint.c                           |   6 --
>>   17 files changed, 542 insertions(+), 80 deletions(-)
>>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.exp
>>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
>>   create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp
>>
>

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [ping 2][PATCH V4 0/6] Fortran: Resolve target types of pointers.
  2016-09-28 12:45   ` Bernhard Heckel
@ 2016-10-05  6:03     ` Bernhard Heckel
  0 siblings, 0 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-05  6:03 UTC (permalink / raw)
  To: qiyaoltc, brobecker; +Cc: gdb-patches


Ping for Patches V4 2..6/6

Patch V4 1/6 was already reviewed by Yao
News was reviewed by Eli

>
> On 14/09/2016 14:55, Bernhard Heckel wrote:
>> On 07/09/2016 08:38, Bernhard Heckel wrote:
>>> Addressed in V4:
>>> - Fix indentation in f-typeprint.
>>>
>>> Addressed in V3:
>>> - Don't resolve target types of pointers when resolving pointer types.
>>> - Address pointers to dynamic types in C99 as well.
>>> - Resolve dynamic target types of pointers when actual needed.
>>> - Fix some type naming in Fortran testcases.
>>> Addressed in V2:
>>> - The type of the pointer should be known regardless it is
>>>    associated with target or not, [PATCH V2 1/5].
>>> - Removed [PATCH V1 1/3], moved tests to [PATCH V2 2/5].
>>> - Added tests to print derefenced pointers, [PATCH V2 2/5].
>>> - Fix address print of not allocated arrays/pointer to
>>>    not allocated types, [PATCH V2 4/5]
>>>
>>> Bernhard Heckel (6):
>>>    Fortran: Testsuite, fix differences in type naming.
>>>    Fortran: Resolve dynamic properties of pointer types.
>>>    Typeprint: Resolve any dynamic target type of a pointer.
>>>    Fortran: Typeprint, fix dangling types.
>>>    Resolve dynamic target types of pointers.
>>>    Fortran: Testsuite, add cyclic pointers.
>>>
>>>   gdb/NEWS                                 |   2 +
>>>   gdb/c-valprint.c                         |  22 +++++
>>>   gdb/f-typeprint.c                        |  93 ++++++++++----------
>>>   gdb/gdbtypes.c                           |  29 ++++++-
>>>   gdb/testsuite/gdb.cp/vla-cxx.cc          |   9 ++
>>>   gdb/testsuite/gdb.cp/vla-cxx.exp         |   9 ++
>>>   gdb/testsuite/gdb.fortran/pointers.exp   | 143 
>>> +++++++++++++++++++++++++++++++
>>>   gdb/testsuite/gdb.fortran/pointers.f90   | 109 
>>> +++++++++++++++++++++++
>>>   gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++++
>>>   gdb/testsuite/gdb.fortran/vla-ptype.exp  |  12 +--
>>>   gdb/testsuite/gdb.fortran/vla-type.exp   |   7 +-
>>>   gdb/testsuite/gdb.fortran/vla-value.exp  |  12 ++-
>>>   gdb/testsuite/gdb.mi/mi-var-child-f.exp  |   7 +-
>>>   gdb/testsuite/gdb.mi/mi-vla-fortran.exp  |  27 +++---
>>>   gdb/typeprint.c                          |  19 ++++
>>>   gdb/valops.c                             |  16 +++-
>>>   gdb/valprint.c                           |   6 --
>>>   17 files changed, 542 insertions(+), 80 deletions(-)
>>>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.exp
>>>   create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
>>>   create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp
>>>
>>
>

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types.
  2016-09-07  6:38 ` [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types Bernhard Heckel
@ 2016-10-05  8:44   ` Yao Qi
  2016-10-05  9:36     ` Yao Qi
  0 siblings, 1 reply; 33+ messages in thread
From: Yao Qi @ 2016-10-05  8:44 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

> 2016-07-08  Bernhard Heckel  <bernhard.heckel@intel.com>
>
> gdb/Changelog:
> 	* gdbtypes.c (resolve_dynamic_types_internal): Resolve pointer types.

This line doesn't match the change, which is in is_dynamic_type_internal.

> 	  (resolve_dynamic_pointer): New.

Otherwise, patch is good to me.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types.
  2016-10-05  8:44   ` Yao Qi
@ 2016-10-05  9:36     ` Yao Qi
  2016-10-05 10:07       ` Bernhard Heckel
  0 siblings, 1 reply; 33+ messages in thread
From: Yao Qi @ 2016-10-05  9:36 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: Yao Qi, Joel Brobecker, gdb-patches

On Wed, Oct 5, 2016 at 9:44 AM, Yao Qi <qiyaoltc@gmail.com> wrote:
> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>
>> 2016-07-08  Bernhard Heckel  <bernhard.heckel@intel.com>
>>
>> gdb/Changelog:
>>       * gdbtypes.c (resolve_dynamic_types_internal): Resolve pointer types.
>
> This line doesn't match the change, which is in is_dynamic_type_internal.
>
>>         (resolve_dynamic_pointer): New.
>
> Otherwise, patch is good to me.
>

Do we already have a test case which has a Fortran pointer which has
a dynamic associated property?  If no, we need to add one.

Patch 3/6 resolves dynamic target type of a pointer, a pointer points
to a dynamic type, but what does this patch do?

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types.
  2016-10-05  9:36     ` Yao Qi
@ 2016-10-05 10:07       ` Bernhard Heckel
  0 siblings, 0 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-05 10:07 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joel Brobecker, gdb-patches

On 05/10/2016 11:35, Yao Qi wrote:
> On Wed, Oct 5, 2016 at 9:44 AM, Yao Qi <qiyaoltc@gmail.com> wrote:
>> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>>
>>> 2016-07-08  Bernhard Heckel  <bernhard.heckel@intel.com>
>>>
>>> gdb/Changelog:
>>>        * gdbtypes.c (resolve_dynamic_types_internal): Resolve pointer types.
>> This line doesn't match the change, which is in is_dynamic_type_internal.
>>
>>>          (resolve_dynamic_pointer): New.
>> Otherwise, patch is good to me.
>>
> Do we already have a test case which has a Fortran pointer which has
> a dynamic associated property?  If no, we need to add one.
Yes, we have a testcase already.
vla-ptype.exp + vla.f90
This testcase was already passing as gfortran describes a pointer to an 
array as an array +  associated property.
For Ifort, a pointer in the program is still a pointer type in the debug 
info.

>
> Patch 3/6 resolves dynamic target type of a pointer, a pointer points
> to a dynamic type, but what does this patch do?
>

The patch only resolves the "associated property" of a pointer.
According to Joel review (some time ago), I only resolve target types of 
pointer when we actually have to (see following patches in this series).
I wanted to keep this patch separate from resolving dynamic target 
types, as this patch is independent from those but not vice verse.

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer.
  2016-09-07  6:38 ` [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer Bernhard Heckel
@ 2016-10-05 10:10   ` Yao Qi
  2016-10-05 11:03     ` Bernhard Heckel
  0 siblings, 1 reply; 33+ messages in thread
From: Yao Qi @ 2016-10-05 10:10 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

> +extern "C" {
> +#include <stddef.h>
> +}
> +

Why do you include stddef.h?

> diff --git a/gdb/typeprint.c b/gdb/typeprint.c
> index e77513e..e3d84c7 100644
> --- a/gdb/typeprint.c
> +++ b/gdb/typeprint.c
> @@ -485,6 +485,25 @@ whatis_exp (char *exp, int show)
>        printf_filtered (" */\n");    
>      }
>  
> +  /* Resolve any dynamic target type, as we might print
> +     additional information about the target.
> +     For example, in Fortran and C we are printing the dimension of the
> +     dynamic array the pointer is pointing to.  */
> +  if (TYPE_CODE (type) == TYPE_CODE_PTR
> +      && is_dynamic_type (type) == 1)

is_dynamic_type returns bool-like value, so don't check it with 1.
Looks we need to check is_dynamic_type (TYPE_TARGET_TYPE (type)), no?

> +    {
> +      CORE_ADDR addr;
> +      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
> +	addr = value_address (val);
> +      else
> +	addr = value_as_address (val);
> +
> +      if (addr != 0
> +	  && type_not_associated (type) == 0)

likewise, !type_not_associated (type)

> +	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
> +							NULL, addr);
> +    }

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer.
  2016-10-05 10:10   ` Yao Qi
@ 2016-10-05 11:03     ` Bernhard Heckel
  2016-10-13 13:41       ` Yao Qi
  0 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-05 11:03 UTC (permalink / raw)
  To: Yao Qi; +Cc: brobecker, gdb-patches

On 05/10/2016 12:09, Yao Qi wrote:
> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>
>> +extern "C" {
>> +#include <stddef.h>
>> +}
>> +
> Why do you include stddef.h?
definition of NULL
+  typeof (vla) *ptr = NULL;

>> diff --git a/gdb/typeprint.c b/gdb/typeprint.c
>> index e77513e..e3d84c7 100644
>> --- a/gdb/typeprint.c
>> +++ b/gdb/typeprint.c
>> @@ -485,6 +485,25 @@ whatis_exp (char *exp, int show)
>>         printf_filtered (" */\n");
>>       }
>>   
>> +  /* Resolve any dynamic target type, as we might print
>> +     additional information about the target.
>> +     For example, in Fortran and C we are printing the dimension of the
>> +     dynamic array the pointer is pointing to.  */
>> +  if (TYPE_CODE (type) == TYPE_CODE_PTR
>> +      && is_dynamic_type (type) == 1)
> is_dynamic_type returns bool-like value, so don't check it with 1.
> Looks we need to check is_dynamic_type (TYPE_TARGET_TYPE (type)), no?
is_dynamic_type takes care of target types for pointer and reference types.
So, we can keep it.
>
>> +    {
>> +      CORE_ADDR addr;
>> +      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
>> +	addr = value_address (val);
>> +      else
>> +	addr = value_as_address (val);
>> +
>> +      if (addr != 0
>> +	  && type_not_associated (type) == 0)
> likewise, !type_not_associated (type)
>
>> +	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
>> +							NULL, addr);
>> +    }

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer.
  2016-10-05 11:03     ` Bernhard Heckel
@ 2016-10-13 13:41       ` Yao Qi
  0 siblings, 0 replies; 33+ messages in thread
From: Yao Qi @ 2016-10-13 13:41 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: Yao Qi, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

>>> +extern "C" {
>>> +#include <stddef.h>
>>> +}
>>> +
>> Why do you include stddef.h?
> definition of NULL
> +  typeof (vla) *ptr = NULL;
>

It is c++, so we can include <cstddef> for NULL.

>>> diff --git a/gdb/typeprint.c b/gdb/typeprint.c
>>> index e77513e..e3d84c7 100644
>>> --- a/gdb/typeprint.c
>>> +++ b/gdb/typeprint.c
>>> @@ -485,6 +485,25 @@ whatis_exp (char *exp, int show)
>>>         printf_filtered (" */\n");
>>>       }
>>>   +  /* Resolve any dynamic target type, as we might print
>>> +     additional information about the target.
>>> +     For example, in Fortran and C we are printing the dimension of the
>>> +     dynamic array the pointer is pointing to.  */
>>> +  if (TYPE_CODE (type) == TYPE_CODE_PTR
>>> +      && is_dynamic_type (type) == 1)
>> is_dynamic_type returns bool-like value, so don't check it with 1.
>> Looks we need to check is_dynamic_type (TYPE_TARGET_TYPE (type)), no?
> is_dynamic_type takes care of target types for pointer and reference types.
> So, we can keep it.

OK, no problem.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 4/6] Fortran: Typeprint, fix dangling types.
  2016-09-07  6:38 ` [PATCH V4 4/6] Fortran: Typeprint, fix dangling types Bernhard Heckel
@ 2016-10-13 13:53   ` Yao Qi
  0 siblings, 0 replies; 33+ messages in thread
From: Yao Qi @ 2016-10-13 13:53 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

> +set test "ptype intap, not associated"
> +gdb_test_multiple "ptype intap" $test {
> +    -re "type = PTR TO -> \\( $int \\(:,:\\)\\)\r\n$gdb_prompt $" {
> +        pass $test
> +    }
> +    -re "type = $int \\(:,:\\)\r\n$gdb_prompt $" {

How does GDB print like this?  I think GDB should always print
"type = PTR TO -> ....", no?

> +        pass $test
> +    }
> +}

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-09-07  6:38 ` [PATCH V4 5/6] Resolve dynamic " Bernhard Heckel
  2016-09-07 14:24   ` Eli Zaretskii
@ 2016-10-13 14:07   ` Yao Qi
  2016-10-13 14:57     ` Bernhard Heckel
  1 sibling, 1 reply; 33+ messages in thread
From: Yao Qi @ 2016-10-13 14:07 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

> diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
> index 2cb418d..120163f 100644
> --- a/gdb/c-valprint.c
> +++ b/gdb/c-valprint.c
> @@ -645,6 +645,28 @@ c_value_print (struct value *val, struct ui_file *stream,
>        else
>  	{
>  	  /* normal case */
> +	  if (TYPE_CODE (type) == TYPE_CODE_PTR
> +	      && 1 == is_dynamic_type (type))

Use is_dynamic_type return value as bool.

> +	    {
> +	      CORE_ADDR addr;
> +	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
> +		addr = value_address (val);
> +	      else
> +		addr = value_as_address (val);
> +
> +	      /* We resolve the target-type only when the
> +	         pointer is associated.  */
> +	      if ((addr != 0)
> +		  && (0 == type_not_associated (type)))

!type_not_associated (type)

> +
> +
> +gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
> +gdb_continue_to_breakpoint "Before pointer assignment"
> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) 0x0" "print logp, not associated"
> +gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) 0x0" "print comp, not associated"
> +gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "print charp, not associated"
> +gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" "print charap, not associated"
> +gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" "print intp, not associated"
> +gdb_test "print *intp" "Cannot access memory at address 0x0" "print
> *intp, not associated"

These lines are too long.

> +set test "print intap, not associated"
> +gdb_test_multiple "print intap" $test {
> +  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
> +    pass $test
> +  }
> +  -re " = <not associated>\r\n$gdb_prompt $" {
> +    pass $test
> +  }
> +}

Why do we need to different regex here?  Need to handle the differences
of different compilers?  IMO, the former looks reasonable to me.

> +gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
> +gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"

They are too long.

> +gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
> +
> +
> +gdb_breakpoint [gdb_get_line_number "Before value assignment"]
> +gdb_continue_to_breakpoint "Before value assignment"
> +gdb_test "print *(twop)%ivla2" "= <not allocated>"
> +
> +
> +gdb_breakpoint [gdb_get_line_number "After value assignment"]
> +gdb_continue_to_breakpoint "After value assignment"
> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *logp" "= \\.TRUE\\."
> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *comp" "= \\(1,2\\)"
> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *charp" "= 'a'"
> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *charap" "= 'abc'"
> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *intp" "= 10"
> +set test_name "print intap, associated"
> +gdb_test_multiple "print intap" $test_name {
> +  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
> +    pass $test_name
> +  }
> +  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
> +    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
> +    pass $test_name
> +  }
> +}

Again, different outputs due to different compilers?  The latter looks
reasonable to me.

> +set test_name "print intvlap, associated"
> +gdb_test_multiple "print intvlap" $test_name {
> +  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
> +    pass $test_name
> +  }
> +  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
> +    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
> +    pass $test_name
> +  }
> +}

Likewise.

> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index 6896da2..f592278 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -1141,12 +1141,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
>        return 0;
>      }
>  
> -  if (type_not_associated (value_type (val)))
> -    {
> -      val_print_not_associated (stream);
> -      return 0;
> -    }
> -

Could you explain why do you remove this?

>    if (type_not_allocated (value_type (val)))
>      {
>        val_print_not_allocated (stream);

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 6/6] Fortran: Testsuite, add cyclic pointers.
  2016-09-07  6:38 ` [PATCH V4 6/6] Fortran: Testsuite, add cyclic pointers Bernhard Heckel
@ 2016-10-13 14:08   ` Yao Qi
  0 siblings, 0 replies; 33+ messages in thread
From: Yao Qi @ 2016-10-13 14:08 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: qiyaoltc, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

> 2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>
>
> gdb/testsuite/Changelog:
> 	* pointers.f90: Add cylic pointers.
> 	* pointers.exp: Add print of cyclic pointers.

Patch is good to me.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-13 14:07   ` Yao Qi
@ 2016-10-13 14:57     ` Bernhard Heckel
  2016-10-17 10:32       ` Yao Qi
  0 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-13 14:57 UTC (permalink / raw)
  To: Yao Qi; +Cc: brobecker, gdb-patches

On 13/10/2016 16:07, Yao Qi wrote:
> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>
>> diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
>> index 2cb418d..120163f 100644
>> --- a/gdb/c-valprint.c
>> +++ b/gdb/c-valprint.c
>> @@ -645,6 +645,28 @@ c_value_print (struct value *val, struct ui_file *stream,
>>         else
>>   	{
>>   	  /* normal case */
>> +	  if (TYPE_CODE (type) == TYPE_CODE_PTR
>> +	      && 1 == is_dynamic_type (type))
> Use is_dynamic_type return value as bool.
>
>> +	    {
>> +	      CORE_ADDR addr;
>> +	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
>> +		addr = value_address (val);
>> +	      else
>> +		addr = value_as_address (val);
>> +
>> +	      /* We resolve the target-type only when the
>> +	         pointer is associated.  */
>> +	      if ((addr != 0)
>> +		  && (0 == type_not_associated (type)))
> !type_not_associated (type)
>
>> +
>> +
>> +gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
>> +gdb_continue_to_breakpoint "Before pointer assignment"
>> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) 0x0" "print logp, not associated"
>> +gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
>> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) 0x0" "print comp, not associated"
>> +gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
>> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "print charp, not associated"
>> +gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
>> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" "print charap, not associated"
>> +gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
>> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" "print intp, not associated"
>> +gdb_test "print *intp" "Cannot access memory at address 0x0" "print
>> *intp, not associated"
> These lines are too long.
>
>> +set test "print intap, not associated"
>> +gdb_test_multiple "print intap" $test {
>> +  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
>> +    pass $test
>> +  }
>> +  -re " = <not associated>\r\n$gdb_prompt $" {
>> +    pass $test
>> +  }
>> +}
> Why do we need to different regex here?  Need to handle the differences
> of different compilers?  IMO, the former looks reasonable to me.
A pointer to an array (especially to Variable Length Array, VLA) is 
described in Gfortran's  compiled debug info
like normal array types + associated property of an pointer.
Not sure if this is a bug in Gfortran or not? I was also thinking to 
make the
output equal, and check if an array has pointer attributes but ..... I 
don't really like this approach. This would
cause a lot of "if .. else" construct in the code for example: 
De-reference this pointer, Address operator, ...

>> +gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
>> +gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
> They are too long.
>
>> +gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
>> +
>> +
>> +gdb_breakpoint [gdb_get_line_number "Before value assignment"]
>> +gdb_continue_to_breakpoint "Before value assignment"
>> +gdb_test "print *(twop)%ivla2" "= <not allocated>"
>> +
>> +
>> +gdb_breakpoint [gdb_get_line_number "After value assignment"]
>> +gdb_continue_to_breakpoint "After value assignment"
>> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"
>> +gdb_test "print *logp" "= \\.TRUE\\."
>> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"
>> +gdb_test "print *comp" "= \\(1,2\\)"
>> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?"
>> +gdb_test "print *charp" "= 'a'"
>> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?"
>> +gdb_test "print *charap" "= 'abc'"
>> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"
>> +gdb_test "print *intp" "= 10"
>> +set test_name "print intap, associated"
>> +gdb_test_multiple "print intap" $test_name {
>> +  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
>> +    pass $test_name
>> +  }
>> +  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
>> +    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
>> +    pass $test_name
>> +  }
>> +}
> Again, different outputs due to different compilers?  The latter looks
> reasonable to me.
>
>> +set test_name "print intvlap, associated"
>> +gdb_test_multiple "print intvlap" $test_name {
>> +  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
>> +    pass $test_name
>> +  }
>> +  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
>> +    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
>> +    pass $test_name
>> +  }
>> +}
> Likewise.
>
>> diff --git a/gdb/valprint.c b/gdb/valprint.c
>> index 6896da2..f592278 100644
>> --- a/gdb/valprint.c
>> +++ b/gdb/valprint.c
>> @@ -1141,12 +1141,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
>>         return 0;
>>       }
>>   
>> -  if (type_not_associated (value_type (val)))
>> -    {
>> -      val_print_not_associated (stream);
>> -      return 0;
>> -    }
>> -
> Could you explain why do you remove this?
I we keep this, we shortcut any additional printing of the target type 
of a pointer in case it is not associated.
>
>>     if (type_not_allocated (value_type (val)))
>>       {
>>         val_print_not_allocated (stream);

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-13 14:57     ` Bernhard Heckel
@ 2016-10-17 10:32       ` Yao Qi
  2016-10-17 11:25         ` Bernhard Heckel
  0 siblings, 1 reply; 33+ messages in thread
From: Yao Qi @ 2016-10-17 10:32 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: Yao Qi, brobecker, gdb-patches

Bernhard Heckel <bernhard.heckel@intel.com> writes:

>>> +set test "print intap, not associated"
>>> +gdb_test_multiple "print intap" $test {
>>> + -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not
>>> associated>\r\n$gdb_prompt $" {
>>> +    pass $test
>>> +  }
>>> +  -re " = <not associated>\r\n$gdb_prompt $" {
>>> +    pass $test
>>> +  }
>>> +}
>> Why do we need to different regex here?  Need to handle the differences
>> of different compilers?  IMO, the former looks reasonable to me.
> A pointer to an array (especially to Variable Length Array, VLA) is
> described in Gfortran's  compiled debug info
> like normal array types + associated property of an pointer.

Could you show the debug information gfortran and ifort generates
respectively?

> Not sure if this is a bug in Gfortran or not? I was also thinking to
> make the
> output equal, and check if an array has pointer attributes but ..... I
> don't really like this approach. This would
> cause a lot of "if .. else" construct in the code for example:
> De-reference this pointer, Address operator, ...

If gfortran people confirm it is a bug, we can xfail the test.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-17 10:32       ` Yao Qi
@ 2016-10-17 11:25         ` Bernhard Heckel
  2016-10-17 12:18           ` Bernhard Heckel
  0 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-17 11:25 UTC (permalink / raw)
  To: Yao Qi; +Cc: brobecker, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1536 bytes --]

On 17/10/2016 12:32, Yao Qi wrote:
> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>
>>>> +set test "print intap, not associated"
>>>> +gdb_test_multiple "print intap" $test {
>>>> + -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not
>>>> associated>\r\n$gdb_prompt $" {
>>>> +    pass $test
>>>> +  }
>>>> +  -re " = <not associated>\r\n$gdb_prompt $" {
>>>> +    pass $test
>>>> +  }
>>>> +}
>>> Why do we need to different regex here?  Need to handle the differences
>>> of different compilers?  IMO, the former looks reasonable to me.
>> A pointer to an array (especially to Variable Length Array, VLA) is
>> described in Gfortran's  compiled debug info
>> like normal array types + associated property of an pointer.
> Could you show the debug information gfortran and ifort generates
> respectively?

see attachment

>
>> Not sure if this is a bug in Gfortran or not? I was also thinking to
>> make the
>> output equal, and check if an array has pointer attributes but ..... I
>> don't really like this approach. This would
>> cause a lot of "if .. else" construct in the code for example:
>> De-reference this pointer, Address operator, ...
> If gfortran people confirm it is a bug, we can xfail the test.
>

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

[-- Attachment #2: gcc_dwarf.txt --]
[-- Type: text/plain, Size: 6032 bytes --]

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x143 (32-bit)
   Version:       4
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : (indirect string, offset: 0xa5): GNU Fortran 4.8.3 20140911 (Red Hat 4.8.3-9) -mtune=generic -march=x86-64 -g -O0 -fintrinsic-modules-path /usr/lib/gcc/x86_64-redhat-linux/4.8.3/finclude	
    <10>   DW_AT_language    : 14	(Fortran 95)
    <11>   DW_AT_identifier_case: 2	(down_case)
    <12>   DW_AT_name        : (indirect string, offset: 0x17): pointers.f90	
    <16>   DW_AT_comp_dir    : (indirect string, offset: 0x44): .../gdb/testsuite/gdb.fortran	
    <1a>   DW_AT_low_pc      : 0x400830	
    <22>   DW_AT_high_pc     : 0x1de	
    <2a>   DW_AT_stmt_list   : 0x0	
 <1><2e>: Abbrev Number: 2 (DW_TAG_base_type)
    <2f>   DW_AT_byte_size   : 8	
    <30>   DW_AT_encoding    : 5	(signed)
    <31>   DW_AT_name        : (indirect string, offset: 0x2b): integer(kind=8)	
 <1><35>: Abbrev Number: 3 (DW_TAG_subprogram)
    <36>   DW_AT_name        : (indirect string, offset: 0x3b): pointers	
    <3a>   DW_AT_decl_file   : 1	
    <3b>   DW_AT_decl_line   : 16	
    <3c>   DW_AT_low_pc      : 0x400830	
    <44>   DW_AT_high_pc     : 0x1a3	
    <4c>   DW_AT_frame_base  : 1 byte block: 9c 	(DW_OP_call_frame_cfa)
    <4e>   DW_AT_GNU_all_tail_call_sites: 1	
    <4e>   DW_AT_main_subprogram: 1	
    <4e>   DW_AT_calling_convention: 2	(program)
    <4f>   DW_AT_sibling     : <0xa6>	
 <2><53>: Abbrev Number: 4 (DW_TAG_variable)
    <54>   DW_AT_name        : (indirect string, offset: 0x24): intvla	
    <58>   DW_AT_decl_file   : 1	
    <59>   DW_AT_decl_line   : 18	
    <5a>   DW_AT_type        : <0xa6>	
    <5e>   DW_AT_location    : 2 byte block: 91 40 	(DW_OP_fbreg: -64)
 <2><61>: Abbrev Number: 4 (DW_TAG_variable)
    <62>   DW_AT_name        : (indirect string, offset: 0x83): intvlap	
    <66>   DW_AT_decl_file   : 1	
    <67>   DW_AT_decl_line   : 19	
    <68>   DW_AT_type        : <0xd1>	
    <6c>   DW_AT_location    : 3 byte block: 91 90 7f 	(DW_OP_fbreg: -112)
 <2><70>: Abbrev Number: 5 (DW_TAG_lexical_block)
    <71>   DW_AT_low_pc      : 0x400848	
    <79>   DW_AT_high_pc     : 0x16c	
 <3><81>: Abbrev Number: 5 (DW_TAG_lexical_block)
    <82>   DW_AT_low_pc      : 0x40092a	
    <8a>   DW_AT_high_pc     : 0x26	
 <4><92>: Abbrev Number: 6 (DW_TAG_lexical_block)
    <93>   DW_AT_low_pc      : 0x40093a	
    <9b>   DW_AT_high_pc     : 0x16	
 <4><a3>: Abbrev Number: 0
 <3><a4>: Abbrev Number: 0
 <2><a5>: Abbrev Number: 0
 <1><a6>: Abbrev Number: 7 (DW_TAG_array_type)
    <a7>   DW_AT_data_location: 2 byte block: 97 6 	(DW_OP_push_object_address; DW_OP_deref)
    <aa>   DW_AT_allocated   : 4 byte block: 97 6 30 2e 	(DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne)
    <af>   DW_AT_type        : <0xca>	
    <b3>   DW_AT_sibling     : <0xca>	
 <2><b7>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <b8>   DW_AT_lower_bound : 4 byte block: 97 23 20 6 	(DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
    <bd>   DW_AT_upper_bound : 4 byte block: 97 23 28 6 	(DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
    <c2>   DW_AT_byte_stride : 6 byte block: 97 23 18 6 34 1e 	(DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_lit4; DW_OP_mul)
 <2><c9>: Abbrev Number: 0
 <1><ca>: Abbrev Number: 2 (DW_TAG_base_type)
    <cb>   DW_AT_byte_size   : 4	
    <cc>   DW_AT_encoding    : 5	(signed)
    <cd>   DW_AT_name        : (indirect string, offset: 0x8b): integer(kind=4)	
 <1><d1>: Abbrev Number: 9 (DW_TAG_array_type)
    <d2>   DW_AT_data_location: 2 byte block: 97 6 	(DW_OP_push_object_address; DW_OP_deref)
    <d5>   DW_AT_associated  : 4 byte block: 97 6 30 2e 	(DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne)
    <da>   DW_AT_type        : <0xca>	
    <de>   DW_AT_sibling     : <0xf5>	
 <2><e2>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <e3>   DW_AT_lower_bound : 4 byte block: 97 23 20 6 	(DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
    <e8>   DW_AT_upper_bound : 4 byte block: 97 23 28 6 	(DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
    <ed>   DW_AT_byte_stride : 6 byte block: 97 23 18 6 34 1e 	(DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_lit4; DW_OP_mul)
 <2><f4>: Abbrev Number: 0
 <1><f5>: Abbrev Number: 10 (DW_TAG_subprogram)
    <f6>   DW_AT_external    : 1	
    <f6>   DW_AT_name        : (indirect string, offset: 0x9b): main	
    <fa>   DW_AT_decl_file   : 1	
    <fb>   DW_AT_decl_line   : 32	
    <fc>   DW_AT_type        : <0xca>	
    <100>   DW_AT_low_pc      : 0x4009d3	
    <108>   DW_AT_high_pc     : 0x3b	
    <110>   DW_AT_frame_base  : 1 byte block: 9c 	(DW_OP_call_frame_cfa)
    <112>   DW_AT_GNU_all_tail_call_sites: 1	
    <112>   DW_AT_sibling     : <0x134>	
 <2><116>: Abbrev Number: 11 (DW_TAG_formal_parameter)
    <117>   DW_AT_name        : (indirect string, offset: 0xa0): argc	
    <11b>   DW_AT_decl_file   : 1	
    <11c>   DW_AT_decl_line   : 32	
    <11d>   DW_AT_type        : <0x134>	
    <121>   DW_AT_location    : 2 byte block: 91 6c 	(DW_OP_fbreg: -20)
 <2><124>: Abbrev Number: 11 (DW_TAG_formal_parameter)
    <125>   DW_AT_name        : (indirect string, offset: 0x12): argv	
    <129>   DW_AT_decl_file   : 1	
    <12a>   DW_AT_decl_line   : 32	
    <12b>   DW_AT_type        : <0x139>	
    <12f>   DW_AT_location    : 3 byte block: 91 60 6 	(DW_OP_fbreg: -32; DW_OP_deref)
 <2><133>: Abbrev Number: 0
 <1><134>: Abbrev Number: 12 (DW_TAG_const_type)
    <135>   DW_AT_type        : <0xca>	
 <1><139>: Abbrev Number: 13 (DW_TAG_pointer_type)
    <13a>   DW_AT_byte_size   : 8	
    <13b>   DW_AT_type        : <0x13f>	
 <1><13f>: Abbrev Number: 2 (DW_TAG_base_type)
    <140>   DW_AT_byte_size   : 1	
    <141>   DW_AT_encoding    : 8	(unsigned char)
    <142>   DW_AT_name        : (indirect string, offset: 0x0): character(kind=1)	
 <1><146>: Abbrev Number: 0


[-- Attachment #3: icc_dwarf.txt --]
[-- Type: text/plain, Size: 4178 bytes --]

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0xdf (32-bit)
   Version:       4
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_comp_dir    : (indirect string, offset: 0x0): .../gdb/testsuite/gdb.fortran	
    <10>   DW_AT_name        : (indirect string, offset: 0x51): pointers.f90	
    <14>   DW_AT_producer    : (indirect string, offset: 0x5e): Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.0
    <18>   Unknown AT value: 3b01: (indirect string, offset: 0xd0): -g -O0	
    <1c>   DW_AT_language    : 14	(Fortran 95)
    <1d>   DW_AT_use_UTF8    : 1	
    <1e>   DW_AT_low_pc      : 0x402ab0	
    <26>   DW_AT_high_pc     : 0x27d	
    <2e>   DW_AT_main_subprogram: 1	
    <2f>   DW_AT_stmt_list   : 0x0	
 <1><33>: Abbrev Number: 2 (DW_TAG_subprogram)
    <34>   DW_AT_decl_line   : 16	
    <35>   DW_AT_decl_file   : 1	
    <36>   DW_AT_name        : (indirect string, offset: 0xd7): pointers	
    <3a>   DW_AT_calling_convention: 2	(program)
    <3b>   DW_AT_low_pc      : 0x402ab0	
    <43>   DW_AT_high_pc     : 0x27d	
    <4b>   DW_AT_main_subprogram: 1	
    <4c>   DW_AT_external    : 1	
 <2><4d>: Abbrev Number: 3 (DW_TAG_variable)
    <4e>   DW_AT_decl_line   : 19	
    <4f>   DW_AT_decl_file   : 1	
    <50>   DW_AT_name        : (indirect string, offset: 0xe0): intvlap	
    <54>   DW_AT_type        : <0x78>	
    <58>   DW_AT_location    : 9 byte block: 3 0 f1 6a 0 0 0 0 0 	(DW_OP_addr: 6af100)
 <2><62>: Abbrev Number: 3 (DW_TAG_variable)
    <63>   DW_AT_decl_line   : 18	
    <64>   DW_AT_decl_file   : 1	
    <65>   DW_AT_name        : (indirect string, offset: 0xf3): intvla	
    <69>   DW_AT_type        : <0xb0>	
    <6d>   DW_AT_location    : 9 byte block: 3 a0 c3 6a 0 0 0 0 0 	(DW_OP_addr: 6ac3a0)
 <2><77>: Abbrev Number: 0
 <1><78>: Abbrev Number: 4 (DW_TAG_pointer_type)
    <79>   DW_AT_type        : <0x83>	
    <7d>   DW_AT_associated  : 5 byte block: 97 6 10 0 2e 	(DW_OP_push_object_address; DW_OP_deref; DW_OP_constu: 0; DW_OP_ne)
 <1><83>: Abbrev Number: 5 (DW_TAG_array_type)
    <84>   DW_AT_ordering    : 1	(column major)
    <85>   DW_AT_type        : <0xa9>	
    <89>   DW_AT_data_location: 2 byte block: 97 6 	(DW_OP_push_object_address; DW_OP_deref)
 <2><8c>: Abbrev Number: 6 (DW_TAG_subrange_type)
    <8d>   DW_AT_byte_stride : 5 byte block: 97 10 38 22 6 	(DW_OP_push_object_address; DW_OP_constu: 56; DW_OP_plus; DW_OP_deref)
    <93>   DW_AT_upper_bound : 14 byte block: 97 10 40 22 6 97 10 30 22 6 22 10 1 1c 	(DW_OP_push_object_address; DW_OP_constu: 64; DW_OP_plus; DW_OP_deref; DW_OP_push_object_address; DW_OP_constu: 48; DW_OP_plus; DW_OP_deref; DW_OP_plus; DW_OP_constu: 1; DW_OP_minus)
    <a2>   DW_AT_lower_bound : 5 byte block: 97 10 40 22 6 	(DW_OP_push_object_address; DW_OP_constu: 64; DW_OP_plus; DW_OP_deref)
 <2><a8>: Abbrev Number: 0
 <1><a9>: Abbrev Number: 7 (DW_TAG_base_type)
    <aa>   DW_AT_byte_size   : 4	
    <ab>   DW_AT_encoding    : 5	(signed)
    <ac>   DW_AT_name        : (indirect string, offset: 0xe8): INTEGER(4)	
 <1><b0>: Abbrev Number: 8 (DW_TAG_array_type)
    <b1>   DW_AT_ordering    : 1	(column major)
    <b2>   DW_AT_type        : <0xa9>	
    <b6>   DW_AT_data_location: 2 byte block: 97 6 	(DW_OP_push_object_address; DW_OP_deref)
    <b9>   DW_AT_allocated   : 11 byte block: 97 10 18 22 6 c 1 0 0 0 1a 	(DW_OP_push_object_address; DW_OP_constu: 24; DW_OP_plus; DW_OP_deref; DW_OP_const4u: 1; DW_OP_and)
 <2><c5>: Abbrev Number: 6 (DW_TAG_subrange_type)
    <c6>   DW_AT_byte_stride : 5 byte block: 97 10 38 22 6 	(DW_OP_push_object_address; DW_OP_constu: 56; DW_OP_plus; DW_OP_deref)
    <cc>   DW_AT_upper_bound : 14 byte block: 97 10 40 22 6 97 10 30 22 6 22 10 1 1c 	(DW_OP_push_object_address; DW_OP_constu: 64; DW_OP_plus; DW_OP_deref; DW_OP_push_object_address; DW_OP_constu: 48; DW_OP_plus; DW_OP_deref; DW_OP_plus; DW_OP_constu: 1; DW_OP_minus)
    <db>   DW_AT_lower_bound : 5 byte block: 97 10 40 22 6 	(DW_OP_push_object_address; DW_OP_constu: 64; DW_OP_plus; DW_OP_deref)
 <2><e1>: Abbrev Number: 0
 <1><e2>: Abbrev Number: 0


[-- Attachment #4: pointers.f90 --]
[-- Type: text/plain, Size: 1004 bytes --]

! Copyright 2016 Free Software Foundation, Inc.
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program.  If not, see <http://www.gnu.org/licenses/>.

program pointers

  integer, target, allocatable, dimension (:) :: intvla
  integer, pointer, dimension (:) :: intvlap
  
  nullify (intvlap)
 
  intvlap => intvla
 
  allocate (intvla(10))
  intvla(:) = 2
  intvla(4) = 4
  intvlap => intvla
 
  intvla(1) = intvla(1) + 1 ! After value assignment

end program pointers

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-17 11:25         ` Bernhard Heckel
@ 2016-10-17 12:18           ` Bernhard Heckel
  2016-10-20 11:52             ` Bernhard Heckel
  2016-10-20 15:33             ` Yao Qi
  0 siblings, 2 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-17 12:18 UTC (permalink / raw)
  To: Yao Qi; +Cc: brobecker, gdb-patches

On 17/10/2016 13:24, Bernhard Heckel wrote:
> On 17/10/2016 12:32, Yao Qi wrote:
>> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>>
>>>>> +set test "print intap, not associated"
>>>>> +gdb_test_multiple "print intap" $test {
>>>>> + -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not
>>>>> associated>\r\n$gdb_prompt $" {
>>>>> +    pass $test
>>>>> +  }
>>>>> +  -re " = <not associated>\r\n$gdb_prompt $" {
>>>>> +    pass $test
>>>>> +  }
>>>>> +}
>>>> Why do we need to different regex here?  Need to handle the 
>>>> differences
>>>> of different compilers?  IMO, the former looks reasonable to me.
>>> A pointer to an array (especially to Variable Length Array, VLA) is
>>> described in Gfortran's  compiled debug info
>>> like normal array types + associated property of an pointer.
>> Could you show the debug information gfortran and ifort generates
>> respectively?
>
> see attachment
>
>>
>>> Not sure if this is a bug in Gfortran or not? I was also thinking to
>>> make the
>>> output equal, and check if an array has pointer attributes but ..... I
>>> don't really like this approach. This would
>>> cause a lot of "if .. else" construct in the code for example:
>>> De-reference this pointer, Address operator, ...
>> If gfortran people confirm it is a bug, we can xfail the test.

I just looked again in the specification. It is not a bug.
FORTRAN specification (http://www.j3-fortran.org/doc/year/04/04-007.pdf) 
mention this as "array pointer"

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-17 12:18           ` Bernhard Heckel
@ 2016-10-20 11:52             ` Bernhard Heckel
  2016-10-20 15:33             ` Yao Qi
  1 sibling, 0 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-10-20 11:52 UTC (permalink / raw)
  To: Yao Qi; +Cc: brobecker, gdb-patches

On 17/10/2016 14:18, Bernhard Heckel wrote:
> On 17/10/2016 13:24, Bernhard Heckel wrote:
>> On 17/10/2016 12:32, Yao Qi wrote:
>>> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>>>
>>>>>> +set test "print intap, not associated"
>>>>>> +gdb_test_multiple "print intap" $test {
>>>>>> + -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not
>>>>>> associated>\r\n$gdb_prompt $" {
>>>>>> +    pass $test
>>>>>> +  }
>>>>>> +  -re " = <not associated>\r\n$gdb_prompt $" {
>>>>>> +    pass $test
>>>>>> +  }
>>>>>> +}
>>>>> Why do we need to different regex here?  Need to handle the 
>>>>> differences
>>>>> of different compilers?  IMO, the former looks reasonable to me.
>>>> A pointer to an array (especially to Variable Length Array, VLA) is
>>>> described in Gfortran's  compiled debug info
>>>> like normal array types + associated property of an pointer.
>>> Could you show the debug information gfortran and ifort generates
>>> respectively?
>>
>> see attachment
>>
>>>
>>>> Not sure if this is a bug in Gfortran or not? I was also thinking to
>>>> make the
>>>> output equal, and check if an array has pointer attributes but ..... I
>>>> don't really like this approach. This would
>>>> cause a lot of "if .. else" construct in the code for example:
>>>> De-reference this pointer, Address operator, ...
>>> If gfortran people confirm it is a bug, we can xfail the test.
>
> I just looked again in the specification. It is not a bug.
> FORTRAN specification 
> (http://www.j3-fortran.org/doc/year/04/04-007.pdf) mention this as 
> "array pointer"
Any comments on this?

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-17 12:18           ` Bernhard Heckel
  2016-10-20 11:52             ` Bernhard Heckel
@ 2016-10-20 15:33             ` Yao Qi
  2016-11-08  7:07               ` Bernhard Heckel
  1 sibling, 1 reply; 33+ messages in thread
From: Yao Qi @ 2016-10-20 15:33 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: Joel Brobecker, gdb-patches

On Mon, Oct 17, 2016 at 1:18 PM, Bernhard Heckel
<bernhard.heckel@intel.com> wrote:
>
> I just looked again in the specification. It is not a bug.
> FORTRAN specification (http://www.j3-fortran.org/doc/year/04/04-007.pdf)
> mention this as "array pointer"
>

In "Glossary of technical terms", array pointer (5.1.2.5.3) : A pointer to an
array, so it is a pointer, not an array.

In your example,

  integer, pointer, dimension (:) :: intvlap

It is a pointer in the debug information generated by icc.  IMO, it is correct,

- <1><78>: Abbrev Number: 4 (DW_TAG_pointer_type)
-    <79>   DW_AT_type        : <0x83>
-    <7d>   DW_AT_associated  : 5 byte block: 97 6 10 0 2e
(DW_OP_push_object_address; DW_OP_deref; DW_OP_constu: 0; DW_OP_ne)
- <1><83>: Abbrev Number: 5 (DW_TAG_array_type)
-    <84>   DW_AT_ordering    : 1       (column major)
-    <85>   DW_AT_type        : <0xa9>
-    <89>   DW_AT_data_location: 2 byte block: 97 6
(DW_OP_push_object_address; DW_OP_deref)
- <2><8c>: Abbrev Number: 6 (DW_TAG_subrange_type)
-    <8d>   DW_AT_byte_stride : 5 byte block: 97 10 38 22 6
(DW_OP_push_object_address; DW_OP_constu: 56; DW_OP_plus; DW_OP_deref)
-    <93>   DW_AT_upper_bound : 14 byte block: 97 10 40 22 6 97 10 30
22 6 22 10 1 1c   (DW_OP_push_object_address; DW_OP_constu: 64;
DW_OP_plus; DW_OP_deref; DW_OP_push_object_address; DW_OP_constu: 48;
DW_OP_plus; DW_OP_deref; DW_OP_plus; DW_OP_constu: 1; DW_OP_minus)
-    <a2>   DW_AT_lower_bound : 5 byte block: 97 10 40 22 6
(DW_OP_push_object_address; DW_OP_constu: 64; DW_OP_plus; DW_OP_deref)
- <2><a8>: Abbrev Number: 0

however, it is an array in the debug information generated by gfortran,
which is wrong.

+ <1><d1>: Abbrev Number: 9 (DW_TAG_array_type)
+    <d2>   DW_AT_data_location: 2 byte block: 97 6
(DW_OP_push_object_address; DW_OP_deref)
+    <d5>   DW_AT_associated  : 4 byte block: 97 6 30 2e
(DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne)
+    <da>   DW_AT_type        : <0xca>
+    <de>   DW_AT_sibling     : <0xf5>
+ <2><e2>: Abbrev Number: 8 (DW_TAG_subrange_type)
+    <e3>   DW_AT_lower_bound : 4 byte block: 97 23 20 6
(DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
+    <e8>   DW_AT_upper_bound : 4 byte block: 97 23 28 6
(DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
+    <ed>   DW_AT_byte_stride : 6 byte block: 97 23 18 6 34 1e
(DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref;
DW_OP_lit4; DW_OP_mul)
+ <2><f4>: Abbrev Number: 0

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-10-20 15:33             ` Yao Qi
@ 2016-11-08  7:07               ` Bernhard Heckel
  2016-11-08 11:26                 ` Yao Qi
  0 siblings, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-11-08  7:07 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joel Brobecker, gdb-patches

On 20/10/2016 17:33, Yao Qi wrote:
> On Mon, Oct 17, 2016 at 1:18 PM, Bernhard Heckel
> <bernhard.heckel@intel.com> wrote:
>> I just looked again in the specification. It is not a bug.
>> FORTRAN specification (http://www.j3-fortran.org/doc/year/04/04-007.pdf)
>> mention this as "array pointer"
>>
> In "Glossary of technical terms", array pointer (5.1.2.5.3) : A pointer to an
> array, so it is a pointer, not an array.
>
> In your example,
>
>    integer, pointer, dimension (:) :: intvlap
>
> It is a pointer in the debug information generated by icc.  IMO, it is correct,
>
> - <1><78>: Abbrev Number: 4 (DW_TAG_pointer_type)
> -    <79>   DW_AT_type        : <0x83>
> -    <7d>   DW_AT_associated  : 5 byte block: 97 6 10 0 2e
> (DW_OP_push_object_address; DW_OP_deref; DW_OP_constu: 0; DW_OP_ne)
> - <1><83>: Abbrev Number: 5 (DW_TAG_array_type)
> -    <84>   DW_AT_ordering    : 1       (column major)
> -    <85>   DW_AT_type        : <0xa9>
> -    <89>   DW_AT_data_location: 2 byte block: 97 6
> (DW_OP_push_object_address; DW_OP_deref)
> - <2><8c>: Abbrev Number: 6 (DW_TAG_subrange_type)
> -    <8d>   DW_AT_byte_stride : 5 byte block: 97 10 38 22 6
> (DW_OP_push_object_address; DW_OP_constu: 56; DW_OP_plus; DW_OP_deref)
> -    <93>   DW_AT_upper_bound : 14 byte block: 97 10 40 22 6 97 10 30
> 22 6 22 10 1 1c   (DW_OP_push_object_address; DW_OP_constu: 64;
> DW_OP_plus; DW_OP_deref; DW_OP_push_object_address; DW_OP_constu: 48;
> DW_OP_plus; DW_OP_deref; DW_OP_plus; DW_OP_constu: 1; DW_OP_minus)
> -    <a2>   DW_AT_lower_bound : 5 byte block: 97 10 40 22 6
> (DW_OP_push_object_address; DW_OP_constu: 64; DW_OP_plus; DW_OP_deref)
> - <2><a8>: Abbrev Number: 0
>
> however, it is an array in the debug information generated by gfortran,
> which is wrong.
>
> + <1><d1>: Abbrev Number: 9 (DW_TAG_array_type)
> +    <d2>   DW_AT_data_location: 2 byte block: 97 6
> (DW_OP_push_object_address; DW_OP_deref)
> +    <d5>   DW_AT_associated  : 4 byte block: 97 6 30 2e
> (DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne)
> +    <da>   DW_AT_type        : <0xca>
> +    <de>   DW_AT_sibling     : <0xf5>
> + <2><e2>: Abbrev Number: 8 (DW_TAG_subrange_type)
> +    <e3>   DW_AT_lower_bound : 4 byte block: 97 23 20 6
> (DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
> +    <e8>   DW_AT_upper_bound : 4 byte block: 97 23 28 6
> (DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
> +    <ed>   DW_AT_byte_stride : 6 byte block: 97 23 18 6 34 1e
> (DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref;
> DW_OP_lit4; DW_OP_mul)
> + <2><f4>: Abbrev Number: 0
>

Created a ticket
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78059

Can we agree to move forward with a "known fail" for Gfortran?



Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-11-08  7:07               ` Bernhard Heckel
@ 2016-11-08 11:26                 ` Yao Qi
  2016-11-08 12:27                   ` Bernhard Heckel
  2016-11-16 12:16                   ` Bernhard Heckel
  0 siblings, 2 replies; 33+ messages in thread
From: Yao Qi @ 2016-11-08 11:26 UTC (permalink / raw)
  To: Bernhard Heckel; +Cc: Joel Brobecker, gdb-patches

On Tue, Nov 8, 2016 at 7:07 AM, Bernhard Heckel
<bernhard.heckel@intel.com> wrote:
>
> Created a ticket
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78059
>
> Can we agree to move forward with a "known fail" for Gfortran?
>

Can we wait until PR 78059 is confirmed by gfortran people?

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-11-08 11:26                 ` Yao Qi
@ 2016-11-08 12:27                   ` Bernhard Heckel
  2016-11-16 12:16                   ` Bernhard Heckel
  1 sibling, 0 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-11-08 12:27 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joel Brobecker, gdb-patches

On 08/11/2016 12:26, Yao Qi wrote:
> On Tue, Nov 8, 2016 at 7:07 AM, Bernhard Heckel
> <bernhard.heckel@intel.com> wrote:
>> Created a ticket
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78059
>>
>> Can we agree to move forward with a "known fail" for Gfortran?
>>
> Can we wait until PR 78059 is confirmed by gfortran people?
>

I fear it take some time.

There is one more patch series which handles "variable length strings"
and the series depends on the pointer feature.
It would be nice to move on, as the "variable length string" 
implementation is the last
piece which is missing to complete the VLA feature set.



Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-11-08 11:26                 ` Yao Qi
  2016-11-08 12:27                   ` Bernhard Heckel
@ 2016-11-16 12:16                   ` Bernhard Heckel
  2016-11-21 15:03                     ` Bernhard Heckel
  1 sibling, 1 reply; 33+ messages in thread
From: Bernhard Heckel @ 2016-11-16 12:16 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joel Brobecker, gdb-patches

On 08/11/2016 12:26, Yao Qi wrote:
> On Tue, Nov 8, 2016 at 7:07 AM, Bernhard Heckel
> <bernhard.heckel@intel.com> wrote:
>> Created a ticket
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78059
>>
>> Can we agree to move forward with a "known fail" for Gfortran?
>>
> Can we wait until PR 78059 is confirmed by gfortran people?
>

DWARF4 gives an implementation proposal of array pointers and it is like 
Gfortran is
implementing it.
->  See D.2 Aggregate Examples
    -> ! Description for type of 'ap'

So, Gfortran is ok here.



Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
  2016-11-16 12:16                   ` Bernhard Heckel
@ 2016-11-21 15:03                     ` Bernhard Heckel
  0 siblings, 0 replies; 33+ messages in thread
From: Bernhard Heckel @ 2016-11-21 15:03 UTC (permalink / raw)
  To: Yao Qi; +Cc: Joel Brobecker, gdb-patches

On 16/11/2016 13:16, Bernhard Heckel wrote:
> On 08/11/2016 12:26, Yao Qi wrote:
>> On Tue, Nov 8, 2016 at 7:07 AM, Bernhard Heckel
>> <bernhard.heckel@intel.com> wrote:
>>> Created a ticket
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78059
>>>
>>> Can we agree to move forward with a "known fail" for Gfortran?
>>>
>> Can we wait until PR 78059 is confirmed by gfortran people?
>>
>
> DWARF4 gives an implementation proposal of array pointers and it is 
> like Gfortran is
> implementing it.
> ->  See D.2 Aggregate Examples
>    -> ! Description for type of 'ap'
>
> So, Gfortran is ok here.

Ok to checkin?
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2016-11-21 15:03 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07  6:38 [PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
2016-09-07  6:38 ` [PATCH V4 5/6] Resolve dynamic " Bernhard Heckel
2016-09-07 14:24   ` Eli Zaretskii
2016-10-13 14:07   ` Yao Qi
2016-10-13 14:57     ` Bernhard Heckel
2016-10-17 10:32       ` Yao Qi
2016-10-17 11:25         ` Bernhard Heckel
2016-10-17 12:18           ` Bernhard Heckel
2016-10-20 11:52             ` Bernhard Heckel
2016-10-20 15:33             ` Yao Qi
2016-11-08  7:07               ` Bernhard Heckel
2016-11-08 11:26                 ` Yao Qi
2016-11-08 12:27                   ` Bernhard Heckel
2016-11-16 12:16                   ` Bernhard Heckel
2016-11-21 15:03                     ` Bernhard Heckel
2016-09-07  6:38 ` [PATCH V4 2/6] Fortran: Resolve dynamic properties of pointer types Bernhard Heckel
2016-10-05  8:44   ` Yao Qi
2016-10-05  9:36     ` Yao Qi
2016-10-05 10:07       ` Bernhard Heckel
2016-09-07  6:38 ` [PATCH V4 6/6] Fortran: Testsuite, add cyclic pointers Bernhard Heckel
2016-10-13 14:08   ` Yao Qi
2016-09-07  6:38 ` [PATCH V4 1/6] Fortran: Testsuite, fix differences in type naming Bernhard Heckel
2016-09-21 15:57   ` Yao Qi
2016-09-07  6:38 ` [PATCH V4 3/6] Typeprint: Resolve any dynamic target type of a pointer Bernhard Heckel
2016-10-05 10:10   ` Yao Qi
2016-10-05 11:03     ` Bernhard Heckel
2016-10-13 13:41       ` Yao Qi
2016-09-07  6:38 ` [PATCH V4 4/6] Fortran: Typeprint, fix dangling types Bernhard Heckel
2016-10-13 13:53   ` Yao Qi
2016-09-14 12:55 ` [PING][PATCH V4 0/6] Fortran: Resolve target types of pointers Bernhard Heckel
2016-09-28 12:45   ` Bernhard Heckel
2016-10-05  6:03     ` [ping 2][PATCH " Bernhard Heckel
2016-09-21  9:49 ` [ping 2] [PATCH " Bernhard Heckel

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).