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

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