]>
Commit | Line | Data |
---|---|---|
4a94e368 | 1 | # Copyright 2021-2022 Free Software Foundation, Inc. |
41505c0f TV |
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 | # Test line number information in various configurations. | |
17 | ||
18 | load_lib dwarf.exp | |
19 | ||
20 | # This test can only be run on targets which support DWARF-2 and use gas. | |
21 | require dwarf2_support 1 | |
22 | ||
2a0fa842 | 23 | standard_testfile .c |
41505c0f TV |
24 | |
25 | with_shared_gdb { | |
26 | set func_info_vars \ | |
27 | [concat \ | |
28 | [get_func_info main] \ | |
29 | [get_func_info bar]] | |
30 | } | |
31 | ||
32 | # Helper function. | |
33 | proc line_for { l } { | |
34 | global srcfile | |
35 | set line [gdb_get_line_number "$l:" $srcfile] | |
36 | return [expr $line + 1] | |
37 | } | |
38 | ||
39 | # Execute test. | |
bab31d14 | 40 | proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} { |
41505c0f | 41 | global srcfile srcfile2 testfile |
bab31d14 | 42 | global cv cdw64 lv ldw64 string_form |
41505c0f TV |
43 | set cv $_cv |
44 | set cdw64 $_cdw64 | |
45 | set lv $_lv | |
46 | set ldw64 $_ldw64 | |
bab31d14 | 47 | set string_form $_string_form |
41505c0f | 48 | |
2a0fa842 TV |
49 | standard_testfile .c [prefix_id]-dw.S |
50 | ||
41505c0f TV |
51 | set asm_file [standard_output_file $srcfile2] |
52 | Dwarf::assemble $asm_file { | |
53 | declare_labels Llines | |
bab31d14 | 54 | global srcdir subdir srcfile cv cdw64 lv ldw64 string_form |
41505c0f TV |
55 | global func_info_vars |
56 | foreach var $func_info_vars { | |
57 | global $var | |
58 | } | |
59 | ||
60 | cu { version $cv is_64 $cdw64 } { | |
61 | compile_unit { | |
62 | {language @DW_LANG_C} | |
63 | {name $srcfile} | |
64 | {stmt_list $Llines DW_FORM_sec_offset} | |
65 | } { | |
66 | subprogram { | |
67 | {external 1 flag} | |
68 | {name main} | |
69 | {low_pc $main_start addr} | |
70 | {high_pc "$main_start + $main_len" addr} | |
71 | } | |
72 | subprogram { | |
73 | {external 1 flag} | |
74 | {name bar} | |
75 | {low_pc $bar_start addr} | |
76 | {high_pc "$bar_start + $bar_len" addr} | |
77 | } | |
78 | } | |
79 | } | |
80 | ||
bab31d14 | 81 | lines [list version $lv is_64 $ldw64 string_form $string_form] Llines { |
41505c0f TV |
82 | include_dir "${srcdir}/${subdir}" |
83 | file_name "$srcfile" 1 | |
84 | ||
85 | program { | |
86 | {DW_LNE_set_address bar_label} | |
87 | {line [line_for bar_label]} | |
88 | {DW_LNS_copy} | |
89 | ||
90 | {DW_LNE_set_address bar_label_2} | |
91 | {line [line_for bar_label_2]} | |
92 | {DW_LNS_copy} | |
93 | ||
94 | {DW_LNE_set_address bar_label_3} | |
95 | {line [line_for bar_label_3]} | |
96 | {DW_LNS_copy} | |
97 | ||
98 | {DW_LNE_set_address bar_label_4} | |
99 | {line [line_for bar_label_4]} | |
100 | {DW_LNS_copy} | |
101 | ||
102 | {DW_LNE_set_address bar_label_5} | |
103 | {DW_LNE_end_sequence} | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
2a0fa842 | 108 | if { [prepare_for_testing "failed to prepare" ${testfile}.[prefix_id] \ |
41505c0f TV |
109 | [list $srcfile $asm_file] {nodebug}] } { |
110 | return -1 | |
111 | } | |
112 | ||
113 | if ![runto_main] { | |
114 | return -1 | |
115 | } | |
116 | ||
117 | gdb_breakpoint "bar" | |
118 | gdb_continue_to_breakpoint "foo \\(1\\)" | |
119 | ||
120 | gdb_test "next" "foo \\(2\\).*" "next to foo (2)" | |
121 | gdb_test "next" "foo \\(3\\).*" "next to foo (3)" | |
122 | gdb_test "next" "foo \\(4\\).*" "next to foo (4)" | |
123 | } | |
124 | ||
125 | ||
126 | # Add unique test prefix. | |
bab31d14 | 127 | proc test { cv cdw64 lv ldw64 {string_form ""}} { |
41505c0f TV |
128 | with_test_prefix cv=$cv { |
129 | with_test_prefix cdw=[expr $cdw64 ? 64 : 32] { | |
130 | with_test_prefix lv=$lv { | |
131 | with_test_prefix ldw=[expr $ldw64 ? 64 : 32] { | |
bab31d14 TV |
132 | if { $string_form == "" } { |
133 | test_1 $cv $cdw64 $lv $ldw64 | |
134 | } else { | |
135 | with_test_prefix string_form=$string_form { | |
136 | test_1 $cv $cdw64 $lv $ldw64 $string_form | |
137 | } | |
138 | } | |
41505c0f TV |
139 | } |
140 | } | |
141 | } | |
142 | } | |
143 | } | |
144 | ||
145 | set cv_low 2 | |
146 | set cv_high 4 | |
147 | ||
148 | set lv_low 2 | |
6cb22d4a | 149 | set lv_high 4 |
41505c0f TV |
150 | |
151 | for { set cv $cv_low } { $cv <= $cv_high } { incr cv } { | |
152 | for { set lv $lv_low } { $lv <= $lv_high } { incr lv } { | |
153 | # I'm not sure if it makes sense to have a dwarf vx CU with | |
154 | # a dwarf vx+1 line unit. | |
155 | if { $lv > $lv } { | |
156 | continue | |
157 | } | |
158 | ||
159 | foreach cdw64 { 0 1 } { | |
160 | foreach ldw64 { 0 1 } { | |
161 | test $cv $cdw64 $lv $ldw64 | |
162 | } | |
163 | } | |
164 | } | |
165 | } | |
44fda089 TV |
166 | |
167 | foreach cdw64 { 0 1 } { | |
168 | foreach ldw64 { 0 1 } { | |
bab31d14 TV |
169 | test 5 $cdw64 5 $ldw64 string |
170 | test 5 $cdw64 5 $ldw64 line_strp | |
44fda089 TV |
171 | } |
172 | } |