aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/hbreak-unmapped.exp
blob: b71770fc0da6319d58ca04ce847d59481ceeec12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright 2014 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/>.

if {[skip_hw_breakpoint_tests]} {
    return 0
}

standard_testfile

if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
    return -1
}

if ![runto_main] {
    fail "Can't run to main"
    return -1
}

# If we can read the memory at address 0, skip the test.
if { [is_address_zero_readable] } {
    untested "Memory at address 0 is readable"
    return
}

delete_breakpoints

# Test whether the target supports hardware breakpoints at all.

set supports_hbreak 0
set test "probe hardware breakpoint support"
gdb_test_multiple "hbreak main" $test {
    -re "No hardware breakpoint support in the target.*$gdb_prompt $" {
	pass $test
    }
    -re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" {
	pass $test
    }
    -re "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*$gdb_prompt $" {
	set supports_hbreak 1
	pass $test
    }
}

if {!$supports_hbreak} {
    unsupported "hardware breakpoints"
    return
}

delete_breakpoints

# Force immediate breakpoint insertion.
gdb_test_no_output "set breakpoint always-inserted on"

# Hardware breakpoints are implemented using a mechanism that is not
# dependent on being able to modify the target's memory, we should be
# able to set them even in unmapped memory areas.
gdb_test "hbreak *0" "Hardware assisted breakpoint \[0-9\]+ at 0x0"

gdb_test "info break" "hw breakpoint.*y.*0x0\+\[ \t\]\+" \
    "info break shows hw breakpoint"

gdb_test_no_output "delete \$bpnum" "" "delete" \
    "delete hw breakpoint"

gdb_test "info break" "No breakpoints or watchpoints\." \
    "info break shows no breakpoints"