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 # 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 require dwarf2_support
     23 
     24 # The .c files use __attribute__.
     25 require is_c_compiler_gcc
     26 
     27 standard_testfile main.c -dw.S
     28 
     29 set func_info_vars [get_func_info main]
     30 
     31 set asm_file [standard_output_file $srcfile2]
     32 Dwarf::assemble $asm_file {
     33     declare_labels Llines
     34     global srcdir subdir srcfile
     35     global func_info_vars
     36     foreach var $func_info_vars {
     37 	global $var
     38     }
     39 
     40     cu {} {
     41 	compile_unit {
     42 	    {language @DW_LANG_C}
     43 	    {name $srcfile}
     44 	    {stmt_list $Llines DW_FORM_sec_offset}
     45 	} {
     46 	    subprogram {
     47 		{external 1 flag}
     48 		{name main}
     49 		{low_pc $main_start}
     50 		{high_pc $main_end addr}
     51 	    }
     52 	}
     53     }
     54 
     55     lines {version 2} Llines {
     56 	include_dir "${srcdir}/${subdir}"
     57 	file_name "$srcfile" 1
     58 
     59 	program {
     60 	    DW_LNE_set_address $main_start
     61 	    line 1
     62 	    DW_LNS_copy
     63 
     64 	    DW_LNE_set_address $main_end
     65 	    DW_LNE_end_sequence
     66 
     67 	    DW_LNE_set_address 0
     68 	    line 2
     69 	    DW_LNS_copy
     70 
     71 	    DW_LNS_advance_pc 1
     72 	    DW_LNE_end_sequence
     73 	}
     74     }
     75 }
     76 
     77 if { [prepare_for_testing "failed to prepare" ${testfile} \
     78 	  [list $srcfile $asm_file] {nodebug}] } {
     79     return -1
     80 }
     81 
     82 if ![runto_main] {
     83     return -1
     84 }
     85 
     86 set test "END with address 1 eliminated"
     87 gdb_test_multiple "maint info line-table \\b$srcfile$" $test {
     88     -re -wrap "END *0x0*1 *$hex *Y *\r\n.*" {
     89 	fail $gdb_test_name
     90     }
     91     -re -wrap "END *$hex *$hex *Y *\r\n" {
     92 	pass $gdb_test_name
     93     }
     94 }
     95