2016-01-01 04:33:14 +00:00
|
|
|
# Copyright 2008-2016 Free Software Foundation, Inc.
|
2009-06-27 18:49:20 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
# This file is part of the GDB testsuite. It tests 'until' and
|
|
|
|
# 'advance' in reverse debugging.
|
|
|
|
|
2011-11-08 08:23:49 +00:00
|
|
|
if ![supports_reverse] {
|
2009-06-27 18:49:20 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2012-06-26 17:54:59 +00:00
|
|
|
standard_testfile .c ur1.c
|
2009-06-27 18:49:20 +00:00
|
|
|
|
2012-06-26 17:54:59 +00:00
|
|
|
if { [prepare_for_testing $testfile.exp $testfile \
|
|
|
|
[list $srcfile $srcfile2]] } {
|
2009-06-27 18:49:20 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
|
|
|
|
set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
|
2014-11-14 16:45:41 +00:00
|
|
|
set bp_location8 [gdb_get_line_number "set breakpoint 8 here" "$srcfile2"]
|
2009-06-27 18:49:20 +00:00
|
|
|
set bp_location19 [gdb_get_line_number "set breakpoint 19 here"]
|
|
|
|
set bp_location20 [gdb_get_line_number "set breakpoint 20 here"]
|
|
|
|
set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
|
|
|
|
|
|
|
|
runto main
|
|
|
|
|
2011-11-08 08:23:49 +00:00
|
|
|
if [supports_process_record] {
|
2009-06-27 18:49:20 +00:00
|
|
|
# Activate process record/replay
|
2010-05-28 18:26:41 +00:00
|
|
|
gdb_test_no_output "record" "Turn on process record"
|
2009-06-27 18:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Verify that plain vanilla "until <location>" works.
|
|
|
|
#
|
|
|
|
gdb_test "until $bp_location1" \
|
|
|
|
"main .* at .*:$bp_location1.*" \
|
|
|
|
"until line number"
|
|
|
|
|
|
|
|
# Advance up to factorial, outer invocation
|
|
|
|
#
|
|
|
|
gdb_test "advance factorial" \
|
|
|
|
"factorial .value=6..*$srcfile:$bp_location7.*" \
|
|
|
|
"advance to factorial"
|
|
|
|
|
|
|
|
# At this point, 'until' should continue the inferior up to when all the
|
|
|
|
# inner invocations of factorial() are completed and we are back at this
|
|
|
|
# frame.
|
|
|
|
#
|
|
|
|
gdb_test "until $bp_location19" \
|
|
|
|
"factorial .value=720.*${srcfile}:$bp_location19.*" \
|
|
|
|
"until factorial, recursive function"
|
|
|
|
|
|
|
|
# Finish out to main scope
|
|
|
|
#
|
|
|
|
gdb_test "finish" \
|
Simplify gdb.reverse/until-reverse.c
Nowadays, functions fprintf, printf and malloc are executed in
gdb.reverse/until-reverse.c, so that it takes much time to record
instructions inside them. This may cause timeout, and we had several
fixes to bump the timeout,
https://sourceware.org/ml/gdb-patches/2012-02/msg00038.html
https://sourceware.org/ml/gdb-patches/2015-08/msg00186.html
also I still see this on arm-linux,
continue
Continuing.
Do you want to auto delete previous execution log entries when record/replay buffer becomes full (record full stop-at-limit)?([y] or n) n
Process record: stopped by user.
Program stopped.
0xf77021e6 in __linkin_atfork (newp=0xf7751748 <atfork_mem>) at ../nptl/sysdeps/unix/sysv/linux/register-atfork.c:117
117 ../nptl/sysdeps/unix/sysv/linux/register-atfork.c: No such file or directory.
(gdb) FAIL: gdb.reverse/until-precsave.exp: run to end of main (got interactive prompt)
however, I can't figure out how these functions (fprintf, printf and
malloc) are related to the test itself. marker1 is a function from
shared library too so we don't need these complicated libc functions
at all. IMO, recording the instructions in these libc functions has
nothing to do with the test itself except slow down the test. This
patch is to remove the usage of fprintf and printf, and also move
malloc to a dead code path.
gdb/testsuite:
2016-03-30 Yao Qi <yao.qi@linaro.org>
* gdb.reverse/until-precsave.exp: Match function name only.
* gdb.reverse/until-reverse.c (main): Don't call fprintf nor printf.
Move malloc to a condition block.
* gdb.reverse/until-reverse.exp: Match function name only.
2016-03-30 15:36:51 +00:00
|
|
|
"main .*$srcfile:.*" \
|
2009-06-27 18:49:20 +00:00
|
|
|
"finish to main"
|
|
|
|
|
|
|
|
# Advance to a function called by main (marker2)
|
|
|
|
#
|
|
|
|
gdb_test "advance marker2" \
|
2014-11-14 16:45:41 +00:00
|
|
|
"marker2 .a=43.*$srcfile2:$bp_location8.*" \
|
2009-06-27 18:49:20 +00:00
|
|
|
"advance to marker2"
|
|
|
|
|
|
|
|
# Now issue an until with another function, not called by the current
|
|
|
|
# frame, as argument. This should not work, i.e. the program should
|
|
|
|
# stop at main, the caller, where we put the 'guard' breakpoint.
|
|
|
|
#
|
|
|
|
set test_msg "until func, not called by current frame"
|
|
|
|
gdb_test_multiple "until marker3" "$test_msg" {
|
|
|
|
-re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" {
|
|
|
|
pass "$test_msg"
|
|
|
|
}
|
|
|
|
-re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" {
|
|
|
|
pass "$test_msg"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
###
|
|
|
|
###
|
|
|
|
###
|
|
|
|
|
|
|
|
# Set reverse execution direction
|
|
|
|
|
2010-05-28 18:26:41 +00:00
|
|
|
gdb_test_no_output "set exec-dir reverse" "set reverse execution"
|
2009-06-27 18:49:20 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# We should now be at main, after the return from marker2.
|
|
|
|
# "Advance" backward into marker2.
|
|
|
|
#
|
|
|
|
|
|
|
|
gdb_test "advance marker2" \
|
2014-11-14 16:45:41 +00:00
|
|
|
"marker2 .a=43.*$srcfile2:$bp_location8.*" \
|
2009-06-27 18:49:20 +00:00
|
|
|
"reverse-advance to marker2"
|
|
|
|
|
|
|
|
# Finish out to main scope (backward)
|
|
|
|
|
|
|
|
gdb_test "finish" \
|
|
|
|
" in main .*$srcfile:$bp_location20.*" \
|
|
|
|
"reverse-finish from marker2"
|
|
|
|
|
|
|
|
# Advance backward to last line of factorial (outer invocation)
|
|
|
|
|
|
|
|
gdb_test "advance $bp_location19" \
|
|
|
|
"factorial .value=720.*${srcfile}:$bp_location19.*" \
|
|
|
|
"reverse-advance to final return of factorial"
|
|
|
|
|
|
|
|
# Now do "until" across the recursive calls,
|
|
|
|
# ending up in the same frame where we are now.
|
|
|
|
|
|
|
|
gdb_test "until $bp_location7" \
|
|
|
|
"factorial .value=6..*$srcfile:$bp_location7.*" \
|
|
|
|
"reverse-until to entry of factorial"
|