summaryrefslogtreecommitdiff
path: root/sys/gdb
diff options
context:
space:
mode:
authorRyan Libby <rlibby@FreeBSD.org>2017-10-17 01:12:17 +0000
committerRyan Libby <rlibby@FreeBSD.org>2017-10-17 01:12:17 +0000
commit8a7a65717a62ac8606b9cb342bfba4a4cdfcaa77 (patch)
treeedcdeba16f9739bc22ffc21f439e63772d5e3c01 /sys/gdb
parentf49c813c1d68f32f60e23821ede8eff1a7abd3dc (diff)
downloadsrc-test-8a7a65717a62ac8606b9cb342bfba4a4cdfcaa77.tar.gz
src-test-8a7a65717a62ac8606b9cb342bfba4a4cdfcaa77.zip
Notes
Diffstat (limited to 'sys/gdb')
-rw-r--r--sys/gdb/gdb_main.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/sys/gdb/gdb_main.c b/sys/gdb/gdb_main.c
index f8f3836f66ebc..7c10b3b2b5a9d 100644
--- a/sys/gdb/gdb_main.c
+++ b/sys/gdb/gdb_main.c
@@ -94,6 +94,33 @@ gdb_init(void)
return (cur_pri);
}
+static void
+gdb_do_mem_search(void)
+{
+ 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);
+ return;
+ }
+ 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);
+}
+
static int
gdb_trap(int type, int code)
{
@@ -257,27 +284,7 @@ gdb_trap(int type, int code)
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;
+ gdb_do_mem_search();
} else if (!gdb_cpu_query())
gdb_tx_empty();
break;