1 |
24 |
jeremybenn |
# Copyright 2004, 2007, 2008 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 .
|
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 |
|
|
|
27 |
|
|
if [target_info exists gdb,nosignals] {
|
28 |
|
|
verbose "Skipping savedregs.exp because of nosignals."
|
29 |
|
|
continue
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
if $tracelevel then {
|
33 |
|
|
strace $tracelevel
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
set prms_id 0
|
37 |
|
|
set bug_id 0
|
38 |
|
|
|
39 |
|
|
set testfile savedregs
|
40 |
|
|
set srcfile ${testfile}.c
|
41 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
42 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
43 |
|
|
untested "Couldn't compile ${module}.c"
|
44 |
|
|
return -1
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
# get things started
|
48 |
|
|
gdb_exit
|
49 |
|
|
gdb_start
|
50 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
51 |
|
|
gdb_load ${binfile}
|
52 |
|
|
|
53 |
|
|
# Advance to main
|
54 |
|
|
if { ![runto_main] } {
|
55 |
|
|
gdb_suppress_tests;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
proc process_saved_regs { current inner outer } {
|
59 |
|
|
global gdb_prompt
|
60 |
|
|
global expect_out
|
61 |
|
|
global saved_regs
|
62 |
|
|
|
63 |
|
|
# Skip the CURRENT frame.
|
64 |
|
|
|
65 |
|
|
set level 1
|
66 |
|
|
|
67 |
|
|
# Run over the list of INNER frames capturing the "info frame"
|
68 |
|
|
# output for each. Both dummy and sigtramp frames need to be
|
69 |
|
|
# handled specially: they do not yet have correct function names;
|
70 |
|
|
# and for dummy frames won't have saved registers. If there's a
|
71 |
|
|
# problem, fail but capture the output anyway, hopefully later
|
72 |
|
|
# "info frame" requests for that same frame will at least fail in
|
73 |
|
|
# a consistent manner (stops propogated fails).
|
74 |
|
|
|
75 |
|
|
foreach func $inner {
|
76 |
|
|
set saved_regs($func) "error"
|
77 |
|
|
set test "Get $func info frame"
|
78 |
|
|
# Both dummy and sigtramp frames have problems.
|
79 |
|
|
switch $func {
|
80 |
|
|
dummy {
|
81 |
|
|
# Dummy frame's do not have saved registers, and do
|
82 |
|
|
# not print .
|
83 |
|
|
set pat "Stack frame at .*"
|
84 |
|
|
}
|
85 |
|
|
sigtramp {
|
86 |
|
|
# Sigtramp frames don't yet print .
|
87 |
|
|
set pat "Stack frame at .* Saved registers:.*"
|
88 |
|
|
}
|
89 |
|
|
default {
|
90 |
|
|
set pat "Stack frame at .* in $func .* Saved registers:.*"
|
91 |
|
|
}
|
92 |
|
|
}
|
93 |
|
|
# If the "info frame" barf, capture the output anyway so that
|
94 |
|
|
# it does not cascade further failures.
|
95 |
|
|
gdb_test_multiple "info frame $level" "$test" {
|
96 |
|
|
-re "($pat)$gdb_prompt " {
|
97 |
|
|
set saved_regs($func) "$expect_out(1,string)"
|
98 |
|
|
pass "$test"
|
99 |
|
|
}
|
100 |
|
|
-re "(Stack frame at .*)$gdb_prompt " {
|
101 |
|
|
set saved_regs($func) "$expect_out(1,string)"
|
102 |
|
|
fail "$test"
|
103 |
|
|
}
|
104 |
|
|
-re "(Cannot access .*)$gdb_prompt " {
|
105 |
|
|
set saved_regs($func) "$expect_out(1,string)"
|
106 |
|
|
fail "$test"
|
107 |
|
|
}
|
108 |
|
|
}
|
109 |
|
|
incr level
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
# Now iterate through the list of OUTER frames checking that the
|
113 |
|
|
# "info frame" output from each still matches what was captured
|
114 |
|
|
# during an early query. To avoid cascading failures, checking is
|
115 |
|
|
# abandoned after the first failure. The assumption is that,
|
116 |
|
|
# since frames outer to the botched frame rely on the botched
|
117 |
|
|
# frame's info, those more outer frames are also botched. Besides
|
118 |
|
|
# we've got the failure we're after.
|
119 |
|
|
|
120 |
|
|
set ok 1
|
121 |
|
|
foreach func $outer {
|
122 |
|
|
set test [concat "Check $func info frame; stack contains" \
|
123 |
|
|
$current $inner $outer]
|
124 |
|
|
if $ok {
|
125 |
|
|
set ok 0
|
126 |
|
|
set pat [string_to_regexp "$saved_regs($func)"]
|
127 |
|
|
gdb_test_multiple "info frame $level" "$test" {
|
128 |
|
|
-re "$pat$gdb_prompt " {
|
129 |
|
|
pass "$test"
|
130 |
|
|
set ok 1
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
} {
|
134 |
|
|
pass "$test (skipped)"
|
135 |
|
|
}
|
136 |
|
|
incr level
|
137 |
|
|
}
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
# Continue to the signal thrower, capture main's saved-reg info.
|
142 |
|
|
gdb_test "advance thrower" "thrower .* at .*"
|
143 |
|
|
process_saved_regs thrower { main } { }
|
144 |
|
|
|
145 |
|
|
# Continue to the signal catcher, check main's saved-reg info, capture
|
146 |
|
|
# catcher's saved-reg info.
|
147 |
|
|
gdb_test "handle SIGSEGV pass print nostop"
|
148 |
|
|
gdb_test "advance catcher" "catcher .* at .*"
|
149 |
|
|
process_saved_regs catcher { sigtramp thrower } { main }
|
150 |
|
|
|
151 |
|
|
# Breakpoint at and call the caller function, saved-regs of main and
|
152 |
|
|
# catcher, capture caller's registers.
|
153 |
|
|
gdb_test "break caller"
|
154 |
|
|
gdb_test "call caller (1,2,3,4,5,6,7,8)"
|
155 |
|
|
process_saved_regs caller { dummy catcher } { sigtramp thrower main }
|
156 |
|
|
|
157 |
|
|
# Run to callee, again check everything.
|
158 |
|
|
gdb_test "advance callee" "callee .* at .*"
|
159 |
|
|
process_saved_regs callee { caller } { dummy catcher sigtramp thrower main }
|