diff mbox series

[PULL,6/7] gdbstub: tidy away reverse debugging check into function

Message ID 20210525112431.22005-7-alex.bennee@linaro.org
State Accepted
Commit ed12f5b4ef626bfd1deb6f178282a18ab948750e
Headers show
Series testing, gdbstub and plugin updates | expand

Commit Message

Alex Bennée May 25, 2021, 11:24 a.m. UTC
In theory we don't need an actual record/replay to enact reverse
debugging on a purely deterministic system (i.e one with no external
inputs running under icount). Tidy away the logic into a little
function.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Message-Id: <20210520174303.12310-8-alex.bennee@linaro.org>

-- 
2.20.1
diff mbox series

Patch

diff --git a/gdbstub.c b/gdbstub.c
index 84ce770a04..52bde5bdc9 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -465,6 +465,15 @@  int use_gdb_syscalls(void)
     return gdb_syscall_mode == GDB_SYS_ENABLED;
 }
 
+static bool stub_can_reverse(void)
+{
+#ifdef CONFIG_USER_ONLY
+    return false;
+#else
+    return replay_mode == REPLAY_MODE_PLAY;
+#endif
+}
+
 /* Resume execution.  */
 static inline void gdb_continue(void)
 {
@@ -1880,7 +1889,7 @@  static void handle_step(GArray *params, void *user_ctx)
 
 static void handle_backward(GArray *params, void *user_ctx)
 {
-    if (replay_mode != REPLAY_MODE_PLAY) {
+    if (!stub_can_reverse()) {
         put_packet("E22");
     }
     if (params->len == 1) {
@@ -2153,7 +2162,7 @@  static void handle_query_supported(GArray *params, void *user_ctx)
         g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
     }
 
-    if (replay_mode == REPLAY_MODE_PLAY) {
+    if (stub_can_reverse()) {
         g_string_append(gdbserver_state.str_buf,
             ";ReverseStep+;ReverseContinue+");
     }