Skip to content

Commit 7504982

Browse files
committed
workaround for gdb bug
1 parent 7072c14 commit 7504982

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

gdb-mi.el

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,8 +2464,19 @@ If ARG is non-nil, stop all threads unconditionally."
24642464
(interactive)
24652465
(gdb--with-valid-session
24662466
(when (gdb--session-threads session)
2467-
(gdb--command "kill" nil nil 'no-resume)
2468-
t)))
2467+
;; NOTE(nox): Workaround for GDB bug
2468+
;;
2469+
;; Due to the non-stop mode, GDB sometimes crashes when rerunning an inferior that was killed while
2470+
;; it had some threads running. This ensures all threads are stopped before killing the inferior.
2471+
;;
2472+
(gdb--command "-exec-interrupt --all")
2473+
(cl-loop do (accept-process-output (gdb--session-process session) 0.5)
2474+
if (cl-loop for thread in (gdb--session-threads session)
2475+
unless (string= "stopped" (gdb--thread-state thread)) return nil
2476+
finally return t)
2477+
return nil)
2478+
2479+
(gdb--command "-target-disconnect"))))
24692480

24702481
(defun gdb-select ()
24712482
"Select inferred frame or thread."

0 commit comments

Comments
 (0)