From patchwork Fri Dec 7 11:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Bunt X-Patchwork-Id: 30577 Received: (qmail 4295 invoked by alias); 7 Dec 2018 11:14:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3854 invoked by uid 89); 7 Dec 2018 11:14:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:e020, H*M:e020 X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr130044.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (40.107.13.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Dec 2018 11:14:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=abkPCwDWxI+EXyTqqTtvyfxz4XF0lU/fAx+QjgDwIWk=; b=kLJ9nfIoxS+vNeUNN+mwc6VEIoI/Xw3wI9l4sfwf4tSvs5JCIU6sqh8BPEQDzQPYiRuYK/90vFbos5WOyWc4JsJ2QCDw8MgsDLPBJtY1OLKYKCgu7UJJKh0nzlVzApnLcUF5PERTaPeGulaMrUVoLxzc1t2Lq9LCVYbSfNvT2B4= Received: from VI1PR08MB3200.eurprd08.prod.outlook.com (52.133.15.152) by VI1PR08MB3901.eurprd08.prod.outlook.com (20.178.80.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.17; Fri, 7 Dec 2018 11:14:24 +0000 Received: from VI1PR08MB3200.eurprd08.prod.outlook.com ([fe80::d1bd:f969:ee71:2ecc]) by VI1PR08MB3200.eurprd08.prod.outlook.com ([fe80::d1bd:f969:ee71:2ecc%4]) with mapi id 15.20.1404.021; Fri, 7 Dec 2018 11:14:24 +0000 From: Richard Bunt To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH] gdbserver short-circuit-argument-list failures Date: Fri, 7 Dec 2018 11:14:24 +0000 Message-ID: <6375ccb6-cdb5-e020-45c1-f500ff98054a@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Richard.Bunt@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) Content-ID: <601CD83A50E8BD40B614D0A72FDC7395@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch fixes test case failures observed when running short-circuit-argument-list.exp with gdb server boards. Thanks to Sergio Durigan Junior for pointing this out. Assertions failed with the native{,-extended}-gdbserver boards as the standard output from the test program appears in a different location than observed on non-gdbserver boards. This standard output was used to determine whether a function, which had been logically short-circuited, was called or not. Since the location of the standard out cannot be relied upon to verify this, a new mechanism was needed. The test program now records function calls in module variables named the same as the function with a "_called" suffix. These variables can then be queried from the test case to verify the occurrence of a call. A method "reset_called_flags" has also been added to the test program, so that any future assertions added to this test can ensure a fresh set of zeros before proceeding. Regression tested on x86_64, aarch64 and ppc64le. Regression tested with Ada on x86_64. Regression tested with the native{,-extended}-gdbserver boards on x86_64. gdb/testsuite/ChangeLog: 2018-12-03 Richard Bunt * gdb.fortran/short-circuit-argument-list.exp: Remove reliance on user program standard output. * gdb.fortran/short-circuit-argument-list.f90: Record function calls. --- .../gdb.fortran/short-circuit-argument-list.exp | 50 +++++++++++++++------- .../gdb.fortran/short-circuit-argument-list.f90 | 33 +++++++++++--- 2 files changed, 63 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp index 1b948bb19d289e5327cb2caa3bf665e33cd6d98d..7032dbeea2eb487c5b98713bbf1c2b9807b692c9 100644 --- a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp +++ b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp @@ -49,20 +49,32 @@ foreach_with_prefix arg {"No" "One" "Two"} { set trimmed_args [string trimright $argument_list ,] set arg_lower [string tolower $arg] gdb_test "p function_no_arg_false() .OR. function_${arg_lower}_arg($trimmed_args)" \ - " $arg, return true.\r\n\\\$$decimal = .TRUE." - # Check the skipped function has not printed anything by asserting the - # absence of the full stop from its message. + "\\\$$decimal = .TRUE." + gdb_test "p reset_called_flags()" "VOID" gdb_test "p .TRUE. .OR. function_${arg_lower}_arg($trimmed_args)" \ - "\[^.\]\r\n\\\$$decimal = .TRUE." + "\\\$$decimal = .TRUE." + # Check that none of the short-circuited functions have been called. + gdb_test "p function_no_arg_called" "0" + gdb_test "p function_one_arg_called" "0" + gdb_test "p function_two_arg_called" "0" append argument_list " .TRUE.," } -# Check nested calls -gdb_test "p function_one_arg(.FALSE. .OR. function_no_arg())" \ - " No, return true.\r\n One, return true.\r\n\\\$$decimal = .TRUE." +with_test_prefix "nested call not skipped" { + gdb_test "p reset_called_flags()" "VOID" + # Check nested calls + gdb_test "p function_one_arg(.FALSE. .OR. function_no_arg())" \ + "\\\$$decimal = .TRUE." + gdb_test "p function_no_arg_called" "1" + gdb_test "p function_one_arg_called" "1" +} -gdb_test "p function_one_arg(.TRUE. .OR. function_no_arg())" \ - "\[^.\]\r\n One, return true.\r\n\\\$$decimal = .TRUE." +with_test_prefix "nested call skipped" { + gdb_test "p function_one_arg(.TRUE. .OR. function_no_arg())" \ + "\\\$$decimal = .TRUE." + gdb_test "p function_no_arg_called" "1" + gdb_test "p function_one_arg_called" "2" +} # Vary number of components in the expression to skip. set expression "p .TRUE." @@ -97,10 +109,18 @@ foreach_with_prefix range1 {"1:2" ":" ":2" "1:"} { # Check evaluation of substring operations in logical expressions. gdb_test "p .FALSE. .OR. binary_string(1)" "\\\$$decimal = .FALSE." -# Function call and substring skip. -gdb_test "p .TRUE. .OR. function_one_arg(binary_string(1))" \ - "\\\$$decimal = .TRUE." +with_test_prefix "binary string skip" { + gdb_test "p reset_called_flags()" "VOID" + # Function call and substring skip. + gdb_test "p .TRUE. .OR. function_one_arg(binary_string(1))" \ + "\\\$$decimal = .TRUE." + gdb_test "p function_one_arg_called" "0" +} -# Function call and array skip. -gdb_test "p .TRUE. .OR. function_array(binary_string)" \ - "\\\$$decimal = .TRUE." +with_test_prefix "array skip" { + # Function call and array skip. + gdb_test "p reset_called_flags()" "VOID" + gdb_test "p .TRUE. .OR. function_array(binary_string)" \ + "\\\$$decimal = .TRUE." + gdb_test "p function_array_called" "0" +} diff --git a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.f90 b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.f90 index 5d8b9c73a705c598b513fd85a8d710c7a7dabebf..bd1f94ad6db3c43135c9aa4476d33e694fb52405 100644 --- a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.f90 +++ b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.f90 @@ -15,36 +15,59 @@ ! Source code for short-circuit-argument-list.exp. +module called_flags + implicit none + integer :: function_no_arg_called = 0 + integer :: function_no_arg_false_called = 0 + integer :: function_one_arg_called = 0 + integer :: function_two_arg_called = 0 + integer :: function_array_called = 0 +contains + subroutine reset_called_flags + function_no_arg_called = 0 + function_no_arg_false_called = 0 + function_one_arg_called = 0 + function_two_arg_called = 0 + function_array_called = 0 + end subroutine reset_called_flags +end module called_flags + logical function function_no_arg() - print *, "No, return true." + use called_flags + function_no_arg_called = function_no_arg_called + 1 function_no_arg = .TRUE. end function function_no_arg logical function function_no_arg_false() + use called_flags + function_no_arg_false_called = function_no_arg_false_called + 1 function_no_arg_false = .FALSE. end function function_no_arg_false logical function function_one_arg(x) + use called_flags logical, intent(in) :: x - print *, "One, return true." + function_one_arg_called = function_one_arg_called + 1 function_one_arg = .TRUE. end function function_one_arg logical function function_two_arg(x, y) + use called_flags logical, intent(in) :: x, y - print *, "Two, return true." + function_two_arg_called = function_two_arg_called + 1 function_two_arg = .TRUE. end function function_two_arg logical function function_array(logical_array) + use called_flags logical, dimension(4,2), target, intent(in) :: logical_array logical, dimension(:,:), pointer :: p - p => logical_array - print *, "Array, return true.", p(1,1), logical_array(1,1) + function_array_called = function_array_called + 1 function_array = .TRUE. end function function_array program generate_truth_table + use called_flags implicit none interface logical function function_no_arg()