summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2023-09-29 21:45:07 -0400
committerMalfurious <m@lfurio.us>2024-04-24 13:31:08 -0400
commitd6add3a39a71081efe8b5b45ba2ed8a4f5075969 (patch)
tree09df32410887a50b9bc2b4e96dc4f15b4771bb38
parent66c02b503ac283506eabfcb943b4247ee6efc7b5 (diff)
downloadmisplays-d6add3a39a71081efe8b5b45ba2ed8a4f5075969.tar.gz
misplays-d6add3a39a71081efe8b5b45ba2ed8a4f5075969.zip
Prevent lingering traps after detach
There can sometimes be a pending SIGTRAP when we resume a thread. This is usually due to interrupting a hung single-step. If this trap is hit after the debugger leaves, the original process will crash. This is a quick workaround to attempt to consume such traps ourselves before detaching. Signed-off-by: Malfurious <m@lfurio.us>
-rw-r--r--debugger.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/debugger.c b/debugger.c
index 878ce21..46a6a15 100644
--- a/debugger.c
+++ b/debugger.c
@@ -289,6 +289,9 @@ struct process *dbg_attach(pid_t pid, int child) {
int dbg_detach(struct process *proc) {
interrupt_all_threads(proc);
+ dbg_realcont(proc->threads.head);
+ usleep(100000);
+ interrupt_all_threads(proc);
uninstall_breakpoints(proc->threads.head);
free_breakpoints(proc);