xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp (revision 4439cfd0acf9c7dc90625e5cd83b2317a9ab8967)
1# Copyright 2021-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
16load_lib dwarf.exp
17
18standard_testfile main.c
19
20if {[prepare_for_testing "failed to prepare" "${testfile}" \
21	 [list ${srcfile}] {nodebug}]} {
22    return -1
23}
24
25set have_index [have_index $binfile]
26set have_index_re \
27    [list \
28	 "Error while writing index for \[^\r\n\]*:" \
29	 "Cannot use an index to create the index"]
30set have_index_re [join $have_index_re]
31set no_debug_re \
32    [list \
33	 "Error while writing index for \[^\r\n\]*:" \
34	 "No debugging symbols"]
35set no_debug_re [join $no_debug_re]
36set readnow_p [readnow]
37
38set index_file ${testfile}.gdb-index
39# The bug was that gdb would crash here.
40set cmd "save gdb-index [file dirname ${index_file}]"
41gdb_test_multiple $cmd "try to save gdb index" {
42    -re -wrap $have_index_re {
43	if { $have_index != "" || $readnow_p } {
44	    unsupported $gdb_test_name
45	} else {
46	    fail $gdb_test_name
47	}
48    }
49    -re -wrap $no_debug_re {
50	pass $gdb_test_name
51    }
52    -re -wrap "^$cmd" {
53	pass $gdb_test_name
54    }
55}
56