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