comparison lisp/progmodes/gdb-ui.el @ 75716:8bfa58061d79

(gdb-if-arrow): New macro. (gdb-mouse-until, gdb-mouse-jump): Use it.
author Nick Roberts <nickrob@snap.net.nz>
date Wed, 07 Feb 2007 21:57:04 +0000
parents 9ed49c89489b
children 65ce5be5f7ca 07774e5c3ff5 52a7f3f50b89
comparison
equal deleted inserted replaced
75715:290bc5c215d2 75716:8bfa58061d79
604 (if (re-search-forward "Undefined\\( mi\\)* command:" nil t) 604 (if (re-search-forward "Undefined\\( mi\\)* command:" nil t)
605 (setq gdb-version "pre-6.4") 605 (setq gdb-version "pre-6.4")
606 (setq gdb-version "6.4+")) 606 (setq gdb-version "6.4+"))
607 (gdb-init-2)) 607 (gdb-init-2))
608 608
609 (defmacro gdb-if-arrow (arrow-position &rest body)
610 `(if ,arrow-position
611 (let ((buffer (marker-buffer ,arrow-position)) (line))
612 (if (equal buffer (window-buffer (posn-window end)))
613 (with-current-buffer buffer
614 (when (or (equal start end)
615 (equal (posn-point start)
616 (marker-position ,arrow-position)))
617 ,@body))))))
618
609 (defun gdb-mouse-until (event) 619 (defun gdb-mouse-until (event)
610 "Continue running until a source line past the current line. 620 "Continue running until a source line past the current line.
611 The destination source line can be selected either by clicking with mouse-2 621 The destination source line can be selected either by clicking with mouse-2
612 on the fringe/margin or dragging the arrow with mouse-1 (default bindings)." 622 on the fringe/margin or dragging the arrow with mouse-1 (default bindings)."
613 (interactive "e") 623 (interactive "e")
614 (let ((start (event-start event)) 624 (let ((start (event-start event))
615 (end (event-end event))) 625 (end (event-end event)))
616 (if gud-overlay-arrow-position 626 (gdb-if-arrow gud-overlay-arrow-position
617 (let ((buffer (marker-buffer gud-overlay-arrow-position)) (line))
618 (if (equal buffer (window-buffer (posn-window end)))
619 (with-current-buffer buffer
620 (when (or (equal start end)
621 (equal (posn-point start)
622 (marker-position
623 gud-overlay-arrow-position)))
624 (setq line (line-number-at-pos (posn-point end))) 627 (setq line (line-number-at-pos (posn-point end)))
625 (gud-call (concat "until " (number-to-string line)))))))) 628 (gud-call (concat "until " (number-to-string line))))
626 (if gdb-overlay-arrow-position 629 (gdb-if-arrow gdb-overlay-arrow-position
627 (let ((buffer (marker-buffer gdb-overlay-arrow-position))) 630 (save-excursion
628 (if (equal buffer (window-buffer (posn-window end))) 631 (goto-line (line-number-at-pos (posn-point end)))
629 (with-current-buffer buffer 632 (forward-char 2)
630 (when (or (equal start end) 633 (gud-call (concat "until *%a"))))))
631 (equal (posn-point start)
632 (marker-position
633 gdb-overlay-arrow-position)))
634 (save-excursion
635 (goto-line (line-number-at-pos (posn-point end)))
636 (forward-char 2)
637 (gud-call (concat "until *%a"))))))))))
638 634
639 (defun gdb-mouse-jump (event) 635 (defun gdb-mouse-jump (event)
640 "Set execution address/line. 636 "Set execution address/line.
641 The destination source line can be selected either by clicking with mouse-2 637 The destination source line can be selected either by clicking with mouse-2
642 on the fringe/margin or dragging the arrow with mouse-1 (default bindings). 638 on the fringe/margin or dragging the arrow with mouse-1 (default bindings).
643 Unlike gdb-mouse-until the destination address can be before the current 639 Unlike gdb-mouse-until the destination address can be before the current
644 line, and no execution takes place." 640 line, and no execution takes place."
645 (interactive "e") 641 (interactive "e")
646 (let ((start (event-start event)) 642 (let ((start (event-start event))
647 (end (event-end event))) 643 (end (event-end event)))
648 (if gud-overlay-arrow-position 644 (gdb-if-arrow gud-overlay-arrow-position
649 (let ((buffer (marker-buffer gud-overlay-arrow-position)) (line))
650 (if (equal buffer (window-buffer (posn-window end)))
651 (with-current-buffer buffer
652 (when (or (equal start end)
653 (equal (posn-point start)
654 (marker-position
655 gud-overlay-arrow-position)))
656 (setq line (line-number-at-pos (posn-point end))) 645 (setq line (line-number-at-pos (posn-point end)))
657 (progn 646 (progn
658 (gud-call (concat "tbreak " (number-to-string line))) 647 (gud-call (concat "tbreak " (number-to-string line)))
659 (gud-call (concat "jump " (number-to-string line))))))))) 648 (gud-call (concat "jump " (number-to-string line)))))
660 (if gdb-overlay-arrow-position 649 (gdb-if-arrow gdb-overlay-arrow-position
661 (let ((buffer (marker-buffer gdb-overlay-arrow-position)))
662 (if (equal buffer (window-buffer (posn-window end)))
663 (with-current-buffer buffer
664 (when (or (equal start end)
665 (equal (posn-point start)
666 (marker-position
667 gdb-overlay-arrow-position)))
668 (save-excursion 650 (save-excursion
669 (goto-line (line-number-at-pos (posn-point end))) 651 (goto-line (line-number-at-pos (posn-point end)))
670 (forward-char 2) 652 (forward-char 2)
671 (progn 653 (progn
672 (gud-call (concat "tbreak *%a")) 654 (gud-call (concat "tbreak *%a"))
673 (gud-call (concat "jump *%a"))))))))))) 655 (gud-call (concat "jump *%a")))))))
674 656
675 (defcustom gdb-speedbar-auto-raise nil 657 (defcustom gdb-speedbar-auto-raise nil
676 "If non-nil raise speedbar every time display of watch expressions is\ 658 "If non-nil raise speedbar every time display of watch expressions is\
677 updated." 659 updated."
678 :type 'boolean 660 :type 'boolean