[gdb.fortran] Skip additional continue command for clang

Message ID MW2PR12MB4684CAA946EBEFFC653BD23F87B29@MW2PR12MB4684.namprd12.prod.outlook.com
State New
Headers show
Series
  • [gdb.fortran] Skip additional continue command for clang
Related show

Commit Message

Mike Frysinger via Gdb-patches Oct. 8, 2021, 6:55 p.m.
[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(-)

Comments

Mike Frysinger via Gdb-patches Oct. 12, 2021, 10:39 a.m. | #1
[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
Mike Frysinger via Gdb-patches Nov. 19, 2021, 2:27 p.m. | #2
"Kumar N, Bhuvanendra" <Bhuvanendra.KumarN@amd.com> writes:

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


I wasn't sure if you wanted this patch reviewing or not.  I've given
some feedback below anyway, ignore if this patch is no longer active.

>

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


Instead of optionally doing the continue, could we not just change the
test to this:

  print *, ""
  print *, "" ! First Breakpoint.

Then there should _always_ be something to continue over so we should be
fine on all compilers.

What do you think?

Thanks,
Andrew



> 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

>

>

>

> From c9d235825985930269186fbef1f9175007314141 Mon Sep 17 00:00:00 2001

> From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <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

Patch

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