gdb kernel server: fixup Search:memory style

This is a NFC patch to move around the Search:memory implementation so
that it doesn't exceed the standard column width and doesn't take so
much vertical space in gdb_trap.

Submitted by:	Daniel O'Connor <darius@dons.net.au>
Reviewed by:	cem, jhb
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12684
This commit is contained in:
rlibby 2017-10-17 01:12:17 +00:00
parent 1af39d84c0
commit 15029699bb

View File

@ -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;