[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/30] gdbstub: split out softmmu/user specifics for syscall handl
From: |
Alex Bennée |
Subject: |
[PULL 25/30] gdbstub: split out softmmu/user specifics for syscall handling |
Date: |
Tue, 7 Mar 2023 21:21:34 +0000 |
Most of the syscall code is config agnostic aside from the size of
target_ulong. In preparation for the next patch move the final bits
of specialisation into the appropriate user and softmmu helpers.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230302190846.2593720-26-alex.bennee@linaro.org>
Message-Id: <20230303025805.625589-26-richard.henderson@linaro.org>
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index 8db61f7fb4..94ddff4495 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -195,6 +195,9 @@ bool gdb_handled_syscall(void);
void gdb_disable_syscalls(void);
void gdb_syscall_reset(void);
+/* user/softmmu specific syscall handling */
+void gdb_syscall_handling(const char *syscall_packet);
+
/*
* Break/Watch point support - there is an implementation for softmmu
* and user mode.
diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c
index d3152fb6e7..22ecd09d04 100644
--- a/gdbstub/softmmu.c
+++ b/gdbstub/softmmu.c
@@ -103,6 +103,20 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event)
}
}
+/*
+ * In softmmu mode we stop the VM and wait to send the syscall packet
+ * until notification that the CPU has stopped. This must be done
+ * because if the packet is sent now the reply from the syscall
+ * request could be received while the CPU is still in the running
+ * state, which can cause packets to be dropped and state transition
+ * 'T' packets to be sent while the syscall is still being processed.
+ */
+void gdb_syscall_handling(const char *syscall_packet)
+{
+ vm_stop(RUN_STATE_DEBUG);
+ qemu_cpu_kick(gdbserver_state.c_cpu);
+}
+
static void gdb_vm_state_change(void *opaque, bool running, RunState state)
{
CPUState *cpu = gdbserver_state.c_cpu;
diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c
index 46537938d5..6189940005 100644
--- a/gdbstub/syscalls.c
+++ b/gdbstub/syscalls.c
@@ -105,9 +105,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char
*fmt, va_list va)
}
gdbserver_syscall_state.current_syscall_cb = cb;
-#ifndef CONFIG_USER_ONLY
- vm_stop(RUN_STATE_DEBUG);
-#endif
+
p = &gdbserver_syscall_state.syscall_buf[0];
p_end =
&gdbserver_syscall_state.syscall_buf[sizeof(gdbserver_syscall_state.syscall_buf)];
*(p++) = 'F';
@@ -142,27 +140,8 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const
char *fmt, va_list va)
}
}
*p = 0;
-#ifdef CONFIG_USER_ONLY
- gdb_put_packet(gdbserver_syscall_state.syscall_buf);
- /*
- * Return control to gdb for it to process the syscall request.
- * Since the protocol requires that gdb hands control back to us
- * using a "here are the results" F packet, we don't need to check
- * gdb_handlesig's return value (which is the signal to deliver if
- * execution was resumed via a continue packet).
- */
- gdb_handlesig(gdbserver_state.c_cpu, 0);
-#else
- /*
- * In this case wait to send the syscall packet until notification that
- * the CPU has stopped. This must be done because if the packet is sent
- * now the reply from the syscall request could be received while the CPU
- * is still in the running state, which can cause packets to be dropped
- * and state transition 'T' packets to be sent while the syscall is still
- * being processed.
- */
- qemu_cpu_kick(gdbserver_state.c_cpu);
-#endif
+
+ gdb_syscall_handling(gdbserver_syscall_state.syscall_buf);
}
void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
diff --git a/gdbstub/user.c b/gdbstub/user.c
index 3da410e221..80488b6bb9 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -472,3 +472,17 @@ void gdb_breakpoint_remove_all(CPUState *cs)
{
cpu_breakpoint_remove_all(cs, BP_GDB);
}
+
+/*
+ * For user-mode syscall support we send the system call immediately
+ * and then return control to gdb for it to process the syscall request.
+ * Since the protocol requires that gdb hands control back to us
+ * using a "here are the results" F packet, we don't need to check
+ * gdb_handlesig's return value (which is the signal to deliver if
+ * execution was resumed via a continue packet).
+ */
+void gdb_syscall_handling(const char *syscall_packet)
+{
+ gdb_put_packet(syscall_packet);
+ gdb_handlesig(gdbserver_state.c_cpu, 0);
+}
--
2.39.2
- [PULL 09/30] gdbstub: make various helpers visible to the rest of the module, (continued)
- [PULL 09/30] gdbstub: make various helpers visible to the rest of the module, Alex Bennée, 2023/03/07
- [PULL 11/30] gdbstub: move chunks of user code into own files, Alex Bennée, 2023/03/07
- [PULL 02/30] gdbstub: fix-up copyright and license files, Alex Bennée, 2023/03/07
- [PULL 06/30] gdbstub: move GDBState to shared internals header, Alex Bennée, 2023/03/07
- [PULL 13/30] gdbstub: abstract target specific details from gdb_put_packet_binary, Alex Bennée, 2023/03/07
- [PULL 17/30] gdbstub: specialise stub_can_reverse, Alex Bennée, 2023/03/07
- [PULL 26/30] gdbstub: Remove gdb_do_syscallv, Alex Bennée, 2023/03/07
- [PULL 29/30] gdbstub: Build syscall.c once, Alex Bennée, 2023/03/07
- [PULL 28/30] stubs: split semihosting_get_target from system only stubs, Alex Bennée, 2023/03/07
- [PULL 16/30] gdbstub: introduce gdb_get_max_cpus, Alex Bennée, 2023/03/07
- [PULL 25/30] gdbstub: split out softmmu/user specifics for syscall handling,
Alex Bennée <=
- [PULL 30/30] gdbstub: move update guest debug to accel ops, Alex Bennée, 2023/03/07
- [PULL 27/30] gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t, Alex Bennée, 2023/03/07
- [PULL 19/30] gdbstub: don't use target_ulong while handling registers, Alex Bennée, 2023/03/07
- [PULL 15/30] gdbstub: specialise target_memory_rw_debug, Alex Bennée, 2023/03/07
- [PULL 20/30] gdbstub: move register helpers into standalone include, Alex Bennée, 2023/03/07
- [PULL 24/30] include: split target_long definition from cpu-defs, Alex Bennée, 2023/03/07
- [PULL 18/30] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/03/07
- [PULL 23/30] testing: probe gdb for supported architectures ahead of time, Alex Bennée, 2023/03/07
- [PULL 21/30] gdbstub: move syscall handling to new file, Alex Bennée, 2023/03/07
- [PULL 22/30] gdbstub: only compile gdbstub twice for whole build, Alex Bennée, 2023/03/07