Home | History | Annotate | Line # | Download | only in gdb.dwarf2
dw2-out-of-range-end-of-seq.exp revision 1.1.1.1
      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 
     16 # Check that an out-of-range DW_LNE_end_sequence is removed from the
     17 # line table.
     18 
     19 load_lib dwarf.exp
     20 
     21 # This test can only be run on targets which support DWARF-2 and use gas.
     22 if {![dwarf2_support]} {
     23     verbose "Skipping $gdb_test_file_name."
     24     return 0
     25 }
     26 
     27 # The .c files use __attribute__.
     28 if ![is_c_compiler_gcc] {
     29     verbose "Skipping $gdb_test_file_name."
     30     return 0
     31 }
     32 
     33 standard_testfile main.c -dw.S
     34 
     35 set func_info_vars [get_func_info main]
     36 
     37 set asm_file [standard_output_file $srcfile2]
     38 Dwarf::assemble $asm_file {
     39     declare_labels Llines
     40     global srcdir subdir srcfile
     41     global func_info_vars
     42     foreach var $func_info_vars {
     43 	global $var
     44     }
     45 
     46     cu {} {
     47 	compile_unit {
     48 	    {language @DW_LANG_C}
     49 	    {name $srcfile}
     50 	    {stmt_list $Llines DW_FORM_sec_offset}
     51 	} {
     52 	    subprogram {
     53 		{external 1 flag}
     54 		{name main}
     55 		{low_pc $main_start}
     56 		{high_pc $main_end addr}
     57 	    }
     58 	}
     59     }
     60 
     61     lines {version 2} Llines {
     62 	include_dir "${srcdir}/${subdir}"
     63 	file_name "$srcfile" 1
     64 
     65 	program {
     66 	    DW_LNE_set_address $main_start
     67 	    line 1
     68 	    DW_LNS_copy
     69 
     70 	    DW_LNE_set_address $main_end
     71 	    DW_LNE_end_sequence
     72 
     73 	    DW_LNE_set_address 0
     74 	    line 2
     75 	    DW_LNS_copy
     76 
     77 	    DW_LNS_advance_pc 1
     78 	    DW_LNE_end_sequence
     79 	}
     80     }
     81 }
     82 
     83 if { [prepare_for_testing "failed to prepare" ${testfile} \
     84 	  [list $srcfile $asm_file] {nodebug}] } {
     85     return -1
     86 }
     87 
     88 if ![runto_main] {
     89     return -1
     90 }
     91 
     92 set test "END with address 1 eliminated"
     93 gdb_test_multiple "maint info line-table $srcfile$" $test {
     94     -re -wrap "END *0x0*1 *Y *\r\n.*" {
     95 	fail $gdb_test_name
     96     }
     97     -re -wrap "END *$hex *Y *" {
     98 	pass $gdb_test_name
     99     }
    100 }
    101