aboutsummaryrefslogtreecommitdiff
path: root/gdbstub.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdbstub.c')
-rw-r--r--gdbstub.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/gdbstub.c b/gdbstub.c
index 9dfb6e4142..79e8ccc050 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -51,6 +51,7 @@
#include "sysemu/runstate.h"
#include "hw/semihosting/semihost.h"
#include "exec/exec-all.h"
+#include "sysemu/replay.h"
#ifdef CONFIG_USER_ONLY
#define GDB_ATTACHED "0"
@@ -375,6 +376,20 @@ typedef struct GDBState {
*/
static int sstep_flags = SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER;
+/* Retrieves flags for single step mode. */
+static int get_sstep_flags(void)
+{
+ /*
+ * In replay mode all events written into the log should be replayed.
+ * That is why NOIRQ flag is removed in this mode.
+ */
+ if (replay_mode != REPLAY_MODE_NONE) {
+ return SSTEP_ENABLE;
+ } else {
+ return sstep_flags;
+ }
+}
+
static GDBState gdbserver_state;
static void init_gdbserver_state(void)
@@ -501,7 +516,7 @@ static int gdb_continue_partial(char *newstates)
break; /* nothing to do here */
case 's':
trace_gdbstub_op_stepping(cpu->cpu_index);
- cpu_single_step(cpu, sstep_flags);
+ cpu_single_step(cpu, get_sstep_flags());
cpu_resume(cpu);
flag = 1;
break;
@@ -1874,10 +1889,31 @@ static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx)
gdb_set_cpu_pc((target_ulong)gdb_ctx->params[0].val_ull);
}
- cpu_single_step(gdbserver_state.c_cpu, sstep_flags);
+ cpu_single_step(gdbserver_state.c_cpu, get_sstep_flags());
gdb_continue();
}
+static void handle_backward(GdbCmdContext *gdb_ctx, void *user_ctx)
+{
+ if (replay_mode != REPLAY_MODE_PLAY) {
+ put_packet("E22");
+ }
+ if (gdb_ctx->num_params == 1) {
+ switch (gdb_ctx->params[0].opcode) {
+ case 's':
+ if (replay_reverse_step()) {
+ gdb_continue();
+ } else {
+ put_packet("E14");
+ }
+ return;
+ }
+ }
+
+ /* Default invalid command */
+ put_packet("");
+}
+
static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx)
{
put_packet("vCont;c;C;s;S");
@@ -2124,6 +2160,10 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx)
g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
}
+ if (replay_mode == REPLAY_MODE_PLAY) {
+ g_string_append(gdbserver_state.str_buf, ";ReverseStep+");
+ }
+
if (gdb_ctx->num_params &&
strstr(gdb_ctx->params[0].data, "multiprocess+")) {
gdbserver_state.multiprocess = true;
@@ -2460,6 +2500,17 @@ static int gdb_handle_packet(const char *line_buf)
cmd_parser = &step_cmd_desc;
}
break;
+ case 'b':
+ {
+ static const GdbCmdParseEntry backward_cmd_desc = {
+ .handler = handle_backward,
+ .cmd = "b",
+ .cmd_startswith = 1,
+ .schema = "o0"
+ };
+ cmd_parser = &backward_cmd_desc;
+ }
+ break;
case 'F':
{
static const GdbCmdParseEntry file_io_cmd_desc = {