1 1.1.1.1.4.2 perseant # Copyright 2021-2023 Free Software Foundation, Inc. 2 1.1.1.1.4.2 perseant 3 1.1.1.1.4.2 perseant # This program is free software; you can redistribute it and/or modify 4 1.1.1.1.4.2 perseant # it under the terms of the GNU General Public License as published by 5 1.1.1.1.4.2 perseant # the Free Software Foundation; either version 3 of the License, or 6 1.1.1.1.4.2 perseant # (at your option) any later version. 7 1.1.1.1.4.2 perseant # 8 1.1.1.1.4.2 perseant # This program is distributed in the hope that it will be useful, 9 1.1.1.1.4.2 perseant # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1.1.1.4.2 perseant # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1.1.1.4.2 perseant # GNU General Public License for more details. 12 1.1.1.1.4.2 perseant # 13 1.1.1.1.4.2 perseant # You should have received a copy of the GNU General Public License 14 1.1.1.1.4.2 perseant # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1.1.1.4.2 perseant 16 1.1.1.1.4.2 perseant # Test line number information in various configurations. 17 1.1.1.1.4.2 perseant 18 1.1.1.1.4.2 perseant load_lib dwarf.exp 19 1.1.1.1.4.2 perseant 20 1.1.1.1.4.2 perseant # This test can only be run on targets which support DWARF-2 and use gas. 21 1.1.1.1.4.2 perseant require dwarf2_support 1 22 1.1.1.1.4.2 perseant 23 1.1.1.1.4.2 perseant standard_testfile .c 24 1.1.1.1.4.2 perseant 25 1.1.1.1.4.2 perseant with_shared_gdb { 26 1.1.1.1.4.2 perseant set func_info_vars \ 27 1.1.1.1.4.2 perseant [concat \ 28 1.1.1.1.4.2 perseant [get_func_info main] \ 29 1.1.1.1.4.2 perseant [get_func_info bar]] 30 1.1.1.1.4.2 perseant } 31 1.1.1.1.4.2 perseant 32 1.1.1.1.4.2 perseant # Helper function. 33 1.1.1.1.4.2 perseant proc line_for { l } { 34 1.1.1.1.4.2 perseant global srcfile 35 1.1.1.1.4.2 perseant set line [gdb_get_line_number "$l:" $srcfile] 36 1.1.1.1.4.2 perseant return [expr $line + 1] 37 1.1.1.1.4.2 perseant } 38 1.1.1.1.4.2 perseant 39 1.1.1.1.4.2 perseant # Execute test. 40 1.1.1.1.4.2 perseant proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} { 41 1.1.1.1.4.2 perseant global srcfile srcfile2 testfile 42 1.1.1.1.4.2 perseant global cv cdw64 lv ldw64 string_form 43 1.1.1.1.4.2 perseant set cv $_cv 44 1.1.1.1.4.2 perseant set cdw64 $_cdw64 45 1.1.1.1.4.2 perseant set lv $_lv 46 1.1.1.1.4.2 perseant set ldw64 $_ldw64 47 1.1.1.1.4.2 perseant set string_form $_string_form 48 1.1.1.1.4.2 perseant 49 1.1.1.1.4.2 perseant standard_testfile .c [prefix_id]-dw.S 50 1.1.1.1.4.2 perseant 51 1.1.1.1.4.2 perseant set asm_file [standard_output_file $srcfile2] 52 1.1.1.1.4.2 perseant Dwarf::assemble $asm_file { 53 1.1.1.1.4.2 perseant declare_labels Llines 54 1.1.1.1.4.2 perseant global srcdir subdir srcfile cv cdw64 lv ldw64 string_form 55 1.1.1.1.4.2 perseant global func_info_vars 56 1.1.1.1.4.2 perseant foreach var $func_info_vars { 57 1.1.1.1.4.2 perseant global $var 58 1.1.1.1.4.2 perseant } 59 1.1.1.1.4.2 perseant 60 1.1.1.1.4.2 perseant cu { version $cv is_64 $cdw64 } { 61 1.1.1.1.4.2 perseant compile_unit { 62 1.1.1.1.4.2 perseant {language @DW_LANG_C} 63 1.1.1.1.4.2 perseant {name $srcfile} 64 1.1.1.1.4.2 perseant {stmt_list $Llines DW_FORM_sec_offset} 65 1.1.1.1.4.2 perseant } { 66 1.1.1.1.4.2 perseant subprogram { 67 1.1.1.1.4.2 perseant {external 1 flag} 68 1.1.1.1.4.2 perseant {name main} 69 1.1.1.1.4.2 perseant {low_pc $main_start addr} 70 1.1.1.1.4.2 perseant {high_pc "$main_start + $main_len" addr} 71 1.1.1.1.4.2 perseant } 72 1.1.1.1.4.2 perseant subprogram { 73 1.1.1.1.4.2 perseant {external 1 flag} 74 1.1.1.1.4.2 perseant {name bar} 75 1.1.1.1.4.2 perseant {low_pc $bar_start addr} 76 1.1.1.1.4.2 perseant {high_pc "$bar_start + $bar_len" addr} 77 1.1.1.1.4.2 perseant } 78 1.1.1.1.4.2 perseant } 79 1.1.1.1.4.2 perseant } 80 1.1.1.1.4.2 perseant 81 1.1.1.1.4.2 perseant lines [list version $lv is_64 $ldw64 string_form $string_form] Llines { 82 1.1.1.1.4.2 perseant set diridx [include_dir "${srcdir}/${subdir}"] 83 1.1.1.1.4.2 perseant file_name "$srcfile" $diridx 84 1.1.1.1.4.2 perseant 85 1.1.1.1.4.2 perseant program { 86 1.1.1.1.4.2 perseant # If using DWARF 5, we want to refer to file 0, but the LNP 87 1.1.1.1.4.2 perseant # state machine is still initialized with file 1. So we need 88 1.1.1.1.4.2 perseant # to set the current file explicitly. 89 1.1.1.1.4.2 perseant DW_LNS_set_file $diridx 90 1.1.1.1.4.2 perseant 91 1.1.1.1.4.2 perseant DW_LNE_set_address bar_label 92 1.1.1.1.4.2 perseant line [line_for bar_label] 93 1.1.1.1.4.2 perseant DW_LNS_copy 94 1.1.1.1.4.2 perseant 95 1.1.1.1.4.2 perseant DW_LNE_set_address bar_label_2 96 1.1.1.1.4.2 perseant line [line_for bar_label_2] 97 1.1.1.1.4.2 perseant DW_LNS_copy 98 1.1.1.1.4.2 perseant 99 1.1.1.1.4.2 perseant DW_LNE_set_address bar_label_3 100 1.1.1.1.4.2 perseant line [line_for bar_label_3] 101 1.1.1.1.4.2 perseant DW_LNS_copy 102 1.1.1.1.4.2 perseant 103 1.1.1.1.4.2 perseant DW_LNE_set_address bar_label_4 104 1.1.1.1.4.2 perseant line [line_for bar_label_4] 105 1.1.1.1.4.2 perseant DW_LNS_copy 106 1.1.1.1.4.2 perseant 107 1.1.1.1.4.2 perseant DW_LNE_set_address bar_label_5 108 1.1.1.1.4.2 perseant DW_LNE_end_sequence 109 1.1.1.1.4.2 perseant } 110 1.1.1.1.4.2 perseant } 111 1.1.1.1.4.2 perseant } 112 1.1.1.1.4.2 perseant 113 1.1.1.1.4.2 perseant if { [prepare_for_testing "failed to prepare" ${testfile}.[prefix_id] \ 114 1.1.1.1.4.2 perseant [list $srcfile $asm_file] {nodebug}] } { 115 1.1.1.1.4.2 perseant return -1 116 1.1.1.1.4.2 perseant } 117 1.1.1.1.4.2 perseant 118 1.1.1.1.4.2 perseant if ![runto_main] { 119 1.1.1.1.4.2 perseant return -1 120 1.1.1.1.4.2 perseant } 121 1.1.1.1.4.2 perseant 122 1.1.1.1.4.2 perseant gdb_breakpoint "bar_label" 123 1.1.1.1.4.2 perseant gdb_continue_to_breakpoint "foo \\(1\\)" 124 1.1.1.1.4.2 perseant 125 1.1.1.1.4.2 perseant gdb_test "next" "foo \\(2\\).*" "next to foo (2)" 126 1.1.1.1.4.2 perseant gdb_test "next" "foo \\(3\\).*" "next to foo (3)" 127 1.1.1.1.4.2 perseant gdb_test "next" "foo \\(4\\).*" "next to foo (4)" 128 1.1.1.1.4.2 perseant } 129 1.1.1.1.4.2 perseant 130 1.1.1.1.4.2 perseant 131 1.1.1.1.4.2 perseant # Add unique test prefix. 132 1.1.1.1.4.2 perseant proc test { cv cdw64 lv ldw64 {string_form ""}} { 133 1.1.1.1.4.2 perseant with_test_prefix cv=$cv { 134 1.1.1.1.4.2 perseant with_test_prefix cdw=[expr $cdw64 ? 64 : 32] { 135 1.1.1.1.4.2 perseant with_test_prefix lv=$lv { 136 1.1.1.1.4.2 perseant with_test_prefix ldw=[expr $ldw64 ? 64 : 32] { 137 1.1.1.1.4.2 perseant if { $string_form == "" } { 138 1.1.1.1.4.2 perseant test_1 $cv $cdw64 $lv $ldw64 139 1.1.1.1.4.2 perseant } else { 140 1.1.1.1.4.2 perseant with_test_prefix string_form=$string_form { 141 1.1.1.1.4.2 perseant test_1 $cv $cdw64 $lv $ldw64 $string_form 142 1.1.1.1.4.2 perseant } 143 1.1.1.1.4.2 perseant } 144 1.1.1.1.4.2 perseant } 145 1.1.1.1.4.2 perseant } 146 1.1.1.1.4.2 perseant } 147 1.1.1.1.4.2 perseant } 148 1.1.1.1.4.2 perseant } 149 1.1.1.1.4.2 perseant 150 1.1.1.1.4.2 perseant set cv_low 2 151 1.1.1.1.4.2 perseant set cv_high 4 152 1.1.1.1.4.2 perseant 153 1.1.1.1.4.2 perseant set lv_low 2 154 1.1.1.1.4.2 perseant set lv_high 4 155 1.1.1.1.4.2 perseant 156 1.1.1.1.4.2 perseant for { set cv $cv_low } { $cv <= $cv_high } { incr cv } { 157 1.1.1.1.4.2 perseant for { set lv $lv_low } { $lv <= $lv_high } { incr lv } { 158 1.1.1.1.4.2 perseant # I'm not sure if it makes sense to have a dwarf vx CU with 159 1.1.1.1.4.2 perseant # a dwarf vx+1 line unit. 160 1.1.1.1.4.2 perseant if { $lv > $lv } { 161 1.1.1.1.4.2 perseant continue 162 1.1.1.1.4.2 perseant } 163 1.1.1.1.4.2 perseant 164 1.1.1.1.4.2 perseant foreach cdw64 { 0 1 } { 165 1.1.1.1.4.2 perseant foreach ldw64 { 0 1 } { 166 1.1.1.1.4.2 perseant test $cv $cdw64 $lv $ldw64 167 1.1.1.1.4.2 perseant } 168 1.1.1.1.4.2 perseant } 169 1.1.1.1.4.2 perseant } 170 1.1.1.1.4.2 perseant } 171 1.1.1.1.4.2 perseant 172 1.1.1.1.4.2 perseant foreach cdw64 { 0 1 } { 173 1.1.1.1.4.2 perseant foreach ldw64 { 0 1 } { 174 1.1.1.1.4.2 perseant test 5 $cdw64 5 $ldw64 string 175 1.1.1.1.4.2 perseant test 5 $cdw64 5 $ldw64 line_strp 176 1.1.1.1.4.2 perseant } 177 1.1.1.1.4.2 perseant } 178