1 # Copyright 2020-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 load_lib dwarf.exp 16 17 # This test can only be run on targets which support DWARF-2 and use gas. 18 require dwarf2_support 19 20 # The .c files use __attribute__. 21 require is_c_compiler_gcc 22 23 standard_testfile .c -dw.S 24 25 set asm_file [standard_output_file $srcfile2] 26 Dwarf::assemble $asm_file { 27 declare_labels Llines 28 global srcdir subdir srcfile 29 30 get_func_info bar1 31 get_func_info bar2 32 33 cu {} { 34 compile_unit { 35 {language @DW_LANG_C} 36 {name dw2-line-number-zero.c} 37 {stmt_list $Llines DW_FORM_sec_offset} 38 } { 39 subprogram { 40 {external 1 flag} 41 {MACRO_AT_func {main}} 42 } 43 subprogram { 44 {external 1 flag} 45 {MACRO_AT_func {bar1}} 46 } 47 subprogram { 48 {external 1 flag} 49 {MACRO_AT_func {bar2}} 50 } 51 } 52 } 53 54 lines {version 2} Llines { 55 include_dir "${srcdir}/${subdir}" 56 file_name "$srcfile" 1 57 58 program { 59 DW_LNE_set_address $bar1_start 60 line 25 61 DW_LNS_copy 62 63 DW_LNE_set_address bar1_label 64 line 27 65 DW_LNS_copy 66 67 DW_LNE_set_address bar1_label_2 68 line 29 69 DW_LNS_copy 70 71 DW_LNE_set_address bar1_label_3 72 line 0 73 DW_LNS_copy 74 75 DW_LNE_set_address bar1_label_4 76 line 33 77 DW_LNS_copy 78 79 DW_LNE_set_address $bar1_end 80 DW_LNE_end_sequence 81 82 83 DW_LNE_set_address $bar2_start 84 line 39 85 DW_LNS_copy 86 87 DW_LNE_set_address bar2_label 88 line 41 89 DW_LNS_copy 90 91 DW_LNE_set_address bar2_label_2 92 line 43 93 DW_LNS_copy 94 95 DW_LNE_set_address bar2_label_3 96 line 0 97 DW_LNS_negate_stmt 98 DW_LNS_copy 99 DW_LNS_negate_stmt 100 101 DW_LNE_set_address bar2_label_4 102 line 47 103 DW_LNS_copy 104 105 DW_LNE_set_address $bar2_end 106 DW_LNE_end_sequence 107 } 108 } 109 } 110 111 if { [prepare_for_testing "failed to prepare" ${testfile} \ 112 [list $srcfile $asm_file] {nodebug}] } { 113 return -1 114 } 115 116 if ![runto_main] { 117 return -1 118 } 119 120 gdb_breakpoint "$srcfile:27" 121 gdb_continue_to_breakpoint "bar1" "\[^\r\n\]*:27\r\n.*" 122 123 gdb_test "n" "foo \\(2\\);" "bar1, 1st next" 124 gdb_test "n" "foo \\(4\\);" "bar1, 2nd next" 125 126 gdb_breakpoint "$srcfile:41" 127 gdb_continue_to_breakpoint "bar2" "\[^\r\n\]*:41\r\n.*" 128 129 gdb_test "n" "foo \\(2\\);" "bar2, 1st next" 130 gdb_test "n" "foo \\(4\\);" "bar2, 2nd next" 131 132 if ![runto_main] { 133 return -1 134 } 135 136 gdb_breakpoint "bar1_label_3" 137 setup_kfail "gdb/nnnnn" *-*-* 138 gdb_continue_to_breakpoint "bar1_label_3" "bar1 \\(\\)" 139 140 gdb_breakpoint "bar2_label_3" 141 setup_kfail "gdb/nnnnn" *-*-* 142 gdb_continue_to_breakpoint "bar2_label_3" "bar2 \\(\\)" 143