binutils-gdb/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp
Yao Qi c8064e7e9b Fix gdb.reverse/finish-reverse-bkpt.exp
I see the following fail on aarch64-linux

 break void_func
 Breakpoint 2 at 0x4007a0: file gdb/testsuite/gdb.reverse/finish-reverse.c, line 44.
 (gdb) PASS: gdb.reverse/finish-reverse-bkpt.exp: set breakpoint on void_func
 continue
 Continuing.

 Breakpoint 2, void_func () at gdb/testsuite/gdb.reverse/finish-reverse.c:44^M
 44        void_test = 1;                /* VOID FUNC */^M
 (gdb) PASS: gdb.reverse/finish-reverse-bkpt.exp: continue to breakpoint: void_func
 break *void_func^M
 Note: breakpoint 2 also set at pc 0x4007a0.^M
 Breakpoint 3 at 0x4007a0: file gdb/testsuite/gdb.reverse/finish-reverse.c, line 44.
 (gdb) PASS: gdb.reverse/finish-reverse-bkpt.exp: set breakpoint at void_func's entry
 reverse-finish^M
 Run back to call of #0  void_func () at gdb/testsuite/gdb.reverse/finish-reverse.c:44
 main (argc=1, argv=0x7ffffffb78) at gdb/testsuite/gdb.reverse/finish-reverse.c:98
 98        void_func ();                                 /* call to void_func */^M
 (gdb) FAIL: gdb.reverse/finish-reverse-bkpt.exp: reverse-finish from void_func trips breakpoint at entry

The test assumes that brekapoints on "void_func" and "*void_func" are
set on different places because of function prologue.  However, on
aarch64-linux, there is no prologue in void_func, so two breakpoints
are set at the same place (0x4007a0).

(gdb) disassemble void_func
Dump of assembler code for function void_func:
   0x00000000004007a0 <+0>:	adrp	x0, 0x410000
   0x00000000004007a4 <+4>:	add	x0, x0, #0xc14
   0x00000000004007a8 <+8>:	mov	w1, #0x1
   0x00000000004007ac <+12>:	str	w1, [x0]
   0x00000000004007b0 <+16>:	ret

The fix to this problem is to single step forward before setting
breakpoint on *void_func.

gdb/testsuite:

2016-04-07  Yao Qi  <yao.qi@linaro.org>

	* gdb.reverse/finish-reverse-bkpt.exp: Use temporary breakpoint.
	Execute "si" command.
2016-04-07 17:06:14 +01:00

62 lines
2.0 KiB
Plaintext

# Copyright 2008-2016 Free Software Foundation, Inc.
# 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.
#
# 'reverse-finish' used to have a bug where user breakpoints set at
# the functions entry would be ignored. Make sure the bug doesn't
# reappear.
if ![supports_reverse] {
return
}
standard_testfile finish-reverse.c
if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } {
return -1
}
if ![runto_main] then {
fail "Can't run to main"
return 0
}
if [supports_process_record] {
# Activate process record/replay
gdb_test_no_output "record" "Turn on process record"
}
set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
gdb_test "tbreak void_func" \
"Temporary breakpoint $decimal at .*$srcfile, line $breakloc\." \
"set breakpoint on void_func"
gdb_continue_to_breakpoint "void_func" ".*$srcfile:$breakloc.*"
# We stop at the brekapoint on void_func, but breakpoint on
# *void_func will be set at the same place if function void_func doesn't
# have prologue. One step forward to avoid this.
gdb_test "si"
gdb_test "break \*void_func" \
"Breakpoint $decimal at .*" \
"set breakpoint at void_func's entry"
gdb_test "reverse-finish" \
".*Breakpoint .*, void_func.*" \
"reverse-finish from void_func trips breakpoint at entry"
gdb_test "frame" "#0 void_func.*" "no spurious proceed after breakpoint stop"