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

Kumar N, Bhuvanendra Bhuvanendra.KumarN@amd.com
Thu Apr 15 21:37:05 GMT 2021


[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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb.fortran-Add-type-info-of-formal-parameter.patch
Type: application/octet-stream
Size: 5015 bytes
Desc: gdb.fortran-Add-type-info-of-formal-parameter.patch
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20210415/bedecbfe/attachment.obj>


More information about the Gdb-patches mailing list