diff mbox series

[v2,11/38] gdbserver: fix interrupt double stop reason response

Message ID 20220329154931.493851-12-npiggin@gmail.com
State New
Headers show
Series gdbserver multi-threaded debugging and POWER9/10 support | expand

Commit Message

Nicholas Piggin March 29, 2022, 3:49 p.m. UTC
The interrupt command sends a stop reason (TRAP) response, then the main
loop notices that the thread was stopped and also sends a stop reason
response.

Prevent the second response by having the interrupt handler move
the state to IDLE.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 src/pdbgproxy.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 9e5e7d8..1668126 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -320,11 +320,20 @@  static void v_contc(uint64_t *stack, void *priv)
 
 static void interrupt(uint64_t *stack, void *priv)
 {
-	PR_INFO("Interrupt\n");
+	struct thread_state status;
+
+	PR_INFO("Interrupt from gdb client\n");
+
 	thread_stop(thread_target);
-	send_response(fd, TRAP);
 
-	return;
+	status = thread_status(thread_target);
+	if (!(status.quiesced)) {
+		PR_ERROR("Could not quiesce thread\n");
+		return;
+	}
+	state = IDLE;
+	poll_interval = VCONT_POLL_DELAY;
+	send_response(fd, TRAP);
 }
 
 static void poll(void)