aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/gdb-mi.el31
1 files changed, 28 insertions, 3 deletions
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 4994a5a37ea..2174c8d7908 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -403,6 +403,20 @@ triggers in `gdb-handler-list'."
403 (gdb-wait-for-pending func) 403 (gdb-wait-for-pending func)
404 (funcall func))))) 404 (funcall func)))))
405 405
406(defun gdb-start-wait-for-pending (var func)
407 "Start waiting for pending GDB commands with VAR and FUNC.
408This calls `gdb-wait-for-pending' if there isn't already a timer waiting
409for running the same FUNC, as indicated by a non-nil value of VAR.
410VAR should be a symbol of a boolean variable.
411The assumption is that when FUNC will be called, it will do the job for
412all the events that need to run FUNC after the pending GDB commands are
413finished.
414FUNC should reset VAR to nil, so further events of the same kind will
415be handled after FUNC exits."
416 (when (null (symbol-value var))
417 (set var t)
418 (gdb-wait-for-pending func)))
419
406;; Publish-subscribe 420;; Publish-subscribe
407 421
408(defmacro gdb-add-subscriber (publisher subscriber) 422(defmacro gdb-add-subscriber (publisher subscriber)
@@ -2638,6 +2652,9 @@ means to decode using the coding-system set for the GDB process."
2638 2652
2639(defun gdb-ignored-notification (_token _output-field)) 2653(defun gdb-ignored-notification (_token _output-field))
2640 2654
2655(defvar gdb--update-threads-queued-p nil
2656 "If non-nil, we already queued the `update-threads' signal.")
2657
2641;; gdb-invalidate-threads is defined to accept 'update-threads signal 2658;; gdb-invalidate-threads is defined to accept 'update-threads signal
2642(defun gdb-thread-created (_token _output-field)) 2659(defun gdb-thread-created (_token _output-field))
2643(defun gdb-thread-exited (_token output-field) 2660(defun gdb-thread-exited (_token output-field)
@@ -2649,9 +2666,17 @@ Unset `gdb-thread-number' if current thread exited and update threads list."
2649 ;; When we continue current thread and it quickly exits, 2666 ;; When we continue current thread and it quickly exits,
2650 ;; the pending triggers in gdb-handler-list left after gdb-running 2667 ;; the pending triggers in gdb-handler-list left after gdb-running
2651 ;; disallow us to properly call -thread-info without --thread option. 2668 ;; disallow us to properly call -thread-info without --thread option.
2652 ;; Thus we need to use gdb-wait-for-pending. 2669 ;; Thus we need to use gdb-wait-for-pending. But we should start
2653 (gdb-wait-for-pending 2670 ;; waiting only once if we get a long series of =thread-exited
2654 (lambda () (gdb-emit-signal gdb-buf-publisher 'update-threads))))) 2671 ;; notifications during the wait period, because otherwise we will
2672 ;; flood the Emacs main loop with many timers. When the time
2673 ;; expires, it will process all the threads that exited meanwhile,
2674 ;; and the next =thread-exited notification will start a new wait.
2675 (gdb-start-wait-for-pending
2676 'gdb--update-threads-queued-p
2677 (lambda ()
2678 (setq gdb--update-threads-queued-p nil)
2679 (gdb-emit-signal gdb-buf-publisher 'update-threads)))))
2655 2680
2656(defun gdb-thread-selected (_token output-field) 2681(defun gdb-thread-selected (_token output-field)
2657 "Handler for =thread-selected MI output record. 2682 "Handler for =thread-selected MI output record.