comparison lisp/progmodes/gdb-ui.el @ 58534:c655bc81dfc0

(gdb-view-source, gdb-selected-view): Delete variables. (gdb-ann3): Don't make GUD buffer dedicated. (gdb-goto-breakpoint, gdb-display-buffer): Don't always dedicate. (gdb-display-source-buffer): Delete function. (gdb-view-source-function, gdb-view-assembler): Delete functions. (menu): Delete menu bindings for viewing source/assembler. (gdb-setup-windows, gdb-restore-windows): Don't dedicate GUD. No assembler now. (gdb-reset): No need to undedicate source buffers now. (gdb-source-info): No assembler now.
author Nick Roberts <nickrob@snap.net.nz>
date Fri, 26 Nov 2004 15:41:22 +0000
parents 54bb21951d18
children 4988bdf5db77 549734260e34 f2ebccfa87d4
comparison
equal deleted inserted replaced
58533:f3a663bf5b02 58534:c655bc81dfc0
60 (defvar gdb-previous-address nil) 60 (defvar gdb-previous-address nil)
61 (defvar gdb-previous-frame nil) 61 (defvar gdb-previous-frame nil)
62 (defvar gdb-current-frame nil) 62 (defvar gdb-current-frame nil)
63 (defvar gdb-current-stack-level nil) 63 (defvar gdb-current-stack-level nil)
64 (defvar gdb-current-language nil) 64 (defvar gdb-current-language nil)
65 (defvar gdb-view-source t "Non-nil means that source code can be viewed.")
66 (defvar gdb-selected-view 'source "Code type that user wishes to view.")
67 (defvar gdb-var-list nil "List of variables in watch window.") 65 (defvar gdb-var-list nil "List of variables in watch window.")
68 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.") 66 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")
69 (defvar gdb-buffer-type nil) 67 (defvar gdb-buffer-type nil)
70 (defvar gdb-overlay-arrow-position nil) 68 (defvar gdb-overlay-arrow-position nil)
71 (defvar gdb-server-prefix nil) 69 (defvar gdb-server-prefix nil)
222 (setq gdb-current-address "main") 220 (setq gdb-current-address "main")
223 (setq gdb-previous-address nil) 221 (setq gdb-previous-address nil)
224 (setq gdb-previous-frame nil) 222 (setq gdb-previous-frame nil)
225 (setq gdb-current-frame nil) 223 (setq gdb-current-frame nil)
226 (setq gdb-current-stack-level nil) 224 (setq gdb-current-stack-level nil)
227 (setq gdb-view-source t)
228 (setq gdb-selected-view 'source)
229 (setq gdb-var-list nil) 225 (setq gdb-var-list nil)
230 (setq gdb-var-changed nil) 226 (setq gdb-var-changed nil)
231 (setq gdb-first-prompt nil) 227 (setq gdb-first-prompt nil)
232 (setq gdb-prompting nil) 228 (setq gdb-prompting nil)
233 (setq gdb-input-queue nil) 229 (setq gdb-input-queue nil)
247 ;; find source file and compilation directory here 243 ;; find source file and compilation directory here
248 (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program 244 (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program
249 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program 245 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program
250 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) 246 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))
251 ;; 247 ;;
252 (set-window-dedicated-p (get-buffer-window gud-comint-buffer) t)
253 ;;
254 (run-hooks 'gdba-mode-hook)) 248 (run-hooks 'gdba-mode-hook))
255 249
256 (defcustom gdb-use-colon-colon-notation nil 250 (defcustom gdb-use-colon-colon-notation nil
257 "If non-nil use FUN::VAR format to display variables in the speedbar." ; 251 "If non-nil use FUN::VAR format to display variables in the speedbar." ;
258 :type 'boolean 252 :type 'boolean
275 (list 269 (list
276 (if (eq gud-minor-mode 'gdba) 270 (if (eq gud-minor-mode 'gdba)
277 (concat "server interpreter mi \"-var-create - * " expr "\"\n") 271 (concat "server interpreter mi \"-var-create - * " expr "\"\n")
278 (concat"-var-create - * " expr "\n")) 272 (concat"-var-create - * " expr "\n"))
279 `(lambda () (gdb-var-create-handler ,expr)))))) 273 `(lambda () (gdb-var-create-handler ,expr))))))
280 (select-window (get-buffer-window gud-comint-buffer 'visible))) 274 (select-window (get-buffer-window gud-comint-buffer 0)))
281 275
282 (defun gdb-goto-info () 276 (defun gdb-goto-info ()
283 "Go to Emacs info node: GDB Graphical Interface." 277 "Go to Emacs info node: GDB Graphical Interface."
284 (interactive) 278 (interactive)
285 (select-frame (make-frame)) 279 (select-frame (make-frame))
728 (setq gud-last-frame 722 (setq gud-last-frame
729 (cons 723 (cons
730 (match-string 1 args) 724 (match-string 1 args)
731 (string-to-int (match-string 2 args)))) 725 (string-to-int (match-string 2 args))))
732 (setq gdb-current-address (match-string 3 args)) 726 (setq gdb-current-address (match-string 3 args))
733 (setq gdb-view-source t)
734 ;; cover for auto-display output which comes *before* 727 ;; cover for auto-display output which comes *before*
735 ;; stopped annotation 728 ;; stopped annotation
736 (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user))) 729 (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user)))
737 730
738 (defun gdb-pre-prompt (ignored) 731 (defun gdb-pre-prompt (ignored)
1277 (file (match-string 1))) 1270 (file (match-string 1)))
1278 (save-selected-window 1271 (save-selected-window
1279 (let* ((buf (find-file-noselect (if (file-exists-p file) 1272 (let* ((buf (find-file-noselect (if (file-exists-p file)
1280 file 1273 file
1281 (expand-file-name file gdb-cdir)))) 1274 (expand-file-name file gdb-cdir))))
1282 (window (gdb-display-buffer buf))) 1275 (window (display-buffer buf)))
1283 (with-current-buffer buf 1276 (with-current-buffer buf
1284 (goto-line (string-to-number line)) 1277 (goto-line (string-to-number line))
1285 (set-window-point window (point)))))) 1278 (set-window-point window (point))))))
1286 (error "Not recognized as break/watchpoint line")))) 1279 (error "Not recognized as break/watchpoint line"))))
1287 1280
1593 ;;;; Window management 1586 ;;;; Window management
1594 (defun gdb-display-buffer (buf &optional size) 1587 (defun gdb-display-buffer (buf &optional size)
1595 (let ((answer (get-buffer-window buf 0)) 1588 (let ((answer (get-buffer-window buf 0))
1596 (must-split nil)) 1589 (must-split nil))
1597 (if answer 1590 (if answer
1598 (display-buffer answer) ;Raise the frame if necessary. 1591 (display-buffer buf) ;Raise the frame if necessary.
1599 ;; The buffer is not yet displayed. 1592 ;; The buffer is not yet displayed.
1600 (pop-to-buffer gud-comint-buffer) ;Select the right frame. 1593 (pop-to-buffer gud-comint-buffer) ;Select the right frame.
1601 (let ((window (get-lru-window))) 1594 (let ((window (get-lru-window)))
1602 (if window 1595 (if window
1603 (progn 1596 (progn
1604 (set-window-buffer window buf) 1597 (set-window-buffer window buf)
1605 (setq answer window)) 1598 (setq answer window))
1606 (setq must-split t))) 1599 (setq must-split t)))
1607 (if must-split 1600 (if must-split
1608 (let* ((largest (get-largest-window)) 1601 (let* ((largest (get-largest-window))
1609 (cur-size (window-height largest)) 1602 (cur-size (window-height largest))
1610 (new-size (and size (< size cur-size) (- cur-size size)))) 1603 (new-size (and size (< size cur-size) (- cur-size size))))
1611 (setq answer (split-window largest new-size)) 1604 (setq answer (split-window largest new-size))
1612 (set-window-buffer answer buf))) 1605 (set-window-buffer answer buf)
1613 (set-window-dedicated-p answer t) 1606 (set-window-dedicated-p answer t)))
1614 answer))) 1607 answer)))
1615
1616 (defun gdb-display-source-buffer (buffer)
1617 (if (eq gdb-selected-view 'source)
1618 (gdb-display-buffer buffer)
1619 (gdb-display-buffer (gdb-get-buffer 'gdb-assembler-buffer)))
1620 (get-buffer-window buffer 'visible))
1621 1608
1622 1609
1623 ;;; Shared keymap initialization: 1610 ;;; Shared keymap initialization:
1624 1611
1625 (let ((menu (make-sparse-keymap "GDB-Frames"))) 1612 (let ((menu (make-sparse-keymap "GDB-Frames")))
1642 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer)) 1629 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
1643 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) 1630 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
1644 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer)) 1631 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
1645 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer))) 1632 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)))
1646 1633
1647 (let ((menu (make-sparse-keymap "View")))
1648 (define-key gud-menu-map [view]
1649 `(menu-item "View" ,menu :visible (eq gud-minor-mode 'gdba)))
1650 ; (define-key menu [both] '(menu-item "Both" gdb-view-both
1651 ; :help "Display both source and assembler"
1652 ; :button (:radio . (eq gdb-selected-view 'both))))
1653 (define-key menu [assembler] '(menu-item "Machine" gdb-view-assembler
1654 :help "Display assembler only"
1655 :button (:radio . (eq gdb-selected-view 'assembler))))
1656 (define-key menu [source] '(menu-item "Source" gdb-view-source-function
1657 :help "Display source only"
1658 :button (:radio . (eq gdb-selected-view 'source)))))
1659
1660 (let ((menu (make-sparse-keymap "GDB-UI"))) 1634 (let ((menu (make-sparse-keymap "GDB-UI")))
1661 (define-key gud-menu-map [ui] 1635 (define-key gud-menu-map [ui]
1662 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba))) 1636 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba)))
1663 (define-key menu [gdb-restore-windows] 1637 (define-key menu [gdb-restore-windows]
1664 '("Restore window layout" . gdb-restore-windows)) 1638 '("Restore window layout" . gdb-restore-windows))
1680 (gdb-display-buffer 1654 (gdb-display-buffer
1681 (gdb-get-create-buffer 'gdba))) 1655 (gdb-get-create-buffer 'gdba)))
1682 1656
1683 (defvar gdb-main-file nil "Source file from which program execution begins.") 1657 (defvar gdb-main-file nil "Source file from which program execution begins.")
1684 1658
1685 (defun gdb-view-source-function ()
1686 "Select source view."
1687 (interactive)
1688 (if gdb-view-source
1689 (gdb-display-buffer
1690 (gud-find-file (if gud-last-last-frame
1691 (car gud-last-last-frame)
1692 gdb-main-file))))
1693 (setq gdb-selected-view 'source))
1694
1695 (defun gdb-view-assembler()
1696 "Select disassembly view."
1697 (interactive)
1698 (gdb-display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))
1699 (gdb-invalidate-assembler)
1700 (setq gdb-selected-view 'assembler))
1701
1702 ;(defun gdb-view-both()
1703 ;(interactive)
1704 ;(setq gdb-selected-view 'both))
1705
1706 (defcustom gdb-show-main nil 1659 (defcustom gdb-show-main nil
1707 "Nil means don't display source file containing the main routine." 1660 "Nil means don't display source file containing the main routine."
1708 :type 'boolean 1661 :type 'boolean
1709 :group 'gud 1662 :group 'gud
1710 :version "21.4") 1663 :version "21.4")
1718 (gdb-display-locals-buffer) 1671 (gdb-display-locals-buffer)
1719 (gdb-display-stack-buffer) 1672 (gdb-display-stack-buffer)
1720 (delete-other-windows) 1673 (delete-other-windows)
1721 (gdb-display-breakpoints-buffer) 1674 (gdb-display-breakpoints-buffer)
1722 (delete-other-windows) 1675 (delete-other-windows)
1723 (gdb-set-window-buffer gud-comint-buffer) 1676 ; Don't dedicate.
1677 (pop-to-buffer gud-comint-buffer)
1724 (split-window nil ( / ( * (window-height) 3) 4)) 1678 (split-window nil ( / ( * (window-height) 3) 4))
1725 (split-window nil ( / (window-height) 3)) 1679 (split-window nil ( / (window-height) 3))
1726 (split-window-horizontally) 1680 (split-window-horizontally)
1727 (other-window 1) 1681 (other-window 1)
1728 (gdb-set-window-buffer (gdb-locals-buffer-name)) 1682 (gdb-set-window-buffer (gdb-locals-buffer-name))
1729 (other-window 1) 1683 (other-window 1)
1730 (gdb-set-window-buffer 1684 (switch-to-buffer
1731 (if (and gdb-view-source
1732 (eq gdb-selected-view 'source))
1733 (if gud-last-last-frame 1685 (if gud-last-last-frame
1734 (gud-find-file (car gud-last-last-frame)) 1686 (gud-find-file (car gud-last-last-frame))
1735 (gud-find-file gdb-main-file)) 1687 (gud-find-file gdb-main-file)))
1736 (gdb-get-create-buffer 'gdb-assembler-buffer)))
1737 (when gdb-use-inferior-io-buffer 1688 (when gdb-use-inferior-io-buffer
1738 (split-window-horizontally) 1689 (split-window-horizontally)
1739 (other-window 1) 1690 (other-window 1)
1740 (gdb-set-window-buffer (gdb-inferior-io-name))) 1691 (gdb-set-window-buffer (gdb-inferior-io-name)))
1741 (other-window 1) 1692 (other-window 1)
1774 (delete-other-windows) 1725 (delete-other-windows)
1775 (if gdb-many-windows 1726 (if gdb-many-windows
1776 (gdb-setup-windows) 1727 (gdb-setup-windows)
1777 (split-window) 1728 (split-window)
1778 (other-window 1) 1729 (other-window 1)
1779 (gdb-set-window-buffer 1730 (switch-to-buffer
1780 (if (and gdb-view-source
1781 (eq gdb-selected-view 'source))
1782 (if gud-last-last-frame 1731 (if gud-last-last-frame
1783 (gud-find-file (car gud-last-last-frame)) 1732 (gud-find-file (car gud-last-last-frame))
1784 (gud-find-file gdb-main-file)) 1733 (gud-find-file gdb-main-file)))
1785 (gdb-get-create-buffer 'gdb-assembler-buffer)))
1786 (other-window 1))) 1734 (other-window 1)))
1787 1735
1788 (defun gdb-reset () 1736 (defun gdb-reset ()
1789 "Exit a debugging session cleanly. 1737 "Exit a debugging session cleanly.
1790 Kills the gdb buffers and resets the source buffers." 1738 Kills the gdb buffers and resets the source buffers."
1794 (if (memq gud-minor-mode '(gdbmi gdba)) 1742 (if (memq gud-minor-mode '(gdbmi gdba))
1795 (if (string-match "\\`\\*.+\\*\\'" (buffer-name)) 1743 (if (string-match "\\`\\*.+\\*\\'" (buffer-name))
1796 (kill-buffer nil) 1744 (kill-buffer nil)
1797 (gdb-remove-breakpoint-icons (point-min) (point-max) t) 1745 (gdb-remove-breakpoint-icons (point-min) (point-max) t)
1798 (setq gud-minor-mode nil) 1746 (setq gud-minor-mode nil)
1799 (set-window-dedicated-p (get-buffer-window buffer) nil)
1800 (kill-local-variable 'tool-bar-map) 1747 (kill-local-variable 'tool-bar-map)
1801 (setq gud-running nil)))))) 1748 (setq gud-running nil))))))
1802 (when (markerp gdb-overlay-arrow-position) 1749 (when (markerp gdb-overlay-arrow-position)
1803 (move-marker gdb-overlay-arrow-position nil) 1750 (move-marker gdb-overlay-arrow-position nil)
1804 (setq gdb-overlay-arrow-position nil)) 1751 (setq gdb-overlay-arrow-position nil))
1814 (setq gdb-cdir (match-string 1)) 1761 (setq gdb-cdir (match-string 1))
1815 (looking-at "\\S-*") 1762 (looking-at "\\S-*")
1816 (setq gdb-cdir (match-string 0)))) 1763 (setq gdb-cdir (match-string 0))))
1817 (if (search-forward "Located in " nil t) 1764 (if (search-forward "Located in " nil t)
1818 (if (looking-at "\\S-*") 1765 (if (looking-at "\\S-*")
1819 (setq gdb-main-file (match-string 0))) 1766 (setq gdb-main-file (match-string 0))))
1820 (setq gdb-view-source nil)) 1767 (if gdb-many-windows
1821 (if gdb-many-windows
1822 (gdb-setup-windows) 1768 (gdb-setup-windows)
1823 (gdb-get-create-buffer 'gdb-breakpoints-buffer) 1769 (gdb-get-create-buffer 'gdb-breakpoints-buffer)
1824 (when gdb-show-main 1770 (if gdb-show-main
1825 (let ((pop-up-windows t)) 1771 (let ((pop-up-windows t))
1826 (display-buffer 1772 (display-buffer (gud-find-file gdb-main-file))))))
1827 (if gdb-view-source
1828 (gud-find-file gdb-main-file)
1829 (gdb-get-create-buffer 'gdb-assembler-buffer)))))))
1830 1773
1831 ;;from put-image 1774 ;;from put-image
1832 (defun gdb-put-string (putstring pos &optional dprop) 1775 (defun gdb-put-string (putstring pos &optional dprop)
1833 "Put string PUTSTRING in front of POS in the current buffer. 1776 "Put string PUTSTRING in front of POS in the current buffer.
1834 PUTSTRING is displayed by putting an overlay into the current buffer with a 1777 PUTSTRING is displayed by putting an overlay into the current buffer with a
1870 'breakpoint-enabled-bitmap-face 1813 'breakpoint-enabled-bitmap-face
1871 'breakpoint-disabled-bitmap-face))) 1814 'breakpoint-disabled-bitmap-face)))
1872 (when (< left-margin-width 2) 1815 (when (< left-margin-width 2)
1873 (save-current-buffer 1816 (save-current-buffer
1874 (setq left-margin-width 2) 1817 (setq left-margin-width 2)
1875 (if (get-buffer-window (current-buffer) 'visible) 1818 (if (get-buffer-window (current-buffer) 0)
1876 (set-window-margins 1819 (set-window-margins
1877 (get-buffer-window (current-buffer) 'visible) 1820 (get-buffer-window (current-buffer) 0)
1878 left-margin-width right-margin-width)))) 1821 left-margin-width right-margin-width))))
1879 (put-image 1822 (put-image
1880 (if enabled 1823 (if enabled
1881 (or breakpoint-enabled-icon 1824 (or breakpoint-enabled-icon
1882 (setq breakpoint-enabled-icon 1825 (setq breakpoint-enabled-icon
1897 :ascent 100)))))) 1840 :ascent 100))))))
1898 (+ start 1) nil 'left-margin)) 1841 (+ start 1) nil 'left-margin))
1899 (when (< left-margin-width 2) 1842 (when (< left-margin-width 2)
1900 (save-current-buffer 1843 (save-current-buffer
1901 (setq left-margin-width 2) 1844 (setq left-margin-width 2)
1902 (if (get-buffer-window (current-buffer) 'visible) 1845 (if (get-buffer-window (current-buffer) 0)
1903 (set-window-margins 1846 (set-window-margins
1904 (get-buffer-window (current-buffer) 'visible) 1847 (get-buffer-window (current-buffer) 0)
1905 left-margin-width right-margin-width)))) 1848 left-margin-width right-margin-width))))
1906 (gdb-put-string (if enabled "B" "b") (1+ start))))) 1849 (gdb-put-string (if enabled "B" "b") (1+ start)))))
1907 1850
1908 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin) 1851 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin)
1909 (gdb-remove-strings start end) 1852 (gdb-remove-strings start end)
1910 (if (display-images-p) 1853 (if (display-images-p)
1911 (remove-images start end)) 1854 (remove-images start end))
1912 (when remove-margin 1855 (when remove-margin
1913 (setq left-margin-width 0) 1856 (setq left-margin-width 0)
1914 (if (get-buffer-window (current-buffer) 'visible) 1857 (if (get-buffer-window (current-buffer) 0)
1915 (set-window-margins 1858 (set-window-margins
1916 (get-buffer-window (current-buffer) 'visible) 1859 (get-buffer-window (current-buffer) 0)
1917 left-margin-width right-margin-width)))) 1860 left-margin-width right-margin-width))))
1918 1861
1919 1862
1920 ;; 1863 ;;
1921 ;; Assembler buffer. 1864 ;; Assembler buffer.
1963 (with-current-buffer buffer 1906 (with-current-buffer buffer
1964 (goto-char (point-min)) 1907 (goto-char (point-min))
1965 (if (re-search-forward address nil t) 1908 (if (re-search-forward address nil t)
1966 (gdb-put-breakpoint-icon (eq flag ?y)))))))) 1909 (gdb-put-breakpoint-icon (eq flag ?y))))))))
1967 (if (not (equal gdb-current-address "main")) 1910 (if (not (equal gdb-current-address "main"))
1968 (set-window-point (get-buffer-window buffer 'visible) pos)))) 1911 (set-window-point (get-buffer-window buffer 0) pos))))
1969 1912
1970 (defvar gdb-assembler-mode-map 1913 (defvar gdb-assembler-mode-map
1971 (let ((map (make-sparse-keymap))) 1914 (let ((map (make-sparse-keymap)))
1972 (suppress-keymap map) 1915 (suppress-keymap map)
1973 (define-key map "q" 'kill-this-buffer) 1916 (define-key map "q" 'kill-this-buffer)
2075 ;; remove leading 0s from output of info frame command. 2018 ;; remove leading 0s from output of info frame command.
2076 (if (string-match "^0+\\(.*\\)" address) 2019 (if (string-match "^0+\\(.*\\)" address)
2077 (setq gdb-current-address 2020 (setq gdb-current-address
2078 (concat "0x" (match-string 1 address))) 2021 (concat "0x" (match-string 1 address)))
2079 (setq gdb-current-address (concat "0x" address)))) 2022 (setq gdb-current-address (concat "0x" address))))
2080 (if (or (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t)) 2023 (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t))
2081 (progn (setq gdb-view-source nil) t))
2082 (eq gdb-selected-view 'assembler))
2083 (progn
2084 (gdb-display-buffer
2085 (gdb-get-create-buffer 'gdb-assembler-buffer))
2086 ;;update with new frame for machine code if necessary 2024 ;;update with new frame for machine code if necessary
2087 (gdb-invalidate-assembler)))))) 2025 (gdb-invalidate-assembler)))))
2088 (if (re-search-forward " source language \\(\\S-*\\)\." nil t) 2026 (if (re-search-forward " source language \\(\\S-*\\)\." nil t)
2089 (setq gdb-current-language (match-string 1)))) 2027 (setq gdb-current-language (match-string 1))))
2090 2028
2091 (provide 'gdb-ui) 2029 (provide 'gdb-ui)
2092 2030