]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.opt/inline-locals.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.opt / inline-locals.exp
CommitLineData
42a4f53d 1# Copyright 2008-2019 Free Software Foundation, Inc.
edb3359d
DJ
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
efc9d70a
TT
16standard_testfile .c inline-markers.c
17
5b362f04 18if {[prepare_for_testing "failed to prepare" $testfile \
1f960ced 19 [list $srcfile $srcfile2] {debug additional_flags=-Winline}]} {
edb3359d
DJ
20 return -1
21}
22
edb3359d
DJ
23runto_main
24
4c93b1db 25get_compiler_info
edb3359d
DJ
26get_debug_format
27if { [skip_inline_var_tests] } {
28 untested inline-bt.exp
29 return
30}
31
32set no_frames [skip_inline_frame_tests]
33
34set line1 [gdb_get_line_number "set breakpoint 1 here" ${srcfile2}]
35gdb_breakpoint $srcfile2:$line1
36
ddbb44cf 37gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar 1"
edb3359d 38
ddbb44cf 39gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar 2"
edb3359d
DJ
40
41if { ! $no_frames } {
42 gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*main.*" \
ddbb44cf
SM
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"
41bd68f5 46 setup_kfail "gdb/xyz" *-*-*
ddbb44cf 47 gdb_test "info locals" "array = {.*}" "info locals above bar 2"
edb3359d 48
ddbb44cf 49 set msg "info args above bar 2"
edb3359d
DJ
50 gdb_test_multiple "info args" $msg {
51 -re "arg1 = $decimal\r\n$gdb_prompt $" {
52 pass $msg
53 }
585fdaa1 54 -re "arg1 = <optimized out>\r\n$gdb_prompt $" {
c38f313d
DJ
55 # GCC 4.3 and later lose location information for arg1. GCC 4.2 is OK.
56 if { [test_compiler_info "gcc-4-3-*"] || [test_compiler_info "gcc-4-4-*"]} {
edb3359d
DJ
57 setup_xfail *-*-*
58 }
59 fail $msg
60 }
61 }
62} else {
ddbb44cf
SM
63 gdb_test "up" "#1 .*main .* at .*" "up from bar 2"
64 gdb_test "info locals" ".*arg1 = 0.*" "info locals above bar 2"
edb3359d
DJ
65}
66
67# Make sure that locals on the stack are found. This is an array to
68# prevent it from living in a register.
ddbb44cf 69gdb_test "print array\[0\]" "\\\$$decimal = 0" "print local 2"
edb3359d
DJ
70
71if { ! $no_frames } {
72 # Verify that we do not print out variables from the inlined
73 # function's caller.
74 gdb_test "print val" "No symbol \"val\" in current context\\." \
75 "print out of scope local"
76}
77
78# Repeat the tests from a depth of two inlined functions, and with a
79# more interesting value in the local array.
ddbb44cf 80gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar 3"
edb3359d
DJ
81if { ! $no_frames } {
82 gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*func2.*#3 .*main.*" \
ddbb44cf
SM
83 "backtrace from bar 3"
84 gdb_test "up" "#1 .*func1 .* at .*" "up from bar 3"
85 gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 3"
41bd68f5 86 setup_kfail "gdb/xyz" *-*-*
ddbb44cf 87 gdb_test "info locals" "array = {.*}" "info locals above bar 3"
edb3359d 88
ddbb44cf 89 set msg "info args above bar 3"
edb3359d
DJ
90 gdb_test_multiple "info args" $msg {
91 -re "arg1 = $decimal\r\n$gdb_prompt $" {
92 pass $msg
93 }
585fdaa1 94 -re "arg1 = <optimized out>\r\n$gdb_prompt $" {
c38f313d
DJ
95 # GCC 4.3 and later lose location information for arg1. GCC 4.2 is OK.
96 if { [test_compiler_info "gcc-4-3-*"] || [test_compiler_info "gcc-4-4-*"]} {
edb3359d
DJ
97 setup_xfail *-*-*
98 }
99 fail $msg
100 }
101 }
102} else {
ddbb44cf 103 gdb_test "up" "#1 .*main .* at .*" "up from bar 3"
edb3359d
DJ
104 gdb_test "info locals" ".*arg1 = 1.*" "info locals above bar (3a)"
105 gdb_test "info locals" ".*arg2 = 184.*" "info locals above bar (3b)"
106}
107
ddbb44cf 108gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local 3"