]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/nested-subp2.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / nested-subp2.exp
CommitLineData
213516ef 1# Copyright 2015-2023 Free Software Foundation, Inc.
63e43d3a
PMR
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# This file is part of the gdb testsuite.
17
18#
19# Test nested functions related functionality.
20#
21
22standard_testfile
23
24
25set testcase "nested-subp2"
26
9b2c992c 27if ![support_nested_function_tests] {
b5d1d6f7
GB
28 untested "compiler does not support nested functions"
29 return -1
30}
31
9693166f
TV
32set flags {}
33lappend flags debug
34lappend flags additional_flags=-std=gnu99
35
21f507ef 36set ld_flags ldflags=-Wl,--no-warn-execstack
9693166f
TV
37if { [gdb_can_simple_compile ld-flags {int main () { return 0; }} executable \
38 $ld_flags] } {
39 lappend flags $ld_flags
40}
41
63e43d3a 42if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \
9693166f
TV
43 [standard_output_file "${testcase}"] \
44 executable $flags] != "" } {
63e43d3a
PMR
45 return -1
46}
47
48
49# Run until the variables we are interested in are visible.
50
51clean_restart "${testcase}"
52if ![runto_main] {
cdd42066 53 return
63e43d3a
PMR
54}
55
56set bp_location [gdb_get_line_number "STOP" "${testcase}.c"]
57gdb_test "break ${testcase}.c:${bp_location}" \
58 "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \
59 "breakpoint to the STOP marker"
63e43d3a 60
c6336a6d
LS
61with_test_prefix "stop at first iteration" {
62 gdb_test "continue" \
63 "Breakpoint \[0-9\]+, increment .*" \
64 "continue to the STOP marker"
63e43d3a 65
c6336a6d
LS
66 # Check we get correct values for both local and non-local variable references.
67 gdb_test "print c" "102 'f'"
68 gdb_test "print count" "0"
69}
63e43d3a
PMR
70
71
72# Same but a little later: make sure we were looking at the proper places.
c6336a6d
LS
73with_test_prefix "stop at second iteration" {
74 gdb_test "continue" \
75 "Breakpoint \[0-9\]+, increment .*" \
76 "continue to the STOP marker"
77 gdb_test "print c" "111 'o'"
78 gdb_test "print count" "1"
79}