1# Copyright 2008-2020 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# 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 20if ![supports_process_record] { 21 return 22} 23 24standard_testfile until-reverse.c ur1.c 25set precsave [standard_output_file until.precsave] 26 27if { [prepare_for_testing "failed to prepare" $testfile \ 28 [list $srcfile $srcfile2]] } { 29 return -1 30} 31 32set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] 33set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] 34set bp_location8 [gdb_get_line_number "set breakpoint 8 here" "$srcfile2"] 35set bp_location19 [gdb_get_line_number "set breakpoint 19 here"] 36set bp_location20 [gdb_get_line_number "set breakpoint 20 here"] 37set bp_location21 [gdb_get_line_number "set breakpoint 21 here"] 38 39runto main 40 41if [supports_process_record] { 42 # Activate process record/replay 43 gdb_test_no_output "record" "turn on process record" 44} 45 46set end_of_main [gdb_get_line_number "set breakpoint 10a here" ] 47gdb_test "break $end_of_main" \ 48 "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \ 49 "breakpoint at end of main" 50 51# This can take awhile. 52with_timeout_factor 20 { 53 gdb_test_multiple "continue" "run to end of main" { 54 -wrap -re "Breakpoint .* set breakpoint 10a here .*" { 55 pass $gdb_test_name 56 } 57 -wrap -re "Process record does not support instruction 0xfae64 at.*" { 58 kfail "gdb/25038" $gdb_test_name 59 return -1 60 } 61 } 62} 63 64# So can this, against gdbserver, for example. 65 66with_timeout_factor 10 { 67 gdb_test "record save $precsave" \ 68 "Saved core file $precsave with execution log\." \ 69 "save process recfile" 70} 71 72gdb_test "kill" "" "kill process, prepare to debug log file" \ 73 "Kill the program being debugged\\? \\(y or n\\) " "y" 74 75gdb_test "record restore $precsave" \ 76 "Restored records from core file .*" \ 77 "reload core file" 78 79# Verify that plain vanilla "until <location>" works. 80# 81gdb_test "until $bp_location1" \ 82 "main .* at .*:$bp_location1.*" \ 83 "until line number" 84 85# Advance up to factorial, outer invocation 86# 87gdb_test "advance factorial" \ 88 "factorial .value=6..*$srcfile:$bp_location7.*" \ 89 "advance to factorial" 90 91# At this point, 'until' should continue the inferior up to when all the 92# inner invocations of factorial() are completed and we are back at this 93# frame. 94# 95gdb_test "until $bp_location19" \ 96 "factorial .value=720.*${srcfile}:$bp_location19.*" \ 97 "until factorial, recursive function" 98 99# Finish out to main scope 100# 101gdb_test "finish" \ 102 "main .*$srcfile:.*" \ 103 "finish to main" 104 105# Advance to a function called by main (marker2) 106# 107gdb_test "advance marker2" \ 108 "marker2 .a=43.*$srcfile2:$bp_location8.*" \ 109 "advance to marker2" 110 111# Now issue an until with another function, not called by the current 112# frame, as argument. This should not work, i.e. the program should 113# stop at main, the caller, where we put the 'guard' breakpoint. 114# 115set test_msg "until func, not called by current frame" 116gdb_test_multiple "until marker3" "$test_msg" { 117 -re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" { 118 pass "$test_msg" 119 } 120 -re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" { 121 pass "$test_msg" 122 } 123} 124 125### 126### 127### 128 129# Set reverse execution direction 130 131gdb_test_no_output "set exec-dir reverse" "set reverse execution" 132 133# 134# We should now be at main, after the return from marker2. 135# "Advance" backward into marker2. 136# 137 138gdb_test "advance marker2" \ 139 "marker2 .a=43.*$srcfile2:$bp_location8.*" \ 140 "reverse-advance to marker2" 141 142# Finish out to main scope (backward) 143 144gdb_test "finish" \ 145 " in main .*$srcfile:$bp_location20.*" \ 146 "reverse-finish from marker2" 147 148# Advance backward to last line of factorial (outer invocation) 149 150gdb_test "advance $bp_location19" \ 151 "factorial .value=720.*${srcfile}:$bp_location19.*" \ 152 "reverse-advance to final return of factorial" 153 154# Now do "until" across the recursive calls, 155# ending up in the same frame where we are now. 156 157gdb_test "until $bp_location7" \ 158 "factorial .value=6..*$srcfile:$bp_location7.*" \ 159 "reverse-until to entry of factorial" 160