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.
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 if {![dwarf2_support
]} {
25 # The .c files use __attribute__.
26 if ![is_c_compiler_gcc
] {
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
39 declare_labels lines_label callee_subprog_label cu_label
41 get_func_info func
"$build_options additional_flags=-DWITHMAIN"
55 cu_label
: compile_unit
{
61 {stmt_list
${lines_label
} DW_FORM_sec_offset
}
63 callee_subprog_label
: subprogram
{
71 {low_pc
$func_start addr
}
72 {high_pc
"$func_start + $func_len" addr
}
78 lines
{version
2 default_is_stmt
1} lines_label
{
80 file_name
"$srcfile" 1
83 DW_LNE_set_address line_label_1
84 DW_LNS_advance_line
15
87 DW_LNE_set_address line_label_2
91 DW_LNE_set_address line_label_3
95 DW_LNE_set_address line_label_4
100 DW_LNS_advance_line
-4
104 DW_LNE_set_address line_label_5
105 DW_LNS_advance_line
1
108 DW_LNE_set_address line_label_6
109 DW_LNS_advance_line
1
113 DW_LNE_set_address
"$func_start + $func_len"
119 if { [prepare_for_testing
"failed to prepare" ${testfile
} \
120 [list $srcfile $asm_file $srcfile3] $build_options] } {
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
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 .*"