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# Setup a line table where: 17# 18# | Addr | File | Line | Stmt | Inline | 19# |------|------|------|------|--------| 20# | 1 | 1 | 16 | Y | | 21# | 2 | 1 | 17 | Y | | 22# | 3 | 2 | 21 | Y | X | 23# | 4 | 2 | 22 | Y | X | 24# | 4 | 1 | 18 | N | X | 25# | 5 | 1 | 19 | Y | | 26# | 6 | 1 | 20 | Y | | 27# | 7 | 1 | END | Y | | 28# |------|------|------|------|--------| 29# 30# 31# Place the first brekpoint at file 2, line 22 and a second breakpoint 32# at file 1, line 19. A third breakpoint is placed at file 1, line 33# 18, but as this line table entry will have been discarded[1] the 34# third breakpoint will actually be placed at the same location as the 35# second breakpoint. 36# 37# This test is designed to test GDB's internal behaviour with respect 38# to discarding particular line table entries. GCC and DWARF are 39# starting to introduce the idea of line table views. As the views 40# information becomes better supported within GDB it is likely that 41# this will become out of date. This is fine, the test will have 42# served its purpose by that point and can be deleted. 43# 44# [1] The entry for file 1, line 18 is discarded because it is at the 45# same address as the previous entry, but the previous entry is-stmt, 46# while line 18 is a non-stmt. 47 48load_lib dwarf.exp 49 50# This test can only be run on targets which support DWARF-2 and use gas. 51if {![dwarf2_support]} { 52 return 0 53} 54 55# The .c files use __attribute__. 56if [get_compiler_info] { 57 return -1 58} 59if !$gcc_compiled { 60 return 0 61} 62 63standard_testfile dw2-inline-header-lbls.c dw2-inline-header.S \ 64 dw2-inline-header.c dw2-inline-header.h 65 66set build_options {nodebug optimize=-O1} 67 68set asm_file [standard_output_file $srcfile2] 69Dwarf::assemble $asm_file { 70 global srcdir subdir srcfile srcfile3 srcfile4 71 global build_options 72 declare_labels lines_label callee_subprog_label 73 74 get_func_info main $build_options 75 76 cu {} { 77 compile_unit { 78 {producer "gcc" } 79 {language @DW_LANG_C} 80 {name ${srcfile3}} 81 {low_pc 0 addr} 82 {stmt_list ${lines_label} DW_FORM_sec_offset} 83 } { 84 callee_subprog_label: subprogram { 85 {external 1 flag} 86 {name callee} 87 {inline 3 data1} 88 } 89 subprogram { 90 {external 1 flag} 91 {name main} 92 {low_pc $main_start addr} 93 {high_pc "$main_start + $main_len" addr} 94 } { 95 inlined_subroutine { 96 {abstract_origin %$callee_subprog_label} 97 {low_pc line_label_3 addr} 98 {high_pc line_label_5 addr} 99 {call_file 1 data1} 100 {call_line 18 data1} 101 } 102 } 103 } 104 } 105 106 lines {version 2 default_is_stmt 1} lines_label { 107 include_dir "${srcdir}/${subdir}" 108 file_name "$srcfile3" 1 109 file_name "$srcfile4" 1 110 111 program { 112 {DW_LNE_set_address line_label_1} 113 {DW_LNS_advance_line 15} 114 {DW_LNS_copy} 115 116 {DW_LNE_set_address line_label_2} 117 {DW_LNS_advance_line 1} 118 {DW_LNS_copy} 119 120 {DW_LNS_set_file 2} 121 {DW_LNE_set_address line_label_3} 122 {DW_LNS_advance_line 4} 123 {DW_LNS_copy} 124 125 {DW_LNE_set_address line_label_4} 126 {DW_LNS_advance_line 1} 127 {DW_LNS_copy} 128 129 {DW_LNS_advance_line -4} 130 {DW_LNS_set_file 1} 131 {DW_LNS_negate_stmt} 132 {DW_LNS_copy} 133 134 {DW_LNE_set_address line_label_5} 135 {DW_LNS_advance_line 1} 136 {DW_LNS_negate_stmt} 137 {DW_LNS_copy} 138 139 {DW_LNE_set_address line_label_6} 140 {DW_LNS_advance_line 1} 141 {DW_LNS_copy} 142 143 {DW_LNE_set_address line_label_7} 144 {DW_LNE_end_sequence} 145 } 146 } 147} 148 149if { [prepare_for_testing "failed to prepare" ${testfile} \ 150 [list $srcfile $asm_file] $build_options] } { 151 return -1 152} 153 154if ![runto_main] { 155 return -1 156} 157 158# Delete all breakpoints so that the output of "info breakpoints" 159# below will only contain a single breakpoint. 160delete_breakpoints 161 162# Place a breakpoint within the function in the header file. 163gdb_breakpoint "${srcfile4}:22" 164 165# Check that the breakpoint was placed where we expected. It should 166# appear at the requested line. When the bug in GDB was present the 167# breakpoint would be placed on one of the following lines instead. 168gdb_test "info breakpoints" \ 169 ".* in callee at \[^\r\n\]+${srcfile4}:22\\y.*" \ 170 "check for breakpoint at ${srcfile4}" 171 172# Delete all breakpoints so that the output of "info breakpoints" 173# below will only contain a single breakpoint. 174delete_breakpoints 175 176# Place a breakpoint within the function in the header file. 177gdb_breakpoint "${srcfile3}:19" 178 179# Check that the breakpoint was placed where we expected. It should 180# appear at the requested line. When the bug in GDB was present the 181# breakpoint would be placed on one of the following lines instead. 182gdb_test "info breakpoints" \ 183 ".* in main at \[^\r\n\]+${srcfile3}:19\\y.*" \ 184 "check for breakpoint at ${srcfile3}" 185 186# Line table entry for line 18 will have been discarded, so this 187# brekpoint will be at the same location as line 19. 188gdb_test "break ${srcfile3}:18" \ 189 "Note: breakpoint $decimal also set at pc $hex.*" 190