1# Copyright (C) 2018-2023 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# Test automatic endianness selection. 17 18standard_testfile 19 20set en_auto "The target endianness is set automatically" 21set en_set "The target is set to" 22 23clean_restart 24 25# First check that the automatic endianness is updated 26# with the `set endian' command. 27gdb_test "set endian auto" \ 28 "$en_auto \\\(currently \(\?:big\|little\) endian\\\)\\." \ 29 "default target endianness" 30gdb_test "set endian big" "$en_set big endian\\." \ 31 "set target endianness" 32gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \ 33 "auto target endianness" 34gdb_test "set endian little" "$en_set little endian\\." \ 35 "set target endianness little" 36gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)\\." \ 37 "auto target endianness little" 38gdb_test "set endian big" "$en_set big endian\\." \ 39 "set target endianness big" 40gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \ 41 "auto target endianness big" 42 43if { [build_executable ${testfile}.exp $testfile] } { 44 untested "failed to compile" 45 return 46} 47 48gdb_file_cmd $binfile 49 50set test "get target endianness" 51if { [gdb_test_multiple "show endian" "$test" { 52 -re "$en_auto \\\(currently \(big\|little\) endian\\\)\\..*$gdb_prompt" { 53 set endian $expect_out(1,string) 54 pass "$test" 55 } 56}] } { 57 return 58} 59 60# Now check that the automatic endianness is updated 61# according to the executable selected. 62gdb_unload "unload 1" 63gdb_test "set endian big" "$en_set big endian\\." \ 64 "override target endianness big" 65gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \ 66 "override auto target endianness big" 67 68gdb_file_cmd $binfile 69gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ 70 "previously big default executable endianness" 71 72gdb_unload "unload 2" 73gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ 74 "previously big default no executable endianness" 75gdb_test "set endian little" "$en_set little endian\\." \ 76 "override target endianness little" 77gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)\\." \ 78 "override auto target endianness little" 79 80gdb_file_cmd $binfile 81gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ 82 "previously little default executable endianness" 83 84gdb_unload "unload 3" 85gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ 86 "previously little default no executable endianness" 87