[PATCH 3/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD()

Ilya Leoshkevich posted 3 patches 1 year ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Laurent Vivier <laurent@vivier.eu>
[PATCH 3/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD()
Posted by Ilya Leoshkevich 1 year ago
If multiple threads hit a breakpoint at the same time, GDB gets
confused [1]. Prevent this situation by stopping the other threads once
a thread hits a breakpoint.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=32023

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 gdbstub/user.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdbstub/user.c b/gdbstub/user.c
index 0b4bfa9c488..d72f8ca6106 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -200,6 +200,8 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginfo,
     char buf[256];
     int n;
 
+    EXCLUSIVE_GUARD();
+
     if (!gdbserver_state.init || gdbserver_user_state.fd < 0) {
         return sig;
     }
-- 
2.47.1