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_label 60 line 27 61 DW_LNS_copy 62 63 DW_LNE_set_address bar1_label_2 64 line 29 65 DW_LNS_copy 66 67 DW_LNE_set_address bar1_label_3 68 line 0 69 DW_LNS_copy 70 71 DW_LNE_set_address bar1_label_4 72 line 33 73 DW_LNS_copy 74 75 DW_LNE_set_address $bar1_end 76 DW_LNE_end_sequence 77 78 79 DW_LNE_set_address bar2_label 80 line 41 81 DW_LNS_copy 82 83 DW_LNE_set_address bar2_label_2 84 line 43 85 DW_LNS_copy 86 87 DW_LNE_set_address bar2_label_3 88 line 0 89 DW_LNS_negate_stmt 90 DW_LNS_copy 91 DW_LNS_negate_stmt 92 93 DW_LNE_set_address bar2_label_4 94 line 47 95 DW_LNS_copy 96 97 DW_LNE_set_address $bar2_end 98 DW_LNE_end_sequence 99 } 100 } 101 } 102 103 if { [prepare_for_testing "failed to prepare" ${testfile} \ 104 [list $srcfile $asm_file] {nodebug}] } { 105 return -1 106 } 107 108 if ![runto_main] { 109 return -1 110 } 111 112 gdb_breakpoint "$srcfile:27" 113 gdb_continue_to_breakpoint "bar1" "\[^\r\n\]*:27\r\n.*" 114 115 gdb_test "n" "foo \\(2\\);" "bar1, 1st next" 116 gdb_test "n" "foo \\(4\\);" "bar1, 2nd next" 117 118 gdb_breakpoint "$srcfile:41" 119 gdb_continue_to_breakpoint "bar2" "\[^\r\n\]*:41\r\n.*" 120 121 gdb_test "n" "foo \\(2\\);" "bar2, 1st next" 122 gdb_test "n" "foo \\(4\\);" "bar2, 2nd next" 123 124 if ![runto_main] { 125 return -1 126 } 127 128 gdb_breakpoint "bar1_label_3" 129 setup_kfail "gdb/nnnnn" *-*-* 130 gdb_continue_to_breakpoint "bar1_label_3" "bar1 \\(\\)" 131 132 gdb_breakpoint "bar2_label_3" 133 setup_kfail "gdb/nnnnn" *-*-* 134 gdb_continue_to_breakpoint "bar2_label_3" "bar2 \\(\\)" 135