]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-invalid-stack-middle.exp
CommitLineData
4a94e368 1# Copyright (C) 2014-2022 Free Software Foundation, Inc.
938f0e2f
AB
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
938f0e2f
AB
30standard_testfile .S
31
32if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
33 verbose "Skipping ${testfile}."
34 return
35}
36
6e8b1ab2 37if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {nopie}] } {
938f0e2f
AB
38 return -1
39}
40
41if ![runto breakpt] {
42 return -1
43}
44
53e8a631 45gdb_test "bt" "^bt\r\n#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
938f0e2f
AB
46 "first backtrace, with error message"
47
53e8a631
AB
48gdb_test "bt" "^bt\r\n#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
49 "second backtrace, with error message"
938f0e2f
AB
50
51clean_restart ${binfile}
52
53if ![runto breakpt] {
54 return -1
55}
56
53e8a631
AB
57gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
58 "\\^done,depth=\"4\"" \
59 "check mi -stack-info-depth command, first time"
938f0e2f
AB
60
61gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
62 "\\^done,depth=\"4\"" \
63 "check mi -stack-info-depth command, second time"
64
65clean_restart ${binfile}
66
67if ![runto breakpt] {
68 return -1
69}
70
53e8a631 71gdb_test "interpreter-exec mi \"-stack-list-frames\"" \
b4c0d1a4 72 "\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"breakpt\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\},frame=\{level=\"1\",addr=\"$hex\",func=\"func5\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\},frame=\{level=\"2\",addr=\"$hex\",func=\"func4\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\},frame=\{level=\"3\",addr=\"$hex\",func=\"func3\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\}\\\]" \
53e8a631 73 "check mi -stack-list-frames command, first time"
938f0e2f
AB
74
75gdb_test "interpreter-exec mi \"-stack-list-frames\"" \
b4c0d1a4 76 "\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"breakpt\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\},frame=\{level=\"1\",addr=\"$hex\",func=\"func5\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\},frame=\{level=\"2\",addr=\"$hex\",func=\"func4\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\},frame=\{level=\"3\",addr=\"$hex\",func=\"func3\",file=\"\[^\"\]+\",fullname=\"\[^\"\]+\",line=\"${decimal}\"(,arch=\"\[^\"\]+\")?\}\\\]" \
938f0e2f 77 "check mi -stack-list-frames command, second time"