0225326331b1fe5c54977e4c15a55a3a0dadb825
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-invalid-stack-top.exp
1 # Copyright (C) 2014 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 if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
34 verbose "Skipping ${testfile}."
35 return
36 }
37 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } {
38 return -1
39 }
40
41 if ![runto breakpt] {
42 return -1
43 }
44
45 # Use 'bt no-filters' here as the python filters will raise their own
46 # error during initialisation, the no-filters case is simpler.
47
48 gdb_test "bt no-filters" "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\nCannot access memory at address 0x\[0-9a-f\]+" \
49 "first backtrace, with error message"
50
51 send_gdb "bt no-filters\n"
52 gdb_expect {
53 -re "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\nCannot access memory at address 0x\[0-9a-f\]+\r\n$gdb_prompt $" {
54 # Currently gdb will not display the error message associated with
55 # the truncated backtrace after the first backtrace has been
56 # completed. Ideally, we would do this. If this case is ever hit
57 # then we have started to display the backtrace in all cases and
58 # the xpass should becomd a pass, and the previous pass case below
59 # should be removed, or changed to a fail.
60 xpass "second backtrace, with error message"
61 }
62 -re "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\n$gdb_prompt $" {
63 pass "second backtrace, without error message"
64 }
65 timeout {
66 fail "second backtrace (timeout)"
67 }
68 }
69
70 clean_restart ${binfile}
71
72 if ![runto breakpt] {
73 return -1
74 }
75
76 set test_name "check mi -stack-info-depth command, first time"
77 send_gdb "interpreter-exec mi \"-stack-info-depth\"\n"
78 gdb_expect {
79 -re "\\^done,depth=\"1\"\r\n$gdb_prompt $" {
80 pass $test_name
81 }
82 -re "\\^error,msg=\"Cannot access memory at address $hex\"\r\n$gdb_prompt $" {
83 xfail $test_name
84 }
85 }
86
87 gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
88 "\\^done,depth=\"1\"" \
89 "check mi -stack-info-depth command, second time"
90
91 clean_restart ${binfile}
92
93 if ![runto breakpt] {
94 return -1
95 }
96
97 set test_name "check mi -stack-list-frames command, first time"
98 send_gdb "interpreter-exec mi \"-stack-list-frames\"\n"
99 gdb_expect {
100 -re "\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"func2\"\}\\\]\r\n$gdb_prompt $" {
101 pass $test_name
102 }
103 -re "\\^error,msg=\"Cannot access memory at address $hex\"\r\n$gdb_prompt $" {
104 xfail $test_name
105 }
106 }
107
108
109 gdb_test "interpreter-exec mi \"-stack-list-frames\"" \
110 "\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"func2\"\}\\\]" \
111 "check mi -stack-list-frames command, second time"
This page took 0.031733 seconds and 3 git commands to generate.