]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-entry-points.exp
CommitLineData
1d506c26 1# Copyright 2023-2024 Free Software Foundation, Inc.
3396471b
NCK
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 the DW_TAG_entry_point is handled properly by GDB and that we can
17# set breakpoints on function entry points.
18
19load_lib dwarf.exp
20
21# This test can only be run on targets that support DWARF-2 and use
22# gas.
23require dwarf2_support
24
25standard_testfile .c -dw.S
26
27if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
28 return -1
29}
30
31# Make some DWARF for the test.
32set asm_file [standard_output_file $srcfile2]
33Dwarf::assemble $asm_file {
34 global srcfile
35 declare_labels int_label int2_label
36
37 get_func_info main
38 get_func_info bar_helper
39
40 set int_size [get_sizeof "int" 4]
41
42 set prog_line 1
43 set bar_line 2
44 set foo_line 3
45 set foobar_line 4
46
47 set global_I [gdb_target_symbol I]
48 set global_J [gdb_target_symbol J]
49 set global_K [gdb_target_symbol K]
50
51 cu {} {
52 compile_unit {
53 {language @DW_LANG_Fortran90}
54 {name dw2-entry-points.f90}
55 {comp_dir /tmp}
56 } {
57 int_label: base_type {
58 {name "int"}
59 {byte_size $int_size sdata}
60 {encoding @DW_ATE_signed}
61 }
62 subprogram {
63 {name prog}
64 {decl_file 1 data1}
65 {decl_line $prog_line data1}
66 {low_pc $main_start addr}
67 {high_pc "$main_start + $main_len" addr}
68 {external 1 flag}
69 {main_subprogram 1 flag}
70 }
71 subprogram {
72 {name bar}
73 {decl_file 1 data1}
74 {decl_line $bar_line data1}
75 {external 1 flag}
76 {low_pc $bar_helper_start addr}
77 {high_pc "$bar_helper_start + $bar_helper_len" addr}
78 } {
79 formal_parameter {
80 {name I}
81 {type :$int_label}
82 {location {addr $global_I} SPECIAL_expr}
83 }
84 formal_parameter {
85 {name J}
86 {type :$int_label}
87 {location {addr $global_J} SPECIAL_expr}
88 }
89 entry_point {
90 {name foo}
91 {decl_file 1 data1}
92 {decl_line $foo_line data1}
93 {low_pc foo_entry_label addr}
94 } {
95 formal_parameter {
96 {name J}
97 {type :$int_label}
98 {location {addr $global_J} SPECIAL_expr}
99 }
100 formal_parameter {
101 {name K}
102 {type :$int_label}
103 {location {addr $global_K} SPECIAL_expr}
104 }
105 }
106 entry_point {
107 {name foobar}
108 {decl_file 1 data1}
109 {decl_line $foobar_line data1}
110 {low_pc foobar_entry_label addr}
111 } {
112 formal_parameter {
113 {name J}
114 {type :$int_label}
115 {location {addr $global_J} SPECIAL_expr}
116 }
117 }
118 }
119 }
120 }
121
122 cu {} {
123 compile_unit {
124 {language @DW_LANG_Fortran90}
125 {name dw2-entry-points-2.f90}
126 {comp_dir /tmp}
127 } {
128 int2_label: base_type {
129 {name "int"}
130 {byte_size $int_size sdata}
131 {encoding @DW_ATE_signed}
132 }
133 subprogram {
134 {name barso}
135 {decl_file 1 data1}
136 {decl_line $bar_line data1}
137 {external 1 flag}
138 {low_pc $bar_helper_start addr}
139 {high_pc "$bar_helper_start + $bar_helper_len" addr}
140 } {
141 formal_parameter {
142 {name I}
143 {type :$int2_label}
144 {location {addr $global_I} SPECIAL_expr}
145 }
146 formal_parameter {
147 {name J}
148 {type :$int2_label}
149 {location {addr $global_J} SPECIAL_expr}
150 }
151 entry_point {
152 {name fooso}
153 {decl_file 1 data1}
154 {decl_line $foo_line data1}
155 {low_pc foo_entry_label addr}
156 } {
157 formal_parameter {
158 {name J}
159 {type :$int2_label}
160 {location {addr $global_J} SPECIAL_expr}
161 }
162 formal_parameter {
163 {name K}
164 {type :$int2_label}
165 {location {addr $global_K} SPECIAL_expr}
166 }
167 }
168 }
169 }
170 }
171}
172
173if {[prepare_for_testing "failed to prepare" ${testfile} \
174 [list $srcfile $asm_file] {nodebug}]} {
175 return -1
176}
177
178if ![runto_main] {
179 return -1
180}
181
182# Try whether we can set and hit breakpoints at the entry_points.
fa87f8e1
TV
183gdb_breakpoint "*foo"
184gdb_breakpoint "*foobar"
3396471b
NCK
185
186# Now hit the entry_point break point and check their call-stack.
187gdb_continue_to_breakpoint "foo"
188gdb_test "bt" [multi_line \
189 "#0.*${hex} in foo \\(J=1, K=0\\).*" \
190 "#1.*${hex} in prog \\(\\).*" \
191 ] "bt foo"
192
193gdb_continue_to_breakpoint "foobar"
194gdb_test "bt" [multi_line \
195 "#0.*${hex} in foobar \\(J=2\\).*" \
196 "#1.*${hex} in prog \\(\\).*" \
197 ] "bt foobar"
198
199# Now try whether we can also set breakpoints on entry_points from other CUs.
200
201clean_restart ${testfile}
202
203if ![runto_main] {
204 return -1
205}
206
fa87f8e1 207gdb_breakpoint "*fooso"
3396471b
NCK
208gdb_continue_to_breakpoint "foo_so"
209
210gdb_test "bt" [multi_line \
211 "#0.*${hex} in foo \\(J=1, K=0\\).*" \
212 "#1.*${hex} in prog \\(\\).*" \
213] "bt fooso"