From: Tom Tromey Date: Wed, 8 May 2024 19:46:53 +0000 (-0600) Subject: Introduce and use foreach_gnat_encoding X-Git-Tag: gdb-16-branchpoint~986 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a63b3b2f74e95380a718f9342ee42274dd877a3b;p=thirdparty%2Fbinutils-gdb.git Introduce and use foreach_gnat_encoding gnat-llvm does not support the -fgnat-encodings flag. This patch prepares gdb's Ada tests to handle this situation by introducing a new foreach_gnat_encoding. A subsequent patch may change this to support gnat-llvm; meanwhile this is a little cleaner anyway. --- diff --git a/gdb/testsuite/gdb.ada/O2_float_param.exp b/gdb/testsuite/gdb.ada/O2_float_param.exp index d44f2e57217..86b67ff4626 100644 --- a/gdb/testsuite/gdb.ada/O2_float_param.exp +++ b/gdb/testsuite/gdb.ada/O2_float_param.exp @@ -26,10 +26,8 @@ if {[is_aarch64_target]} { } } -foreach_with_prefix scenario {all minimal} { - set flags [list debug \ - optimize=-O2 \ - additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug optimize=-O2 if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/access_to_unbounded_array.exp b/gdb/testsuite/gdb.ada/access_to_unbounded_array.exp index 7f7bfb3ba4c..eeaceb018ed 100644 --- a/gdb/testsuite/gdb.ada/access_to_unbounded_array.exp +++ b/gdb/testsuite/gdb.ada/access_to_unbounded_array.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap.exp b/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap.exp index 569bb2ec556..4ecb4f8cd78 100644 --- a/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap.exp +++ b/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile enum_with_gap_main -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" \ executable $flags] != ""} { diff --git a/gdb/testsuite/gdb.ada/arr_enum_idx_w_gap.exp b/gdb/testsuite/gdb.ada/arr_enum_idx_w_gap.exp index 5a88f5f3ca9..491402bd78a 100644 --- a/gdb/testsuite/gdb.ada/arr_enum_idx_w_gap.exp +++ b/gdb/testsuite/gdb.ada/arr_enum_idx_w_gap.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo_q418_043 -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/array_of_symbolic_length.exp b/gdb/testsuite/gdb.ada/array_of_symbolic_length.exp index bcf73690801..134b448e64a 100644 --- a/gdb/testsuite/gdb.ada/array_of_symbolic_length.exp +++ b/gdb/testsuite/gdb.ada/array_of_symbolic_length.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/array_of_variable_length.exp b/gdb/testsuite/gdb.ada/array_of_variable_length.exp index 3397760e16c..3c68c805a12 100644 --- a/gdb/testsuite/gdb.ada/array_of_variable_length.exp +++ b/gdb/testsuite/gdb.ada/array_of_variable_length.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/array_of_variant.exp b/gdb/testsuite/gdb.ada/array_of_variant.exp index 1a155d416db..f93260af940 100644 --- a/gdb/testsuite/gdb.ada/array_of_variant.exp +++ b/gdb/testsuite/gdb.ada/array_of_variant.exp @@ -40,8 +40,8 @@ proc gdb_test_with_xfail { cmd re re_xfail msg } { } } -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/array_ptr_renaming.exp b/gdb/testsuite/gdb.ada/array_ptr_renaming.exp index b013fc7e3b6..eadfcb64891 100644 --- a/gdb/testsuite/gdb.ada/array_ptr_renaming.exp +++ b/gdb/testsuite/gdb.ada/array_ptr_renaming.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/arrayparam.exp b/gdb/testsuite/gdb.ada/arrayparam.exp index 2921d64bef1..ef00037be90 100644 --- a/gdb/testsuite/gdb.ada/arrayparam.exp +++ b/gdb/testsuite/gdb.ada/arrayparam.exp @@ -22,8 +22,8 @@ standard_ada_testfile foo # Note we don't test the "none" (no -fgnat-encodings option) scenario # here, because "all" and "minimal" cover the cases, and this way we # don't have to update the test when gnat changes its default. -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/arrayptr.exp b/gdb/testsuite/gdb.ada/arrayptr.exp index ca48993439b..335573b31a7 100644 --- a/gdb/testsuite/gdb.ada/arrayptr.exp +++ b/gdb/testsuite/gdb.ada/arrayptr.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/big_packed_array.exp b/gdb/testsuite/gdb.ada/big_packed_array.exp index 1ba2c4853c8..0078c77de6a 100644 --- a/gdb/testsuite/gdb.ada/big_packed_array.exp +++ b/gdb/testsuite/gdb.ada/big_packed_array.exp @@ -21,8 +21,8 @@ standard_ada_testfile foo_ra24_010 set old_gcc [expr [test_compiler_info {gcc-[0-8]-*}]] -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed.exp b/gdb/testsuite/gdb.ada/enum_idx_packed.exp index 1976092c13b..d56d73bf9bc 100644 --- a/gdb/testsuite/gdb.ada/enum_idx_packed.exp +++ b/gdb/testsuite/gdb.ada/enum_idx_packed.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/fixed_cmp.exp b/gdb/testsuite/gdb.ada/fixed_cmp.exp index de506fdfd99..dcd47455302 100644 --- a/gdb/testsuite/gdb.ada/fixed_cmp.exp +++ b/gdb/testsuite/gdb.ada/fixed_cmp.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile fixed -foreach_with_prefix gnat_encodings {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$gnat_encodings] +foreach_gnat_encoding gnat_encodings flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${gnat_encodings}" executable $flags] != "" } { return -1 diff --git a/gdb/testsuite/gdb.ada/fixed_points.exp b/gdb/testsuite/gdb.ada/fixed_points.exp index 4665595f6f8..ceed34acbc5 100644 --- a/gdb/testsuite/gdb.ada/fixed_points.exp +++ b/gdb/testsuite/gdb.ada/fixed_points.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile fixed_points -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 } diff --git a/gdb/testsuite/gdb.ada/frame_arg_lang.exp b/gdb/testsuite/gdb.ada/frame_arg_lang.exp index 918a922ca2f..b629c429ac8 100644 --- a/gdb/testsuite/gdb.ada/frame_arg_lang.exp +++ b/gdb/testsuite/gdb.ada/frame_arg_lang.exp @@ -27,11 +27,10 @@ gdb_compile "${csrcfile}" "${cobject}" object [list debug] # Note we don't test the "none" (no -fgnat-encodings option) scenario # here, because "all" and "minimal" cover the cases, and this way we # don't have to update the test when gnat changes its default. -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-largs \ - additional_flags=${cobject} \ - additional_flags=-margs \ - additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug additional_flags=-largs \ + additional_flags=${cobject} \ + additional_flags=-margs if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/funcall_ref.exp b/gdb/testsuite/gdb.ada/funcall_ref.exp index 518ceb7118f..1c283923021 100644 --- a/gdb/testsuite/gdb.ada/funcall_ref.exp +++ b/gdb/testsuite/gdb.ada/funcall_ref.exp @@ -22,8 +22,8 @@ standard_ada_testfile foo # Note we don't test the "none" (no -fgnat-encodings option) scenario # here, because "all" and "minimal" cover the cases, and this way we # don't have to update the test when gnat changes its default. -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/mi_string_access.exp b/gdb/testsuite/gdb.ada/mi_string_access.exp index 15b8cf153f4..8fd116b545c 100644 --- a/gdb/testsuite/gdb.ada/mi_string_access.exp +++ b/gdb/testsuite/gdb.ada/mi_string_access.exp @@ -22,8 +22,8 @@ standard_ada_testfile bar load_lib mi-support.exp set MIFLAGS "-i=mi" -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/mi_var_array.exp b/gdb/testsuite/gdb.ada/mi_var_array.exp index 2b504815099..dd770a11718 100644 --- a/gdb/testsuite/gdb.ada/mi_var_array.exp +++ b/gdb/testsuite/gdb.ada/mi_var_array.exp @@ -22,11 +22,8 @@ standard_ada_testfile bar load_lib mi-support.exp set MIFLAGS "-i=mi" -foreach_with_prefix scenario {none all minimal} { - set flags {debug} - if {$scenario != "none"} { - lappend flags additional_flags=-fgnat-encodings=$scenario - } +foreach_gnat_encoding scenario flags {none all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != "" } { return -1 diff --git a/gdb/testsuite/gdb.ada/mi_var_union.exp b/gdb/testsuite/gdb.ada/mi_var_union.exp index eb23c0a4a65..64bfe3355e7 100644 --- a/gdb/testsuite/gdb.ada/mi_var_union.exp +++ b/gdb/testsuite/gdb.ada/mi_var_union.exp @@ -24,11 +24,8 @@ set MIFLAGS "-i=mi" set float "\\-?((\[0-9\]+(\\.\[0-9\]+)?(e\[-+\]\[0-9\]+)?)|(nan\\($hex\\)))" -foreach_with_prefix scenario {none all minimal} { - set flags {debug} - if {$scenario != "none"} { - lappend flags additional_flags=-fgnat-encodings=$scenario - } +foreach_gnat_encoding scenario flags {none all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != "" } { return -1 diff --git a/gdb/testsuite/gdb.ada/mi_variant.exp b/gdb/testsuite/gdb.ada/mi_variant.exp index 7f10b3c511f..f4be5a0b110 100644 --- a/gdb/testsuite/gdb.ada/mi_variant.exp +++ b/gdb/testsuite/gdb.ada/mi_variant.exp @@ -23,11 +23,8 @@ standard_ada_testfile pkg load_lib mi-support.exp set MIFLAGS "-i=mi" -foreach_with_prefix scenario {none all minimal} { - set flags {debug} - if {$scenario != "none"} { - lappend flags additional_flags=-fgnat-encodings=$scenario - } +foreach_gnat_encoding scenario flags {none all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/mod_from_name.exp b/gdb/testsuite/gdb.ada/mod_from_name.exp index c6acc802bbf..33bd854d3ba 100644 --- a/gdb/testsuite/gdb.ada/mod_from_name.exp +++ b/gdb/testsuite/gdb.ada/mod_from_name.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/multiarray.exp b/gdb/testsuite/gdb.ada/multiarray.exp index 9be0aaabeee..91ba1ec0034 100644 --- a/gdb/testsuite/gdb.ada/multiarray.exp +++ b/gdb/testsuite/gdb.ada/multiarray.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile p -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" \ executable $flags] != ""} { diff --git a/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp b/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp index eaa88a30774..2adef97e763 100644 --- a/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp +++ b/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp @@ -19,10 +19,8 @@ require allow_ada_tests standard_ada_testfile foo_o224_021 -foreach_with_prefix scenario {all minimal} { - set flags [list debug \ - optimize=-O2 \ - additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug optimize=-O2 if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp index a3d7136c163..85bc59db882 100644 --- a/gdb/testsuite/gdb.ada/packed_array.exp +++ b/gdb/testsuite/gdb.ada/packed_array.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile pa -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/packed_record.exp b/gdb/testsuite/gdb.ada/packed_record.exp index fa058f70524..bbba9b25c54 100644 --- a/gdb/testsuite/gdb.ada/packed_record.exp +++ b/gdb/testsuite/gdb.ada/packed_record.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile pr -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/packed_tagged.exp b/gdb/testsuite/gdb.ada/packed_tagged.exp index faccc1476d4..1c9e5a07703 100644 --- a/gdb/testsuite/gdb.ada/packed_tagged.exp +++ b/gdb/testsuite/gdb.ada/packed_tagged.exp @@ -22,11 +22,8 @@ standard_ada_testfile comp_bug # Note we don't test the "none" (no -fgnat-encodings option) scenario # here, because "all" and "minimal" cover the cases, and this way we # don't have to update the test when gnat changes its default. -foreach_with_prefix scenario {all minimal} { - set flags {debug} - if {$scenario != "none"} { - lappend flags additional_flags=-fgnat-encodings=$scenario - } +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/pckd_arr_ren.exp b/gdb/testsuite/gdb.ada/pckd_arr_ren.exp index 083ee132714..18bb84f848a 100644 --- a/gdb/testsuite/gdb.ada/pckd_arr_ren.exp +++ b/gdb/testsuite/gdb.ada/pckd_arr_ren.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/ptype-o.exp b/gdb/testsuite/gdb.ada/ptype-o.exp index f7782199d58..5038ee171d2 100644 --- a/gdb/testsuite/gdb.ada/ptype-o.exp +++ b/gdb/testsuite/gdb.ada/ptype-o.exp @@ -21,8 +21,8 @@ require allow_ada_tests standard_ada_testfile prog -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/rec_ptype.exp b/gdb/testsuite/gdb.ada/rec_ptype.exp index f75d09b16ef..fc7bb8b5fac 100644 --- a/gdb/testsuite/gdb.ada/rec_ptype.exp +++ b/gdb/testsuite/gdb.ada/rec_ptype.exp @@ -22,8 +22,8 @@ standard_ada_testfile main # Note we don't test the "none" (no -fgnat-encodings option) scenario # here, because "all" and "minimal" cover the cases, and this way we # don't have to update the test when gnat changes its default. -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/same_component_name.exp b/gdb/testsuite/gdb.ada/same_component_name.exp index 7167a4124d1..84a48b4fd0e 100644 --- a/gdb/testsuite/gdb.ada/same_component_name.exp +++ b/gdb/testsuite/gdb.ada/same_component_name.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != "" } { return -1 diff --git a/gdb/testsuite/gdb.ada/set_pckd_arr_elt.exp b/gdb/testsuite/gdb.ada/set_pckd_arr_elt.exp index d77f8fe6896..2979cb99e83 100644 --- a/gdb/testsuite/gdb.ada/set_pckd_arr_elt.exp +++ b/gdb/testsuite/gdb.ada/set_pckd_arr_elt.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp index 6b2a6fdfa9a..2bcc027cec4 100644 --- a/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp +++ b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/unchecked_union.exp b/gdb/testsuite/gdb.ada/unchecked_union.exp index bff71bdaa2f..5d3256bd52e 100644 --- a/gdb/testsuite/gdb.ada/unchecked_union.exp +++ b/gdb/testsuite/gdb.ada/unchecked_union.exp @@ -51,11 +51,8 @@ set pair_string { case ? is } set pair_full "type = record\n${inner_string}${pair_string}end record" -foreach_with_prefix scenario {none all minimal} { - set flags {debug} - if {$scenario != "none"} { - lappend flags additional_flags=-fgnat-encodings=$scenario - } +foreach_gnat_encoding scenario flags {none all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/var_rec_arr.exp b/gdb/testsuite/gdb.ada/var_rec_arr.exp index a8591089ba8..20598ea708c 100644 --- a/gdb/testsuite/gdb.ada/var_rec_arr.exp +++ b/gdb/testsuite/gdb.ada/var_rec_arr.exp @@ -22,8 +22,8 @@ standard_ada_testfile foo_na09_042 # Note we don't test the "none" (no -fgnat-encodings option) scenario # here, because "all" and "minimal" cover the cases, and this way we # don't have to update the test when gnat changes its default. -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/variant.exp b/gdb/testsuite/gdb.ada/variant.exp index 9fbc449758a..227331c3ac0 100644 --- a/gdb/testsuite/gdb.ada/variant.exp +++ b/gdb/testsuite/gdb.ada/variant.exp @@ -20,11 +20,8 @@ require allow_ada_tests standard_ada_testfile pkg -foreach_with_prefix scenario {none all minimal} { - set flags {debug} - if {$scenario != "none"} { - lappend flags additional_flags=-fgnat-encodings=$scenario - } +foreach_gnat_encoding scenario flags {none all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/gdb.ada/variant_record_packed_array.exp b/gdb/testsuite/gdb.ada/variant_record_packed_array.exp index f6b4e4171a8..8f4192cfd49 100644 --- a/gdb/testsuite/gdb.ada/variant_record_packed_array.exp +++ b/gdb/testsuite/gdb.ada/variant_record_packed_array.exp @@ -19,8 +19,8 @@ require allow_ada_tests standard_ada_testfile foo -foreach_with_prefix scenario {all minimal} { - set flags [list debug additional_flags=-fgnat-encodings=$scenario] +foreach_gnat_encoding scenario flags {all minimal} { + lappend flags debug if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} { return -1 diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp index 1bc0dc1d438..0544544acbe 100644 --- a/gdb/testsuite/lib/ada.exp +++ b/gdb/testsuite/lib/ada.exp @@ -13,6 +13,25 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# A wrapper for foreach_with_prefix that applies suitable +# -fgnat-encodings arguments to a command line. SCENARIO_ARG is the +# name of a loop variable that will hold the scenario currently being +# evaluated. FLAGS_ARG will be set to the appropriate compiler flags +# (if any) for this scenario. LIST is the list of desired scenarios +# to run, and BODY is what actually does the work. + +proc foreach_gnat_encoding {scenario_arg flags_arg list body} { + upvar 1 $scenario_arg scenario + upvar 1 $flags_arg flags + foreach_with_prefix scenario $list { + set flags {} + if {$scenario != "none"} { + lappend flags additional_flags=-fgnat-encodings=$scenario + } + uplevel 1 $body + } +} + # Call target_compile with SOURCE DEST TYPE and OPTIONS as argument, # after having temporarily changed the current working directory to # BUILDDIR.