public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
@ 2021-04-15 21:37 Kumar N, Bhuvanendra
  2021-04-21 16:13 ` Andrew Burgess
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-04-15 21:37 UTC (permalink / raw)
  To: gdb-patches
  Cc: George, Jini Susan, Sharma, Alok Kumar, Achra, Nitika, Tomar,
	Sourabh Singh, E, Nagajyothi

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

[AMD Official Use Only - Internal Distribution Only]

Hello All,

I request all of you to please review this patch. Below are the details.

Problem Description:
All the test points in the test case are failing for clang due to mismatch in type information emitted by clang.

For example test case expects the type information of get_number to be : (where there is only one formal parameter, in this case its "this")

(gdb) ptype some_module::get_number

type = integer(kind=4) (Type __class_some_module_Number_t)

but flang emits few additional compiler created formal parameters just like any other complier. Hence during ptype command, type information for these also emitted as shown below (marked in RED) along with regular formal parameter. This extra ptype info for an formal parameter is causing mismatch in GDB output comparison and test case failure

(gdb) ptype some_module::get_number

type = integer (Type number, integer*8 (10))

similarly all other test points are failing due to mismatch in ptype command output

Resolution:
Test case is modified to cover the missing ptype information for the compiler created formal parameters also. Also few kind parameter printing are removed which is not default for clang.

Thanks and Regards,
Bhuvan

Patch content inlined:

From 3c3bae18be894db971840180b59f56707b6d5ebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
Date: Fri, 16 Apr 2021 02:35:08 +0530
Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
clang.

Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
  commit 0a709cba00d36d490482d0e8673e323ac1e897a6
  Author Alok Kumar Sharma (alokkumar.sharma@amd.com<mailto:alokkumar.sharma@amd.com>)

gdb/testsuite/ChangeLog:
      * gdb.fortran/ptype-on-functions.exp: Add type info of formal
      parameter for clang. Also removed the kind parameter for clang.
      * lib/fortran.exp (fortran_int8): Likewise.
---
gdb/testsuite/ChangeLog                       |  5 ++
.../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
gdb/testsuite/lib/fortran.exp                 |  2 +-
3 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ad289c135d..216d985995 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
+     * gdb.fortran/ptype-on-functions.exp: Add type info of formal
+     parameter for clang. Also removed the kind parameter for clang.
+     * lib/fortran.exp (fortran_int8): Likewise.
+
2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
         * gdb.base/foll-exec.exp: Additional next commands added for
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d4..4e46e10166 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
     continue
}
-gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"
+if {[test_compiler_info {clang-*}]} {
+    set integer4 [fortran_int4]
+    set logical4 [fortran_logical4]
+    set integer8 [fortran_int8]
-gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::get_number" \
+        "type = $integer4 \\(Type<file://(Type> number, $integer8 \\(10\\)\\<file://(10/)/>)"
-gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type<file://(Type> number, $integer4\\, $integer8 \\(10\\)\\<file://(10/)/>)"
-gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype is_bigger" \
+        "type = $logical4 \\($integer4<file://($integer4>, $integer4\\)"
-gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    gdb_test "ptype say_numbers" \
+        "type = void \\($integer4<file://($integer4>, $integer4, $integer4\\)"
-gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\)<file://($integer4/)> \\)"
-gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), $integer8\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\($integer8<file://($integer8>, $integer4 \\(:,:\\)\\)"
+} else {
+    gdb_test "ptype some_module::get_number" \
+        "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"
+
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype is_bigger" \
+        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype say_numbers" \
+        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
+}
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 35db863e9c..f8c442fd09 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -49,7 +49,7 @@ proc fortran_int8 {} {
     } elseif {[test_compiler_info {gcc-*}]} {
     return "integer\\(kind=8\\)"
     } elseif {[test_compiler_info {clang-*}]} {
-     return "integer*8"
+     return "integer\\*8"
     } elseif {[test_compiler_info {icc-*}]} {
     return "INTEGER\\(8\\)"
     } else {
--
2.17.1


[-- Attachment #2: gdb.fortran-Add-type-info-of-formal-parameter.patch --]
[-- Type: application/octet-stream, Size: 5015 bytes --]

From 3c3bae18be894db971840180b59f56707b6d5ebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Fri, 16 Apr 2021 02:35:08 +0530
Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
 clang.

Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
  commit 0a709cba00d36d490482d0e8673e323ac1e897a6
  Author Alok Kumar Sharma (alokkumar.sharma@amd.com)

gdb/testsuite/ChangeLog:
	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
	parameter for clang. Also removed the kind parameter for clang.
	* lib/fortran.exp (fortran_int8): Likewise.
---
 gdb/testsuite/ChangeLog                       |  5 ++
 .../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
 gdb/testsuite/lib/fortran.exp                 |  2 +-
 3 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ad289c135d..216d985995 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>
+	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
+	parameter for clang. Also removed the kind parameter for clang.
+	* lib/fortran.exp (fortran_int8): Likewise.
+
 2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>
 
         * gdb.base/foll-exec.exp: Additional next commands added for
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d4..4e46e10166 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
     continue
 }
 
-gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+if {[test_compiler_info {clang-*}]} {
+    set integer4 [fortran_int4]
+    set logical4 [fortran_logical4]
+    set integer8 [fortran_int8]
 
-gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::get_number" \
+        "type = $integer4 \\(Type number, $integer8 \\(10\\)\\)"
 
-gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type number, $integer4\\, $integer8 \\(10\\)\\)"
 
-gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype is_bigger" \
+        "type = $logical4 \\($integer4, $integer4\\)"
 
-gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    gdb_test "ptype say_numbers" \
+        "type = void \\($integer4, $integer4, $integer4\\)"
 
-gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\) \\)"
 
-gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\), $integer8\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\($integer8, $integer4 \\(:,:\\)\\)"
+} else {
+    gdb_test "ptype some_module::get_number" \
+        "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype is_bigger" \
+        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype say_numbers" \
+        "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+}
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 35db863e9c..f8c442fd09 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -49,7 +49,7 @@ proc fortran_int8 {} {
     } elseif {[test_compiler_info {gcc-*}]} {
 	return "integer\\(kind=8\\)"
     } elseif {[test_compiler_info {clang-*}]} {
-	return "integer*8"
+	return "integer\\*8"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "INTEGER\\(8\\)"
     } else {
-- 
2.17.1


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

* Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-04-15 21:37 [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp Kumar N, Bhuvanendra
@ 2021-04-21 16:13 ` Andrew Burgess
  2021-04-22  6:48   ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Burgess @ 2021-04-21 16:13 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

* Kumar N, Bhuvanendra via Gdb-patches <gdb-patches@sourceware.org> [2021-04-15 21:37:05 +0000]:

Thanks for working on this.

> Additional compiler generated formal parameter exist with clang and type
> information for the same is added accordingly. Also few kind parameter
> printing are removed which is not default for clang.
> Note: More details about this kind parameter omission while printing can
> be found with similar patch
>   commit 0a709cba00d36d490482d0e8673e323ac1e897a6
>   Author Alok Kumar Sharma (alokkumar.sharma@amd.com<mailto:alokkumar.sharma@amd.com>)

I didn't really understand what you were trying to so in this commit
message, nor do I see how commit 0a709cba00d relates to this change.

> 
> gdb/testsuite/ChangeLog:
>       * gdb.fortran/ptype-on-functions.exp: Add type info of formal
>       parameter for clang. Also removed the kind parameter for clang.
>       * lib/fortran.exp (fortran_int8): Likewise.
> ---
> gdb/testsuite/ChangeLog                       |  5 ++
> .../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
> gdb/testsuite/lib/fortran.exp                 |  2 +-
> 3 files changed, 47 insertions(+), 15 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index ad289c135d..216d985995 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
> +     * gdb.fortran/ptype-on-functions.exp: Add type info of formal
> +     parameter for clang. Also removed the kind parameter for clang.
> +     * lib/fortran.exp (fortran_int8): Likewise.

This formatting here is wrong, it should be:

  2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>

	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
	parameter for clang. Also removed the kind parameter for clang.
	* lib/fortran.exp (fortran_int8): Likewise.

> +
> 2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
>          * gdb.base/foll-exec.exp: Additional next commands added for
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d4..4e46e10166 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
>      continue
> }
> -gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"

I'm not sure what happened with the encoding of this email (note
'file://')...

