Introduce and use gnat_version_compare

While testing a modified GNAT, I found that this test in
fun_renaming.exp was returning 0 for GCC 13:

    if {[test_compiler_info {gcc-6*}]}

This patch introduces a new, more robust way to check the GNAT
compiler version, and changes the gda.ada tests to use it.  A small
update to version_compare was also needed.

Note that, in its current form, this new code won't really interact
well with non-GCC compilers (specifically gnat-llvm).  This doesn't
seem like a major issue at this point, though, because gnat-llvm
doesn't properly emit debuginfo yet, and when it does, more changes
will be needed in these tests anyway.

Reviewed-by: Keith Seitz <keiths@redhat.com>
This commit is contained in:
Tom Tromey
2024-09-26 08:48:03 -06:00
parent a104f0a3e6
commit 1411185a57
15 changed files with 55 additions and 25 deletions

View File

@@ -20,7 +20,7 @@ require allow_ada_tests
standard_ada_testfile p standard_ada_testfile p
set old_gcc [expr [test_compiler_info {gcc-[0-7]-*}]] set old_gcc [gnat_version_compare <= 7]
proc gdb_test_with_xfail { cmd re re_xfail msg } { proc gdb_test_with_xfail { cmd re re_xfail msg } {
global scenario old_gcc global scenario old_gcc

View File

@@ -23,8 +23,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
return -1 return -1
} }
set old_gcc [expr [test_compiler_info {gcc-[0-3]-*}] \ set old_gcc [gnat_version_compare <= {4 6}]
|| [test_compiler_info {gcc-4-[0-6]-*}]]
clean_restart ${testfile} clean_restart ${testfile}

View File

@@ -55,7 +55,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
# GNAT >= 12.0 has the needed fix here. # GNAT >= 12.0 has the needed fix here.
set xfail_expected 0 set xfail_expected 0
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} { if {$scenario == "minimal" && [gnat_version_compare < 12]} {
set xfail_expected 1 set xfail_expected 1
} }

View File

@@ -19,7 +19,7 @@ require allow_ada_tests
standard_ada_testfile foo_ra24_010 standard_ada_testfile foo_ra24_010
set old_gcc [expr [test_compiler_info {gcc-[0-8]-*}]] set old_gcc [gnat_version_compare < 9]
foreach_gnat_encoding scenario flags {all minimal} { foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug lappend flags debug

View File

@@ -29,8 +29,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
clean_restart ${testfile}-${scenario} clean_restart ${testfile}-${scenario}
# GNAT 9 and 10 are known to fail. # GNAT 9 and 10 are known to fail.
if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \ if {$scenario == "minimal"
|| [test_compiler_info {gcc-10-*}])} { && [gnat_version_compare >= 9]
&& [gnat_version_compare <= 10]} {
set old_compiler 1 set old_compiler 1
} else { } else {
set old_compiler 0 set old_compiler 0

View File

@@ -88,12 +88,12 @@ foreach_gnat_encoding scenario flags {all minimal} {
gdb_test "print fp4_var / 1" $fp4 gdb_test "print fp4_var / 1" $fp4
# This only started working in GCC 11. # This only started working in GCC 11.
if {$scenario == "minimal" && [test_compiler_info {gcc-11-*}]} { if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
gdb_test "print fp5_var" " = 3e-19" gdb_test "print fp5_var" " = 3e-19"
} }
# This failed before GCC 10. # This failed before GCC 10.
if {$scenario == "all" && [test_compiler_info {gcc-10-*}]} { if {$scenario == "all" && [gnat_version_compare < 10]} {
gdb_test "p Float(Another_Fixed) = Float(Another_Delta * 5)" "true" \ gdb_test "p Float(Another_Fixed) = Float(Another_Delta * 5)" "true" \
"value of another_fixed" "value of another_fixed"
} }

View File

@@ -41,7 +41,7 @@ gdb_test_multiple $test $test {
pass $test pass $test
} }
-wrap -re "No definition of \"fun_rename_test_n\" in current context\\." { -wrap -re "No definition of \"fun_rename_test_n\" in current context\\." {
if {[test_compiler_info {gcc-6*}]} { if {[gnat_version_compare >= 6]} {
fail $test fail $test
} else { } else {
xfail $test xfail $test
@@ -55,7 +55,7 @@ gdb_test_multiple $test $test {
pass $test pass $test
} }
-wrap -re "No definition of \"renamed_fun_rename_test_next\" in current context\\." { -wrap -re "No definition of \"renamed_fun_rename_test_next\" in current context\\." {
if {[test_compiler_info {gcc-6*}]} { if {[gnat_version_compare >= 6]} {
fail $test fail $test
} else { } else {
xfail $test xfail $test
@@ -69,14 +69,14 @@ gdb_test_multiple $test $test {
pass $test pass $test
} }
-wrap -re "No definition of \"pack\\.renamed_fun_rename_test_next\" in current context\\." { -wrap -re "No definition of \"pack\\.renamed_fun_rename_test_next\" in current context\\." {
if {[test_compiler_info {gcc-6*}]} { if {[gnat_version_compare >= 6]} {
fail $test fail $test
} else { } else {
xfail $test xfail $test
} }
} }
-wrap -re "Type <data variable, no debug info> is not a structure or union type\\." { -wrap -re "Type <data variable, no debug info> is not a structure or union type\\." {
if {[test_compiler_info {gcc-6*}]} { if {[gnat_version_compare >= 6]} {
fail $test fail $test
} else { } else {
xfail $test xfail $test

View File

@@ -34,8 +34,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
} }
# GNAT 9 and 10 are known to fail. # GNAT 9 and 10 are known to fail.
if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \ if {$scenario == "minimal"
|| [test_compiler_info {gcc-10-*}])} { && [gnat_version_compare >= 9]
&& [gnat_version_compare <= 10]} {
setup_kfail "minimal encodings" *-*-* setup_kfail "minimal encodings" *-*-*
} }
gdb_test "print xp" \ gdb_test "print xp" \

View File

@@ -28,8 +28,7 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb] set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
runto "foo.adb:$bp_location" runto "foo.adb:$bp_location"
if {[test_compiler_info {gcc-[0-3]-*}] if {[gnat_version_compare <= 4.4]} {
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
# Ada array bounds are missing in older GCCs. # Ada array bounds are missing in older GCCs.
setup_xfail *-*-* setup_xfail *-*-*
} }

View File

@@ -54,7 +54,7 @@ set re \
"packed_array_assign_y => 1\\)\\)"] "packed_array_assign_y => 1\\)\\)"]
# GNAT >= 12.0 has the needed fix here. # GNAT >= 12.0 has the needed fix here.
set zeros_expected [expr {![test_compiler_info {gcc-1[2-9]-*}]}] set zeros_expected [gnat_version_compare >= 12]
set all_zeros \ set all_zeros \
[string_to_regexp "((packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0), (packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0), (packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0))"] [string_to_regexp "((packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0), (packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0), (packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0))"]

View File

@@ -38,7 +38,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
} }
-re " = .*more than max-value-size.*\[\r\n\]+$gdb_prompt $" { -re " = .*more than max-value-size.*\[\r\n\]+$gdb_prompt $" {
# GNAT >= 12.0 has the needed fix here. # GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} { if {$scenario == "minimal" && [gnat_version_compare >= 12]} {
setup_kfail "minimal encodings" *-*-* setup_kfail "minimal encodings" *-*-*
} }
fail $test fail $test

View File

@@ -32,8 +32,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
runto "foo.adb:$bp_location" runto "foo.adb:$bp_location"
# GNAT 9 and 10 are known to fail. # GNAT 9 and 10 are known to fail.
if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \ if {$scenario == "minimal"
|| [test_compiler_info {gcc-10-*}])} { && [gnat_version_compare >= 9]
&& [gnat_version_compare <= 10]} {
setup_kfail "minimal encodings" *-*-* setup_kfail "minimal encodings" *-*-*
} }
gdb_test "print A2" \ gdb_test "print A2" \

