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