[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/29] gdbstub: Support disablement in a multi-threaded process
From: |
Alex Bennée |
Subject: |
[PATCH 02/29] gdbstub: Support disablement in a multi-threaded process |
Date: |
Tue, 5 Mar 2024 12:09:38 +0000 |
From: Ilya Leoshkevich <iii@linux.ibm.com>
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>
Message-Id: <20240219141628.246823-2-iii@linux.ibm.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
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.39.2
- [PATCH 00/29] maintainer/next for 9.0 (testing, gdbstub, plugins, disas), Alex Bennée, 2024/03/05
- [PATCH 04/29] {linux,bsd}-user: Update ts_tid after fork(), Alex Bennée, 2024/03/05
- [PATCH 01/29] tests: bump QOS_PATH_MAX_ELEMENT_SIZE again, Alex Bennée, 2024/03/05
- [PATCH 05/29] gdbstub: Introduce gdbserver_fork_start(), Alex Bennée, 2024/03/05
- [PATCH 02/29] gdbstub: Support disablement in a multi-threaded process,
Alex Bennée <=
- [PATCH 06/29] {linux,bsd}-user: Pass pid to fork_end(), Alex Bennée, 2024/03/05
- [PATCH 03/29] {linux,bsd}-user: Introduce get_task_state(), Alex Bennée, 2024/03/05
- [PATCH 09/29] gdbstub: Introduce gdb_handle_query_supported_user(), Alex Bennée, 2024/03/05
- [PATCH 12/29] gdbstub: Implement follow-fork-mode child, Alex Bennée, 2024/03/05
- [PATCH 14/29] plugins: scoreboard API, Alex Bennée, 2024/03/05
- [PATCH 11/29] gdbstub: Introduce gdb_handle_detach_user(), Alex Bennée, 2024/03/05
- [PATCH 07/29] {linux,bsd}-user: Pass pid to gdbserver_fork(), Alex Bennée, 2024/03/05
- [PATCH 10/29] gdbstub: Introduce gdb_handle_set_thread_user(), Alex Bennée, 2024/03/05
- [PATCH 13/29] tests/tcg: Add two follow-fork-mode tests, Alex Bennée, 2024/03/05
- [PATCH 16/29] plugins: implement inline operation relative to cpu_index, Alex Bennée, 2024/03/05