gdbserver short-circuit-argument-list failures
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.
This commit is contained in:
parent
f5f2031511
commit
7b63ad86ab
@ -1,3 +1,10 @@
|
||||
2019-03-04 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.
|
||||
|
||||
2019-02-28 Alan Hayward <alan.hayward@arm.com>
|
||||
|
||||
* lib/gdbserver-support.exp (gdbserver_start): Check for listen
|
||||
|
@ -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."
|
||||
gdb_test "p .FALSE. .OR. binary_string(1)" " = .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" {
|
||||
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"
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user