1 # Copyright 2020-2024 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 # 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.
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.
24 # This test recreates the exact combination of line table entries that
25 # were seen in the original test using the Dejagnu DWARF compiler.
29 # This test can only be run on targets which support DWARF-2 and use gas.
30 require dwarf2_support
32 # The .c files use __attribute__.
33 require is_c_compiler_gcc
35 standard_testfile -lbls.c .S \
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
43 get_func_info main {debug optimize=-O1}
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.
50 {producer "clang xxxx" }
54 {stmt_list ${lines_label} DW_FORM_sec_offset}
56 callee_subprog_label: subprogram {
64 {low_pc $main_start addr}
65 {high_pc "$main_start + $main_len" addr}
68 {abstract_origin %$callee_subprog_label}
69 {low_pc line_label_1 addr}
70 {high_pc line_label_2 addr}
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
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]
87 set f2_l1 [gdb_get_line_number "callee: body" $srcfile4]
90 DW_LNE_set_address line_label_1
108 DW_LNE_set_address line_label_2
112 DW_LNE_set_address line_label_3
115 DW_LNE_set_address "$main_start + $main_len"
121 if { [prepare_for_testing "failed to prepare" ${testfile} \
122 [list $srcfile $asm_file] {nodebug optimize=-O1}] } {
130 # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
131 # the output of "info breakpoints" below will only contain a single breakpoint.
134 # Place a breakpoint within the function in the header file.
135 set linenum [gdb_get_line_number "callee: body" $srcfile4]
136 gdb_breakpoint "${srcfile4}:${linenum}"
138 # Check that the breakpoint was placed where we expected. It should
139 # appear at the requested line. When the bug in GDB was present the
140 # breakpoint would be placed on one of the following lines instead.
141 gdb_test "info breakpoints" \
142 ".* in callee at \[^\r\n\]+${srcfile4}:${linenum}\\y.*"