Introduce and use gnat_version_compare
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
fail
|
Test failed
|
Commit Message
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.
---
gdb/testsuite/gdb.ada/array_of_variant.exp | 2 +-
gdb/testsuite/gdb.ada/arrayidx.exp | 3 +--
gdb/testsuite/gdb.ada/arrayptr.exp | 2 +-
gdb/testsuite/gdb.ada/big_packed_array.exp | 2 +-
gdb/testsuite/gdb.ada/enum_idx_packed.exp | 5 +++--
gdb/testsuite/gdb.ada/fixed_points.exp | 4 ++--
gdb/testsuite/gdb.ada/fun_renaming.exp | 8 +++----
gdb/testsuite/gdb.ada/mod_from_name.exp | 5 +++--
gdb/testsuite/gdb.ada/null_array.exp | 3 +--
gdb/testsuite/gdb.ada/packed_array_assign.exp | 2 +-
gdb/testsuite/gdb.ada/packed_record.exp | 2 +-
gdb/testsuite/gdb.ada/pckd_arr_ren.exp | 5 +++--
.../gdb.ada/variant_record_packed_array.exp | 4 ++--
gdb/testsuite/lib/ada.exp | 12 +++++++++++
gdb/testsuite/lib/gdb-utils.exp | 21 +++++++++++++++++--
15 files changed, 55 insertions(+), 25 deletions(-)
@@ -20,7 +20,7 @@ require allow_ada_tests
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 } {
global scenario old_gcc
@@ -23,8 +23,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
return -1
}
-set old_gcc [expr [test_compiler_info {gcc-[0-3]-*}] \
- || [test_compiler_info {gcc-4-[0-6]-*}]]
+set old_gcc [gnat_version_compare <= {4 6}]
clean_restart ${testfile}
@@ -55,7 +55,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
# GNAT >= 12.0 has the needed fix here.
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
}
@@ -19,7 +19,7 @@ require allow_ada_tests
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} {
lappend flags debug
@@ -29,8 +29,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
clean_restart ${testfile}-${scenario}
# GNAT 9 and 10 are known to fail.
- if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
- || [test_compiler_info {gcc-10-*}])} {
+ if {$scenario == "minimal"
+ && [gnat_version_compare >= 9]
+ && [gnat_version_compare <= 10]} {
set old_compiler 1
} else {
set old_compiler 0
@@ -88,12 +88,12 @@ foreach_gnat_encoding scenario flags {all minimal} {
gdb_test "print fp4_var / 1" $fp4
# 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"
}
# 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" \
"value of another_fixed"
}
@@ -41,7 +41,7 @@ gdb_test_multiple $test $test {
pass $test
}
-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
} else {
xfail $test
@@ -55,7 +55,7 @@ gdb_test_multiple $test $test {
pass $test
}
-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
} else {
xfail $test
@@ -69,14 +69,14 @@ gdb_test_multiple $test $test {
pass $test
}
-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
} else {
xfail $test
}
}
-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
} else {
xfail $test
@@ -34,8 +34,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
}
# GNAT 9 and 10 are known to fail.
- if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
- || [test_compiler_info {gcc-10-*}])} {
+ if {$scenario == "minimal"
+ && [gnat_version_compare >= 9]
+ && [gnat_version_compare <= 10]} {
setup_kfail "minimal encodings" *-*-*
}
gdb_test "print xp" \
@@ -28,8 +28,7 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
runto "foo.adb:$bp_location"
-if {[test_compiler_info {gcc-[0-3]-*}]
- || [test_compiler_info {gcc-4-[0-4]-*}]} {
+if {[gnat_version_compare <= 4.4]} {
# Ada array bounds are missing in older GCCs.
setup_xfail *-*-*
}
@@ -54,7 +54,7 @@ set re \
"packed_array_assign_y => 1\\)\\)"]
# 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 \
[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))"]
@@ -38,7 +38,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
}
-re " = .*more than max-value-size.*\[\r\n\]+$gdb_prompt $" {
# 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" *-*-*
}
fail $test
@@ -32,8 +32,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
runto "foo.adb:$bp_location"
# GNAT 9 and 10 are known to fail.
- if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
- || [test_compiler_info {gcc-10-*}])} {
+ if {$scenario == "minimal"
+ && [gnat_version_compare >= 9]
+ && [gnat_version_compare <= 10]} {
setup_kfail "minimal encodings" *-*-*
}
gdb_test "print A2" \
@@ -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 $" {
# 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" *-*-*
}
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 $" {
# 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" *-*-*
}
fail $test
@@ -188,6 +188,18 @@ proc gnatmake_version_at_least { major } {
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.
proc gnat_runtime_has_debug_info_1 { shared } {
@@ -110,14 +110,31 @@ proc gdb_get_bp_addr { num } {
}
# Compare the version numbers in L1 to those in L2 using OP, and
-# return 1 if the comparison is true. OP can be "<", "<=", or "==".
-# It is ok if the lengths of the lists differ.
+# return 1 if the comparison is true. OP can be "<", "<=", ">", ">=",
+# or "==". It is ok if the lengths of the lists differ.
proc version_compare { l1 op l2 } {
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" }
}