Home | History | Annotate | Line # | Download | only in gdb.dwarf2
dw2-line-number-zero.exp revision 1.1.1.1
      1  1.1  christos # Copyright 2020 Free Software Foundation, Inc.
      2  1.1  christos 
      3  1.1  christos # This program is free software; you can redistribute it and/or modify
      4  1.1  christos # it under the terms of the GNU General Public License as published by
      5  1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6  1.1  christos # (at your option) any later version.
      7  1.1  christos #
      8  1.1  christos # This program is distributed in the hope that it will be useful,
      9  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  1.1  christos # GNU General Public License for more details.
     12  1.1  christos #
     13  1.1  christos # You should have received a copy of the GNU General Public License
     14  1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  1.1  christos load_lib dwarf.exp
     16  1.1  christos 
     17  1.1  christos # This test can only be run on targets which support DWARF-2 and use gas.
     18  1.1  christos if {![dwarf2_support]} {
     19  1.1  christos     verbose "Skipping dw2-line-number-zero test."
     20  1.1  christos     return 0
     21  1.1  christos }
     22  1.1  christos 
     23  1.1  christos # The .c files use __attribute__.
     24  1.1  christos if [get_compiler_info] {
     25  1.1  christos     return -1
     26  1.1  christos }
     27  1.1  christos if !$gcc_compiled {
     28  1.1  christos     verbose "Skipping dw2-line-number-zero test."
     29  1.1  christos     return 0
     30  1.1  christos }
     31  1.1  christos 
     32  1.1  christos standard_testfile .c dw2-line-number-zero-dw.S
     33  1.1  christos 
     34  1.1  christos set asm_file [standard_output_file $srcfile2]
     35  1.1  christos Dwarf::assemble $asm_file {
     36  1.1  christos     declare_labels Llines
     37  1.1  christos     global srcdir subdir srcfile
     38  1.1  christos 
     39  1.1  christos     cu {} {
     40  1.1  christos 	compile_unit {
     41  1.1  christos 	    {language @DW_LANG_C}
     42  1.1  christos 	    {name dw2-line-number-zero.c}
     43  1.1  christos 	    {stmt_list $Llines DW_FORM_sec_offset}
     44  1.1  christos 	} {
     45  1.1  christos 	    subprogram {
     46  1.1  christos 		{external 1 flag}
     47  1.1  christos 		{MACRO_AT_func {main}}
     48  1.1  christos 	    }
     49  1.1  christos 	    subprogram {
     50  1.1  christos 		{external 1 flag}
     51  1.1  christos 		{MACRO_AT_func {bar1}}
     52  1.1  christos 	    }
     53  1.1  christos 	    subprogram {
     54  1.1  christos 		{external 1 flag}
     55  1.1  christos 		{MACRO_AT_func {bar2}}
     56  1.1  christos 	    }
     57  1.1  christos 	}
     58  1.1  christos     }
     59  1.1  christos 
     60  1.1  christos     lines {version 2} Llines {
     61  1.1  christos 	include_dir "${srcdir}/${subdir}"
     62  1.1  christos 	file_name "$srcfile" 1
     63  1.1  christos 
     64  1.1  christos 	program {
     65  1.1  christos 	    {DW_LNE_set_address bar1_label}
     66  1.1  christos 	    {line 27}
     67  1.1  christos 	    {DW_LNS_copy}
     68  1.1  christos 
     69  1.1  christos 	    {DW_LNE_set_address bar1_label_2}
     70  1.1  christos 	    {line 29}
     71  1.1  christos 	    {DW_LNS_copy}
     72  1.1  christos 
     73  1.1  christos 	    {DW_LNE_set_address bar1_label_3}
     74  1.1  christos 	    {line 0}
     75  1.1  christos 	    {DW_LNS_copy}
     76  1.1  christos 
     77  1.1  christos 	    {DW_LNE_set_address bar1_label_4}
     78  1.1  christos 	    {line 33}
     79  1.1  christos 	    {DW_LNS_copy}
     80  1.1  christos 
     81  1.1  christos 	    {DW_LNE_set_address bar1_label_5}
     82  1.1  christos 	    {DW_LNE_end_sequence}
     83  1.1  christos 
     84  1.1  christos 
     85  1.1  christos 	    {DW_LNE_set_address bar2_label}
     86  1.1  christos 	    {line 41}
     87  1.1  christos 	    {DW_LNS_copy}
     88  1.1  christos 
     89  1.1  christos 	    {DW_LNE_set_address bar2_label_2}
     90  1.1  christos 	    {line 43}
     91  1.1  christos 	    {DW_LNS_copy}
     92  1.1  christos 
     93  1.1  christos 	    {DW_LNE_set_address bar2_label_3}
     94  1.1  christos 	    {line 0}
     95  1.1  christos 	    {DW_LNS_negate_stmt}
     96  1.1  christos 	    {DW_LNS_copy}
     97  1.1  christos 	    {DW_LNS_negate_stmt}
     98  1.1  christos 
     99  1.1  christos 	    {DW_LNE_set_address bar2_label_4}
    100  1.1  christos 	    {line 47}
    101  1.1  christos 	    {DW_LNS_copy}
    102  1.1  christos 
    103  1.1  christos 	    {DW_LNE_set_address bar2_label_5}
    104  1.1  christos 	    {DW_LNE_end_sequence}
    105  1.1  christos 	}
    106  1.1  christos     }
    107  1.1  christos }
    108  1.1  christos 
    109  1.1  christos if { [prepare_for_testing "failed to prepare" ${testfile} \
    110  1.1  christos 	  [list $srcfile $asm_file] {nodebug}] } {
    111  1.1  christos     return -1
    112  1.1  christos }
    113  1.1  christos 
    114  1.1  christos if ![runto_main] {
    115  1.1  christos     return -1
    116  1.1  christos }
    117  1.1  christos 
    118  1.1  christos gdb_breakpoint "$srcfile:27"
    119  1.1  christos gdb_continue_to_breakpoint "bar1" "\[^\r\n\]*:27\r\n.*"
    120  1.1  christos 
    121  1.1  christos gdb_test "n" "foo \\(2\\);" "bar1, 1st next"
    122  1.1  christos gdb_test "n" "foo \\(4\\);" "bar1, 2nd next"
    123  1.1  christos 
    124  1.1  christos gdb_breakpoint "$srcfile:41"
    125  1.1  christos gdb_continue_to_breakpoint "bar2" "\[^\r\n\]*:41\r\n.*"
    126  1.1  christos 
    127  1.1  christos gdb_test "n" "foo \\(2\\);" "bar2, 1st next"
    128  1.1  christos gdb_test "n" "foo \\(4\\);" "bar2, 2nd next"
    129  1.1  christos 
    130  1.1  christos if ![runto_main] {
    131  1.1  christos     return -1
    132  1.1  christos }
    133  1.1  christos 
    134  1.1  christos gdb_breakpoint "bar1_label_3"
    135  1.1  christos setup_kfail "gdb/nnnnn" *-*-*
    136  1.1  christos gdb_continue_to_breakpoint "bar1_label_3" "bar1 \\(\\)"
    137  1.1  christos 
    138  1.1  christos gdb_breakpoint "bar2_label_3"
    139  1.1  christos setup_kfail "gdb/nnnnn" *-*-*
    140  1.1  christos gdb_continue_to_breakpoint "bar2_label_3" "bar2 \\(\\)"
    141