[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 01/12] gdbstub: Support disablement in a multi-threaded proces
From: |
Ilya Leoshkevich |
Subject: |
[PATCH v4 01/12] gdbstub: Support disablement in a multi-threaded process |
Date: |
Mon, 19 Feb 2024 15:15:49 +0100 |
The upcoming follow-fork-mode child support will require disabling
gdbstub in the parent process, which may have multiple threads (which
are represented as CPUs).
Loop over all CPUs in order to remove breakpoints and disable
single-step. Move the respective code into a separate function.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
gdbstub/user.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/gdbstub/user.c b/gdbstub/user.c
index 14918d1a217..3ce20b7bbfc 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -356,16 +356,27 @@ int gdbserver_start(const char *port_or_path)
return -1;
}
+static void disable_gdbstub(CPUState *thread_cpu)
+{
+ CPUState *cpu;
+
+ close(gdbserver_user_state.fd);
+ gdbserver_user_state.fd = -1;
+ CPU_FOREACH(cpu) {
+ cpu_breakpoint_remove_all(cpu, BP_GDB);
+ /* no cpu_watchpoint_remove_all for user-mode */
+ cpu_single_step(cpu, 0);
+ }
+ tb_flush(thread_cpu);
+}
+
/* Disable gdb stub for child processes. */
void gdbserver_fork(CPUState *cpu)
{
if (!gdbserver_state.init || gdbserver_user_state.fd < 0) {
return;
}
- close(gdbserver_user_state.fd);
- gdbserver_user_state.fd = -1;
- cpu_breakpoint_remove_all(cpu, BP_GDB);
- /* no cpu_watchpoint_remove_all for user-mode */
+ disable_gdbstub(cpu);
}
/*
--
2.43.2
- [PATCH v4 00/12] gdbstub: Implement follow-fork-mode child, Ilya Leoshkevich, 2024/02/19
- [PATCH v4 01/12] gdbstub: Support disablement in a multi-threaded process,
Ilya Leoshkevich <=
- [PATCH v4 05/12] {linux,bsd}-user: Pass pid to fork_end(), Ilya Leoshkevich, 2024/02/19
- [PATCH v4 06/12] {linux,bsd}-user: Pass pid to gdbserver_fork(), Ilya Leoshkevich, 2024/02/19
- [PATCH v4 07/12] gdbstub: Call gdbserver_fork() both in parent and in child, Ilya Leoshkevich, 2024/02/19
- [PATCH v4 12/12] tests/tcg: Add two follow-fork-mode tests, Ilya Leoshkevich, 2024/02/19
- [PATCH v4 04/12] gdbstub: Introduce gdbserver_fork_start(), Ilya Leoshkevich, 2024/02/19
- [PATCH v4 10/12] gdbstub: Introduce gdb_handle_detach_user(), Ilya Leoshkevich, 2024/02/19
- [PATCH v4 08/12] gdbstub: Introduce gdb_handle_query_supported_user(), Ilya Leoshkevich, 2024/02/19
- [PATCH v4 09/12] gdbstub: Introduce gdb_handle_set_thread_user(), Ilya Leoshkevich, 2024/02/19
- [PATCH v4 11/12] gdbstub: Implement follow-fork-mode child, Ilya Leoshkevich, 2024/02/19
- [PATCH v4 02/12] {linux,bsd}-user: Introduce get_task_state(), Ilya Leoshkevich, 2024/02/19