[PATCH] [gdb.fortran] Skip additional continue command for clang

Kumar N, Bhuvanendra Bhuvanendra.KumarN@amd.com
Tue Oct 12 10:39:04 GMT 2021


[AMD Official Use Only]

Hi all,

Could you please ignore my earlier email (which can be found below in this email chain) and details sent along with that email, I have rephrased it here again. Sorry for the inconvenience caused.
Fix remains same, but the problem/fix details furnished are rephrased. Complete details are furnished here, please consider these details for the review or approval, thanks in advance.

Problem Description:

23        integer, allocatable :: other (:, :)

If there is an "allocatable" keyword in the declaration like this, then GCC emits an .debug_line entry for it.

(gdb) disas /s test (with gfortran emitted executable) :

23        integer, allocatable :: other (:, :)
0x00005555555549a5 <+11>:    movq   $0x0,-0x1e0(%rbp)
. . .

.debug_line contents:

Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
. . .
0x00000000000009a5     23      0      1   0             0  is_stmt

Whereas clang does not emit .debug_line information for such declarations. Hence the test case is modified to skip the additional "continue" command for clang compiler alone.
This simple test case change now caters the compiler(GCC and clang) dependent implementation for allocatable array declaration. More details are mentioned in the commit message.

(gdb) disas /s test (with flang emitted executable) :
. . .
23        integer, allocatable :: other (:, :)
24        integer, dimension(:,:), pointer :: pointer2d => null()
. . .

PATCH inlined:

>From c9d235825985930269186fbef1f9175007314141 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, 8 Oct 2021 23:23:22 +0530
Subject: [PATCH] [gdb.fortran] Skip additional continue command for clang.

If there is an "allocatable" keyword in the declaration like in
gdb.fortran/array-slices-bad.f90:23, then gcc emits an .debug_line
entry for this. Hence in gdb.fortran/array-slices-bad.exp, it
require additional "continue" command to reach "First Breakpoint"
from MAIN__. Whereas clang does not emit .debug_line information for
such declarations, hence MAIN_ and "First Breakpoint" points to same
location and it does not require additional "continue" command to
reach "First Breakpoint".
This test case change is done for clang compiler alone.
---
gdb/testsuite/gdb.fortran/array-slices-bad.exp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
index a68903498d6..b592eb51d92 100644
--- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
@@ -34,7 +34,9 @@ gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
-gdb_continue_to_breakpoint "First Breakpoint"
+if ![test_compiler_info "clang-*"] {
+    gdb_continue_to_breakpoint "First Breakpoint"
+}
 # Access not yet allocated array.
gdb_test "print other" " = <not allocated>"
--
2.17.1





From: Kumar N, Bhuvanendra
Sent: Saturday, October 9, 2021 12:26 AM
To: gdb-patches@sourceware.org; Andrew Burgess <andrew.burgess@embecosm.com>
Cc: George, Jini Susan <JiniSusan.George@amd.com>; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; E, Nagajyothi <Nagajyothi.E@amd.com>; Potharla, Rupesh <Rupesh.Potharla@amd.com>
Subject: [PATCH] [gdb.fortran] Skip additional continue command for clang


[AMD Official Use Only]

Hi all,

I request all of you to please review this simple patch.

Problem Description:

Generally gcc/clang does not emit .debug_line entries for declarations. But gcc is emitting it if the array declaration has an "allocatable" keyword, i.e. allocatable array's. Even if it contains "allocatable" keyword, its still an declaration as per the standard and actual memory allocation for it happens during allocate() call. Hence not sure this gcc behavior is proper or not. But clang and icc behavior is proper here by not emitting any .debug_line entries for it. Hence I have modified the test case only for clang compiler for the time being. This is a simple test case change.

Multiple test point failures are mainly because of one single "continue" command which is not required in case of clang compiler. Hence the test case is modified to skip the additional "continue" command for clang compiler. More details are mentioned in the commit message.

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

regards,
bhuvan

PATCH inlined :

>From e8b12cbb7d8703fa5bfb34f9a484139b5ba323c4 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, 8 Oct 2021 23:23:22 +0530
Subject: [PATCH] [gdb.fortran] Skip additional continue command for clang.

If there is an "allocatable" keyword in the declaration like in
gdb.fortran/array-slices-bad.f90:23, then gcc emits an .debug_line
entry for this, even though its an declaration. Hence in
gdb.fortran/array-slices-bad.exp, it require additional "continue"
command to reach "First Breakpoint" from MAIN__. Whereas clang does
not emit .debug_line information for declarations, hence MAIN_ and
"First Breakpoint" points to same location and it does not require
additional "continue" command to reach "First Breakpoint".
This test case change is done for clang compiler alone.
---
gdb/testsuite/gdb.fortran/array-slices-bad.exp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
index a68903498d6..b592eb51d92 100644
--- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
@@ -34,7 +34,9 @@ gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]

-gdb_continue_to_breakpoint "First Breakpoint"
+if ![test_compiler_info "clang-*"] {
+    gdb_continue_to_breakpoint "First Breakpoint"
+}

 # Access not yet allocated array.
gdb_test "print other" " = <not allocated>"
--
2.17.1



-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gdb.fortran-Skip-additional-continue-command-for-cla.patch
Type: application/octet-stream
Size: 1590 bytes
Desc: 0001-gdb.fortran-Skip-additional-continue-command-for-cla.patch
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20211012/14043589/attachment.obj>


More information about the Gdb-patches mailing list