1 # Copyright 2020-2022 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 unwinding when we have a frame inlined in the outer frame (in the sense
17 # of frame.c:outer_frame_id).
19 # The conditions required to reproduce the original issue are:
21 # 1. Have an outer frame whose DWARF CFI explicitly says that the frame return
22 # address is undefined.
23 # 2. A frame inlined in this other frame.
25 # Because of (1), the test has to be written in assembly with explicit CFI
28 # Check if starti command is supported.
29 require use_gdb_stub 0
33 if {![dwarf2_support]} {
39 set dwarf_asm [standard_output_file dwarf-asm.S]
40 Dwarf::assemble $dwarf_asm {
43 declare_labels foo_subprogram bar_subprogram
44 declare_labels stmt_list
46 # See the comment in the .S file for the equivalent C program this is meant
49 cu { label cu_label addr_size 4 } {
52 {DW_AT_stmt_list $stmt_list DW_FORM_sec_offset}
53 {DW_AT_language @DW_LANG_C99}
54 {DW_AT_low_pc __cu_low_pc DW_FORM_addr}
55 {DW_AT_high_pc __cu_high_pc DW_FORM_addr}
59 {DW_AT_low_pc __start_low_pc DW_FORM_addr}
60 {DW_AT_high_pc __start_high_pc DW_FORM_addr}
62 DW_TAG_inlined_subroutine {
63 {DW_AT_abstract_origin :$foo_subprogram}
64 {DW_AT_low_pc __foo_low_pc DW_FORM_addr}
65 {DW_AT_high_pc __foo_high_pc DW_FORM_addr}
66 {DW_AT_call_file 1 DW_FORM_data1}
67 {DW_AT_call_line 13 DW_FORM_data1}
69 DW_TAG_inlined_subroutine {
70 {DW_AT_abstract_origin :$bar_subprogram}
71 {DW_AT_low_pc __bar_low_pc DW_FORM_addr}
72 {DW_AT_high_pc __bar_high_pc DW_FORM_addr}
73 {DW_AT_call_file 1 DW_FORM_data1}
74 {DW_AT_call_line 7 DW_FORM_data1}
79 foo_subprogram: DW_TAG_subprogram {
81 {DW_AT_prototyped 1 DW_FORM_flag_present}
82 {DW_AT_inline 0x1 DW_FORM_data1}
85 bar_subprogram: DW_TAG_subprogram {
87 {DW_AT_prototyped 1 DW_FORM_flag_present}
88 {DW_AT_inline 0x1 DW_FORM_data1}
94 global srcdir subdir srcfile
96 include_dir "/some/directory"
97 file_name "/some/directory/file.c" 0
100 aranges {} cu_label {
101 arange {} __cu_low_pc __cu_high_pc
105 if { [build_executable ${testfile}.exp ${testfile} "$srcfile $dwarf_asm" \
106 {additional_flags=-nostdlib additional_flags=-static}] != 0 } {
107 untested "failed to compile"
111 clean_restart $binfile
113 if { [gdb_starti_cmd] != 0 } {
114 fail "failed to run to first instruction"
117 gdb_test "" "Program stopped.*" "starti prompt"
119 gdb_test "frame" "in _start .*"
121 gdb_test "stepi" "in foo .*" "step into foo"
122 gdb_test "stepi" "in bar .*" "step into bar"
123 gdb_test "stepi" "in foo .*" "step back into foo"
124 gdb_test "stepi" "in _start .*" "step back into _start"