> +if {[test_compiler_info {clang-*}]} {
> +    set integer4 [fortran_int4]
> +    set logical4 [fortran_logical4]
> +    set integer8 [fortran_int8]
> -gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    gdb_test "ptype some_module::get_number" \
> +        "type = $integer4 \\(Type<file://(Type> number, $integer8 \\(10\\)\\<file://(10/)/>)"

I'm not suggesting it's wrong, but I've really curious what the '10'
here represents.  I don't see the value 10 anywhere in the test source
code, and as this is a type signature, I wouldn't really expect a
value in this position.

In general, rather than forking two separate code paths, could we not
try to extract the differences out into variables, so we might have
something like:

  gdb_test "ptype some_module::get_number" \
      "type = $integer4 \\($number_class_type\\)"

doing things this way helps prevent tests from diverging too much for
the different compilers.

Thanks,
Andrew

> -gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
> +    gdb_test "ptype some_module::set_number" \
> +        "type = void \\(Type<file://(Type> number, $integer4\\, $integer8 \\(10\\)\\<file://(10/)/>)"
> -gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    gdb_test "ptype is_bigger" \
> +        "type = $logical4 \\($integer4<file://($integer4>, $integer4\\)"
> -gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    gdb_test "ptype say_numbers" \
> +        "type = void \\($integer4<file://($integer4>, $integer4, $integer4\\)"
> -gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
> +    gdb_test "ptype fun_ptr" \
> +        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\)<file://($integer4/)> \\)"
> -gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
> +    gdb_test "ptype say_string" \
> +        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), $integer8\\)"
> +
> +    gdb_test "ptype say_array" \
> +        "type = void \\($integer8<file://($integer8>, $integer4 \\(:,:\\)\\)"
> +} else {
> +    gdb_test "ptype some_module::get_number" \
> +        "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"
> +
> +    gdb_test "ptype some_module::set_number" \
> +        "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype is_bigger" \
> +        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype say_numbers" \
> +        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype fun_ptr" \
> +        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +
> +    gdb_test "ptype say_string" \
> +        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
> +
> +    gdb_test "ptype say_array" \
> +        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
> +}
> diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
> index 35db863e9c..f8c442fd09 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -49,7 +49,7 @@ proc fortran_int8 {} {
>      } elseif {[test_compiler_info {gcc-*}]} {
>      return "integer\\(kind=8\\)"
>      } elseif {[test_compiler_info {clang-*}]} {
> -     return "integer*8"
> +     return "integer\\*8"
>      } elseif {[test_compiler_info {icc-*}]} {
>      return "INTEGER\\(8\\)"
>      } else {
> --
> 2.17.1
> 



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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-04-21 16:13 ` Andrew Burgess
@ 2021-04-22  6:48   ` Kumar N, Bhuvanendra
  2021-04-30  8:52     ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-04-22  6:48 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

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

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew,

Thanks for your valuable comments, multiple issues are there, mostly during the test patch inlining, encoding went wrong. Hence I have attached the relevant info or files as attachments this time. Hope its fine.

> I didn't really understand what you were trying to do in this commit message, nor do I see how commit 0a709cba00d relates to this change

I have attached the git show and git log command output as attachment here (commit id: 0a709cba00d36d490482d0e8673e323ac1e897a6). As explained in the commit message, basically the test case expects the kind information as integer(kind=4) or integer(kind=8). But flang by default emits kind information as integer or integer*8 respectively, hence there is mismatch in GDB command output comparison. This required test case modification and it was done earlier as mentioned in this commit message by Alok CC'ed in this email.
Hence similar "kind" related changes were done in ptype-on-functions.exp.

> This formatting here is wrong, it should be

Thanks, I have corrected Changelog now

> I'm not sure what happened with the encoding of this email (note 'file://')...

I have attached the test patch and also the test case itself for better clarity here, inlining was messed up earlier and its confusing, could you please refer the attachments, please

> I'm not suggesting it's wrong, but I've really curious what the '10' here represents.  I don't see the value 10 anywhere in the test source code, and as this is a type signature, I wouldn't really expect a value in this position.

As we can see in the below flang emitted IR(intermediate representation), flang compiler is emitting additional formal parameter of type array with 10 elements. Flang or any other compiler creates these type of additional and internal variables or parameters for its purpose. I am covering the type information of these flang emitted internal parameters in this test case change, also addressing the default "kind" information emitted by flang. These type of changes for flang was done in other test cases also, earlier.

flang emitted IR snippet: 

define signext i32 @some_module_get_number_(i64* noalias %this, i64* noalias %.O0000) #0 !dbg !26 {
. . .
        call void @llvm.dbg.declare (metadata i64* %this, metadata !31, metadata !20), !dbg !27
        call void @llvm.dbg.declare (metadata i64* %.O0000, metadata !36, metadata !20), !dbg !27
. . .
!32 = !DISubrange(lowerBound: 1, upperBound: 10)
!33 = !DIBasicType(tag: DW_TAG_base_type, name: "integer*8", size: 64, align: 64, encoding: DW_ATE_signed)
!34 = !{ !32 }
!35 = !DICompositeType(tag: DW_TAG_array_type, size: 640, align: 64, baseType: !33, elements: !34)
!36 = !DILocalVariable(scope: !26, arg: 2, file: !3, line: 28, type: !35, flags: 64)

> In general, rather than forking two separate code paths, could we not try to extract the differences out into variables

I have attached the modified test case also,  gfortran and flang differs with i.number of formal parameters ii.type of each of these formal parameters, hence for different compiler, followed different code path

Thanks again for your review, please let me know any other details if required

Regards,
bhuvan

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Wednesday, April 21, 2021 9:43 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra via Gdb-patches <gdb-patches@sourceware.org> [2021-04-15 21:37:05 +0000]:

Thanks for working on this.

> Additional compiler generated formal parameter exist with clang and 
> type information for the same is added accordingly. Also few kind 
> parameter printing are removed which is not default for clang.
> Note: More details about this kind parameter omission while printing 
> can be found with similar patch
>   commit 0a709cba00d36d490482d0e8673e323ac1e897a6
>   Author Alok Kumar Sharma 
> (alokkumar.sharma@amd.com<mailto:alokkumar.sharma@amd.com>)

I didn't really understand what you were trying to so in this commit message, nor do I see how commit 0a709cba00d relates to this change.

>
> gdb/testsuite/ChangeLog:
>       * gdb.fortran/ptype-on-functions.exp: Add type info of formal
>       parameter for clang. Also removed the kind parameter for clang.
>       * lib/fortran.exp (fortran_int8): Likewise.
> ---
> gdb/testsuite/ChangeLog                       |  5 ++
> .../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
> gdb/testsuite/lib/fortran.exp                 |  2 +-
> 3 files changed, 47 insertions(+), 15 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 
> ad289c135d..216d985995 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
> +     * gdb.fortran/ptype-on-functions.exp: Add type info of formal
> +     parameter for clang. Also removed the kind parameter for clang.
> +     * lib/fortran.exp (fortran_int8): Likewise.

This formatting here is wrong, it should be:

  2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>

        * gdb.fortran/ptype-on-functions.exp: Add type info of formal
        parameter for clang. Also removed the kind parameter for clang.
        * lib/fortran.exp (fortran_int8): Likewise.

> +
> 2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
>          * gdb.base/foll-exec.exp: Additional next commands added for 
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp 
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d4..4e46e10166 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
>      continue
> }
> -gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"

I'm not sure what happened with the encoding of this email (note 'file://')...

