[gdb/testsuite] Fix gdb.dwarf2/frame-inlined-in-outer-frame.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / frame-inlined-in-outer-frame.exp
CommitLineData
22b9b4b0
SL
1# Copyright 2020 Free Software Foundation, Inc.
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 {
38 declare_labels foo_subprogram bar_subprogram
39 declare_labels stmt_list
40
41 # See the comment in the .S file for the equivalent C program this is meant
42 # to represent.
43
44 cu { addr_size 4 } {
45 DW_TAG_compile_unit {
46 {DW_AT_name file1.txt}
47 {DW_AT_stmt_list $stmt_list DW_FORM_sec_offset}
48 {DW_AT_language @DW_LANG_C99}
49 {DW_AT_low_pc __cu_low_pc DW_FORM_addr}
50 {DW_AT_high_pc __cu_high_pc DW_FORM_addr}
51 } {
52 DW_TAG_subprogram {
53 {DW_AT_name "_start"}
54 {DW_AT_low_pc __start_low_pc DW_FORM_addr}
55 {DW_AT_high_pc __start_high_pc DW_FORM_addr}
56 } {
57 DW_TAG_inlined_subroutine {
58 {DW_AT_abstract_origin :$foo_subprogram}
59 {DW_AT_low_pc __foo_low_pc DW_FORM_addr}
60 {DW_AT_high_pc __foo_high_pc DW_FORM_addr}
61 {DW_AT_call_file 1 DW_FORM_data1}
62 {DW_AT_call_line 13 DW_FORM_data1}
63 } {
64 DW_TAG_inlined_subroutine {
65 {DW_AT_abstract_origin :$bar_subprogram}
66 {DW_AT_low_pc __bar_low_pc DW_FORM_addr}
67 {DW_AT_high_pc __bar_high_pc DW_FORM_addr}
68 {DW_AT_call_file 1 DW_FORM_data1}
69 {DW_AT_call_line 7 DW_FORM_data1}
70 }
71 }
72 }
73
74 foo_subprogram: DW_TAG_subprogram {
75 {DW_AT_name "foo"}
76 {DW_AT_prototyped 1 DW_FORM_flag_present}
77 {DW_AT_inline 0x1 DW_FORM_data1}
78 }
79
80 bar_subprogram: DW_TAG_subprogram {
81 {DW_AT_name "bar"}
82 {DW_AT_prototyped 1 DW_FORM_flag_present}
83 {DW_AT_inline 0x1 DW_FORM_data1}
84 }
85 }
86 }
87
88 lines { } stmt_list {
89 global srcdir subdir srcfile
90
91 include_dir "/some/directory"
92 file_name "/some/directory/file.c" 0
93 }
94}
95
96if { [build_executable ${testfile}.exp ${testfile} "$srcfile $dwarf_asm" \
97 {additional_flags=-nostdlib additional_flags=-static}] != 0 } {
98 untested "failed to compile"
99 return
100}
101
102clean_restart $binfile
103
104if { [gdb_starti_cmd] != 0 } {
105 fail "failed to run to first instruction"
106 return
107}
cac1e71d 108gdb_test "" "Program stopped.*" "starti prompt"
22b9b4b0
SL
109
110gdb_test "frame" "in _start .*"
111
112gdb_test "stepi" "in foo .*" "step into foo"
113gdb_test "stepi" "in bar .*" "step into bar"
114gdb_test "stepi" "in foo .*" "step back into foo"
115gdb_test "stepi" "in _start .*" "step back into _start"
This page took 0.028493 seconds and 4 git commands to generate.