* ld.texinfo (SEGMENT_START): Rephrase to indicate that a -T
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / savedregs.exp
CommitLineData
28e7fd62 1# Copyright 2004-2013 Free Software Foundation, Inc.
a1e167bb
AC
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
a1e167bb 6# (at your option) any later version.
e22f8b7c 7#
a1e167bb
AC
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.
e22f8b7c 12#
a1e167bb 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
a1e167bb
AC
15
16# This test is to check that a frame's "info frame", especially the
17# saved registers list, doesn't change while that frame isn't current.
18
19# It uses the program savedregs.c to construct a somewhat warped
20# backtrace (contains both signal and dummy frames) and then, at each
21# step checks that non-inner frames have consistent "info frame"
22# output. Note that a frame's "info frame" can only be captured after
23# it is non-current (made a call, interrupted, ...), this is because
24# instructions executed to perform the call may affect "info frame"
25# output.
26
27if [target_info exists gdb,nosignals] {
28 verbose "Skipping savedregs.exp because of nosignals."
29 continue
30}
31
a1e167bb
AC
32
33set testfile savedregs
34set srcfile ${testfile}.c
35set binfile ${objdir}/${subdir}/${testfile}
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 untested "Couldn't compile ${module}.c"
38 return -1
39}
40
41# get things started
42gdb_exit
43gdb_start
44gdb_reinitialize_dir $srcdir/$subdir
45gdb_load ${binfile}
46
47# Advance to main
48if { ![runto_main] } {
49 gdb_suppress_tests;
50}
51
52proc process_saved_regs { current inner outer } {
53 global gdb_prompt
54 global expect_out
55 global saved_regs
56
57 # Skip the CURRENT frame.
58
59 set level 1
60
61 # Run over the list of INNER frames capturing the "info frame"
62 # output for each. Both dummy and sigtramp frames need to be
63 # handled specially: they do not yet have correct function names;
64 # and for dummy frames won't have saved registers. If there's a
65 # problem, fail but capture the output anyway, hopefully later
66 # "info frame" requests for that same frame will at least fail in
67 # a consistent manner (stops propogated fails).
68
69 foreach func $inner {
70 set saved_regs($func) "error"
71 set test "Get $func info frame"
72 # Both dummy and sigtramp frames have problems.
73 switch $func {
74 dummy {
75 # Dummy frame's do not have saved registers, and do
76 # not print <dummy>.
1303f75e 77 set pat "Stack frame at .*"
a1e167bb
AC
78 }
79 sigtramp {
80 # Sigtramp frames don't yet print <signal trampoline>.
9cf0961b 81 set pat "Stack frame at .* Saved registers:.*"
a1e167bb
AC
82 }
83 default {
84 set pat "Stack frame at .* in $func .* Saved registers:.*"
85 }
86 }
87 # If the "info frame" barf, capture the output anyway so that
88 # it does not cascade further failures.
89 gdb_test_multiple "info frame $level" "$test" {
90 -re "($pat)$gdb_prompt " {
91 set saved_regs($func) "$expect_out(1,string)"
92 pass "$test"
93 }
94 -re "(Stack frame at .*)$gdb_prompt " {
95 set saved_regs($func) "$expect_out(1,string)"
96 fail "$test"
97 }
98 -re "(Cannot access .*)$gdb_prompt " {
99 set saved_regs($func) "$expect_out(1,string)"
100 fail "$test"
101 }
102 }
103 incr level
104 }
105
106 # Now iterate through the list of OUTER frames checking that the
107 # "info frame" output from each still matches what was captured
108 # during an early query. To avoid cascading failures, checking is
109 # abandoned after the first failure. The assumption is that,
110 # since frames outer to the botched frame rely on the botched
111 # frame's info, those more outer frames are also botched. Besides
112 # we've got the failure we're after.
113
114 set ok 1
115 foreach func $outer {
116 set test [concat "Check $func info frame; stack contains" \
117 $current $inner $outer]
118 if $ok {
119 set ok 0
120 set pat [string_to_regexp "$saved_regs($func)"]
121 gdb_test_multiple "info frame $level" "$test" {
122 -re "$pat$gdb_prompt " {
123 pass "$test"
124 set ok 1
125 }
126 }
127 } {
128 pass "$test (skipped)"
129 }
130 incr level
131 }
132}
133
134
135# Continue to the signal thrower, capture main's saved-reg info.
136gdb_test "advance thrower" "thrower .* at .*"
137process_saved_regs thrower { main } { }
138
139# Continue to the signal catcher, check main's saved-reg info, capture
140# catcher's saved-reg info.
141gdb_test "handle SIGSEGV pass print nostop"
d93f7b5c 142gdb_test "handle SIGILL pass print nostop"
a1e167bb
AC
143gdb_test "advance catcher" "catcher .* at .*"
144process_saved_regs catcher { sigtramp thrower } { main }
145
146# Breakpoint at and call the caller function, saved-regs of main and
147# catcher, capture caller's registers.
148gdb_test "break caller"
149gdb_test "call caller (1,2,3,4,5,6,7,8)"
150process_saved_regs caller { dummy catcher } { sigtramp thrower main }
151
152# Run to callee, again check everything.
153gdb_test "advance callee" "callee .* at .*"
154process_saved_regs callee { caller } { dummy catcher sigtramp thrower main }
This page took 0.862051 seconds and 4 git commands to generate.