summaryrefslogtreecommitdiffstats
path: root/sys/gdb/gdb_main.c
diff options
context:
space:
mode:
authorbenno <benno@FreeBSD.org>2014-09-05 16:40:47 +0000
committerbenno <benno@FreeBSD.org>2014-09-05 16:40:47 +0000
commitb46fbbac90c150e0c7ed397aee01711a8e2b6461 (patch)
tree9c65549c84dd3404b6d357698cfa4a416e414b44 /sys/gdb/gdb_main.c
parentca6e87735466b49e624fca023d7c8aade7025e62 (diff)
downloadFreeBSD-src-b46fbbac90c150e0c7ed397aee01711a8e2b6461.zip
FreeBSD-src-b46fbbac90c150e0c7ed397aee01711a8e2b6461.tar.gz
Add support for gdb's memory searching capabilities to our in-kernel gdb
server. Submitted by: Daniel O'Connor <daniel.oconnor@isilon.com> Reviewed by: jhb Sponsored by: EMC Isilon Storage Division
Diffstat (limited to 'sys/gdb/gdb_main.c')
-rw-r--r--sys/gdb/gdb_main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/gdb/gdb_main.c b/sys/gdb/gdb_main.c
index 4ed3272..f8f3836 100644
--- a/sys/gdb/gdb_main.c
+++ b/sys/gdb/gdb_main.c
@@ -53,6 +53,8 @@ SET_DECLARE(gdb_dbgport_set, struct gdb_dbgport);
struct gdb_dbgport *gdb_cur = NULL;
int gdb_listening = 0;
+static unsigned char gdb_bindata[64];
+
static int
gdb_init(void)
{
@@ -254,6 +256,28 @@ gdb_trap(int type, int code)
gdb_tx_begin('l');
gdb_tx_end();
}
+ } else if (gdb_rx_equal("Search:memory:")) {
+ size_t patlen;
+ intmax_t addr, size;
+ const unsigned char *found;
+ if (gdb_rx_varhex(&addr) || gdb_rx_char() != ';' ||
+ gdb_rx_varhex(&size) || gdb_rx_char() != ';' ||
+ gdb_rx_bindata(gdb_bindata, sizeof(gdb_bindata), &patlen)) {
+ gdb_tx_err(EINVAL);
+ break;
+ }
+ if (gdb_search_mem((char *)(uintptr_t)addr, size, gdb_bindata, patlen, &found)) {
+ if (found == 0ULL)
+ gdb_tx_begin('0');
+ else {
+ gdb_tx_begin('1');
+ gdb_tx_char(',');
+ gdb_tx_hex((intmax_t)(uintptr_t)found, 8);
+ }
+ gdb_tx_end();
+ } else
+ gdb_tx_err(EIO);
+ break;
} else if (!gdb_cpu_query())
gdb_tx_empty();
break;
OpenPOWER on IntegriCloud