Home | History | Annotate | Line # | Download | only in gdb.dwarf2
      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 
     16 load_lib dwarf.exp
     17 
     18 standard_testfile main.c
     19 
     20 if {[prepare_for_testing "failed to prepare" "${testfile}" \
     21 	 [list ${srcfile}] {nodebug}]} {
     22     return -1
     23 }
     24 
     25 set have_index [have_index $binfile]
     26 set have_index_re \
     27     [list \
     28 	 "Error while writing index for \[^\r\n\]*:" \
     29 	 "Cannot use an index to create the index"]
     30 set have_index_re [join $have_index_re]
     31 set no_debug_re \
     32     [list \
     33 	 "Error while writing index for \[^\r\n\]*:" \
     34 	 "No debugging symbols"]
     35 set no_debug_re [join $no_debug_re]
     36 set readnow_p [readnow]
     37 
     38 set index_dir [host_standard_output_file ""]
     39 # The bug was that gdb would crash here.
     40 set cmd "save gdb-index $index_dir"
     41 gdb_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 "^" {
     53 	pass $gdb_test_name
     54     }
     55 }
     56