[gdb/testsuite] Compile dwzbuildid-mismatch more quietly
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-inline-small-func.exp
1 # Copyright 2020 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 if {![dwarf2_support]} {
31 return 0
32 }
33
34 # The .c files use __attribute__.
35 if [get_compiler_info] {
36 return -1
37 }
38 if !$gcc_compiled {
39 return 0
40 }
41
42 standard_testfile dw2-inline-small-func-lbls.c dw2-inline-small-func.S \
43 dw2-inline-small-func.c dw2-inline-small-func.h
44
45 set asm_file [standard_output_file $srcfile2]
46 Dwarf::assemble $asm_file {
47 global srcdir subdir srcfile srcfile3 srcfile4
48 declare_labels lines_label callee_subprog_label
49
50 get_func_info main {debug optimize=-O1}
51
52 cu {} {
53 # It is important that the producer here be 'clang' as, at the
54 # time of writing this, GCC for x86-64 doesn't make use of
55 # skip_prologue_using_sal, while clang does.
56 compile_unit {
57 {producer "clang xxxx" }
58 {language @DW_LANG_C}
59 {name ${srcfile3}}
60 {low_pc 0 addr}
61 {stmt_list ${lines_label} DW_FORM_sec_offset}
62 } {
63 callee_subprog_label: subprogram {
64 {external 1 flag}
65 {name callee}
66 {inline 3 data1}
67 }
68 subprogram {
69 {external 1 flag}
70 {name main}
71 {low_pc $main_start addr}
72 {high_pc "$main_start + $main_len" addr}
73 } {
74 inlined_subroutine {
75 {abstract_origin %$callee_subprog_label}
76 {low_pc line_label_1 addr}
77 {high_pc line_label_2 addr}
78 {call_file 1 data1}
79 {call_line 21 data1}
80 }
81 }
82 }
83 }
84
85 lines {version 2 default_is_stmt 1} lines_label {
86 include_dir "${srcdir}/${subdir}"
87 file_name "$srcfile3" 1
88 file_name "$srcfile4" 1
89
90 set f1_l1 [gdb_get_line_number "caller: before call" $srcfile3]
91 set f1_l2 [gdb_get_line_number "caller: the call" $srcfile3]
92 set f1_l3 [gdb_get_line_number "caller: after call" $srcfile3]
93
94 set f2_l1 [gdb_get_line_number "callee: body" $srcfile4]
95
96 program {
97 {DW_LNE_set_address line_label_1}
98 {DW_LNS_advance_line [expr $f1_l1 - 1]}
99 {DW_LNS_copy}
100
101 {DW_LNS_advance_line [expr ${f1_l2} - ${f1_l1}]}
102 {DW_LNS_copy}
103
104 {DW_LNS_set_file 2}
105 {DW_LNS_advance_line [expr ${f2_l1} - ${f1_l2}]}
106 {DW_LNS_copy}
107
108 {DW_LNS_negate_stmt}
109 {DW_LNS_copy}
110
111 {DW_LNS_set_file 1}
112 {DW_LNE_set_address line_label_2}
113 {DW_LNS_advance_line [expr ${f1_l3} - ${f2_l1}]}
114 {DW_LNS_copy}
115
116 {DW_LNE_set_address line_label_3}
117 {DW_LNS_copy}
118 {DW_LNE_end_sequence}
119 }
120 }
121 }
122
123 if { [prepare_for_testing "failed to prepare" ${testfile} \
124 [list $srcfile $asm_file] {nodebug optimize=-O1}] } {
125 return -1
126 }
127
128 if ![runto_main] {
129 return -1
130 }
131
132 # Delete all breakpoints so that the output of "info breakpoints"
133 # below will only contain a single breakpoint.
134 delete_breakpoints
135
136 # Place a breakpoint within the function in the header file.
137 set linenum [gdb_get_line_number "callee: body" $srcfile4]
138 gdb_breakpoint "${srcfile4}:${linenum}"
139
140 # Check that the breakpoint was placed where we expected. It should
141 # appear at the requested line. When the bug in GDB was present the
142 # breakpoint would be placed on one of the following lines instead.
143 gdb_test "info breakpoints" \
144 ".* in callee at \[^\r\n\]+${srcfile4}:${linenum}\\y.*"
This page took 0.032524 seconds and 4 git commands to generate.