standard_testfile
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
-set test "complete set gnutarget"
-gdb_test_multiple "complete set gnutarget " $test {
- -re "set gnutarget elf64-little\r\n(.*\r\n)?$gdb_prompt $" {
- pass $test
- }
- -re "\r\n$gdb_prompt $" {
- pass $test
- untested ".text is readable"
- return
- }
+set gnutargets [get_set_option_choices "set gnutarget"]
+if { [lsearch -exact $gnutargets elf64-little] == -1 } {
+ untested ".text is readable"
+ return
}
set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2
# First check if this particular GDB supports i386, otherwise we should not
# expect the i386 core file to be loaded successfully.
-set supports_arch_i386 1
-set test "complete set architecture i386"
-gdb_test_multiple $test $test {
- -re "\r\nset architecture i386\r\n(.*\r\n)?$gdb_prompt $" {
- }
- -re "\r\n$gdb_prompt $" {
- set supports_arch_i386 0
- }
-}
+set archs [get_set_option_choices "set architecture" "i386"]
+set supports_arch_i386 [expr [lsearch -exact $archs i386] != -1]
# Wrongly built GDB complains by:
# "..." is not a core dump: File format not recognized
return $has_hw_wp_support
}
-# Return a list of all the accepted values of the set command SET_CMD.
+# Return a list of all the accepted values of the set command
+# "SET_CMD SET_ARG".
+# For example get_set_option_choices "set architecture" "i386".
-proc get_set_option_choices {set_cmd} {
+proc get_set_option_choices { set_cmd {set_arg ""} } {
set values {}
- set cmd "complete $set_cmd "
- set test "complete $set_cmd"
+ if { $set_arg == "" } {
+ # Add trailing space to signal that we need completion of the choices,
+ # not of set_cmd itself.
+ set cmd "complete $set_cmd "
+ } else {
+ set cmd "complete $set_cmd $set_arg"
+ }
+
+ # Set test name without trailing space.
+ set test [string trim $cmd]
with_set max-completions unlimited {
gdb_test_multiple $cmd $test {