1 # Copyright 2023-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 # Check that prologue analysis in foo is correct in the presence of a
17 # prologue_end marker in immediately following function bar.
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 require dwarf2_support
24 standard_testfile .c .S
26 set asm_file [standard_output_file $srcfile2]
27 Dwarf::assemble $asm_file {
28 global srcdir subdir srcfile srcfile2
29 declare_labels lines_label
34 {name dw2-prologue-end.c}
35 {stmt_list ${lines_label} DW_FORM_sec_offset}
40 {low_pc foo_label addr}
41 {high_pc foo_end addr}
46 {low_pc bar_label addr}
47 {high_pc bar_end addr}
52 lines {version 5} lines_label {
53 set diridx [include_dir "${srcdir}/${subdir}"]
54 file_name "$srcfile" $diridx
57 DW_LNS_set_file $diridx
59 DW_LNE_set_address foo_label
60 line [gdb_get_line_number "Foo body"]
63 DW_LNE_set_address bar_label
64 DW_LNS_set_prologue_end
65 line [gdb_get_line_number "Bar body"]
68 DW_LNE_set_address bar_end
74 if { [prepare_for_testing "failed to prepare" ${testfile} \
75 [list $srcfile $asm_file] {nodebug}] } {
79 # Don't runto main here, otherwise the following doesn't
80 # function as regression test for PR30369.
82 # Get the "break foo" address.
85 gdb_test_multiple "break foo" "" {
86 -re -wrap "at ($hex):\[^\r\n\]*" {
87 set break_addr $expect_out(1,string)
92 if { $break_addr == "" } {
96 # Get the "bar_label" address.
99 gdb_test_multiple "print /x &bar_label" "" {
100 -re -wrap "= ($hex)" {
101 set bar_label_addr $expect_out(1,string)
106 if { $bar_label_addr == "" } {
110 # Check that bar immediately follows foo. Otherwise the following doesn't
111 # function as regression test for PR30369.
113 gdb_test "print &foo_end == &bar_label" " = 1"
115 # Check that the breakpoint is set at the expected address. Regression test
118 gdb_assert { $break_addr < $bar_label_addr }