1 1.1 christos # This testcase is part of GDB, the GNU debugger. 2 1.1 christos # 3 1.1 christos # Copyright 2019-2020 Free Software Foundation, Inc. 4 1.1 christos # 5 1.1 christos # This program is free software; you can redistribute it and/or modify 6 1.1 christos # it under the terms of the GNU General Public License as published by 7 1.1 christos # the Free Software Foundation; either version 3 of the License, or 8 1.1 christos # (at your option) any later version. 9 1.1 christos # 10 1.1 christos # This program is distributed in the hope that it will be useful, 11 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 christos # GNU General Public License for more details. 14 1.1 christos # 15 1.1 christos # You should have received a copy of the GNU General Public License 16 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 1.1 christos 18 1.1 christos # Test that GDB can correctly read the binary and shared libraries 19 1.1 christos # with different sysroot setups: local and "target:". 20 1.1 christos 21 1.1 christos load_lib gdbserver-support.exp 22 1.1 christos 23 1.1 christos if { [skip_gdbserver_tests] } { 24 1.1 christos verbose "skipping gdbserver tests" 25 1.1 christos return -1 26 1.1 christos } 27 1.1 christos 28 1.1 christos standard_testfile 29 1.1 christos if {[build_executable "failed to prepare" $testfile $srcfile "additional_flags=--no-builtin"] == -1} { 30 1.1 christos return -1 31 1.1 christos } 32 1.1 christos 33 1.1 christos # Run once with sysroot set to the local filesystem and once set to the remote 34 1.1 christos # target. 35 1.1 christos foreach_with_prefix sysroot { "local" "remote" } { 36 1.1 christos global srcdir 37 1.1 christos global subdir 38 1.1 christos global binfile 39 1.1 christos 40 1.1 christos if { $sysroot == "local" } { 41 1.1 christos set sysroot_command "/" 42 1.1 christos set reading_symbols "Reading symbols from $binfile..." 43 1.1 christos } else { 44 1.1 christos set sysroot_command "target:" 45 1.1 christos set reading_symbols "Reading $binfile from remote target..." 46 1.1 christos } 47 1.1 christos 48 1.1 christos # Restart GDB. 49 1.1 christos clean_restart 50 1.1 christos 51 1.1 christos # Make sure we're disconnected, in case we're testing with an 52 1.1 christos # extended-remote board, therefore already connected. 53 1.1 christos gdb_test "disconnect" ".*" 54 1.1 christos 55 1.1 christos # Start GDBserver. 56 1.1 christos set res [gdbserver_start "" $binfile] 57 1.1 christos set gdbserver_protocol [lindex $res 0] 58 1.1 christos set gdbserver_gdbport [lindex $res 1] 59 1.1 christos 60 1.1 christos # Set the sysroot. 61 1.1 christos gdb_test_no_output "set sysroot $sysroot_command" 62 1.1 christos 63 1.1 christos # Connect to gdbserver, making sure GDB reads in the binary correctly. 64 1.1 christos set test "connect to remote and read binary" 65 1.1 christos if {[gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport $reading_symbols] == 0} { 66 1.1 christos pass $test 67 1.1 christos } else { 68 1.1 christos fail $test 69 1.1 christos } 70 1.1 christos 71 1.1 christos gdb_breakpoint main 72 1.1 christos gdb_test "continue" "Breakpoint $decimal.* main.*" "continue to main" 73 1.1 christos 74 1.1 christos # Test that we can stop inside a library. 75 1.1 christos gdb_breakpoint printf 76 1.1 christos gdb_test "continue" "Breakpoint $decimal.* (__)?printf .*" \ 77 1.1 christos "continue to printf" 78 1.1 christos } 79