Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / frame-inlined-in-outer-frame.exp
CommitLineData
88b9d363 1# Copyright 2020-2022 Free Software Foundation, Inc.
22b9b4b0
SL
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 unwinding when we have a frame inlined in the outer frame (in the sense
17# of frame.c:outer_frame_id).
18#
19# The conditions required to reproduce the original issue are:
20#
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.
24#
25# Because of (1), the test has to be written in assembly with explicit CFI
26# directives.
27
28load_lib dwarf.exp
29
30if {![dwarf2_support]} {
31 return 0
32}
33
34standard_testfile .S
35
36set dwarf_asm [standard_output_file dwarf-asm.S]
37Dwarf::assemble $dwarf_asm {
9476b583
TV
38 global srcfile
39
22b9b4b0
SL
40 declare_labels foo_subprogram bar_subprogram
41 declare_labels stmt_list
42
43 # See the comment in the .S file for the equivalent C program this is meant
44 # to represent.
45
46 cu { addr_size 4 } {
47 DW_TAG_compile_unit {
9476b583 48 {DW_AT_name $srcfile}
22b9b4b0
SL
49 {DW_AT_stmt_list $stmt_list DW_FORM_sec_offset}
50 {DW_AT_language @DW_LANG_C99}
51 {DW_AT_low_pc __cu_low_pc DW_FORM_addr}
52 {DW_AT_high_pc __cu_high_pc DW_FORM_addr}
53 } {
54 DW_TAG_subprogram {
55 {DW_AT_name "_start"}
56 {DW_AT_low_pc __start_low_pc DW_FORM_addr}
57 {DW_AT_high_pc __start_high_pc DW_FORM_addr}
58 } {
59 DW_TAG_inlined_subroutine {
60 {DW_AT_abstract_origin :$foo_subprogram}
61 {DW_AT_low_pc __foo_low_pc DW_FORM_addr}
62 {DW_AT_high_pc __foo_high_pc DW_FORM_addr}
63 {DW_AT_call_file 1 DW_FORM_data1}
64 {DW_AT_call_line 13 DW_FORM_data1}
65 } {
66 DW_TAG_inlined_subroutine {
67 {DW_AT_abstract_origin :$bar_subprogram}
68 {DW_AT_low_pc __bar_low_pc DW_FORM_addr}
69 {DW_AT_high_pc __bar_high_pc DW_FORM_addr}
70 {DW_AT_call_file 1 DW_FORM_data1}
71 {DW_AT_call_line 7 DW_FORM_data1}
72 }
73 }
74 }
75
76 foo_subprogram: DW_TAG_subprogram {
77 {DW_AT_name "foo"}
78 {DW_AT_prototyped 1 DW_FORM_flag_present}
79 {DW_AT_inline 0x1 DW_FORM_data1}
80 }
81
82 bar_subprogram: DW_TAG_subprogram {
83 {DW_AT_name "bar"}
84 {DW_AT_prototyped 1 DW_FORM_flag_present}
85 {DW_AT_inline 0x1 DW_FORM_data1}
86 }
87 }
88 }
89
90 lines { } stmt_list {
91 global srcdir subdir srcfile
92
93 include_dir "/some/directory"
94 file_name "/some/directory/file.c" 0
95 }
96}
97
98if { [build_executable ${testfile}.exp ${testfile} "$srcfile $dwarf_asm" \
99 {additional_flags=-nostdlib additional_flags=-static}] != 0 } {
100 untested "failed to compile"
101 return
102}
103
104clean_restart $binfile
105
106if { [gdb_starti_cmd] != 0 } {
107 fail "failed to run to first instruction"
108 return
109}
cac1e71d 110gdb_test "" "Program stopped.*" "starti prompt"
22b9b4b0
SL
111
112gdb_test "frame" "in _start .*"
113
114gdb_test "stepi" "in foo .*" "step into foo"
115gdb_test "stepi" "in bar .*" "step into bar"
116gdb_test "stepi" "in foo .*" "step back into foo"
117gdb_test "stepi" "in _start .*" "step back into _start"
This page took 0.156497 seconds and 4 git commands to generate.