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