mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-21 09:02:00 -06:00
gdbstub: add support to Xfer:auxv:read: packet
This allows gdb to access the target’s auxiliary vector, which can be helpful for telling system libraries important details about the hardware, operating system, and process. Signed-off-by: Lirong Yuan <yuanzi@google.com> [AJB: minor tweaks to test case, update MAINTAINERS, restrict to Linux] Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200730193932.3654677-1-yuanzi@google.com> Message-Id: <20210108224256.2321-7-alex.bennee@linaro.org>
This commit is contained in:
parent
c00506aa26
commit
51c623b0de
4 changed files with 121 additions and 0 deletions
54
gdbstub.c
54
gdbstub.c
|
@ -2172,6 +2172,12 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx)
|
|||
";ReverseStep+;ReverseContinue+");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
if (gdbserver_state.c_cpu->opaque) {
|
||||
g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gdb_ctx->num_params &&
|
||||
strstr(gdb_ctx->params[0].data, "multiprocess+")) {
|
||||
gdbserver_state.multiprocess = true;
|
||||
|
@ -2233,6 +2239,46 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx)
|
|||
gdbserver_state.str_buf->len, true);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER)
|
||||
static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx)
|
||||
{
|
||||
TaskState *ts;
|
||||
unsigned long offset, len, saved_auxv, auxv_len;
|
||||
const char *mem;
|
||||
|
||||
if (gdb_ctx->num_params < 2) {
|
||||
put_packet("E22");
|
||||
return;
|
||||
}
|
||||
|
||||
offset = gdb_ctx->params[0].val_ul;
|
||||
len = gdb_ctx->params[1].val_ul;
|
||||
ts = gdbserver_state.c_cpu->opaque;
|
||||
saved_auxv = ts->info->saved_auxv;
|
||||
auxv_len = ts->info->auxv_len;
|
||||
mem = (const char *)(saved_auxv + offset);
|
||||
if (offset > auxv_len) {
|
||||
put_packet("E00");
|
||||
return;
|
||||
}
|
||||
|
||||
if (len > (MAX_PACKET_LENGTH - 5) / 2) {
|
||||
len = (MAX_PACKET_LENGTH - 5) / 2;
|
||||
}
|
||||
|
||||
if (len < auxv_len - offset) {
|
||||
g_string_assign(gdbserver_state.str_buf, "m");
|
||||
memtox(gdbserver_state.str_buf, mem, len);
|
||||
} else {
|
||||
g_string_assign(gdbserver_state.str_buf, "l");
|
||||
memtox(gdbserver_state.str_buf, mem, auxv_len - offset);
|
||||
}
|
||||
|
||||
put_packet_binary(gdbserver_state.str_buf->str,
|
||||
gdbserver_state.str_buf->len, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx)
|
||||
{
|
||||
put_packet(GDB_ATTACHED);
|
||||
|
@ -2338,6 +2384,14 @@ static GdbCmdParseEntry gdb_gen_query_table[] = {
|
|||
.cmd_startswith = 1,
|
||||
.schema = "s:l,l0"
|
||||
},
|
||||
#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER)
|
||||
{
|
||||
.handler = handle_query_xfer_auxv,
|
||||
.cmd = "Xfer:auxv:read::",
|
||||
.cmd_startswith = 1,
|
||||
.schema = "l,l0"
|
||||
},
|
||||
#endif
|
||||
{
|
||||
.handler = handle_query_attached,
|
||||
.cmd = "Attached:",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue