1 # Copyright 2012-2018 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/>.
18 if { [prepare_for_testing "failed to prepare" ${testfile}] } {
26 # Basic attempt to read memory from globals.
27 gdb_test "x/5w global_var_1" \
28 "$hex:\[ \t\]+0\[ \t\]+0\[ \t\]+0\[ \t\]+0\r\n$hex:\[ \t\]+Cannot access memory at address $hex"
29 gdb_test "x/5w global_var_2" \
30 "$hex:\[ \t\]+Cannot access memory at address $hex"
33 # Try a find starting from each global, expecting the search to fail
34 # due to memory access failure.
36 # If EXPECT_WARNING is true, then expect the "Unable to access
37 # ... halting search" warning before the "Pattern not found" output.
38 # Otherwise, don't expect the warning.
40 # (EXPECT_WARNING is necessary because when testing with the RSP
41 # against servers that support the remote search memory packet, GDB
42 # does not print that "halting search" warning. While there are
43 # servers that do print the same warning message as GDB would if it
44 # were in charge of the search (like GDBserver), we're only parsing
45 # GDB's output here, not the server's output. And while we could read
46 # GDBserver's output from $inferior_spawn_id, having GDBserver print
47 # the warnings on its terminal doesn't really help users. Much better
48 # would be to extend the remote protocol to let the server tell GDB
49 # which memory range couldn't be accessed, and then let GDB print the
50 # warning instead of the server. See PR gdb/22293.)
52 proc test_not_found {expect_warning} {
55 if {$expect_warning} {
56 set halting_search_re \
57 "warning: Unable to access $decimal bytes of target memory at $hex, halting search\.\r\n"
59 set halting_search_re ""
62 # Now try a find starting from each global.
63 gdb_test "find global_var_0, global_var_2, 0xff" \
64 "${halting_search_re}Pattern not found."
66 gdb_test "find global_var_1, global_var_2, 0xff" \
67 "${halting_search_re}Pattern not found."
69 gdb_test "find global_var_2, (global_var_2 + 16), 0xff" \
70 "${halting_search_re}Pattern not found."
73 # If testing with the RSP, also test with target-side search
74 # acceleration disabled. This serves as proxy for servers that don't
75 # support the memory search packet, when testing with GDBserver.
77 if {[target_info gdb_protocol] == "remote"
78 || [target_info gdb_protocol] == "extended-remote"} {
80 with_test_prefix "search-memory-packet off" {
81 gdb_test_no_output "set remote search-memory-packet off"