> +if {[test_compiler_info {clang-*}]} {
> +    set integer4 [fortran_int4]
> +    set logical4 [fortran_logical4]
> +    set integer8 [fortran_int8]
> -gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    gdb_test "ptype some_module::get_number" \
> +        "type = $integer4 \\(Type<file://(Type> number, $integer8 \\(10\\)\\<file://(10/)/>)"

I'm not suggesting it's wrong, but I've really curious what the '10'
here represents.  I don't see the value 10 anywhere in the test source code, and as this is a type signature, I wouldn't really expect a value in this position.

In general, rather than forking two separate code paths, could we not try to extract the differences out into variables, so we might have something like:

  gdb_test "ptype some_module::get_number" \
      "type = $integer4 \\($number_class_type\\)"

doing things this way helps prevent tests from diverging too much for the different compilers.

Thanks,
Andrew

> -gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
> +    gdb_test "ptype some_module::set_number" \
> +        "type = void \\(Type<file://(Type> number, $integer4\\, $integer8 \\(10\\)\\<file://(10/)/>)"
> -gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    gdb_test "ptype is_bigger" \
> +        "type = $logical4 \\($integer4<file://($integer4>, $integer4\\)"
> -gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    gdb_test "ptype say_numbers" \
> +        "type = void \\($integer4<file://($integer4>, $integer4, $integer4\\)"
> -gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
> +    gdb_test "ptype fun_ptr" \
> +        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\)<file://($integer4/)> \\)"
> -gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
> +    gdb_test "ptype say_string" \
> +        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), $integer8\\)"
> +
> +    gdb_test "ptype say_array" \
> +        "type = void \\($integer8<file://($integer8>, $integer4 \\(:,:\\)\\)"
> +} else {
> +    gdb_test "ptype some_module::get_number" \
> +        "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"
> +
> +    gdb_test "ptype some_module::set_number" \
> +        "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype is_bigger" \
> +        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype say_numbers" \
> +        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype fun_ptr" \
> +        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +
> +    gdb_test "ptype say_string" \
> +        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
> +
> +    gdb_test "ptype say_array" \
> +        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
> +}
> diff --git a/gdb/testsuite/lib/fortran.exp 
> b/gdb/testsuite/lib/fortran.exp index 35db863e9c..f8c442fd09 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -49,7 +49,7 @@ proc fortran_int8 {} {
>      } elseif {[test_compiler_info {gcc-*}]} {
>      return "integer\\(kind=8\\)"
>      } elseif {[test_compiler_info {clang-*}]} {
> -     return "integer*8"
> +     return "integer\\*8"
>      } elseif {[test_compiler_info {icc-*}]} {
>      return "INTEGER\\(8\\)"
>      } else {
> --
> 2.17.1
>


[-- Attachment #2: gdb.fortran-Add-type-info-of-formal-parameter.patch --]
[-- Type: application/octet-stream, Size: 5133 bytes --]

From 3c3bae18be894db971840180b59f56707b6d5ebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Fri, 16 Apr 2021 02:35:08 +0530
Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
 clang.

Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
  commit 0a709cba00d36d490482d0e8673e323ac1e897a6
  Author Alok Kumar Sharma (alokkumar.sharma@amd.com)

gdb/testsuite/ChangeLog:
	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
	parameter for clang. Also removed the kind parameter for clang.
	* lib/fortran.exp (fortran_int8): Likewise.
---
 gdb/testsuite/ChangeLog                       |  5 ++
 .../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
 gdb/testsuite/lib/fortran.exp                 |  2 +-
 3 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ad289c135d..216d985995 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16 Bhuvanendra Kumar <Bhuvanendra.KumarN@amd.com>
+	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
+	parameter for clang. Also removed the kind parameter for clang.
+	* lib/fortran.exp (fortran_int8): Likewise.
+
 2021-04-16 Bhuvanendra Kumar <Bhuvanendra.KumarN@amd.com>
 
         * gdb.base/foll-exec.exp: Additional next commands added for
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d4..4e46e10166 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
     continue
 }
 
-gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+if {[test_compiler_info {clang-*}]} {
+    set integer4 [fortran_int4]
+    set logical4 [fortran_logical4]
+    set integer8 [fortran_int8]
 
-gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::get_number" \
+        "type = $integer4 \\(Type number, $integer8 \\(10\\)\\)"
 
-gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type number, $integer4\\, $integer8 \\(10\\)\\)"
 
-gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype is_bigger" \
+        "type = $logical4 \\($integer4, $integer4\\)"
 
-gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    gdb_test "ptype say_numbers" \
+        "type = void \\($integer4, $integer4, $integer4\\)"
 
-gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\) \\)"
 
-gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\), $integer8\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\($integer8, $integer4 \\(:,:\\)\\)"
+} else {
+    gdb_test "ptype some_module::get_number" \
+        "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype is_bigger" \
+        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype say_numbers" \
+        "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+}
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 35db863e9c..f8c442fd09 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -49,7 +49,7 @@ proc fortran_int8 {} {
     } elseif {[test_compiler_info {gcc-*}]} {
 	return "integer\\(kind=8\\)"
     } elseif {[test_compiler_info {clang-*}]} {
-	return "integer*8"
+	return "integer\\*8"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "INTEGER\\(8\\)"
     } else {
-- 
2.17.1


[-- Attachment #3: ptype-on-functions.exp.txt --]
[-- Type: text/plain, Size: 2724 bytes --]

# Copyright 2019-2021 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/>.

# This file contains a test for printing the types of functions.

if { [skip_fortran_tests] } { return -1 }

standard_testfile .f90
load_lib "fortran.exp"

if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
    return -1
}

if ![fortran_runto_main] then {
    perror "couldn't run to main"
    continue
}

if {[test_compiler_info {clang-*}]} {
    set integer4 [fortran_int4]
    set logical4 [fortran_logical4]
    set integer8 [fortran_int8]

    gdb_test "ptype some_module::get_number" \
        "type = $integer4 \\(Type number, $integer8 \\(10\\)\\)"

    gdb_test "ptype some_module::set_number" \
        "type = void \\(Type number, $integer4\\, $integer8 \\(10\\)\\)"

    gdb_test "ptype is_bigger" \
        "type = $logical4 \\($integer4, $integer4\\)"

    gdb_test "ptype say_numbers" \
        "type = void \\($integer4, $integer4, $integer4\\)"

    gdb_test "ptype fun_ptr" \
        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\) \\)"

    gdb_test "ptype say_string" \
        "type = void \\(character\\*\\(\\*\\), $integer8\\)"

    gdb_test "ptype say_array" \
        "type = void \\($integer8, $integer4 \\(:,:\\)\\)"
} else {
    gdb_test "ptype some_module::get_number" \
        "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"

    gdb_test "ptype some_module::set_number" \
        "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"

    gdb_test "ptype is_bigger" \
        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"

    gdb_test "ptype say_numbers" \
        "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"

    gdb_test "ptype fun_ptr" \
        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"

    gdb_test "ptype say_string" \
        "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"

    gdb_test "ptype say_array" \
        "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
}

