Files
binutils-gdb/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
Richard Bunt be1b6474f0 Fixed top frame assumption in watchpoint-hw-attach
watchpoint-hw-attach.exp was noticed to fail on some machines.
Thanks to the input from sergiodj and palves on the IRC channel,
it was concluded that the test case incorrectly assumed that on
attach it was landed in the top-most frame of the inferior. This
was fixed by running to a break point in main by explicitly
defining the source file name before continuing with the test.

Tested on the following architectures x86_64, aarch64 and ppc64le.

gdb/testsuite/ChangeLog:

	* gdb.base/watchpoint-hw-attach.c (main): Remove unneeded
	code.
	* gdb.base/watchpoint-hw-attach.exp: Break in outermost frame.
2018-06-28 08:59:59 +01:00

72 lines
2.2 KiB
Plaintext

# Copyright 2018 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/>.
# watchpoint-hw-attach.exp -- Test if hardware watchpoints are used
# when attaching to a target.
if {[skip_hw_watchpoint_tests]} {
return 0
}
if {![can_spawn_for_attach]} {
return 0
}
standard_testfile
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
return -1
}
clean_restart $binfile
if ![runto_main] {
untested "can't run to main"
return -1
}
# Run to the point where mypid in the test program has been
# populated.
gdb_breakpoint [gdb_get_line_number "pidacquired"]
gdb_continue_to_breakpoint "pidacquired"
# Get the PID of the test process.
set testpid [get_integer_valueof "mypid" 0]
gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior $decimal \\(process $testpid\\) detached\\\]"
if {$testpid == ""} {
return -1
}
# A clean restart is needed to force the hardware watchpoint setup
# logic to run post attach rather than post inferior launch.
clean_restart $binfile
gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*"
# Ensure the test program is in the top frame so the required
# variables are in scope.
gdb_breakpoint $srcfile:[gdb_get_line_number "pidacquired"]
gdb_continue_to_breakpoint "$srcfile:pidacquired"
gdb_test_no_output "set should_continue = 1"
gdb_test "watch watched_variable" \
"Hardware watchpoint $decimal: watched_variable"
gdb_test "continue" \
"continue.*Continuing.*\.Hardware watchpoint $decimal: watched_variable.*Old value = 0.*New value = 4.*watched_variable\\);"