[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/29] gdbstub: Support disablement in a multi-threaded process
From: |
Alex Bennée |
Subject: |
[PULL 02/29] gdbstub: Support disablement in a multi-threaded process |
Date: |
Wed, 6 Mar 2024 14:40:14 +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>
Message-Id: <20240305121005.3528075-3-alex.bennee@linaro.org>
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
- [PULL for 9.0 00/29] maintainer updates (tests, gdbstub, plugins), Alex Bennée, 2024/03/06
- [PULL 05/29] gdbstub: Introduce gdbserver_fork_start(), Alex Bennée, 2024/03/06
- [PULL 02/29] gdbstub: Support disablement in a multi-threaded process,
Alex Bennée <=
- [PULL 10/29] gdbstub: Introduce gdb_handle_set_thread_user(), Alex Bennée, 2024/03/06
- [PULL 04/29] {linux,bsd}-user: Update ts_tid after fork(), Alex Bennée, 2024/03/06
- [PULL 06/29] {linux,bsd}-user: Pass pid to fork_end(), Alex Bennée, 2024/03/06
- [PULL 09/29] gdbstub: Introduce gdb_handle_query_supported_user(), Alex Bennée, 2024/03/06
- [PULL 08/29] gdbstub: Call gdbserver_fork() both in parent and in child, Alex Bennée, 2024/03/06
- [PULL 12/29] gdbstub: Implement follow-fork-mode child, Alex Bennée, 2024/03/06
- [PULL 11/29] gdbstub: Introduce gdb_handle_detach_user(), Alex Bennée, 2024/03/06
- [PULL 07/29] {linux,bsd}-user: Pass pid to gdbserver_fork(), Alex Bennée, 2024/03/06
- [PULL 16/29] plugins: implement inline operation relative to cpu_index, Alex Bennée, 2024/03/06