]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / imported-unit-bp.exp.tcl
CommitLineData
213516ef 1# Copyright 2020-2023 Free Software Foundation, Inc.
e8b6c1da
TT
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
18load_lib dwarf.exp
19
20# This test can only be run on targets which support DWARF-2 and use gas.
21if {![dwarf2_support]} {
22 return 0
23}
24
25# The .c files use __attribute__.
ef7a6b97 26if ![is_c_compiler_gcc] {
e8b6c1da
TT
27 return 0
28}
29
30standard_testfile imported-unit-bp-alt.c .S imported-unit-bp-main.c
31
32set build_options {nodebug optimize=-O1}
33
34set asm_file [standard_output_file $srcfile2]
35Dwarf::assemble $asm_file {
36 global srcdir subdir srcfile srcfile
37 global build_options
752e4193 38 global lang
e8b6c1da
TT
39 declare_labels lines_label callee_subprog_label cu_label
40
41 get_func_info func "$build_options additional_flags=-DWITHMAIN"
42
43 cu {} {
44 compile_unit {
752e4193 45 {language @$lang}
e8b6c1da
TT
46 {name "<artificial>"}
47 } {
48 imported_unit {
49 {import %$cu_label}
50 }
51 }
52 }
53
54 cu {} {
55 cu_label: compile_unit {
56 {producer "gcc"}
752e4193 57 {language @$lang}
e8b6c1da
TT
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}
67 }
68 subprogram {
69 {external 1 flag}
70 {name func}
71 {low_pc $func_start addr}
72 {high_pc "$func_start + $func_len" addr}
73 } {
74 }
75 }
76 }
77
78 lines {version 2 default_is_stmt 1} lines_label {
79 include_dir "/tmp"
80 file_name "$srcfile" 1
81
82 program {
d4c4a229
SM
83 DW_LNE_set_address line_label_1
84 DW_LNS_advance_line 15
85 DW_LNS_copy
e8b6c1da 86
d4c4a229
SM
87 DW_LNE_set_address line_label_2
88 DW_LNS_advance_line 1
89 DW_LNS_copy
e8b6c1da 90
d4c4a229
SM
91 DW_LNE_set_address line_label_3
92 DW_LNS_advance_line 4
93 DW_LNS_copy
e8b6c1da 94
d4c4a229
SM
95 DW_LNE_set_address line_label_4
96 DW_LNS_advance_line 1
97 DW_LNS_copy
e8b6c1da 98
d4c4a229
SM
99 DW_LNS_advance_line -4
100 DW_LNS_negate_stmt
101 DW_LNS_copy
e8b6c1da 102
d4c4a229
SM
103 DW_LNE_set_address line_label_5
104 DW_LNS_advance_line 1
105 DW_LNS_copy
e8b6c1da 106
d4c4a229
SM
107 DW_LNE_set_address line_label_6
108 DW_LNS_advance_line 1
109 DW_LNS_negate_stmt
110 DW_LNS_copy
e8b6c1da 111
d4c4a229
SM
112 DW_LNE_set_address line_label_7
113 DW_LNE_end_sequence
e8b6c1da
TT
114 }
115 }
116}
117
118if { [prepare_for_testing "failed to prepare" ${testfile} \
119 [list $srcfile $asm_file $srcfile3] $build_options] } {
120 return -1
121}
122
123gdb_reinitialize_dir /tmp
124
125# Using an absolute path is important to see the bug.
126gdb_test "break /tmp/${srcfile}:19" "Breakpoint .* file $srcfile, line .*"