[-- Attachment #4: gdb.show.output.txt --]
[-- Type: text/plain, Size: 5851 bytes --]

commit 0a709cba00d36d490482d0e8673e323ac1e897a6
Author: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date:   Wed Mar 4 17:16:52 2020 +0530

    gdb.fortran: Allow Flang kind printing in fortran testing
    
    In lib/fortran.exp, in the helper function fortran_int4, kind
    parameter is expected to be printed as (kind=4) for the LLVM
    Fortran compiler, Flang along with gfortran.  And in the helper
    function fortran_int8 kind parameter is expected to be printed
    as (kind=8).  But for the Flang compiler default kind is not
    printed and non default kind is printed differently than gfortran
    as below.
      integer(kind=4) => integer
      integer(kind=8) => integer*8
      real(kind=4) => real
      real(kind=8) => double precision
      complex(kind=4) => complex
      logical(kind=4) => logical
      character(kind=1) => character
    This commit adds support for printing of kind parameter for the
    Flang.  There should be no change when testing with gfortran.
    
    Note: The current patch overrides earlier patch with below details.
      commit c3b149eb7697b376df1b3a47d0102afda389ee6d
      Author Alok Kumar Sharma (alokkumar.sharma@amd.com)
    Earlier patch was incomplete and based on assumption that flang
    should be changed to dump a type with kind like the way gfortan does.
    Later it was realized that the way flang dumps this info is not
    incorrect but different. And changes in gdb test framework are
    finalized.
    
    gdb/testsuite/ChangeLog:
    
            * lib/fortran.exp (fortran_int4): Handle flang kind printing.
            (fortran_int8): Likewise.
            (fortran_real4): Likewise.
            (fortran_real8): Likewise.
            (fortran_complex4): Likewise.
            (fortran_logical4): Likewise.
            (fortran_character1): Likewise.

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3912a1c609..acd155f924 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2020-03-04  Alok Kumar Sharma  <AlokKumar.Sharma@amd.com>
+
+	* lib/fortran.exp (fortran_int4): Handle flang kind printing.
+	(fortran_int8): Likewise.
+	(fortran_real4): Likewise.
+	(fortran_real8): Likewise.
+	(fortran_complex4): Likewise.
+	(fortran_logical4): Likewise.
+	(fortran_character1): Likewise.
+
 2020-03-03  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* gdb.fortran/logical.exp: Add tests that any non-zero value is
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 54f3293677..549ed65790 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -32,9 +32,10 @@ proc set_lang_fortran {} {
 proc fortran_int4 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "int4"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "integer\\(kind=4\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "integer"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "INTEGER\\(4\\)"
     } else {
@@ -45,9 +46,10 @@ proc fortran_int4 {} {
 proc fortran_int8 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "int8"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "integer\\(kind=8\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "integer*8"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "INTEGER\\(8\\)"
     } else {
@@ -58,9 +60,10 @@ proc fortran_int8 {} {
 proc fortran_real4 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "real4"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "real\\(kind=4\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "real"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "REAL\\(4\\)"
     } else {
@@ -71,9 +74,10 @@ proc fortran_real4 {} {
 proc fortran_real8 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "real8"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "real\\(kind=8\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "double precision"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "REAL\\(8\\)"
     } else {
@@ -84,9 +88,10 @@ proc fortran_real8 {} {
 proc fortran_complex4 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "complex4"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "complex\\(kind=4\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "complex"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "COMPLEX\\(4\\)"
     } else {
@@ -97,9 +102,10 @@ proc fortran_complex4 {} {
 proc fortran_logical4 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "logical4"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "logical\\(kind=4\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "logical"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "LOGICAL\\(4\\)"
     } else {
@@ -110,9 +116,10 @@ proc fortran_logical4 {} {
 proc fortran_character1 {} {
     if {[test_compiler_info {gcc-4-[012]-*}]} {
 	return "character1"
-    } elseif {[test_compiler_info {gcc-*}]
-	      || [test_compiler_info {clang-*}]} {
+    } elseif {[test_compiler_info {gcc-*}]} {
 	return "character\\(kind=1\\)"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "character"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "CHARACTER\\(1\\)"
     } else {

[-- Attachment #5: gdb.log.output.txt --]
[-- Type: text/plain, Size: 3504 bytes --]

commit 0a709cba00d36d490482d0e8673e323ac1e897a6
Author: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date:   Wed Mar 4 17:16:52 2020 +0530

    gdb.fortran: Allow Flang kind printing in fortran testing

    In lib/fortran.exp, in the helper function fortran_int4, kind
    parameter is expected to be printed as (kind=4) for the LLVM
    Fortran compiler, Flang along with gfortran.  And in the helper
    function fortran_int8 kind parameter is expected to be printed
    as (kind=8).  But for the Flang compiler default kind is not
    printed and non default kind is printed differently than gfortran
    as below.
      integer(kind=4) => integer
      integer(kind=8) => integer*8
      real(kind=4) => real
      real(kind=8) => double precision
      complex(kind=4) => complex
      logical(kind=4) => logical
      character(kind=1) => character
    This commit adds support for printing of kind parameter for the
    Flang.  There should be no change when testing with gfortran.

    Note: The current patch overrides earlier patch with below details.
      commit c3b149eb7697b376df1b3a47d0102afda389ee6d
      Author Alok Kumar Sharma (alokkumar.sharma@amd.com)
    Earlier patch was incomplete and based on assumption that flang
    should be changed to dump a type with kind like the way gfortan does.
    Later it was realized that the way flang dumps this info is not
    incorrect but different. And changes in gdb test framework are
    finalized.

    gdb/testsuite/ChangeLog:

            * lib/fortran.exp (fortran_int4): Handle flang kind printing.
            (fortran_int8): Likewise.
            (fortran_real4): Likewise.
            (fortran_real8): Likewise.
            (fortran_complex4): Likewise.
            (fortran_logical4): Likewise.
            (fortran_character1): Likewise.

commit a847e32224d9a4297514a9a291c024c207eefdb9
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Mar 4 08:58:13 2020 +0100

    x86: support VMGEXIT

    It has been publicly documented for quite some time, albeit not in the
    "General-Purpose and System Instructions" volume:
    https://www.amd.com/system/files/TechDocs/24593.pdf.

commit 45830fd60e3c7b694dfa03f6fc1e7de431a3fcd1
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Mar 4 16:38:59 2020 +1030

    Revert "PR25570, ld duplicate "warning: changing start of section""

    This reverts commit 91114f7583fac8fdf57c58a1f632839da62e43da.
. . .

commit c3b149eb7697b376df1b3a47d0102afda389ee6d
Author: Alok Kumar Sharma <alokkumar.sharma@amd.com>
Date:   Tue Feb 4 17:17:20 2020 +0000

    gdb/fortran: Allow for using Flang in Fortran testing

    In lib/fortran.exp, in the helper function fortran_int4, there is
    currently no support for the LLVM Fortran compiler, Flang.  As a
    result we return the default pattern 'unknown' to match against all
    4-byte integer types, which causes many tests to fail.

    The same is true for all of the other helper functions related to
    finding a suitable type pattern.

    This commit adds support for Flang.  There should be no change when
    testing with gfortran.

    gdb/testsuite/ChangeLog:

            * lib/fortran.exp (fortran_int4): Handle clang.
            (fortran_int8): Likewise.
            (fortran_real4): Likewise.
            (fortran_real8): Likewise.
            (fortran_complex4): Likewise.
            (fortran_logical4): Likewise.
            (fortran_character1): Likewise.

    Change-Id: Ife0d9828f78361fbd992bf21af746042b017dafc
. . .


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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-04-22  6:48   ` Kumar N, Bhuvanendra
@ 2021-04-30  8:52     ` Kumar N, Bhuvanendra
  2021-04-30 12:14       ` Andrew Burgess
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-04-30  8:52 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew and all,

Gentle Ping!

Regards,
bhuvan

-----Original Message-----
From: Kumar N, Bhuvanendra
Sent: Thursday, April 22, 2021 12:19 PM
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew,

Thanks for your valuable comments, multiple issues are there, mostly during the test patch inlining, encoding went wrong. Hence I have attached the relevant info or files as attachments this time. Hope its fine.

> I didn't really understand what you were trying to do in this commit 
> message, nor do I see how commit 0a709cba00d relates to this change

I have attached the git show and git log command output as attachment here (commit id: 0a709cba00d36d490482d0e8673e323ac1e897a6). As explained in the commit message, basically the test case expects the kind information as integer(kind=4) or integer(kind=8). But flang by default emits kind information as integer or integer*8 respectively, hence there is mismatch in GDB command output comparison. This required test case modification and it was done earlier as mentioned in this commit message by Alok CC'ed in this email.
Hence similar "kind" related changes were done in ptype-on-functions.exp.

> This formatting here is wrong, it should be

Thanks, I have corrected Changelog now

> I'm not sure what happened with the encoding of this email (note 'file://')...

I have attached the test patch and also the test case itself for better clarity here, inlining was messed up earlier and its confusing, could you please refer the attachments, please

> I'm not suggesting it's wrong, but I've really curious what the '10' here represents.  I don't see the value 10 anywhere in the test source code, and as this is a type signature, I wouldn't really expect a value in this position.

As we can see in the below flang emitted IR(intermediate representation), flang compiler is emitting additional formal parameter of type array with 10 elements. Flang or any other compiler creates these type of additional and internal variables or parameters for its purpose. I am covering the type information of these flang emitted internal parameters in this test case change, also addressing the default "kind" information emitted by flang. These type of changes for flang was done in other test cases also, earlier.

flang emitted IR snippet: 

define signext i32 @some_module_get_number_(i64* noalias %this, i64* noalias %.O0000) #0 !dbg !26 { . . .
        call void @llvm.dbg.declare (metadata i64* %this, metadata !31, metadata !20), !dbg !27
        call void @llvm.dbg.declare (metadata i64* %.O0000, metadata !36, metadata !20), !dbg !27 . . .
!32 = !DISubrange(lowerBound: 1, upperBound: 10)
!33 = !DIBasicType(tag: DW_TAG_base_type, name: "integer*8", size: 64, align: 64, encoding: DW_ATE_signed)
!34 = !{ !32 }
!35 = !DICompositeType(tag: DW_TAG_array_type, size: 640, align: 64, baseType: !33, elements: !34)
!36 = !DILocalVariable(scope: !26, arg: 2, file: !3, line: 28, type: !35, flags: 64)

> In general, rather than forking two separate code paths, could we not 
> try to extract the differences out into variables

I have attached the modified test case also,  gfortran and flang differs with i.number of formal parameters ii.type of each of these formal parameters, hence for different compiler, followed different code path

Thanks again for your review, please let me know any other details if required

Regards,
bhuvan

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com>
Sent: Wednesday, April 21, 2021 9:43 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra via Gdb-patches <gdb-patches@sourceware.org> [2021-04-15 21:37:05 +0000]:

Thanks for working on this.

> Additional compiler generated formal parameter exist with clang and 
> type information for the same is added accordingly. Also few kind 
> parameter printing are removed which is not default for clang.
> Note: More details about this kind parameter omission while printing 
> can be found with similar patch
>   commit 0a709cba00d36d490482d0e8673e323ac1e897a6
>   Author Alok Kumar Sharma
> (alokkumar.sharma@amd.com<mailto:alokkumar.sharma@amd.com>)

I didn't really understand what you were trying to so in this commit message, nor do I see how commit 0a709cba00d relates to this change.

>
> gdb/testsuite/ChangeLog:
>       * gdb.fortran/ptype-on-functions.exp: Add type info of formal
>       parameter for clang. Also removed the kind parameter for clang.
>       * lib/fortran.exp (fortran_int8): Likewise.
> ---
> gdb/testsuite/ChangeLog                       |  5 ++
> .../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
> gdb/testsuite/lib/fortran.exp                 |  2 +-
> 3 files changed, 47 insertions(+), 15 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index
> ad289c135d..216d985995 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
> +     * gdb.fortran/ptype-on-functions.exp: Add type info of formal
> +     parameter for clang. Also removed the kind parameter for clang.
> +     * lib/fortran.exp (fortran_int8): Likewise.

This formatting here is wrong, it should be:

  2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>

        * gdb.fortran/ptype-on-functions.exp: Add type info of formal
        parameter for clang. Also removed the kind parameter for clang.
        * lib/fortran.exp (fortran_int8): Likewise.

> +
> 2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
>          * gdb.base/foll-exec.exp: Additional next commands added for 
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d4..4e46e10166 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
>      continue
> }
> -gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"

I'm not sure what happened with the encoding of this email (note 'file://')...

> +if {[test_compiler_info {clang-*}]} {
> +    set integer4 [fortran_int4]
> +    set logical4 [fortran_logical4]
> +    set integer8 [fortran_int8]
> -gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    gdb_test "ptype some_module::get_number" \
> +        "type = $integer4 \\(Type<file://(Type> number, $integer8 \\(10\\)\\<file://(10/)/>)"

I'm not suggesting it's wrong, but I've really curious what the '10'
here represents.  I don't see the value 10 anywhere in the test source code, and as this is a type signature, I wouldn't really expect a value in this position.

In general, rather than forking two separate code paths, could we not try to extract the differences out into variables, so we might have something like:

  gdb_test "ptype some_module::get_number" \
      "type = $integer4 \\($number_class_type\\)"

doing things this way helps prevent tests from diverging too much for the different compilers.

Thanks,
Andrew

> -gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
> +    gdb_test "ptype some_module::set_number" \
> +        "type = void \\(Type<file://(Type> number, $integer4\\, $integer8 \\(10\\)\\<file://(10/)/>)"
> -gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    gdb_test "ptype is_bigger" \
> +        "type = $logical4 \\($integer4<file://($integer4>, $integer4\\)"
> -gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    gdb_test "ptype say_numbers" \
> +        "type = void \\($integer4<file://($integer4>, $integer4, $integer4\\)"
> -gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
> +    gdb_test "ptype fun_ptr" \
> +        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\)<file://($integer4/)> \\)"
> -gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
> +    gdb_test "ptype say_string" \
> +        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), $integer8\\)"
> +
> +    gdb_test "ptype say_array" \
> +        "type = void \\($integer8<file://($integer8>, $integer4 \\(:,:\\)\\)"
> +} else {
> +    gdb_test "ptype some_module::get_number" \
> +        "type = integer\\(kind=4\\) \\(Type<file://(Type> __class_some_module_Number(_t)?\\)"
> +
> +    gdb_test "ptype some_module::set_number" \
> +        "type = void \\(Type<file://(Type> __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype is_bigger" \
> +        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype say_numbers" \
> +        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +
> +    gdb_test "ptype fun_ptr" \
> +        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF<file://(REF> TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +
> +    gdb_test "ptype say_string" \
> +        "type = void \\(character\\*\\(\\*\\<file://(character/*/(/*/>), integer\\(kind=\\d+\\)\\)"
> +
> +    gdb_test "ptype say_array" \
> +        "type = void \\(integer\\(kind=4\\<file://(integer/(kind=4/>) \\(:,:\\)\\)"
> +}
> diff --git a/gdb/testsuite/lib/fortran.exp 
> b/gdb/testsuite/lib/fortran.exp index 35db863e9c..f8c442fd09 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -49,7 +49,7 @@ proc fortran_int8 {} {
>      } elseif {[test_compiler_info {gcc-*}]} {
>      return "integer\\(kind=8\\)"
>      } elseif {[test_compiler_info {clang-*}]} {
> -     return "integer*8"
> +     return "integer\\*8"
>      } elseif {[test_compiler_info {icc-*}]} {
>      return "INTEGER\\(8\\)"
>      } else {
> --
> 2.17.1
>

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

* Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-04-30  8:52     ` Kumar N, Bhuvanendra
@ 2021-04-30 12:14       ` Andrew Burgess
  2021-05-03  6:36         ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Burgess @ 2021-04-30 12:14 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-04-30 08:52:51 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
> 
> Hi Andrew and all,
> 
> Gentle Ping!

Hi Kumar,

Do you have details for which version of Flang I could use to
reproduce this behaviour?  I assume I'll need to build from source, so
do you have a pointer to the appropriate repository.

Thanks,
Andrew

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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-04-30 12:14       ` Andrew Burgess
@ 2021-05-03  6:36         ` Kumar N, Bhuvanendra
  2021-05-26  7:59           ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-05-03  6:36 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew,

Steps to build, repo details of flang is shared below :

https://github.com/flang-compiler/flang

https://github.com/flang-compiler/flang/wiki/Building-Flang

please let me know if you need any further information

regards,
bhuvan

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Friday, April 30, 2021 5:44 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-04-30 08:52:51 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
>
> Hi Andrew and all,
>
> Gentle Ping!

Hi Kumar,

Do you have details for which version of Flang I could use to reproduce this behaviour?  I assume I'll need to build from source, so do you have a pointer to the appropriate repository.

Thanks,
Andrew

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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-05-03  6:36         ` Kumar N, Bhuvanendra
@ 2021-05-26  7:59           ` Kumar N, Bhuvanendra
  2021-06-02  9:43             ` Andrew Burgess
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-05-26  7:59 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

[AMD Official Use Only - Internal Distribution Only]

Hi all,

Gentle Ping 2! 

Please let me know if any other details are required, thanks

regards,
bhuvan

-----Original Message-----
From: Kumar N, Bhuvanendra 
Sent: Monday, May 3, 2021 12:06 PM
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew,

Steps to build, repo details of flang is shared below :

https://github.com/flang-compiler/flang

https://github.com/flang-compiler/flang/wiki/Building-Flang

please let me know if you need any further information

regards,
bhuvan

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Friday, April 30, 2021 5:44 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-04-30 08:52:51 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
>
> Hi Andrew and all,
>
> Gentle Ping!

Hi Kumar,

Do you have details for which version of Flang I could use to reproduce this behaviour?  I assume I'll need to build from source, so do you have a pointer to the appropriate repository.

Thanks,
Andrew

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

* Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-05-26  7:59           ` Kumar N, Bhuvanendra
@ 2021-06-02  9:43             ` Andrew Burgess
  2021-06-02 10:30               ` Kumar N, Bhuvanendra
  2021-06-10 16:52               ` Kumar N, Bhuvanendra
  0 siblings, 2 replies; 13+ messages in thread
From: Andrew Burgess @ 2021-06-02  9:43 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-05-26 07:59:08 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
> 
> Hi all,
> 
> Gentle Ping 2! 
> 
> Please let me know if any other details are required, thanks

Hi,

Thanks for your patience, sorry to have taken so long to get back to
you.

Below is a patch more inline with how I think cases like this should
be addressed.

The difference to the approach you have taken is that, instead of just
having two code paths, and in each path duplicating all of the tests,
I use compiler checks to setup variables that are then used to tweak
the expected output patterns.

The benefit I see is that if common parts of the output change, we
only need to update one pattern, and if any extra tests are added then
there will be less chance of the new test only being added along one
path by mistake.

The only reason I didn't just commit this is that I think I'm not
getting the same output as you are, you'll notice that some of the
tests in this commit have setup_kfail, these are all the tests where
I'm seeing different output to you.

Would you be willing to take this commit and see if you can finish
this off so that it meets your needs?

Thanks,
Andrew




---

diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d42..772edc7e8a9 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,54 @@ if ![fortran_runto_main] then {
     continue
 }
 
+set integer4 [fortran_int4]
+set logical4 [fortran_logical4]
+set integer8 [fortran_int8]
+
+if {[test_compiler_info {clang-*}]} {
+    set some_module_class_type "Type number"
+    set some_module_aux_info ", $integer8 \\(10\\)"
+} else {
+    set some_module_class_type "Type __class_some_module_Number(_t)?"
+    set some_module_aux_info ""
+}
+
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "gets a pointer for some reason"
+}
 gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
 
 gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
 
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "gets a pointer for some reason"
+}
 gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = $logical4 \\($integer4, $integer4\\)"
 
 gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = void \\($integer4, $integer4, $integer4\\)"
 
+set fun_ptr_arg "$integer4"
+if {[test_compiler_info {gcc-*}]} {
+    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
+}
+
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "missing symbol"
+}
 gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
 
 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
+
+set say_array_artificial_first_arg ""
+if {[test_compiler_info {clang-*}]} {
+    set say_array_artificial_first_arg "$integer8, "
+}
 
 gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"

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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-06-02  9:43             ` Andrew Burgess
@ 2021-06-02 10:30               ` Kumar N, Bhuvanendra
  2021-06-10 16:52               ` Kumar N, Bhuvanendra
  1 sibling, 0 replies; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-06-02 10:30 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew,

> Would you be willing to take this commit and see if you can finish this off so that it meets your needs?

Sure, will complete this patch and send fresh patch for review. Thanks for your comments

regards,
bhuvan

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Wednesday, June 2, 2021 3:13 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-05-26 07:59:08 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Gentle Ping 2!
>
> Please let me know if any other details are required, thanks

Hi,

Thanks for your patience, sorry to have taken so long to get back to you.

Below is a patch more inline with how I think cases like this should be addressed.

The difference to the approach you have taken is that, instead of just having two code paths, and in each path duplicating all of the tests, I use compiler checks to setup variables that are then used to tweak the expected output patterns.

The benefit I see is that if common parts of the output change, we only need to update one pattern, and if any extra tests are added then there will be less chance of the new test only being added along one path by mistake.

The only reason I didn't just commit this is that I think I'm not getting the same output as you are, you'll notice that some of the tests in this commit have setup_kfail, these are all the tests where I'm seeing different output to you.

Would you be willing to take this commit and see if you can finish this off so that it meets your needs?

Thanks,
Andrew




---

diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d42..772edc7e8a9 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,54 @@ if ![fortran_runto_main] then {
     continue
 }

+set integer4 [fortran_int4]
+set logical4 [fortran_logical4]
+set integer8 [fortran_int8]
+
+if {[test_compiler_info {clang-*}]} {
+    set some_module_class_type "Type number"
+    set some_module_aux_info ", $integer8 \\(10\\)"
+} else {
+    set some_module_class_type "Type __class_some_module_Number(_t)?"
+    set some_module_aux_info ""
+}
+
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "gets a pointer for some reason"
+}
 gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"

 gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"

+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "gets a pointer for some reason"
+}
 gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = $logical4 \\($integer4, $integer4\\)"

 gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = void \\($integer4, $integer4, $integer4\\)"

+set fun_ptr_arg "$integer4"
+if {[test_compiler_info {gcc-*}]} {
+    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
+}
+
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "missing symbol"
+}
 gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"

 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
+
+set say_array_artificial_first_arg ""
+if {[test_compiler_info {clang-*}]} {
+    set say_array_artificial_first_arg "$integer8, "
+}

 gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"

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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-06-02  9:43             ` Andrew Burgess
  2021-06-02 10:30               ` Kumar N, Bhuvanendra
@ 2021-06-10 16:52               ` Kumar N, Bhuvanendra
  2021-06-21 14:24                 ` Andrew Burgess
  1 sibling, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-06-10 16:52 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

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

[AMD Official Use Only - Internal Distribution Only]

Hi Andrew,

> Would you be willing to take this commit and see if you can finish this off so that it meets your needs?

Your earlier GDB test patch works fine with clang/flang compiler, hence removed 3 instances of setup_kfail from your patch and tested with flang and it worked fine. Hence I am attaching the modified final patch for review, could you please review/approve? Thanks in advance.

I have attached the revised patch with this email and also inlined it here.

Patch inlined:

From 0075cc40ad1f69ff983fdf848a1b497fe3aaf778 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Thu, 10 Jun 2021 21:48:11 +0530
Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
 clang.

Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
      commit 0a709cba00d36d490482d0e8673e323ac1e897a6
      Author Alok Kumar Sharma (alokkumar.sharma@amd.com)

gdb/testsuite/ChangeLog:
	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
	parameter for clang. Also removed the kind parameter for clang.
---
 gdb/testsuite/ChangeLog                       |  5 +++
 .../gdb.fortran/ptype-on-functions.exp        | 36 +++++++++++++++----
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 65517eacd99..87cf3e2a061 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
+
+	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
+	parameter for clang. Also removed the kind parameter for clang.
+
 2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
 
 	* gdb.base/foll-exec.c: convert the multi-line function call into
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d42..75197952b6f 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,45 @@ if ![fortran_runto_main] then {
     continue
 }
 
+set integer4 [fortran_int4]
+set logical4 [fortran_logical4]
+set integer8 [fortran_int8]
+
+if {[test_compiler_info {clang-*}]} {
+    set some_module_class_type "Type number"
+    set some_module_aux_info ", $integer8 \\(10\\)"
+} else {
+    set some_module_class_type "Type __class_some_module_Number(_t)?"
+    set some_module_aux_info ""
+}
+
 gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
 
 gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
 
 gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = $logical4 \\($integer4, $integer4\\)"
 
 gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = void \\($integer4, $integer4, $integer4\\)"
+
+set fun_ptr_arg "$integer4"
+if {[test_compiler_info {gcc-*}]} {
+    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
+}
 
 gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
 
 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
+
+set say_array_artificial_first_arg ""
+if {[test_compiler_info {clang-*}]} {
+    set say_array_artificial_first_arg "$integer8, "
+}
 
 gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"
-- 
2.17.1


-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Wednesday, June 2, 2021 3:13 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-05-26 07:59:08 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Gentle Ping 2!
>
> Please let me know if any other details are required, thanks

Hi,

Thanks for your patience, sorry to have taken so long to get back to you.

Below is a patch more inline with how I think cases like this should be addressed.

The difference to the approach you have taken is that, instead of just having two code paths, and in each path duplicating all of the tests, I use compiler checks to setup variables that are then used to tweak the expected output patterns.

The benefit I see is that if common parts of the output change, we only need to update one pattern, and if any extra tests are added then there will be less chance of the new test only being added along one path by mistake.

The only reason I didn't just commit this is that I think I'm not getting the same output as you are, you'll notice that some of the tests in this commit have setup_kfail, these are all the tests where I'm seeing different output to you.

Would you be willing to take this commit and see if you can finish this off so that it meets your needs?

Thanks,
Andrew




---

diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d42..772edc7e8a9 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,54 @@ if ![fortran_runto_main] then {
     continue
 }

+set integer4 [fortran_int4]
+set logical4 [fortran_logical4]
+set integer8 [fortran_int8]
+
+if {[test_compiler_info {clang-*}]} {
+    set some_module_class_type "Type number"
+    set some_module_aux_info ", $integer8 \\(10\\)"
+} else {
+    set some_module_class_type "Type __class_some_module_Number(_t)?"
+    set some_module_aux_info ""
+}
+
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "gets a pointer for some reason"
+}
 gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"

 gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"

+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "gets a pointer for some reason"
+}
 gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = $logical4 \\($integer4, $integer4\\)"

 gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = void \\($integer4, $integer4, $integer4\\)"

+set fun_ptr_arg "$integer4"
+if {[test_compiler_info {gcc-*}]} {
+    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
+}
+
+if {[test_compiler_info {clang-*}]} {
+    setup_kfail *-*-* "missing symbol"
+}
 gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"

 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
+
+set say_array_artificial_first_arg ""
+if {[test_compiler_info {clang-*}]} {
+    set say_array_artificial_first_arg "$integer8, "
+}

 gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"

[-- Attachment #2: PATCH-gdb.fortran-Add-type-info-of-formal-parameter-.patch --]
[-- Type: application/octet-stream, Size: 3755 bytes --]

From 0075cc40ad1f69ff983fdf848a1b497fe3aaf778 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Thu, 10 Jun 2021 21:48:11 +0530
Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
 clang.

Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
      commit 0a709cba00d36d490482d0e8673e323ac1e897a6
      Author Alok Kumar Sharma (alokkumar.sharma@amd.com)

gdb/testsuite/ChangeLog:
	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
	parameter for clang. Also removed the kind parameter for clang.
---
 gdb/testsuite/ChangeLog                       |  5 +++
 .../gdb.fortran/ptype-on-functions.exp        | 36 +++++++++++++++----
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 65517eacd99..87cf3e2a061 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
+
+	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
+	parameter for clang. Also removed the kind parameter for clang.
+
 2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
 
 	* gdb.base/foll-exec.c: convert the multi-line function call into
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d42..75197952b6f 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,45 @@ if ![fortran_runto_main] then {
     continue
 }
 
+set integer4 [fortran_int4]
+set logical4 [fortran_logical4]
+set integer8 [fortran_int8]
+
+if {[test_compiler_info {clang-*}]} {
+    set some_module_class_type "Type number"
+    set some_module_aux_info ", $integer8 \\(10\\)"
+} else {
+    set some_module_class_type "Type __class_some_module_Number(_t)?"
+    set some_module_aux_info ""
+}
+
 gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
 
 gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
 
 gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = $logical4 \\($integer4, $integer4\\)"
 
 gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    "type = void \\($integer4, $integer4, $integer4\\)"
+
+set fun_ptr_arg "$integer4"
+if {[test_compiler_info {gcc-*}]} {
+    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
+}
 
 gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
 
 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
+
+set say_array_artificial_first_arg ""
+if {[test_compiler_info {clang-*}]} {
+    set say_array_artificial_first_arg "$integer8, "
+}
 
 gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"
-- 
2.17.1


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

* Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-06-10 16:52               ` Kumar N, Bhuvanendra
@ 2021-06-21 14:24                 ` Andrew Burgess
  2021-06-21 14:26                   ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Burgess @ 2021-06-21 14:24 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-06-10 16:52:01 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
> 
> Hi Andrew,
> 
> > Would you be willing to take this commit and see if you can finish this off so that it meets your needs?
> 
> Your earlier GDB test patch works fine with clang/flang compiler, hence removed 3 instances of setup_kfail from your patch and tested with flang and it worked fine. Hence I am attaching the modified final patch for review, could you please review/approve? Thanks in advance.
> 
> I have attached the revised patch with this email and also inlined it here.
> 
> Patch inlined:
> 
> From 0075cc40ad1f69ff983fdf848a1b497fe3aaf778 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
> Date: Thu, 10 Jun 2021 21:48:11 +0530
> Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
>  clang.
> 
> Additional compiler generated formal parameter exist with clang and type
> information for the same is added accordingly. Also few kind parameter
> printing are removed which is not default for clang.
> Note: More details about this kind parameter omission while printing can
> be found with similar patch
>       commit 0a709cba00d36d490482d0e8673e323ac1e897a6
>       Author Alok Kumar Sharma (alokkumar.sharma@amd.com)
> 
> gdb/testsuite/ChangeLog:
> 	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
> 	parameter for clang. Also removed the kind parameter for clang.

This looks great.  Thanks for all your work on this.  Feel free to
commit.

Thanks,
Andrew


> ---
>  gdb/testsuite/ChangeLog                       |  5 +++
>  .../gdb.fortran/ptype-on-functions.exp        | 36 +++++++++++++++----
>  2 files changed, 34 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 65517eacd99..87cf3e2a061 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
> +
> +	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
> +	parameter for clang. Also removed the kind parameter for clang.
> +
>  2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
>  
>  	* gdb.base/foll-exec.c: convert the multi-line function call into
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d42..75197952b6f 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,45 @@ if ![fortran_runto_main] then {
>      continue
>  }
>  
> +set integer4 [fortran_int4]
> +set logical4 [fortran_logical4]
> +set integer8 [fortran_int8]
> +
> +if {[test_compiler_info {clang-*}]} {
> +    set some_module_class_type "Type number"
> +    set some_module_aux_info ", $integer8 \\(10\\)"
> +} else {
> +    set some_module_class_type "Type __class_some_module_Number(_t)?"
> +    set some_module_aux_info ""
> +}
> +
>  gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
> +    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
>  
>  gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
>  
>  gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = $logical4 \\($integer4, $integer4\\)"
>  
>  gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = void \\($integer4, $integer4, $integer4\\)"
> +
> +set fun_ptr_arg "$integer4"
> +if {[test_compiler_info {gcc-*}]} {
> +    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
> +}
>  
>  gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
>  
>  gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
> +    "type = void \\(character\[^,\]+, $integer8\\)"
> +
> +set say_array_artificial_first_arg ""
> +if {[test_compiler_info {clang-*}]} {
> +    set say_array_artificial_first_arg "$integer8, "
> +}
>  
>  gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
> +    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"
> -- 
> 2.17.1
> 
> 
> -----Original Message-----
> From: Andrew Burgess <andrew.burgess@embecosm.com> 
> Sent: Wednesday, June 2, 2021 3:13 PM
> To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
> Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
> Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
> 
> [CAUTION: External Email]
> 
> * Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-05-26 07:59:08 +0000]:
> 
> > [AMD Official Use Only - Internal Distribution Only]
> >
> > Hi all,
> >
> > Gentle Ping 2!
> >
> > Please let me know if any other details are required, thanks
> 
> Hi,
> 
> Thanks for your patience, sorry to have taken so long to get back to you.
> 
> Below is a patch more inline with how I think cases like this should be addressed.
> 
> The difference to the approach you have taken is that, instead of just having two code paths, and in each path duplicating all of the tests, I use compiler checks to setup variables that are then used to tweak the expected output patterns.
> 
> The benefit I see is that if common parts of the output change, we only need to update one pattern, and if any extra tests are added then there will be less chance of the new test only being added along one path by mistake.
> 
> The only reason I didn't just commit this is that I think I'm not getting the same output as you are, you'll notice that some of the tests in this commit have setup_kfail, these are all the tests where I'm seeing different output to you.
> 
> Would you be willing to take this commit and see if you can finish this off so that it meets your needs?
> 
> Thanks,
> Andrew
> 
> 
> 
> 
> ---
> 
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d42..772edc7e8a9 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,54 @@ if ![fortran_runto_main] then {
>      continue
>  }
> 
> +set integer4 [fortran_int4]
> +set logical4 [fortran_logical4]
> +set integer8 [fortran_int8]
> +
> +if {[test_compiler_info {clang-*}]} {
> +    set some_module_class_type "Type number"
> +    set some_module_aux_info ", $integer8 \\(10\\)"
> +} else {
> +    set some_module_class_type "Type __class_some_module_Number(_t)?"
> +    set some_module_aux_info ""
> +}
> +
> +if {[test_compiler_info {clang-*}]} {
> +    setup_kfail *-*-* "gets a pointer for some reason"
> +}
>  gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
> +    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
> 
>  gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
> 
> +if {[test_compiler_info {clang-*}]} {
> +    setup_kfail *-*-* "gets a pointer for some reason"
> +}
>  gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = $logical4 \\($integer4, $integer4\\)"
> 
>  gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = void \\($integer4, $integer4, $integer4\\)"
> 
> +set fun_ptr_arg "$integer4"
> +if {[test_compiler_info {gcc-*}]} {
> +    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
> +}
> +
> +if {[test_compiler_info {clang-*}]} {
> +    setup_kfail *-*-* "missing symbol"
> +}
>  gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
> 
>  gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
> +    "type = void \\(character\[^,\]+, $integer8\\)"
> +
> +set say_array_artificial_first_arg ""
> +if {[test_compiler_info {clang-*}]} {
> +    set say_array_artificial_first_arg "$integer8, "
> +}
> 
>  gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
> +    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"



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

* RE: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp
  2021-06-21 14:24                 ` Andrew Burgess
@ 2021-06-21 14:26                   ` Kumar N, Bhuvanendra
  2021-07-05 14:29                     ` [committed][gdb/testsuite] Fix fail in gdb.fortran/ptype-on-functions.exp with gcc-7 Tom de Vries
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-06-21 14:26 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: gdb-patches, George, Jini Susan, Achra, Nitika, Sharma,
	Alok Kumar, E, Nagajyothi, Tomar, Sourabh Singh

[AMD Official Use Only]

Thanks Andrew. Actually its your patch only, I just modified little. Will proceed.

regards,
bhuvan

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Monday, June 21, 2021 7:54 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>
Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp

[CAUTION: External Email]

* Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-06-10 16:52:01 +0000]:

> [AMD Official Use Only - Internal Distribution Only]
>
> Hi Andrew,
>
> > Would you be willing to take this commit and see if you can finish this off so that it meets your needs?
>
> Your earlier GDB test patch works fine with clang/flang compiler, hence removed 3 instances of setup_kfail from your patch and tested with flang and it worked fine. Hence I am attaching the modified final patch for review, could you please review/approve? Thanks in advance.
>
> I have attached the revised patch with this email and also inlined it here.
>
> Patch inlined:
>
> From 0075cc40ad1f69ff983fdf848a1b497fe3aaf778 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= 
> <Bhuvanendra.KumarN@amd.com>
> Date: Thu, 10 Jun 2021 21:48:11 +0530
> Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for  
> clang.
>
> Additional compiler generated formal parameter exist with clang and 
> type information for the same is added accordingly. Also few kind 
> parameter printing are removed which is not default for clang.
> Note: More details about this kind parameter omission while printing 
> can be found with similar patch
>       commit 0a709cba00d36d490482d0e8673e323ac1e897a6
>       Author Alok Kumar Sharma (alokkumar.sharma@amd.com)
>
> gdb/testsuite/ChangeLog:
>       * gdb.fortran/ptype-on-functions.exp: Add type info of formal
>       parameter for clang. Also removed the kind parameter for clang.

This looks great.  Thanks for all your work on this.  Feel free to commit.

Thanks,
Andrew


> ---
>  gdb/testsuite/ChangeLog                       |  5 +++
>  .../gdb.fortran/ptype-on-functions.exp        | 36 +++++++++++++++----
>  2 files changed, 34 insertions(+), 7 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 
> 65517eacd99..87cf3e2a061 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
> +
> +     * gdb.fortran/ptype-on-functions.exp: Add type info of formal
> +     parameter for clang. Also removed the kind parameter for clang.
> +
>  2021-06-10  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
>
>       * gdb.base/foll-exec.c: convert the multi-line function call 
> into diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp 
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d42..75197952b6f 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,45 @@ if ![fortran_runto_main] then {
>      continue
>  }
>
> +set integer4 [fortran_int4]
> +set logical4 [fortran_logical4]
> +set integer8 [fortran_int8]
> +
> +if {[test_compiler_info {clang-*}]} {
> +    set some_module_class_type "Type number"
> +    set some_module_aux_info ", $integer8 \\(10\\)"
> +} else {
> +    set some_module_class_type "Type __class_some_module_Number(_t)?"
> +    set some_module_aux_info ""
> +}
> +
>  gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
> +    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
>
>  gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
>
>  gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = $logical4 \\($integer4, $integer4\\)"
>
>  gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = void \\($integer4, $integer4, $integer4\\)"
> +
> +set fun_ptr_arg "$integer4"
> +if {[test_compiler_info {gcc-*}]} {
> +    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
> +}
>
>  gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
>
>  gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
> +    "type = void \\(character\[^,\]+, $integer8\\)"
> +
> +set say_array_artificial_first_arg ""
> +if {[test_compiler_info {clang-*}]} {
> +    set say_array_artificial_first_arg "$integer8, "
> +}
>
>  gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
> +    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"
> --
> 2.17.1
>
>
> -----Original Message-----
> From: Andrew Burgess <andrew.burgess@embecosm.com>
> Sent: Wednesday, June 2, 2021 3:13 PM
> To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
> Cc: gdb-patches@sourceware.org; George, Jini Susan 
> <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; 
> Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; E, Nagajyothi 
> <Nagajyothi.E@amd.com>; Tomar, Sourabh Singh 
> <SourabhSingh.Tomar@amd.com>
> Subject: Re: [PATCH] [gdb.fortran] Add type info of formal parameter 
> for clang in ptype-on-functions.exp
>
> [CAUTION: External Email]
>
> * Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com> [2021-05-26 07:59:08 +0000]:
>
> > [AMD Official Use Only - Internal Distribution Only]
> >
> > Hi all,
> >
> > Gentle Ping 2!
> >
> > Please let me know if any other details are required, thanks
>
> Hi,
>
> Thanks for your patience, sorry to have taken so long to get back to you.
>
> Below is a patch more inline with how I think cases like this should be addressed.
>
> The difference to the approach you have taken is that, instead of just having two code paths, and in each path duplicating all of the tests, I use compiler checks to setup variables that are then used to tweak the expected output patterns.
>
> The benefit I see is that if common parts of the output change, we only need to update one pattern, and if any extra tests are added then there will be less chance of the new test only being added along one path by mistake.
>
> The only reason I didn't just commit this is that I think I'm not getting the same output as you are, you'll notice that some of the tests in this commit have setup_kfail, these are all the tests where I'm seeing different output to you.
>
> Would you be willing to take this commit and see if you can finish this off so that it meets your needs?
>
> Thanks,
> Andrew
>
>
>
>
> ---
>
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp 
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index 14f522d6d42..772edc7e8a9 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -29,23 +29,54 @@ if ![fortran_runto_main] then {
>      continue
>  }
>
> +set integer4 [fortran_int4]
> +set logical4 [fortran_logical4]
> +set integer8 [fortran_int8]
> +
> +if {[test_compiler_info {clang-*}]} {
> +    set some_module_class_type "Type number"
> +    set some_module_aux_info ", $integer8 \\(10\\)"
> +} else {
> +    set some_module_class_type "Type __class_some_module_Number(_t)?"
> +    set some_module_aux_info ""
> +}
> +
> +if {[test_compiler_info {clang-*}]} {
> +    setup_kfail *-*-* "gets a pointer for some reason"
> +}
>  gdb_test "ptype some_module::get_number" \
> -    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
> +    "type = $integer4 \\(${some_module_class_type}${some_module_aux_info}\\)"
>
>  gdb_test "ptype some_module::set_number" \
> -    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
> +    "type = void \\(${some_module_class_type}, $integer4${some_module_aux_info}\\)"
>
> +if {[test_compiler_info {clang-*}]} {
> +    setup_kfail *-*-* "gets a pointer for some reason"
> +}
>  gdb_test "ptype is_bigger" \
> -    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = $logical4 \\($integer4, $integer4\\)"
>
>  gdb_test "ptype say_numbers" \
> -    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
> +    "type = void \\($integer4, $integer4, $integer4\\)"
>
> +set fun_ptr_arg "$integer4"
> +if {[test_compiler_info {gcc-*}]} {
> +    set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
> +}
> +
> +if {[test_compiler_info {clang-*}]} {
> +    setup_kfail *-*-* "missing symbol"
> +}
>  gdb_test "ptype fun_ptr" \
> -    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
> +    "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
>
>  gdb_test "ptype say_string" \
> -    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
> +    "type = void \\(character\[^,\]+, $integer8\\)"
> +
> +set say_array_artificial_first_arg ""
> +if {[test_compiler_info {clang-*}]} {
> +    set say_array_artificial_first_arg "$integer8, "
> +}
>
>  gdb_test "ptype say_array" \
> -    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
> +    "type = void \\(${say_array_artificial_first_arg}$integer4 \\(:,:\\)\\)"


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

* [committed][gdb/testsuite] Fix fail in gdb.fortran/ptype-on-functions.exp with gcc-7
  2021-06-21 14:26                   ` Kumar N, Bhuvanendra
@ 2021-07-05 14:29                     ` Tom de Vries
  0 siblings, 0 replies; 13+ messages in thread
From: Tom de Vries @ 2021-07-05 14:29 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra, Andrew Burgess
  Cc: Achra, Nitika, E, Nagajyothi, George, Jini Susan, Sharma,
	Alok Kumar, gdb-patches, Tomar, Sourabh Singh

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

[was: Re: [PATCH] [gdb.fortran] Add type info of formal parameter for
clang in ptype-on-functions.exp]

Hi,

committed follow-up patch fixing regression with gcc-7.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Fix-fail-in-gdb.fortran-ptype-on-functions.exp-with-gcc-7.patch --]
[-- Type: text/x-patch, Size: 2242 bytes --]

[gdb/testsuite] Fix fail in gdb.fortran/ptype-on-functions.exp with gcc-7

Since commit 05b85772061 "gdb/fortran: Add type info of formal parameter for
clang" I see:
...
(gdb) ptype say_string^M
type = void (character*(*), integer(kind=4))^M
(gdb) FAIL: gdb.fortran/ptype-on-functions.exp: ptype say_string
...

The part of the commit causing the fail is:
...
 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
...
which fails to take into account that for gcc-7 and before, the type for
string length of a string argument is int, not size_t.

Fix this by allowing both $integer8 and $integer4.

Tested on x86_64-linux, with gcc-7 and gcc-10.

gdb/testsuite/ChangeLog:

2021-07-05  Tom de Vries  <tdevries@suse.de>

	* gdb.fortran/ptype-on-functions.exp: Allow both $integer8 and
	$integer4 for size of string length.

---
 gdb/testsuite/gdb.fortran/ptype-on-functions.exp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 75197952b6f..7d119679e65 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -33,6 +33,13 @@ set integer4 [fortran_int4]
 set logical4 [fortran_logical4]
 set integer8 [fortran_int8]
 
+# A fortran string parameter is passed as a char *, and an additional
+# argument str_ for the string length.  The type used for the string length
+# argument is size_t, but for gcc 7 and earlier, the actual type is int
+# instead ( see
+# https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html ).
+set stringlen ($integer8|$integer4)
+
 if {[test_compiler_info {clang-*}]} {
     set some_module_class_type "Type number"
     set some_module_aux_info ", $integer8 \\(10\\)"
@@ -62,7 +69,7 @@ gdb_test "ptype fun_ptr" \
     "type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
 
 gdb_test "ptype say_string" \
-    "type = void \\(character\[^,\]+, $integer8\\)"
+    "type = void \\(character\[^,\]+, $stringlen\\)"
 
 set say_array_artificial_first_arg ""
 if {[test_compiler_info {clang-*}]} {

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

end of thread, other threads:[~2021-07-05 14:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 21:37 [PATCH] [gdb.fortran] Add type info of formal parameter for clang in ptype-on-functions.exp Kumar N, Bhuvanendra
2021-04-21 16:13 ` Andrew Burgess
2021-04-22  6:48   ` Kumar N, Bhuvanendra
2021-04-30  8:52     ` Kumar N, Bhuvanendra
2021-04-30 12:14       ` Andrew Burgess
2021-05-03  6:36         ` Kumar N, Bhuvanendra
2021-05-26  7:59           ` Kumar N, Bhuvanendra
2021-06-02  9:43             ` Andrew Burgess
2021-06-02 10:30               ` Kumar N, Bhuvanendra
2021-06-10 16:52               ` Kumar N, Bhuvanendra
2021-06-21 14:24                 ` Andrew Burgess
2021-06-21 14:26                   ` Kumar N, Bhuvanendra
2021-07-05 14:29                     ` [committed][gdb/testsuite] Fix fail in gdb.fortran/ptype-on-functions.exp with gcc-7 Tom de Vries

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