summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gdbstub.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gdbstub.c b/gdbstub.c
index a3ff8702ce..88a34c8f52 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -443,6 +443,15 @@ static int get_char(void)
}
#endif
+/*
+ * Return true if there is a GDB currently connected to the stub
+ * and attached to a CPU
+ */
+static bool gdb_attached(void)
+{
+ return gdbserver_state.init && gdbserver_state.c_cpu;
+}
+
static enum {
GDB_SYS_UNKNOWN,
GDB_SYS_ENABLED,
@@ -464,8 +473,7 @@ int use_gdb_syscalls(void)
/* -semihosting-config target=auto */
/* On the first call check if gdb is connected and remember. */
if (gdb_syscall_mode == GDB_SYS_UNKNOWN) {
- gdb_syscall_mode = gdbserver_state.init ?
- GDB_SYS_ENABLED : GDB_SYS_DISABLED;
+ gdb_syscall_mode = gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DISABLED;
}
return gdb_syscall_mode == GDB_SYS_ENABLED;
}
@@ -2886,7 +2894,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va)
target_ulong addr;
uint64_t i64;
- if (!gdbserver_state.init) {
+ if (!gdb_attached()) {
return;
}