[PATCH] [gdb.fortran] Update Breakpoint location in array-element.exp

Andrew Burgess andrew.burgess@embecosm.com
Thu Apr 15 15:23:23 GMT 2021


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

> [AMD Official Use Only - Internal Distribution Only]
> 
> Hello All,
> 
> I request you all to please review this patch. Below are the details.
> 
> Problem Description:
> In array-element.exp testcase, break point is set at "continue" statement which is at label 100 and later with "print a(1)" command and 1 is printed. Then again "print a(2)" is tried and with gfortran generated executable 2 is printed, whereas with flang generated executable 0 is printed inside the GDB session. label 100 of DO loop gets executed for each iteration with flang, whereas it does not executed with gfortran, there is a bug filed against gfortran in Bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99816. As reported in the bug, with gfortran, label 100 of DO loop is reached only after the completion of the entire DO loop. Hence at label 100, all the array elements are set and printing of array element a(2) succeeds. Whereas with flang, when we are at label 100 for first time, array element a(2) is not yet set, only a(1) is set and "print a(2)" results in 0. Due to this mismatch in GDB output, test case fails for flang compiler.
> 
> Resolution:
> http://www-pnp.physics.ox.ac.uk/~gronbech/intfor/node18.html
> As shown in the above link, flang behavior is correct and the DO loop should be executed till and including the label 100 for each iteration. In order to print array element a(2), test case require change and instead of putting break point at "continue" statement, breakpoint location needs to be modified to "return" statement, which is outside the DO loop. This way "print a(2)" will succeed with all fortran compilers. This testcase change is done as applicable to all fortran compilers.
> 
> gdb/testsuite/ChangeLog:
>         * gdb.fortran/array-element.exp: Breakpoint location is modified.
> 
> Thanks and Regards,
> Bhuvan
> 
> Patch content inlined:
> 
> From c2116c02db3c7c36738a12da2135d63b3bc7c631 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: Thu, 15 Apr 2021 17:20:13 +0530
> Subject: [PATCH] [gdb.fortran] Breakpoint location is modified.
> 
> Breakpoint location is modified to "return" statement which is
> outside the DO loop. Because the label 100 of DO loop should get
> executed for each iteration as shared in this external link:
> http://www-pnp.physics.ox.ac.uk/~gronbech/intfor/node18.html.
> flang compiler is following this fortran standard, whereas gfortran
> compiler is not following, hence the test case is passing with
> gfortran and failing with flang. but to correct this gfortran
> behavior, bug has been filed in bugzilla
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99816). As reported in
> the bug, with gfortran, label 100 of DO loop is reached only after
> the completion of the entire DO loop. Hence at label 100, all the
> array elements are set and printing of array element a(2) succeeds.
> whereas with flang, when we are at label 100 for first time, array
> element a(2) is not yet set, only a(1) is set, hence moving the
> breakpoint location to outside the DO loop, so that once we are
> outside the DO loop, we can print any of the array elements. This
> change in test case is done irrespective of any fortran compiler.
> 
> gdb/testsuite/ChangeLog:
>         * gdb.fortran/array-element.exp: Breakpoint location is modified.

This looks good.  Please go ahead and merge.

Thanks,
Andrew


> ---
> gdb/testsuite/gdb.fortran/array-element.exp | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.fortran/array-element.exp b/gdb/testsuite/gdb.fortran/array-element.exp
> index 28b0e6f348..9518b87a62 100644
> --- a/gdb/testsuite/gdb.fortran/array-element.exp
> +++ b/gdb/testsuite/gdb.fortran/array-element.exp
> @@ -31,8 +31,8 @@ if ![runto sub_] then {
>      continue
> }
> -gdb_breakpoint [gdb_get_line_number "continue"]
> -gdb_continue_to_breakpoint "continue"
> +gdb_breakpoint [gdb_get_line_number "return"]
> +gdb_continue_to_breakpoint "return"
>  gdb_test "print a(1)" ".*1 = 1.*" "print the first element of array a"
> gdb_test "print a(2)" ".*2 = 2.*" "print the second element of array a"
> --
> 2.17.1




More information about the Gdb-patches mailing list