[PATCH 2/7] PowerPC/testsuite: Reduce feature tests in terms of `allow_target_tests'
"Maciej W. Rozycki" <[email protected]> Thu, 23 Jul 2026 19:52:51 +0100 (BST)
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
From: Maciej W. Rozycki <[email protected]> Reimplement `allow_altivec_tests', `allow_power_isa_3_1_tests', and `allow_vsx_tests' in terms of `allow_target_tests', removing duplicate code. No functional change. Eventually it may make sense to migrate the resulting wrappers to testsuite/gdb.arch/ so as to declutter generic test framework from target-specific stuff. --- gdb/testsuite/lib/gdb.exp | 163 +++++++++------------------------------------- 1 file changed, 35 insertions(+), 128 deletions(-) gdb-powerpc-test-target-allow.diff Index: binutils-gdb/gdb/testsuite/lib/gdb.exp =================================================================== --- binutils-gdb.orig/gdb/testsuite/lib/gdb.exp +++ binutils-gdb/gdb/testsuite/lib/gdb.exp @@ -4333,8 +4333,6 @@ proc allow_target_tests { me feature mes # 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite. gdb_caching_proc allow_altivec_tests {} { - global srcdir subdir gdb_prompt inferior_exited_re - set me "allow_altivec_tests" # Some simulators are known to not support VMX instructions. @@ -4350,110 +4348,47 @@ gdb_caching_proc allow_altivec_tests {} # Make sure we have a compiler that understands altivec. if {[test_compiler_info gcc*]} { - set compile_flags "additional_flags=-maltivec" + set flags "-maltivec" } elseif {[test_compiler_info xlc*]} { - set compile_flags "additional_flags=-qaltivec" + set flags "-qaltivec" } else { verbose "Could not compile with altivec support, returning 0" 2 return 0 } # Compile a test program containing VMX instructions. - set src { - int main() { - #ifdef __MACH__ - asm volatile ("vor v0,v0,v0"); - #else - asm volatile ("vor 0,0,0"); - #endif - return 0; - } - } - if {![gdb_simple_compile $me $src executable $compile_flags]} { - return 0 - } - - # Compilation succeeded so now run it via gdb. - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - gdb_load "$obj" - gdb_run_cmd - gdb_expect { - -re ".*Illegal instruction.*${gdb_prompt} $" { - verbose -log "\n$me altivec hardware not detected" - set allow_vmx_tests 0 - } - -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { - verbose -log "\n$me: altivec hardware detected" - set allow_vmx_tests 1 - } - default { - warning "\n$me: default case taken" - set allow_vmx_tests 0 - } - } - gdb_exit - remote_file build delete $obj - - verbose "$me: returning $allow_vmx_tests" 2 - return $allow_vmx_tests + return [allow_target_tests $me "altivec hardware" "Illegal instruction" \ + { + int main() { + #ifdef __MACH__ + asm volatile ("vor v0,v0,v0"); + #else + asm volatile ("vor 0,0,0"); + #endif + return 0; + } + } \ + $flags] } # Run a test on the power target to see if it supports ISA 3.1 instructions gdb_caching_proc allow_power_isa_3_1_tests {} { - global srcdir subdir gdb_prompt inferior_exited_re - - set me "allow_power_isa_3_1_tests" - # Compile a test program containing ISA 3.1 instructions. - set src { - int main() { - asm volatile ("pnop"); // marker + return [allow_target_tests "allow_power_isa_3_1_tests" \ + "Power ISA 3.1 hardware" "Illegal instruction" \ + { + int main() { + asm volatile ("pnop"); // marker asm volatile ("nop"); return 0; } - } - - if {![gdb_simple_compile $me $src executable ]} { - return 0 - } - - # No error message, compilation succeeded so now run it via gdb. - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - gdb_load "$obj" - gdb_run_cmd - gdb_expect { - -re ".*Illegal instruction.*${gdb_prompt} $" { - verbose -log "\n$me Power ISA 3.1 hardware not detected" - set allow_power_isa_3_1_tests 0 - } - -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { - verbose -log "\n$me: Power ISA 3.1 hardware detected" - set allow_power_isa_3_1_tests 1 - } - default { - warning "\n$me: default case taken" - set allow_power_isa_3_1_tests 0 - } - } - gdb_exit - remote_file build delete $obj - - verbose "$me: returning $allow_power_isa_3_1_tests" 2 - return $allow_power_isa_3_1_tests + }] } # Run a test on the target to see if it supports vmx hardware. Return 1 if so, # 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite. gdb_caching_proc allow_vsx_tests {} { - global srcdir subdir gdb_prompt inferior_exited_re - set me "allow_vsx_tests" # Some simulators are known to not support Altivec instructions, so @@ -4465,56 +4400,28 @@ gdb_caching_proc allow_vsx_tests {} { # Make sure we have a compiler that understands altivec. if {[test_compiler_info gcc*]} { - set compile_flags "additional_flags=-mvsx" + set flags "-mvsx" } elseif {[test_compiler_info xlc*]} { - set compile_flags "additional_flags=-qasm=gcc" + set flags "-qasm=gcc" } else { verbose "Could not compile with vsx support, returning 0" 2 return 0 } # Compile a test program containing VSX instructions. - set src { - int main() { - double a[2] = { 1.0, 2.0 }; - #ifdef __MACH__ - asm volatile ("lxvd2x v0,v0,%[addr]" : : [addr] "r" (a)); - #else - asm volatile ("lxvd2x 0,0,%[addr]" : : [addr] "r" (a)); - #endif - return 0; - } - } - if {![gdb_simple_compile $me $src executable $compile_flags]} { - return 0 - } - - # No error message, compilation succeeded so now run it via gdb. - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - gdb_load "$obj" - gdb_run_cmd - gdb_expect { - -re ".*Illegal instruction.*${gdb_prompt} $" { - verbose -log "\n$me VSX hardware not detected" - set allow_vsx_tests 0 - } - -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { - verbose -log "\n$me: VSX hardware detected" - set allow_vsx_tests 1 - } - default { - warning "\n$me: default case taken" - set allow_vsx_tests 0 - } - } - gdb_exit - remote_file build delete $obj - - verbose "$me: returning $allow_vsx_tests" 2 - return $allow_vsx_tests + return [allow_target_tests $me "VSX hardware" "Illegal instruction" \ + { + int main() { + double a[2] = { 1.0, 2.0 }; + #ifdef __MACH__ + asm volatile ("lxvd2x v0,v0,%[addr]" : : [addr] "r" (a)); + #else + asm volatile ("lxvd2x 0,0,%[addr]" : : [addr] "r" (a)); + #endif + return 0; + } + } \ + $flags] } # Run a test on the target to see if it supports TSX hardware. Return 1 if so,