]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-invalid-stack-top.exp
1 # Copyright (C) 2014-2024 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 # In this test we're looking at how gdb handles backtraces and
17 # investigating the stack depth when confronted with an "invalid" stack,
18 # that is a stack where the first few frames are normal, and then there's a
19 # frame where the stack in unreadable.
20 #
21 # One interesting bug that has been observed is that gdb will sometime
22 # exhibit different behaviour the first time a stack command is run
23 # compared to the second (and later) times a command is run. This is
24 # because the first time a command is run gdb actually tries to figure out
25 # the answer, while the second (and later) times gdb relies on the answer
26 # cached from the first time. As a result in this test each command is
27 # run twice, and we restart gdb before testing each different command to
28 # ensure that nothing is being cached.
29
30 set opts {}
31 standard_testfile .c
32
33 require is_x86_64_m64_target
34
35 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
36 return -1
37 }
38
39 if ![runto breakpt] {
40 return -1
41 }
42
43 # Use 'bt no-filters' here as the python filters will raise their own
44 # error during initialisation, the no-filters case is simpler.
45
46 gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
47 "first backtrace, with error message"
48
49 gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
50 "second backtrace, with error message"
51
52 clean_restart ${binfile}
53
54 if ![runto breakpt] {
55 return -1
56 }
57
58 gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
59 "\\^done,depth=\"1\"" \
60 "check mi -stack-info-depth command, first time"
61
62 gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
63 "\\^done,depth=\"1\"" \
64 "check mi -stack-info-depth command, second time"
65
66 clean_restart ${binfile}
67
68 if ![runto breakpt] {
69 return -1
70 }
71
72 gdb_test "interpreter-exec mi \"-stack-list-frames\"" \
73 "\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"func2\"(,arch=\"\[^\"\]+\")?\}\\\]" \
74 "check mi -stack-list-frames command, first time"
75
76 gdb_test "interpreter-exec mi \"-stack-list-frames\"" \
77 "\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"func2\"(,arch=\"\[^\"\]+\")?\}\\\]" \
78 "check mi -stack-list-frames command, second time"