#include "qemu/ctype.h"
#include "qemu/cutils.h"
#include "qemu/module.h"
-#include "trace-root.h"
+#include "trace/trace-root.h"
#ifdef CONFIG_USER_ONLY
#include "qemu.h"
#else
#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"
*/
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)
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;
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;
+ case 'c':
+ if (replay_reverse_continue()) {
+ 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");
/* Print the CPU model and name in multiprocess mode */
ObjectClass *oc = object_get_class(OBJECT(cpu));
const char *cpu_model = object_class_get_name(oc);
- g_autofree char *cpu_name =
+ const char *cpu_name =
object_get_canonical_path_component(OBJECT(cpu));
g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
cpu->halted ? "halted " : "running");
g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
}
+ if (replay_mode == REPLAY_MODE_PLAY) {
+ g_string_append(gdbserver_state.str_buf,
+ ";ReverseStep+;ReverseContinue+");
+ }
+
if (gdb_ctx->num_params &&
strstr(gdb_ctx->params[0].data, "multiprocess+")) {
gdbserver_state.multiprocess = true;
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 = {
s->g_cpu = s->c_cpu;
vm_stop(RUN_STATE_PAUSED);
+ replay_gdb_attached();
gdb_has_xml = false;
break;
default: