1# Copyright 2021-2024 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 16load_lib dwarf.exp 17 18# This test can only be run on targets which support DWARF-2. 19require dwarf2_support 20 21# The current implementation of ensure_gdb_index doesn't work on remote host. 22require {!is_remote host} 23 24standard_testfile main.c 25 26# First check whether we can actually handle the non-symlink case. 27with_test_prefix non-symlink { 28 if { [prepare_for_testing "failed to prepare" "${testfile}" \ 29 [list ${srcfile}]] } { 30 return -1 31 } 32 33 if { [ensure_gdb_index $binfile] == -1 } { 34 untested "error adding gdb index" 35 return -1 36 } 37} 38 39# Regenerate exec without index. 40if { [prepare_for_testing "failed to prepare" "${testfile}" \ 41 [list ${srcfile}]] } { 42 return -1 43} 44 45set symlink [file dirname $binfile]/symlink 46 47if { ![file exists $symlink] } { 48 file link -symbolic $symlink $binfile 49} 50 51if { [ensure_gdb_index $symlink] == -1 } { 52 fail "Unable to call gdb-add-index with a symlink to a symfile" 53 return -1 54} 55 56# Ok, we have a copy of $binfile with an index. 57# Restart gdb and verify the index was used. 58 59clean_restart $symlink 60gdb_test "mt print objfiles ${testfile}" \ 61 "(gdb_index|debug_names).*" \ 62 "index used" 63