diff mbox series

[03/10] gdbserver: use TRAP for step stop reason

Message ID 20220531091457.2208488-4-npiggin@gmail.com
State New
Headers show
Series [01/10] sbefifo: correct typo in thread target name | expand

Commit Message

Nicholas Piggin May 31, 2022, 9:14 a.m. UTC
gdb expects single step to provide the TRAP stop reason, otherwise it
considers it an unknown / other stop. This makes it print odd thread
stop messages when single stepping, and it also causes it to break
unexpectedly when continuing threads that had hit a breakpoint because
it steps those threads over the breakpoint address before continuing,
and that step causes it to break again unless the stop reason is TRAP.

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

Patch

diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 2d579a4a..29845762 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -66,6 +66,7 @@  struct gdb_thread {
 	bool attn_set;
 	bool initial_stopped;
 	bool stop_attn;
+	bool stop_sstep;
 	bool stop_ctrlc;
 };
 
@@ -208,7 +209,7 @@  static void send_stop_for_thread(struct pdbg_target *target)
 	int sig;
 	int i;
 
-	if (gdb_thread->stop_attn)
+	if (gdb_thread->stop_attn || gdb_thread->stop_sstep)
 		sig = 5; /* TRAP */
 	else if (gdb_thread->stop_ctrlc)
 		sig = 2; /* INT */
@@ -853,8 +854,9 @@  static void v_conts(uint64_t *stack, void *priv)
 
 	thread_step(thread_target, 1);
 
-	gdb_thread->stop_ctrlc = false;
 	gdb_thread->stop_attn = false;
+	gdb_thread->stop_sstep = true;
+	gdb_thread->stop_ctrlc = false;
 
 	send_stop_for_thread(thread_target);
 }
@@ -901,6 +903,7 @@  static void start_all(void)
 		gdb_thread = thread->gdbserver_priv;
 
 		gdb_thread->stop_attn = false;
+		gdb_thread->stop_sstep = false;
 		gdb_thread->stop_ctrlc = false;
 	}