Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2020-2022 Free Software Foundation, Inc. |
1313c56e AB |
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 | # Setup a line table where: | |
17 | # | |
18 | # | Addr | File | Line | Stmt | Inline | | |
19 | # |------|------|------|------|--------| | |
20 | # | 1 | 1 | 16 | Y | | | |
21 | # | 2 | 1 | 17 | Y | | | |
22 | # | 3 | 2 | 21 | Y | X | | |
23 | # | 4 | 2 | 22 | Y | X | | |
24 | # | 4 | 1 | 18 | N | | | |
25 | # | 5 | 1 | 19 | N | | | |
26 | # | 6 | 1 | 20 | Y | | | |
27 | # | 7 | 1 | END | Y | | | |
28 | # |------|------|------|------|--------| | |
29 | # | |
30 | # Break at file 2, line 22, then single instruction step forward. We | |
31 | # should pass through line 19 and then encounter line 20. | |
32 | # | |
33 | # Currently we don't expect GDB to see file 1, line 18, as this is a | |
34 | # non-stmt line in a different file at the same address as the | |
35 | # previous is-stmt line. | |
36 | ||
37 | load_lib dwarf.exp | |
38 | ||
39 | # This test can only be run on targets which support DWARF-2 and use gas. | |
40 | if {![dwarf2_support]} { | |
41 | return 0 | |
42 | } | |
43 | ||
44 | # The .c files use __attribute__. | |
45 | if [get_compiler_info] { | |
46 | return -1 | |
47 | } | |
48 | if !$gcc_compiled { | |
49 | return 0 | |
50 | } | |
51 | ||
52 | standard_testfile dw2-inline-header-lbls.c dw2-inline-header.S \ | |
53 | dw2-inline-header.c dw2-inline-header.h | |
54 | ||
55 | set build_options {nodebug optimize=-O1} | |
56 | ||
57 | set asm_file [standard_output_file $srcfile2] | |
58 | Dwarf::assemble $asm_file { | |
59 | global srcdir subdir srcfile srcfile3 srcfile4 | |
60 | global build_options | |
61 | declare_labels lines_label callee_subprog_label | |
62 | ||
63 | get_func_info main $build_options | |
64 | ||
65 | cu {} { | |
66 | compile_unit { | |
67 | {producer "gcc" } | |
68 | {language @DW_LANG_C} | |
69 | {name ${srcfile3}} | |
70 | {low_pc 0 addr} | |
71 | {stmt_list ${lines_label} DW_FORM_sec_offset} | |
72 | } { | |
73 | callee_subprog_label: subprogram { | |
74 | {external 1 flag} | |
75 | {name callee} | |
76 | {inline 3 data1} | |
77 | } | |
78 | subprogram { | |
79 | {external 1 flag} | |
80 | {name main} | |
81 | {low_pc $main_start addr} | |
82 | {high_pc "$main_start + $main_len" addr} | |
83 | } { | |
84 | inlined_subroutine { | |
85 | {abstract_origin %$callee_subprog_label} | |
86 | {low_pc line_label_3 addr} | |
87 | {high_pc line_label_5 addr} | |
88 | {call_file 1 data1} | |
89 | {call_line 18 data1} | |
90 | } | |
91 | } | |
92 | } | |
93 | } | |
94 | ||
95 | lines {version 2 default_is_stmt 1} lines_label { | |
96 | include_dir "${srcdir}/${subdir}" | |
97 | file_name "$srcfile3" 1 | |
98 | file_name "$srcfile4" 1 | |
99 | ||
100 | program { | |
101 | {DW_LNE_set_address line_label_1} | |
102 | {DW_LNS_advance_line 15} | |
103 | {DW_LNS_copy} | |
104 | ||
105 | {DW_LNE_set_address line_label_2} | |
106 | {DW_LNS_advance_line 1} | |
107 | {DW_LNS_copy} | |
108 | ||
109 | {DW_LNS_set_file 2} | |
110 | {DW_LNE_set_address line_label_3} | |
111 | {DW_LNS_advance_line 4} | |
112 | {DW_LNS_copy} | |
113 | ||
114 | {DW_LNE_set_address line_label_4} | |
115 | {DW_LNS_advance_line 1} | |
116 | {DW_LNS_copy} | |
117 | ||
118 | {DW_LNS_advance_line -4} | |
119 | {DW_LNS_set_file 1} | |
120 | {DW_LNS_negate_stmt} | |
121 | {DW_LNS_copy} | |
122 | ||
123 | {DW_LNE_set_address line_label_5} | |
124 | {DW_LNS_advance_line 1} | |
125 | {DW_LNS_copy} | |
126 | ||
127 | {DW_LNE_set_address line_label_6} | |
128 | {DW_LNS_advance_line 1} | |
129 | {DW_LNS_negate_stmt} | |
130 | {DW_LNS_copy} | |
131 | ||
132 | {DW_LNE_set_address line_label_7} | |
133 | {DW_LNE_end_sequence} | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
139 | [list $srcfile $asm_file] $build_options] } { | |
140 | return -1 | |
141 | } | |
142 | ||
143 | if ![runto_main] { | |
144 | return -1 | |
145 | } | |
146 | ||
147 | # Delete all breakpoints so that the output of "info breakpoints" | |
148 | # below will only contain a single breakpoint. | |
149 | delete_breakpoints | |
150 | ||
151 | # Place a breakpoint within the function in the header file. | |
152 | gdb_breakpoint "${srcfile4}:22" | |
153 | ||
154 | # Check that the breakpoint was placed where we expected. It should | |
155 | # appear at the requested line. When the bug in GDB was present the | |
156 | # breakpoint would be placed on one of the following lines instead. | |
157 | gdb_test "info breakpoints" \ | |
158 | ".* in callee at \[^\r\n\]+${srcfile4}:22\\y.*" | |
159 | ||
160 | gdb_continue_to_breakpoint "${srcfile4}:22" \ | |
161 | ".* ${srcfile4} : 22 .*" | |
162 | ||
163 | # Now single instruction step forward. Eventually we should hit | |
164 | # ${srcfile3}:20, but before we do we should hit the non-statement | |
165 | # line ${srcfile3}:19. | |
166 | # | |
167 | # We don't know how many instructions we'll need to step, but 100 | |
168 | # should be enough for everyone (surely), and this stops us looping | |
169 | # forever if something goes wrong. | |
170 | set found_line_19 0 | |
171 | set found_line_20 0 | |
172 | set keep_going 1 | |
173 | for { set i 0 } { $i < 100 && $keep_going } { incr i } { | |
174 | set keep_going 0 | |
175 | gdb_test_multiple "stepi" "stepi ${i}" { | |
176 | -re "${srcfile3} : 19 .*${gdb_prompt} " { | |
177 | set found_line_19 1 | |
178 | set keep_going 1 | |
179 | } | |
180 | ||
181 | -re "${srcfile3} : 20 .*${gdb_prompt} " { | |
182 | set found_line_20 1 | |
183 | } | |
184 | ||
185 | -re "${srcfile4} : 22 .*${gdb_prompt} " { | |
186 | # Not left line 22 yet. | |
187 | set keep_going 1 | |
188 | } | |
189 | } | |
190 | } | |
191 | ||
192 | gdb_assert { $found_line_19 && $found_line_20 } \ | |
193 | "found line 19 and 20" |