1 # Copyright 2020-2025 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 # Test that "break /absolute/file:line" works ok with imported CUs. 17 18 load_lib dwarf.exp 19 20 # This test can only be run on targets which support DWARF-2 and use gas. 21 require dwarf2_support 22 23 # The .c files use __attribute__. 24 require is_c_compiler_gcc 25 26 standard_testfile imported-unit-bp-alt.c .S imported-unit-bp-main.c 27 28 set build_options {nodebug optimize=-O1} 29 30 set asm_file [standard_output_file $srcfile2] 31 Dwarf::assemble $asm_file { 32 global srcdir subdir srcfile srcfile 33 global build_options 34 global lang 35 declare_labels lines_label callee_subprog_label cu_label 36 37 get_func_info func "$build_options additional_flags=-DWITHMAIN" 38 39 cu {} { 40 compile_unit { 41 {language @$lang} 42 {name "<artificial>"} 43 } { 44 imported_unit { 45 {import %$cu_label} 46 } 47 } 48 } 49 50 cu {} { 51 cu_label: compile_unit { 52 {producer "gcc"} 53 {language @$lang} 54 {name ${srcfile}} 55 {comp_dir "/tmp"} 56 {low_pc 0 addr} 57 {stmt_list ${lines_label} DW_FORM_sec_offset} 58 } { 59 callee_subprog_label: subprogram { 60 {external 1 flag} 61 {name callee} 62 {inline 3 data1} 63 } 64 subprogram { 65 {external 1 flag} 66 {name func} 67 {low_pc $func_start addr} 68 {high_pc "$func_start + $func_len" addr} 69 } { 70 } 71 } 72 } 73 74 lines {version 2 default_is_stmt 1} lines_label { 75 include_dir "/tmp" 76 file_name "$srcfile" 1 77 78 program { 79 DW_LNE_set_address line_label_1 80 DW_LNS_advance_line 15 81 DW_LNS_copy 82 83 DW_LNE_set_address line_label_2 84 DW_LNS_advance_line 1 85 DW_LNS_copy 86 87 DW_LNE_set_address line_label_3 88 DW_LNS_advance_line 4 89 DW_LNS_copy 90 91 DW_LNE_set_address line_label_4 92 DW_LNS_advance_line 1 93 DW_LNS_copy 94 95 DW_LNS_advance_pc 0 96 DW_LNS_advance_line -4 97 DW_LNS_negate_stmt 98 DW_LNS_copy 99 100 DW_LNE_set_address line_label_5 101 DW_LNS_advance_line 1 102 DW_LNS_copy 103 104 DW_LNE_set_address line_label_6 105 DW_LNS_advance_line 1 106 DW_LNS_negate_stmt 107 DW_LNS_copy 108 109 DW_LNE_set_address "$func_start + $func_len" 110 DW_LNE_end_sequence 111 } 112 } 113 } 114 115 if { [prepare_for_testing "failed to prepare" ${testfile} \ 116 [list $srcfile $asm_file $srcfile3] $build_options] } { 117 return -1 118 } 119 120 gdb_reinitialize_dir /tmp 121 122 # Compilation on remote host downloads the source files to remote host, but 123 # doesn't clean them up, allowing gdb to find $srcfile, in contrast to 124 # non-remote host. 125 remote_file host delete $srcfile 126 127 # Using an absolute path is important to see the bug. 128 gdb_test "break /tmp/${srcfile}:19" "Breakpoint .* file $srcfile, line .*" 129