public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Richard Bunt <Richard.Bunt@arm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: Re: [PATCH v2] gdbserver short-circuit-argument-list failures
Date: Fri, 08 Feb 2019 11:10:00 -0000	[thread overview]
Message-ID: <f24a5b2a-8fb9-f656-db71-7373748d8efc@arm.com> (raw)
In-Reply-To: <a2bdf615-773e-5f2a-616d-d0881701851d@arm.com>

Polite ping.

On 1/17/19 3:37 PM, Richard Bunt wrote:
> 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 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 to reset the call counts has been included in the test case, so
> that any future assertions added to this test can ensure a fresh set of
> initial values before proceeding. Not resetting values between groups of
> assertions creates a dependency between them, which increases the
> likelihood that a single failure causes subsequent assertions to fail.
> 
> 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  <richard.bunt@arm.com>
> 
> 	* 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    | 75 ++++++++++++++++------
>  .../gdb.fortran/short-circuit-argument-list.f90    | 33 ++++++++--
>  2 files changed, 82 insertions(+), 26 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp
> index 739df97d0b973dac21c97fddf6b32a1e059139fe..c2fb69044e8e55e22920777a1b9677f5d20eed23 100644
> --- a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp
> +++ b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp
> @@ -30,6 +30,20 @@ if {![runto [gdb_get_line_number "post_truth_table_init"]]} then {
>      continue
>  }
>  
> +# Non-zero value to use as the function call count base. Using zero is avoided
> +# as this is a common value in memory.
> +set prime 17
> +
> +# Reset all call counts to the initial value ($prime).
> +proc reset_called_flags { } {
> +    global prime
> +    foreach counter {no_arg no_arg_false one_arg two_arg array} {
> +	gdb_test_no_output "set var calls%function_${counter}_called=$prime"
> +    }
> +}
> +
> +reset_called_flags
> +
>  # Vary conditional and input over the standard truth table.
>  # Test that the debugger can evaluate expressions of the form
>  # a(x,y) .OR./.AND. a(a,b) correctly.
> @@ -49,31 +63,42 @@ 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.
> +	     " = .TRUE."
> +    reset_called_flags
>      gdb_test "p .TRUE. .OR. function_${arg_lower}_arg($trimmed_args)" \
> -	     "\[^.\]\r\n\\\$$decimal = .TRUE."
> +	     " = .TRUE."
> +    # Check that none of the short-circuited functions have been called.
> +    gdb_test "p calls" \
> +	     " = \\\( function_no_arg_called = $prime, function_no_arg_false_called = $prime, function_one_arg_called = $prime, function_two_arg_called = $prime, function_array_called = $prime \\\)"
>      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" {
> +    reset_called_flags
> +    # Check nested calls
> +    gdb_test "p function_one_arg(.FALSE. .OR. function_no_arg())" \
> +	     " = .TRUE."
> +    gdb_test "p calls" \
> +	     " = \\\( function_no_arg_called = [expr $prime + 1], function_no_arg_false_called = $prime, function_one_arg_called = [expr $prime + 1], function_two_arg_called = $prime, function_array_called = $prime \\\)"
> +}
>  
> -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())" \
> +	     " = .TRUE."
> +    gdb_test "p calls" \
> +	     " = \\\( function_no_arg_called = [expr $prime + 1], function_no_arg_false_called = $prime, function_one_arg_called = [expr $prime + 2], function_two_arg_called = $prime, function_array_called = $prime \\\)"
> +}
>  
>  # Vary number of components in the expression to skip.
>  set expression "p .TRUE."
>  foreach_with_prefix expression_components {1 2 3 4} {
>      set expression "$expression .OR. function_one_arg(.TRUE.)"
>      gdb_test "$expression" \
> -	     "\\\$$decimal = .TRUE."
> +	     " = .TRUE."
>  }
>  
>  # Check parsing skipped substring operations.
> -gdb_test "p .TRUE. .OR. binary_string(1)" "\\\$$decimal = .TRUE."
> +gdb_test "p .TRUE. .OR. binary_string(1)" " = .TRUE."
>  
>  # Check parsing skipped substring operations with ranges. These should all
>  # return true as the result is > 0.
> @@ -82,7 +107,7 @@ gdb_test "p .TRUE. .OR. binary_string(1)" "\\\$$decimal = .TRUE."
>  foreach_with_prefix range1 {"1:2" ":" ":2" "1:"} {
>      foreach_with_prefix range2 {"1:2" ":" ":2" "1:"} {
>  	gdb_test "p .TRUE. .OR. binary_string($range1) .OR. binary_string($range2)" \
> -		 "\\\$$decimal = .TRUE."
> +		 " = .TRUE."
>      }
>  }
>  
> @@ -90,17 +115,25 @@ foreach_with_prefix range1 {"1:2" ":" ":2" "1:"} {
>  foreach_with_prefix range1 {"1:2" ":" ":2" "1:"} {
>      foreach_with_prefix range2 {"1:2" ":" ":2" "1:"} {
>  	gdb_test "p .TRUE. .OR. binary_string($range1) .OR. truth_table($range2, 1)" \
> -		 "\\\$$decimal = .TRUE."
> +		 " = .TRUE."
>      }
>  }
>  
>  # 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."
> +gdb_test "p .FALSE. .OR. binary_string(1)" " = .FALSE."
> +
> +with_test_prefix "binary string skip" {
> +    reset_called_flags
> +    # Function call and substring skip.
> +    gdb_test "p .TRUE. .OR. function_one_arg(binary_string(1))" \
> +	     " = .TRUE."
> +    gdb_test "p calls%function_one_arg_called" " = $prime"
> +}
>  
> -# 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.
> +    reset_called_flags
> +    gdb_test "p .TRUE. .OR. function_array(binary_string)" \
> +	     " = .TRUE."
> +    gdb_test "p calls%function_array_called" " = $prime"
> +}
> diff --git a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.f90 b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.f90
> index 7c1c917d87ff035e68dc5f488b431544e07bf9e3..d2ce55f46898f2f45d8a4106b3317836386010a2 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_state
> +    implicit none
> +    type called_counts
> +	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
> +    end type
> +    type(called_counts) :: calls
> +end module called_state
> +
>  logical function function_no_arg()
> -    print *, "No, return true."
> +    use called_state
> +    implicit none
> +    calls%function_no_arg_called = calls%function_no_arg_called + 1
>      function_no_arg = .TRUE.
>  end function function_no_arg
>  
>  logical function function_no_arg_false()
> +    use called_state
> +    implicit none
> +    calls%function_no_arg_false_called = calls%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_state
> +    implicit none
>      logical, intent(in) :: x
> -    print *, "One, return true."
> +    calls%function_one_arg_called = calls%function_one_arg_called + 1
>      function_one_arg = .TRUE.
>  end function function_one_arg
>  
>  logical function function_two_arg(x, y)
> +    use called_state
> +    implicit none
>      logical, intent(in) :: x, y
> -    print *, "Two, return true."
> +    calls%function_two_arg_called = calls%function_two_arg_called + 1
>      function_two_arg = .TRUE.
>  end function function_two_arg
>  
>  logical function function_array(logical_array)
> +    use called_state
> +    implicit none
>      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)
> +    calls%function_array_called = calls%function_array_called + 1
>      function_array = .TRUE.
>  end function function_array
>  
>  program generate_truth_table
> +    use called_state
>      implicit none
>      interface
>  	logical function function_no_arg()
> 

  reply	other threads:[~2019-02-08 11:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 15:38 Richard Bunt
2019-02-08 11:10 ` Richard Bunt [this message]
2019-02-14 22:45   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f24a5b2a-8fb9-f656-db71-7373748d8efc@arm.com \
    --to=richard.bunt@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).