1 # Copyright 2020-2021 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Setup a line table where:
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 # |------|------|------|------|--------|
30 # Break at file 2, line 22, then single instruction step forward. We
31 # should pass through line 19 and then encounter line 20.
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.
39 # This test can only be run on targets which support DWARF-2 and use gas.
40 if {![dwarf2_support]} {
44 # The .c files use __attribute__.
45 if [get_compiler_info] {
52 standard_testfile dw2-inline-header-lbls.c dw2-inline-header.S \
53 dw2-inline-header.c dw2-inline-header.h
55 set build_options {nodebug optimize=-O1}
57 set asm_file [standard_output_file $srcfile2]
58 Dwarf::assemble $asm_file {
59 global srcdir subdir srcfile srcfile3 srcfile4
61 declare_labels lines_label callee_subprog_label
63 get_func_info main $build_options
71 {stmt_list ${lines_label} DW_FORM_sec_offset}
73 callee_subprog_label: subprogram {
81 {low_pc $main_start addr}
82 {high_pc "$main_start + $main_len" addr}
85 {abstract_origin %$callee_subprog_label}
86 {low_pc line_label_3 addr}
87 {high_pc line_label_5 addr}
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
101 {DW_LNE_set_address line_label_1}
102 {DW_LNS_advance_line 15}
105 {DW_LNE_set_address line_label_2}
106 {DW_LNS_advance_line 1}
110 {DW_LNE_set_address line_label_3}
111 {DW_LNS_advance_line 4}
114 {DW_LNE_set_address line_label_4}
115 {DW_LNS_advance_line 1}
118 {DW_LNS_advance_line -4}
123 {DW_LNE_set_address line_label_5}
124 {DW_LNS_advance_line 1}
127 {DW_LNE_set_address line_label_6}
128 {DW_LNS_advance_line 1}
132 {DW_LNE_set_address line_label_7}
133 {DW_LNE_end_sequence}
138 if { [prepare_for_testing "failed to prepare" ${testfile} \
139 [list $srcfile $asm_file] $build_options] } {
147 # Delete all breakpoints so that the output of "info breakpoints"
148 # below will only contain a single breakpoint.
151 # Place a breakpoint within the function in the header file.
152 gdb_breakpoint "${srcfile4}:22"
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.*"
160 gdb_continue_to_breakpoint "${srcfile4}:22" \
161 ".* ${srcfile4} : 22 .*"
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.
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.
173 for { set i 0 } { $i < 100 && $keep_going } { incr i } {
175 gdb_test_multiple "stepi" "stepi ${i}" {
176 -re "${srcfile3} : 19 .*${gdb_prompt} " {
181 -re "${srcfile3} : 20 .*${gdb_prompt} " {
185 -re "${srcfile4} : 22 .*${gdb_prompt} " {
186 # Not left line 22 yet.
192 gdb_assert { $found_line_19 && $found_line_20 } \
193 "found line 19 and 20"