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