Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2012-2020 Free Software Foundation, Inc. |
b3dc46ff AB |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
b3dc46ff AB |
16 | standard_testfile |
17 | ||
5b362f04 | 18 | if { [prepare_for_testing "failed to prepare" ${testfile}] } { |
b3dc46ff AB |
19 | return -1 |
20 | } | |
21 | ||
22 | if ![runto breakpt] { | |
23 | return -1 | |
24 | } | |
25 | ||
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" | |
31 | ||
b3dc46ff | 32 | |
8b0553c1 PA |
33 | # Try a find starting from each global, expecting the search to fail |
34 | # due to memory access failure. | |
35 | # | |
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. | |
39 | # | |
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.) | |
51 | ||
52 | proc test_not_found {expect_warning} { | |
53 | global decimal hex | |
54 | ||
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" | |
58 | } else { | |
59 | set halting_search_re "" | |
60 | } | |
b3dc46ff | 61 | |
8b0553c1 PA |
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." | |
65 | ||
66 | gdb_test "find global_var_1, global_var_2, 0xff" \ | |
67 | "${halting_search_re}Pattern not found." | |
68 | ||
69 | gdb_test "find global_var_2, (global_var_2 + 16), 0xff" \ | |
70 | "${halting_search_re}Pattern not found." | |
71 | } | |
72 | ||
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. | |
76 | ||
77 | if {[target_info gdb_protocol] == "remote" | |
78 | || [target_info gdb_protocol] == "extended-remote"} { | |
79 | test_not_found 0 | |
80 | with_test_prefix "search-memory-packet off" { | |
81 | gdb_test_no_output "set remote search-memory-packet off" | |
82 | test_not_found 0 | |
83 | } | |
84 | } else { | |
85 | test_not_found 1 | |
86 | } |