1 # Copyright 2008-2020 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 standard_testfile .c inline-markers.c
18 if {[prepare_for_testing "failed to prepare" $testfile \
19 [list $srcfile $srcfile2] {debug additional_flags=-Winline}]} {
27 if { [skip_inline_var_tests] } {
28 untested inline-bt.exp
32 set no_frames [skip_inline_frame_tests]
34 set line1 [gdb_get_line_number "set breakpoint 1 here" ${srcfile2}]
35 gdb_breakpoint $srcfile2:$line1
37 gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar 1"
39 gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar 2"
42 gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*main.*" \
43 "backtrace from bar 2"
44 gdb_test "up" "#1 .*func1 .* at .*" "up from bar 2"
45 gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 2"
46 set pass_re "array = {$decimal, \[^\r\n\]*}"
47 set kfail_re [multi_line $pass_re \
48 "array = {<optimized out> <repeats 64 times>}"]
49 gdb_test_multiple "info locals" "info locals above bar 2" {
54 kfail gdb/25695 $gdb_test_name
58 set msg "info args above bar 2"
59 gdb_test_multiple "info args" $msg {
60 -re "arg1 = $decimal\r\n$gdb_prompt $" {
63 -re "arg1 = <optimized out>\r\n$gdb_prompt $" {
64 # GCC 4.3 and later lose location information for arg1. GCC 4.2 is OK.
65 if { [test_compiler_info "gcc-4-3-*"] || [test_compiler_info "gcc-4-4-*"]} {
72 gdb_test "up" "#1 .*main .* at .*" "up from bar 2"
73 gdb_test "info locals" ".*arg1 = 0.*" "info locals above bar 2"
76 # Make sure that locals on the stack are found. This is an array to
77 # prevent it from living in a register.
78 gdb_test "print array\[0\]" "\\\$$decimal = 0" "print local 2"
81 # Verify that we do not print out variables from the inlined
83 gdb_test "print val" "No symbol \"val\" in current context\\." \
84 "print out of scope local"
87 # Repeat the tests from a depth of two inlined functions, and with a
88 # more interesting value in the local array.
89 gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar 3"
91 gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*func2.*#3 .*main.*" \
92 "backtrace from bar 3"
93 gdb_test "up" "#1 .*func1 .* at .*" "up from bar 3"
94 gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 3"
95 set pass_re "array = {$decimal, \[^\r\n\]*}"
96 set kfail_re [multi_line $pass_re \
97 "array = {<optimized out> <repeats 64 times>}"]
98 gdb_test_multiple "info locals" "info locals above bar 3" {
102 -re -wrap $kfail_re {
103 kfail gdb/25695 $gdb_test_name
107 set msg "info args above bar 3"
108 gdb_test_multiple "info args" $msg {
109 -re "arg1 = $decimal\r\n$gdb_prompt $" {
112 -re "arg1 = <optimized out>\r\n$gdb_prompt $" {
113 # GCC 4.3 and later lose location information for arg1. GCC 4.2 is OK.
114 if { [test_compiler_info "gcc-4-3-*"] || [test_compiler_info "gcc-4-4-*"]} {
121 gdb_test "up" "#1 .*main .* at .*" "up from bar 3"
122 gdb_test "info locals" ".*arg1 = 1.*" "info locals above bar (3a)"
123 gdb_test "info locals" ".*arg2 = 184.*" "info locals above bar (3b)"
126 gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local 3"