]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-inline-header-2.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 | X |
25# | 5 | 1 | 19 | Y | |
26# | 6 | 1 | 20 | Y | |
27# | 7 | 1 | END | Y | |
28# |------|------|------|------|--------|
29#
30#
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
35# second breakpoint.
36#
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.
43#
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.
47
48load_lib dwarf.exp
49
50# This test can only be run on targets which support DWARF-2 and use gas.
51if {![dwarf2_support]} {
52 return 0
53}
54
55# The .c files use __attribute__.
ef7a6b97 56if ![is_c_compiler_gcc] {
1313c56e
AB
57 return 0
58}
59
60standard_testfile dw2-inline-header-lbls.c dw2-inline-header.S \
61 dw2-inline-header.c dw2-inline-header.h
62
63set build_options {nodebug optimize=-O1}
64
65set asm_file [standard_output_file $srcfile2]
66Dwarf::assemble $asm_file {
67 global srcdir subdir srcfile srcfile3 srcfile4
68 global build_options
69 declare_labels lines_label callee_subprog_label
70
71 get_func_info main $build_options
72
73 cu {} {
74 compile_unit {
75 {producer "gcc" }
76 {language @DW_LANG_C}
77 {name ${srcfile3}}
78 {low_pc 0 addr}
79 {stmt_list ${lines_label} DW_FORM_sec_offset}
80 } {
81 callee_subprog_label: subprogram {
82 {external 1 flag}
83 {name callee}
84 {inline 3 data1}
85 }
86 subprogram {
87 {external 1 flag}
88 {name main}
89 {low_pc $main_start addr}
90 {high_pc "$main_start + $main_len" addr}
91 } {
92 inlined_subroutine {
93 {abstract_origin %$callee_subprog_label}
94 {low_pc line_label_3 addr}
95 {high_pc line_label_5 addr}
96 {call_file 1 data1}
97 {call_line 18 data1}
98 }
99 }
100 }
101 }
102
103 lines {version 2 default_is_stmt 1} lines_label {
104 include_dir "${srcdir}/${subdir}"
105 file_name "$srcfile3" 1
106 file_name "$srcfile4" 1
107
108 program {
d4c4a229
SM
109 DW_LNE_set_address line_label_1
110 DW_LNS_advance_line 15
111 DW_LNS_copy
112
113 DW_LNE_set_address line_label_2
114 DW_LNS_advance_line 1
115 DW_LNS_copy
116
117 DW_LNS_set_file 2
118 DW_LNE_set_address line_label_3
119 DW_LNS_advance_line 4
120 DW_LNS_copy
121
122 DW_LNE_set_address line_label_4
123 DW_LNS_advance_line 1
124 DW_LNS_copy
125
126 DW_LNS_advance_line -4
127 DW_LNS_set_file 1
128 DW_LNS_negate_stmt
129 DW_LNS_copy
130
131 DW_LNE_set_address line_label_5
132 DW_LNS_advance_line 1
133 DW_LNS_negate_stmt
134 DW_LNS_copy
135
136 DW_LNE_set_address line_label_6
137 DW_LNS_advance_line 1
138 DW_LNS_copy
139
140 DW_LNE_set_address line_label_7
141 DW_LNE_end_sequence
1313c56e
AB
142 }
143 }
144}
145
146if { [prepare_for_testing "failed to prepare" ${testfile} \
147 [list $srcfile $asm_file] $build_options] } {
148 return -1
149}
150
151if ![runto_main] {
152 return -1
153}
154
155# Delete all breakpoints so that the output of "info breakpoints"
156# below will only contain a single breakpoint.
157delete_breakpoints
158
159# Place a breakpoint within the function in the header file.
160gdb_breakpoint "${srcfile4}:22"
161
162# Check that the breakpoint was placed where we expected. It should
163# appear at the requested line. When the bug in GDB was present the
164# breakpoint would be placed on one of the following lines instead.
165gdb_test "info breakpoints" \
166 ".* in callee at \[^\r\n\]+${srcfile4}:22\\y.*" \
167 "check for breakpoint at ${srcfile4}"
168
169# Delete all breakpoints so that the output of "info breakpoints"
170# below will only contain a single breakpoint.
171delete_breakpoints
172
173# Place a breakpoint within the function in the header file.
174gdb_breakpoint "${srcfile3}:19"
175
176# Check that the breakpoint was placed where we expected. It should
177# appear at the requested line. When the bug in GDB was present the
178# breakpoint would be placed on one of the following lines instead.
179gdb_test "info breakpoints" \
180 ".* in main at \[^\r\n\]+${srcfile3}:19\\y.*" \
181 "check for breakpoint at ${srcfile3}"
182
183# Line table entry for line 18 will have been discarded, so this
184# brekpoint will be at the same location as line 19.
185gdb_test "break ${srcfile3}:18" \
186 "Note: breakpoint $decimal also set at pc $hex.*"