Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-inline-small-func.exp
blobed7166983d5e8265f7579db3a6ba115ebfbcc84c
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.
27 load_lib dwarf.exp
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 \
36     .c .h
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}
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     }
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]
89         program {
90             DW_LNE_set_address line_label_1
91             line $f1_l1
92             DW_LNS_copy
94             DW_LNS_advance_pc 0
95             line ${f1_l2}
96             DW_LNS_copy
98             DW_LNS_advance_pc 0
99             DW_LNS_set_file 2
100             line ${f2_l1}
101             DW_LNS_copy
103             DW_LNS_advance_pc 0
104             DW_LNS_negate_stmt
105             DW_LNS_copy
107             DW_LNS_set_file 1
108             DW_LNE_set_address line_label_2
109             line ${f1_l3}
110             DW_LNS_copy
112             DW_LNE_set_address line_label_3
113             DW_LNS_copy
115             DW_LNE_set_address "$main_start + $main_len"
116             DW_LNE_end_sequence
117         }
118     }
121 if { [prepare_for_testing "failed to prepare" ${testfile} \
122           [list $srcfile $asm_file] {nodebug optimize=-O1}] } {
123     return -1
126 if ![runto_main] {
127     return -1
130 # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that
131 # the output of "info breakpoints" below will only contain a single breakpoint.
132 delete_breakpoints
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.*"