1 |
227 |
jeremybenn |
# Copyright 2008, 2009, 2010 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 file is part of the GDB testsuite. It tests 'until' and
|
17 |
|
|
# 'advance' in precord logfile.
|
18 |
|
|
|
19 |
|
|
# This test suitable only for process record-replay
|
20 |
|
|
if ![target_info exists gdb,use_precord] {
|
21 |
|
|
return
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
set testfile "until-reverse"
|
25 |
|
|
set srcfile ${testfile}.c
|
26 |
|
|
set srcfile1 ur1.c
|
27 |
|
|
|
28 |
|
|
if { [prepare_for_testing $testfile.exp $testfile {until-reverse.c ur1.c} ] } {
|
29 |
|
|
return -1
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
|
33 |
|
|
set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
|
34 |
|
|
set bp_location9 [gdb_get_line_number "set breakpoint 9 here" "$srcfile1"]
|
35 |
|
|
set bp_location19 [gdb_get_line_number "set breakpoint 19 here"]
|
36 |
|
|
set bp_location20 [gdb_get_line_number "set breakpoint 20 here"]
|
37 |
|
|
set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
|
38 |
|
|
|
39 |
|
|
runto main
|
40 |
|
|
|
41 |
|
|
if [target_info exists gdb,use_precord] {
|
42 |
|
|
# Activate process record/replay
|
43 |
|
|
gdb_test "record" "" "Turn on process record"
|
44 |
|
|
# FIXME: command ought to acknowledge, so we can test if it succeeded.
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
set end_of_main [gdb_get_line_number "set breakpoint 10a here" ]
|
48 |
|
|
gdb_test "break $end_of_main" \
|
49 |
|
|
"Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
|
50 |
|
|
"BP at end of main"
|
51 |
|
|
|
52 |
|
|
gdb_test "continue" "Breakpoint .* set breakpoint 10a here .*" "run to end of main"
|
53 |
|
|
|
54 |
|
|
gdb_test "record save until.precsave" \
|
55 |
|
|
"Saved core file until.precsave with execution log\." \
|
56 |
|
|
"save process recfile"
|
57 |
|
|
|
58 |
|
|
gdb_test "kill" "" "Kill process, prepare to debug log file" \
|
59 |
|
|
"Kill the program being debugged\\? \\(y or n\\) " "y"
|
60 |
|
|
|
61 |
|
|
gdb_test "record restore until.precsave" \
|
62 |
|
|
"Program terminated with signal .*" \
|
63 |
|
|
"reload core file"
|
64 |
|
|
|
65 |
|
|
# Verify that plain vanilla "until " works.
|
66 |
|
|
#
|
67 |
|
|
gdb_test "until $bp_location1" \
|
68 |
|
|
"main .* at .*:$bp_location1.*" \
|
69 |
|
|
"until line number"
|
70 |
|
|
|
71 |
|
|
# Advance up to factorial, outer invocation
|
72 |
|
|
#
|
73 |
|
|
gdb_test "advance factorial" \
|
74 |
|
|
"factorial .value=6..*$srcfile:$bp_location7.*" \
|
75 |
|
|
"advance to factorial"
|
76 |
|
|
|
77 |
|
|
# At this point, 'until' should continue the inferior up to when all the
|
78 |
|
|
# inner invocations of factorial() are completed and we are back at this
|
79 |
|
|
# frame.
|
80 |
|
|
#
|
81 |
|
|
gdb_test "until $bp_location19" \
|
82 |
|
|
"factorial .value=720.*${srcfile}:$bp_location19.*" \
|
83 |
|
|
"until factorial, recursive function"
|
84 |
|
|
|
85 |
|
|
# Finish out to main scope
|
86 |
|
|
#
|
87 |
|
|
gdb_test "finish" \
|
88 |
|
|
" in main .*$srcfile:$bp_location1.*" \
|
89 |
|
|
"finish to main"
|
90 |
|
|
|
91 |
|
|
# Advance to a function called by main (marker2)
|
92 |
|
|
#
|
93 |
|
|
gdb_test "advance marker2" \
|
94 |
|
|
"marker2 .a=43.*$srcfile1:$bp_location9.*" \
|
95 |
|
|
"advance to marker2"
|
96 |
|
|
|
97 |
|
|
# Now issue an until with another function, not called by the current
|
98 |
|
|
# frame, as argument. This should not work, i.e. the program should
|
99 |
|
|
# stop at main, the caller, where we put the 'guard' breakpoint.
|
100 |
|
|
#
|
101 |
|
|
set test_msg "until func, not called by current frame"
|
102 |
|
|
gdb_test_multiple "until marker3" "$test_msg" {
|
103 |
|
|
-re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" {
|
104 |
|
|
pass "$test_msg"
|
105 |
|
|
}
|
106 |
|
|
-re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" {
|
107 |
|
|
pass "$test_msg"
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
###
|
112 |
|
|
###
|
113 |
|
|
###
|
114 |
|
|
|
115 |
|
|
# Set reverse execution direction
|
116 |
|
|
# FIXME: command needs to acknowledge, so we can test if it succeeded.
|
117 |
|
|
|
118 |
|
|
gdb_test "set exec-dir reverse" "" "set reverse execution"
|
119 |
|
|
|
120 |
|
|
#
|
121 |
|
|
# We should now be at main, after the return from marker2.
|
122 |
|
|
# "Advance" backward into marker2.
|
123 |
|
|
#
|
124 |
|
|
|
125 |
|
|
gdb_test "advance marker2" \
|
126 |
|
|
"marker2 .a=43.*$srcfile1:$bp_location9.*" \
|
127 |
|
|
"reverse-advance to marker2"
|
128 |
|
|
|
129 |
|
|
# Finish out to main scope (backward)
|
130 |
|
|
|
131 |
|
|
gdb_test "finish" \
|
132 |
|
|
" in main .*$srcfile:$bp_location20.*" \
|
133 |
|
|
"reverse-finish from marker2"
|
134 |
|
|
|
135 |
|
|
# Advance backward to last line of factorial (outer invocation)
|
136 |
|
|
|
137 |
|
|
gdb_test "advance $bp_location19" \
|
138 |
|
|
"factorial .value=720.*${srcfile}:$bp_location19.*" \
|
139 |
|
|
"reverse-advance to final return of factorial"
|
140 |
|
|
|
141 |
|
|
# Now do "until" across the recursive calls,
|
142 |
|
|
# ending up in the same frame where we are now.
|
143 |
|
|
|
144 |
|
|
gdb_test "until $bp_location7" \
|
145 |
|
|
"factorial .value=6..*$srcfile:$bp_location7.*" \
|
146 |
|
|
"reverse-until to entry of factorial"
|