aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-10-07 12:07:55 -0600
committerTom Tromey <tromey@adacore.com>2020-10-07 12:07:55 -0600
commit4a72de73660810536e9bb416d41dc8a6128f91da (patch)
tree4ada40b22e18b0ab7b64494c58d45c1492a76187 /gdb/remote.c
parente86efb3310cf3aa9515cca07d0835b7e8af79b38 (diff)
downloadgdb-4a72de73660810536e9bb416d41dc8a6128f91da.zip
gdb-4a72de73660810536e9bb416d41dc8a6128f91da.tar.gz
gdb-4a72de73660810536e9bb416d41dc8a6128f91da.tar.bz2
Move simple_search_memory to gdbsupport/search.cc
This moves the simple_search_memory function to a new file, gdbsupport/search.cc. The API is slightly changed to make it more general. This generality is useful for wiring it to gdbserver, and also for unit testing. gdb/ChangeLog 2020-10-07 Tom Tromey <tromey@adacore.com> * target.h (simple_search_memory): Don't declare. * target.c (simple_search_memory): Move to gdbsupport. (default_search_memory): Update. * remote.c (remote_target::search_memory): Update. gdbsupport/ChangeLog 2020-10-07 Tom Tromey <tromey@adacore.com> * Makefile.in: Rebuild. * Makefile.am (libgdbsupport_a_SOURCES): Add search.cc. * search.h: New file. * search.cc: New file.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index f951486..26ee28d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -75,6 +75,7 @@
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/environ.h"
#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/search.h"
#include <algorithm>
#include <unordered_map>
#include "async-event.h"
@@ -11186,6 +11187,12 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
int found;
ULONGEST found_addr;
+ auto read_memory = [=] (CORE_ADDR addr, gdb_byte *result, size_t len)
+ {
+ return (target_read (this, TARGET_OBJECT_MEMORY, NULL, result, addr, len)
+ == len);
+ };
+
/* Don't go to the target if we don't have to. This is done before
checking packet_config_support to avoid the possibility that a
success for this edge case means the facility works in
@@ -11205,7 +11212,7 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
{
/* Target doesn't provided special support, fall back and use the
standard support (copy memory and do the search here). */
- return simple_search_memory (this, start_addr, search_space_len,
+ return simple_search_memory (read_memory, start_addr, search_space_len,
pattern, pattern_len, found_addrp);
}
@@ -11237,7 +11244,7 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
supported. If so, fall back to the simple way. */
if (packet_config_support (packet) == PACKET_DISABLE)
{
- return simple_search_memory (this, start_addr, search_space_len,
+ return simple_search_memory (read_memory, start_addr, search_space_len,
pattern, pattern_len, found_addrp);
}
return -1;