(dolist (handler gdb-handler-list)
(setf (gdb-handler-pending-trigger handler) nil)))
-(defmacro gdb-wait-for-pending (&rest body)
- "Wait for all pending GDB commands to finish and evaluate BODY.
+(defun gdb-wait-for-pending (func)
+ "Wait for all pending GDB commands to finish and call FUNC.
This function checks every 0.5 seconds if there are any pending
triggers in `gdb-handler-list'."
- `(run-with-timer
- 0.5 nil
- '(lambda ()
- (if (not (cl-find-if (lambda (handler)
- (gdb-handler-pending-trigger handler))
- gdb-handler-list))
- (progn ,@body)
- (gdb-wait-for-pending ,@body)))))
+ (run-with-timer
+ 0.5 nil
+ (lambda ()
+ (if (cl-some #'gdb-handler-pending-trigger gdb-handler-list)
+ (gdb-wait-for-pending func)
+ (funcall func)))))
;; Publish-subscribe
;; disallow us to properly call -thread-info without --thread option.
;; Thus we need to use gdb-wait-for-pending.
(gdb-wait-for-pending
- (gdb-emit-signal gdb-buf-publisher 'update-threads))))
+ (lambda () (gdb-emit-signal gdb-buf-publisher 'update-threads)))))
(defun gdb-thread-selected (_token output-field)
"Handler for =thread-selected MI output record.
;; as usually. Things happen too fast and second call (from
;; gdb-thread-selected handler) gets cut off by our beloved
;; pending triggers.
- ;; Solution is `gdb-wait-for-pending' macro: it guarantees that its
- ;; body will get executed when `gdb-handler-list' if free of
+ ;; Solution is `gdb-wait-for-pending': it guarantees that its
+ ;; argument will get called when `gdb-handler-list' if free of
;; pending triggers.
- (gdb-wait-for-pending
- (gdb-update))))
+ (gdb-wait-for-pending #'gdb-update)))
(defun gdb-running (_token output-field)
(let* ((thread-id