]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-inline-small-func.exp
1 # Copyright 2020-2024 Free Software Foundation, Inc.
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 # Check for an issue in GDB where buildsym_compunit::record_line was
17 # removing duplicate line table entries, but skip_prologue_using_sal
18 # depends on these duplicates to spot the end of the prologue.
19 #
20 # When the de-duplication was added this regression was not spotted as
21 # it requires a particular combination of a (very) small function
22 # being inlined into an also very small outer function.
23 #
24 # This test recreates the exact combination of line table entries that
25 # were seen in the original test using the Dejagnu DWARF compiler.
26
27 load_lib dwarf.exp
28
29 # This test can only be run on targets which support DWARF-2 and use gas.
30 require dwarf2_support
31
32 # The .c files use __attribute__.
33 require is_c_compiler_gcc
34
35 standard_testfile -lbls.c .S \
36 .c .h
37
38 set asm_file [standard_output_file $srcfile2]
39 Dwarf::assemble $asm_file {
40 global srcdir subdir srcfile srcfile3 srcfile4
41 declare_labels lines_label callee_subprog_label
42
43 get_func_info main {debug optimize=-O1}
44
45 cu {} {
46 # It is important that the producer here be 'clang' as, at the
47 # time of writing this, GCC for x86-64 doesn't make use of
48 # skip_prologue_using_sal, while clang does.
49 compile_unit {
50 {producer "clang xxxx" }
51 {language @DW_LANG_C}
52 {name ${srcfile3}}
53 {low_pc 0 addr}
54 {stmt_list ${lines_label} DW_FORM_sec_offset}
55 } {
56 callee_subprog_label: subprogram {
57 {external 1 flag}
58 {name callee}
59 {inline 3 data1}
60 }
61 subprogram {
62 {external 1 flag}
63 {name main}
64 {low_pc $main_start addr}
65 {high_pc "$main_start + $main_len" addr}
66 } {
67 inlined_subroutine {
68 {abstract_origin %$callee_subprog_label}
69 {low_pc line_label_1 addr}
70 {high_pc line_label_2 addr}
71 {call_file 1 data1}
72 {call_line 21 data1}
73 }
74 }
75 }
76 }
77
78 lines {version 2 default_is_stmt 1} lines_label {
79 include_dir "${srcdir}/${subdir}"
80 file_name "$srcfile3" 1
81 file_name "$srcfile4" 1
82
83 set f1_l1 [gdb_get_line_number "caller: before call" $srcfile3]
84 set f1_l2 [gdb_get_line_number "caller: the call" $srcfile3]
85 set f1_l3 [gdb_get_line_number "caller: after call" $srcfile3]
86
87 set f2_l1 [gdb_get_line_number "callee: body" $srcfile4]
88
89 program {
90 DW_LNE_set_address line_label_1
91 line $f1_l1
92 DW_LNS_copy
93
94 line ${f1_l2}
95 DW_LNS_copy
96
97 DW_LNS_set_file 2
98 line ${f2_l1}
99 DW_LNS_copy
100
101 DW_LNS_negate_stmt
102 DW_LNS_copy
103
104 DW_LNS_set_file 1
105 DW_LNE_set_address line_label_2
106 line ${f1_l3}
107 DW_LNS_copy
108
109 DW_LNE_set_address line_label_3
110 DW_LNS_copy
111 DW_LNE_end_sequence
112 }
113 }
114 }
115
116 if { [prepare_for_testing "failed to prepare" ${testfile} \
117 [list $srcfile $asm_file] {nodebug optimize=-O1}] } {
118 return -1
119 }
120
121 if ![runto_main] {
122 return -1
123 }
124
125 # Delete all breakpoints so that the output of "info breakpoints"
126 # below will only contain a single breakpoint.
127 delete_breakpoints
128
129 # Place a breakpoint within the function in the header file.
130 set linenum [gdb_get_line_number "callee: body" $srcfile4]
131 gdb_breakpoint "${srcfile4}:${linenum}"
132
133 # Check that the breakpoint was placed where we expected. It should
134 # appear at the requested line. When the bug in GDB was present the
135 # breakpoint would be placed on one of the following lines instead.
136 gdb_test "info breakpoints" \
137 ".* in callee at \[^\r\n\]+${srcfile4}:${linenum}\\y.*"