View File

@@ -41,7 +41,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
} }
-re " = \\(size => 8, length => 8, buffer => warning: could not find bounds information on packed array.*$gdb_prompt $" { -re " = \\(size => 8, length => 8, buffer => warning: could not find bounds information on packed array.*$gdb_prompt $" {
# GNAT >= 11.0 has the needed fix here. # GNAT >= 11.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[1-9]-*}]} { if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
setup_kfail "minimal encodings" *-*-* setup_kfail "minimal encodings" *-*-*
} }
fail $test fail $test
@@ -62,7 +62,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
} }
-re " = \\(size => 8, length => 8, buffer => warning: could not find bounds information on packed array.*$gdb_prompt $" { -re " = \\(size => 8, length => 8, buffer => warning: could not find bounds information on packed array.*$gdb_prompt $" {
# GNAT >= 11.0 has the needed fix here. # GNAT >= 11.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[1-9]-*}]} { if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
setup_kfail "minimal encodings" *-*-* setup_kfail "minimal encodings" *-*-*
} }
fail $test fail $test

View File

@@ -188,6 +188,18 @@ proc gnatmake_version_at_least { major } {
return 1 return 1
} }
# Compare the GNAT version against L2 using version_compare. If the
# compiler does not appear to be GCC, this will always return false.
proc gnat_version_compare {op l2} {
set gccvers [gcc_major_version]
if {$gccvers == -1} {
return 0
}
return [version_compare [split $gccvers .] $op $l2]
}
# Return 1 if the GNAT runtime appears to have debug info. # Return 1 if the GNAT runtime appears to have debug info.
proc gnat_runtime_has_debug_info_1 { shared } { proc gnat_runtime_has_debug_info_1 { shared } {

View File

@@ -111,14 +111,31 @@ proc gdb_get_bp_addr { num } {
} }
# Compare the version numbers in L1 to those in L2 using OP, and # Compare the version numbers in L1 to those in L2 using OP, and
# return 1 if the comparison is true. OP can be "<", "<=", or "==". # return 1 if the comparison is true. OP can be "<", "<=", ">", ">=",
# It is ok if the lengths of the lists differ. # or "==". It is ok if the lengths of the lists differ.
proc version_compare { l1 op l2 } { proc version_compare { l1 op l2 } {
switch -exact $op { switch -exact $op {
"==" - "==" -
"<=" - "<=" -
"<" {} "<" {}
">=" {
# a >= b => b <= a
set x $l2
set l2 $l1
set l1 $x
set op "<="
}
">" {
# a > b => b < a
set x $l2
set l2 $l1
set l1 $x
set op "<"
}
default { error "unsupported op: $op" } default { error "unsupported op: $op" }
} }