gdbstub: Add Xfer:siginfo:read stub

Add stub to handle Xfer:siginfo:read packet query that requests the
machine's siginfo data.

This is used when GDB user executes 'print $_siginfo' and when the
machine stops due to a signal, for instance, on SIGSEGV. The information
in siginfo allows GDB to determiner further details on the signal, like
the fault address/insn when the SIGSEGV is caught.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-Id: <20240309030901.1726211-5-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Gustavo Romero 2024-03-09 03:09:00 +00:00 committed by Alex Bennée
parent f84e313e02
commit 9ae5801d35
3 changed files with 32 additions and 0 deletions

View file

@ -852,3 +852,26 @@ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx)
err:
gdb_put_packet("E00");
}
void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx)
{
unsigned long offset, len;
uint8_t *siginfo_offset;
offset = get_param(params, 0)->val_ul;
len = get_param(params, 1)->val_ul;
if (offset + len > gdbserver_user_state.siginfo_len) {
/* Invalid offset and/or requested length. */
gdb_put_packet("E01");
return;
}
siginfo_offset = (uint8_t *)gdbserver_user_state.siginfo + offset;
/* Reply */
g_string_assign(gdbserver_state.str_buf, "l");
gdb_memtox(gdbserver_state.str_buf, (const char *)siginfo_offset, len);
gdb_put_packet_binary(gdbserver_state.str_buf->str,
gdbserver_state.str_buf->len, true);
}