1 1.11 christos # Copyright 2007-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.11 christos require allow_xml_test 17 1.1 christos 18 1.1 christos gdb_start 19 1.1 christos 20 1.1 christos # Find some valid architectures - we just need legitimate values 21 1.1 christos # to put in our <architecture> elements. 22 1.1 christos set arch1 "" 23 1.1 christos set arch2 "" 24 1.1 christos set msg "read valid architectures" 25 1.1 christos gdb_test_multiple "set architecture" $msg { 26 1.1 christos -re "Requires an argument. Valid arguments are (\[^ \]*), (\[^ \]*), .*auto\\.\r\n$gdb_prompt $" { 27 1.1 christos set arch1 $expect_out(1,string) 28 1.1 christos set arch2 $expect_out(2,string) 29 1.1 christos pass $msg 30 1.1 christos } 31 1.1 christos -re "Requires an argument. Valid arguments are (\[^ \]*), auto\\.\r\n$gdb_prompt $" { 32 1.1 christos # If there is just one supported architecture, we can't do this test. 33 1.1 christos unsupported "tdesc-arch.exp" 34 1.1 christos return -1 35 1.1 christos } 36 1.1 christos } 37 1.1 christos 38 1.1 christos set default_arch "" 39 1.1 christos set msg "read default architecture" 40 1.1 christos gdb_test_multiple "show architecture" $msg { 41 1.9 christos -re "The target architecture is set to \"auto\" \\(currently \"(\[^ \]*)\"\\)\\.\r\n$gdb_prompt $" { 42 1.1 christos set default_arch $expect_out(1,string) 43 1.1 christos pass $msg 44 1.1 christos } 45 1.1 christos } 46 1.1 christos 47 1.1 christos # If that did not work, no point running further tests. 48 1.1 christos if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } { 49 1.1 christos unresolved "architecture XML tests" 50 1.1 christos return -1 51 1.1 christos } 52 1.1 christos 53 1.1 christos # Run these tests twice, once for $arch1 and once for $arch2, to 54 1.1 christos # make sure that the tdesc file overrides the global default. 55 1.9 christos # TRANS_MODE indicates how newlines should be represented; it should 56 1.9 christos # be one of the values supported by "fconfigure -translation". 57 1.1 christos 58 1.9 christos proc set_arch { arch which trans_mode } { 59 1.1 christos global gdb_prompt 60 1.1 christos global subdir 61 1.1 christos 62 1.1 christos set filename [standard_output_file tdesc-arch.xml] 63 1.1 christos set fd [open $filename w] 64 1.9 christos fconfigure $fd -translation $trans_mode 65 1.1 christos puts $fd \ 66 1.1 christos "<target> 67 1.1 christos <architecture>$arch</architecture> 68 1.1 christos </target>" 69 1.1 christos close $fd 70 1.1 christos if {[is_remote host]} { 71 1.1 christos set filename [remote_download host $filename tdesc-arch.xml] 72 1.1 christos } 73 1.1 christos 74 1.1 christos # Anchor the test output, so that error messages are detected. 75 1.1 christos set cmd "set tdesc filename $filename" 76 1.12 christos set msg "set tdesc filename tdesc-arch.xml, $which architecture" 77 1.1 christos set cmd_regex [string_to_regexp $cmd] 78 1.1 christos gdb_test_multiple $cmd $msg { 79 1.1 christos -re "^$cmd_regex\r\n$gdb_prompt $" { 80 1.1 christos pass $msg 81 1.1 christos } 82 1.1 christos -re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" { 83 1.1 christos kfail gdb/2225 $msg 84 1.1 christos } 85 1.1 christos } 86 1.1 christos 87 1.1 christos set cmd "show architecture" 88 1.1 christos gdb_test $cmd \ 89 1.9 christos "The target architecture is set to \"auto\" \\(currently \"$arch\"\\)\\." \ 90 1.12 christos "$cmd, $which architecture" 91 1.1 christos 92 1.1 christos remote_file host delete $filename 93 1.1 christos } 94 1.1 christos 95 1.9 christos set_arch $arch1 first lf 96 1.9 christos set_arch $arch2 second lf 97 1.9 christos 98 1.9 christos with_test_prefix crlf { 99 1.9 christos set_arch $arch1 first crlf 100 1.9 christos set_arch $arch2 second crlf 101 1.9 christos } 102 1.1 christos 103 1.1 christos # Check an invalid architecture setting. 104 1.1 christos set filename [standard_output_file tdesc-arch.xml] 105 1.1 christos set fd [open $filename w] 106 1.1 christos puts $fd \ 107 1.1 christos "<target> 108 1.1 christos <architecture>invalid</architecture> 109 1.1 christos </target>" 110 1.1 christos close $fd 111 1.1 christos if {[is_remote host]} { 112 1.1 christos set filename [remote_download host $filename "tdesc-arch.xml"] 113 1.1 christos } 114 1.1 christos 115 1.1 christos set cmd "set tdesc filename $filename" 116 1.1 christos gdb_test $cmd \ 117 1.1 christos "warning:.*Target description specified unknown architecture.*" \ 118 1.12 christos "set tdesc filename tdesc-arch.xml, invalid architecture" 119 1.1 christos 120 1.1 christos set cmd "show architecture" 121 1.1 christos gdb_test $cmd \ 122 1.9 christos "The target architecture is set to \"auto\" \\(currently \"$default_arch\"\\)\\." \ 123 1.12 christos "$cmd, invalid architecture" 124 1.1 christos 125 1.1 christos remote_file host delete $filename 126