1 # Copyright 2014-2016 Free Software Foundation, Inc.
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.
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.
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/>. */
16 # Test that GDB isn't silent if it fails to remove a breakpoint from
17 # the main program, independently of whether the program was loaded
18 # with "file PROGRAM" or directly from the command line with "gdb
23 if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
27 # Run the test proper. INITIAL_LOAD determines whether the program is
28 # initially loaded by the "file" command or by passing it to GDB on
30 proc test_remove_bp { initial_load } {
31 with_test_prefix "$initial_load" {
32 global srcdir subdir binfile
38 set saved_gdbflags $GDBFLAGS
40 # See "used to behave differently" further below.
41 if { $initial_load == "file" } {
45 global last_loaded_file
47 # gdb_file_cmd sets this. This is what gdb_reload
48 # implementations use as binary.
49 set last_loaded_file $binfile
51 set GDBFLAGS "$GDBFLAGS $binfile"
54 gdb_reinitialize_dir $srcdir/$subdir
56 set GDBFLAGS $saved_gdbflags
59 fail "can't run to start"
65 # So we can easily control when are breakpoints removed.
66 gdb_test_no_output "set breakpoint always-inserted on"
71 gdb_test_multiple $test $test {
72 -re "Breakpoint .* at ($hex).*$gdb_prompt $" {
73 set bp_addr $expect_out(1,string)
79 unsupported "can't extract foo's address"
83 gdb_test "info break" "y.*$hex.*in foo at.*" \
86 # Now unmap the page where the breakpoint is set. Trying to
87 # remove the memory breakpoint afterwards should fail, and GDB
88 # should warn the user about it.
89 set pagesize [get_integer_valueof "pg_size" 0]
90 set align_addr [expr $bp_addr - $bp_addr % $pagesize]
91 set munmap [get_integer_valueof "munmap ($align_addr, $pagesize)" -1]
94 unsupported "can't munmap foo's page"
98 gdb_test "delete \$bpnum" \
99 "warning: Error removing breakpoint .*" \
100 "failure to remove breakpoint warns"
104 foreach initial_load { "cmdline" "file" } {
105 test_remove_bp $initial_load