1 # Copyright 2020 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 # Setup a line table where:
18 # | | | | | Inline | Inline |
19 # | Addr | File | Line | Stmt | Rng A | Rng B |
20 # |------|------|------|------|--------|--------|
21 # | 1 | 1 | 16 | Y | | |
22 # | 2 | 1 | 17 | Y | | |
23 # | 3 | 2 | 21 | Y | X | |
24 # | 4 | 2 | 22 | Y | X | |
25 # | 4 | 1 | 18 | N | X | |
26 # | 5 | 2 | 23 | N | X | X |
27 # | 6 | 1 | 24 | Y | | |
28 # | 7 | 1 | END | Y | | |
29 # |------|------|------|------|--------|--------|
31 # Places a brekpoint at file 2, line 22. Previously GDB would discard
32 # the line table entry for this line due to switching files for the
33 # file 1, line 18 non-statement line. After patching however, GDB now
34 # discards the file 1, line 18 entry instead, and the breakpoint at
35 # line 22 should succeed.
37 # The two inlined subroutine ranges 'A' and 'B' represent two possible
38 # ways that a compiler might represent this siuatio in the DWARF.
40 # Range 'B' is something that has been seen in the wild using GCC 8.2.
41 # In this case the compilers range information is clearly wrong, but
42 # this shouldn't impact the main point of the test.
44 # Range 'A' is a hypothetical case of how the compiler might choose to
45 # represent this range, this has never been seen in the wild, but is
46 # an improved debug experiece over range 'B'. However, if we ever run
47 # in to the situation where GDB can support the range 'A' test, or
48 # support some real DWARF seen in the wild, then the range 'A' case
49 # should be dropped in favour of supporting real world cases. This is
50 # included here as it "just worked" once the range 'B' case was
55 # This test can only be run on targets which support DWARF-2 and use gas.
56 if {![dwarf2_support]} {
60 # The .c files use __attribute__.
61 if [get_compiler_info] {
68 # Prepare and run the test.
69 proc do_test { start_label func_name tag } {
70 global srcfile srcfile2 srcfile3 srcfile4 testfile
72 standard_testfile dw2-inline-header-lbls.c dw2-inline-header-${tag}.S \
73 dw2-inline-header.c dw2-inline-header.h
75 set build_options {nodebug optimize=-O1}
77 set asm_file [standard_output_file $srcfile2]
78 Dwarf::assemble $asm_file {
79 global srcdir subdir srcfile srcfile3 srcfile4 testfile
80 upvar build_options build_options
81 upvar start_label start_label
82 declare_labels lines_label callee_subprog_label
84 get_func_info main $build_options
92 {stmt_list ${lines_label} DW_FORM_sec_offset}
94 callee_subprog_label: subprogram {
102 {low_pc $main_start addr}
103 {high_pc "$main_start + $main_len" addr}
106 {abstract_origin %$callee_subprog_label}
107 {low_pc $start_label addr}
108 {high_pc line_label_6 addr}
116 lines {version 2 default_is_stmt 1} lines_label {
117 include_dir "${srcdir}/${subdir}"
118 file_name "$srcfile3" 1
119 file_name "$srcfile4" 1
122 {DW_LNE_set_address line_label_1}
123 {DW_LNS_advance_line 15}
126 {DW_LNE_set_address line_label_2}
127 {DW_LNS_advance_line 1}
131 {DW_LNE_set_address line_label_3}
132 {DW_LNS_advance_line 4}
135 {DW_LNE_set_address line_label_4}
136 {DW_LNS_advance_line 1}
139 {DW_LNS_advance_line -4}
145 {DW_LNE_set_address line_label_5}
146 {DW_LNS_advance_line 5}
151 {DW_LNE_set_address line_label_6}
152 {DW_LNS_advance_line 1}
155 {DW_LNE_set_address line_label_7}
156 {DW_LNE_end_sequence}
161 if { [prepare_for_testing "failed to prepare" ${testfile}-${tag} \
162 [list $srcfile $asm_file] $build_options] } {
170 # Delete all breakpoints so that the output of "info breakpoints"
171 # below will only contain a single breakpoint.
174 # Place a breakpoint within the function in the header file.
175 gdb_breakpoint "${srcfile4}:22"
177 # Check that the breakpoint was placed where we expected. It should
178 # appear at the requested line. When the bug in GDB was present the
179 # breakpoint would be placed on one of the following lines instead.
180 gdb_test "info breakpoints" \
181 ".* in $func_name at \[^\r\n\]+${srcfile4}:22\\y.*" \
182 "info breakpoints, $tag"
185 do_test line_label_3 "callee" "range-a"
186 do_test line_label_5 "main" "range-b"