1 # Copyright 2020-2022 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 | X |
25 # | 5 | 1 | 19 | Y | |
26 # | 6 | 1 | 20 | Y | |
27 # | 7 | 1 | END | Y | |
28 # |------|------|------|------|--------|
31 # Place the first brekpoint at file 2, line 22 and a second breakpoint
32 # at file 1, line 19. A third breakpoint is placed at file 1, line
33 # 18, but as this line table entry will have been discarded[1] the
34 # third breakpoint will actually be placed at the same location as the
37 # This test is designed to test GDB's internal behaviour with respect
38 # to discarding particular line table entries. GCC and DWARF are
39 # starting to introduce the idea of line table views. As the views
40 # information becomes better supported within GDB it is likely that
41 # this will become out of date. This is fine, the test will have
42 # served its purpose by that point and can be deleted.
44 # [1] The entry for file 1, line 18 is discarded because it is at the
45 # same address as the previous entry, but the previous entry is-stmt,
46 # while line 18 is a non-stmt.
50 # This test can only be run on targets which support DWARF-2 and use gas.
51 if {![dwarf2_support]} {
55 # The .c files use __attribute__.
56 if [get_compiler_info] {
63 standard_testfile dw2-inline-header-lbls.c dw2-inline-header.S \
64 dw2-inline-header.c dw2-inline-header.h
66 set build_options {nodebug optimize=-O1}
68 set asm_file [standard_output_file $srcfile2]
69 Dwarf::assemble $asm_file {
70 global srcdir subdir srcfile srcfile3 srcfile4
72 declare_labels lines_label callee_subprog_label
74 get_func_info main $build_options
82 {stmt_list ${lines_label} DW_FORM_sec_offset}
84 callee_subprog_label: subprogram {
92 {low_pc $main_start addr}
93 {high_pc "$main_start + $main_len" addr}
96 {abstract_origin %$callee_subprog_label}
97 {low_pc line_label_3 addr}
98 {high_pc line_label_5 addr}
106 lines {version 2 default_is_stmt 1} lines_label {
107 include_dir "${srcdir}/${subdir}"
108 file_name "$srcfile3" 1
109 file_name "$srcfile4" 1
112 {DW_LNE_set_address line_label_1}
113 {DW_LNS_advance_line 15}
116 {DW_LNE_set_address line_label_2}
117 {DW_LNS_advance_line 1}
121 {DW_LNE_set_address line_label_3}
122 {DW_LNS_advance_line 4}
125 {DW_LNE_set_address line_label_4}
126 {DW_LNS_advance_line 1}
129 {DW_LNS_advance_line -4}
134 {DW_LNE_set_address line_label_5}
135 {DW_LNS_advance_line 1}
139 {DW_LNE_set_address line_label_6}
140 {DW_LNS_advance_line 1}
143 {DW_LNE_set_address line_label_7}
144 {DW_LNE_end_sequence}
149 if { [prepare_for_testing "failed to prepare" ${testfile} \
150 [list $srcfile $asm_file] $build_options] } {
158 # Delete all breakpoints so that the output of "info breakpoints"
159 # below will only contain a single breakpoint.
162 # Place a breakpoint within the function in the header file.
163 gdb_breakpoint "${srcfile4}:22"
165 # Check that the breakpoint was placed where we expected. It should
166 # appear at the requested line. When the bug in GDB was present the
167 # breakpoint would be placed on one of the following lines instead.
168 gdb_test "info breakpoints" \
169 ".* in callee at \[^\r\n\]+${srcfile4}:22\\y.*" \
170 "check for breakpoint at ${srcfile4}"
172 # Delete all breakpoints so that the output of "info breakpoints"
173 # below will only contain a single breakpoint.
176 # Place a breakpoint within the function in the header file.
177 gdb_breakpoint "${srcfile3}:19"
179 # Check that the breakpoint was placed where we expected. It should
180 # appear at the requested line. When the bug in GDB was present the
181 # breakpoint would be placed on one of the following lines instead.
182 gdb_test "info breakpoints" \
183 ".* in main at \[^\r\n\]+${srcfile3}:19\\y.*" \
184 "check for breakpoint at ${srcfile3}"
186 # Line table entry for line 18 will have been discarded, so this
187 # brekpoint will be at the same location as line 19.
188 gdb_test "break ${srcfile3}:18" \
189 "Note: breakpoint $decimal also set at pc $hex.*"