aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Roberts2003-01-04 22:45:39 +0000
committerNick Roberts2003-01-04 22:45:39 +0000
commit82ab9672da5b6b46135a3fee9cfd114522d77514 (patch)
tree5f4e52f74e2d7bed65fd56143c20583a674f3cf0
parent67206a8418f0bcf56ca8aa1b6496bb6313c56f12 (diff)
downloademacs-82ab9672da5b6b46135a3fee9cfd114522d77514.tar.gz
emacs-82ab9672da5b6b46135a3fee9cfd114522d77514.zip
Acknowledge Tom Lord as author of gdba.el.
Use let construction to bind buffer-read-only to nil. (gdba): 'set height 0' in GDB. (gdb-display-end, gdb-frame-handler): Corrections to forming full expression name for header-line in display frame. (gdb-info-breakpoints-custom): Highlight breakpoints since they may be clicked on with mouse-2. (gdb-quit): Delete frames of displayed expressions when quitting. (gdb-delete-frames): New function. (gdb-source-info): Don't create stack buffer automatically.
-rw-r--r--lisp/gdb-ui.el227
1 files changed, 118 insertions, 109 deletions
diff --git a/lisp/gdb-ui.el b/lisp/gdb-ui.el
index 0e7c7ba1301..f61a5a30338 100644
--- a/lisp/gdb-ui.el
+++ b/lisp/gdb-ui.el
@@ -25,12 +25,12 @@
25 25
26;;; Commentary: 26;;; Commentary:
27 27
28;; This file is based on gdba.el from GDB 5.0 written by Jim Kingdon and uses 28;; This file is based on gdba.el from GDB 5.0 written by Tom Lord and Jim
29;; GDB's annotation interface. It has been extended to use features of Emacs 29;; Kingdon and uses GDB's annotation interface. It has been extended to use
30;; 21 such as the display margin for breakpoints and the toolbar. It also has 30;; features of Emacs 21 such as the display margin for breakpoints and the
31;; new buffers and lots of other new features such as formatted auto-display 31;; toolbar. It also has new buffers and lots of other new features such as
32;; of arrays and structures (see the GDB-UI section in the Emacs info 32;; formatted auto-display of arrays and structures (see the GDB-UI section in
33;; manual). 33;; the Emacs info manual). Start the debugger with M-x gdba.
34 34
35;; You don't need to know about annotations to use this mode as a graphical 35;; You don't need to know about annotations to use this mode as a graphical
36;; user interface to GDB. However, if you are interested developing the mode 36;; user interface to GDB. However, if you are interested developing the mode
@@ -141,6 +141,7 @@ The following interactive lisp functions help control operation :
141 ;; 141 ;;
142 (gdb-clear-inferior-io) 142 (gdb-clear-inferior-io)
143 ;; 143 ;;
144 (gdb-enqueue-input (list "set height 0\n" 'ignore))
144 ;; find source file and compilation directory here 145 ;; find source file and compilation directory here
145 (gdb-enqueue-input (list "server list\n" 'ignore)) 146 (gdb-enqueue-input (list "server list\n" 'ignore))
146 (gdb-enqueue-input (list "server info source\n" 147 (gdb-enqueue-input (list "server info source\n"
@@ -149,7 +150,7 @@ The following interactive lisp functions help control operation :
149 (run-hooks 'gdba-mode-hook)) 150 (run-hooks 'gdba-mode-hook))
150 151
151(defun gud-display () 152(defun gud-display ()
152 "Display (possibly dereferenced) C expression at point." 153 "Auto-display (possibly dereferenced) C expression at point."
153 (interactive) 154 (interactive)
154 (save-excursion 155 (save-excursion
155 (let ((expr (gud-find-c-expr))) 156 (let ((expr (gud-find-c-expr)))
@@ -165,6 +166,9 @@ The following interactive lisp functions help control operation :
165 (gdb-enqueue-input 166 (gdb-enqueue-input
166 (list (concat "server display " expr "\n") 'ignore)))) 167 (list (concat "server display " expr "\n") 'ignore))))
167 168
169; this would messy because these bindings don't work with M-x gdb
170; (define-key global-map "\C-x\C-a\C-a" 'gud-display)
171; (define-key gud-minor-mode-map "\C-c\C-a" 'gud-display)
168 172
169;; The completion process filter is installed temporarily to slurp the 173;; The completion process filter is installed temporarily to slurp the
170;; output of GDB up to the next prompt and build the completion list. 174;; output of GDB up to the next prompt and build the completion list.
@@ -726,18 +730,18 @@ output from the current command if that happens to be appropriate."
726 "::" gdb-expression)) 730 "::" gdb-expression))
727 ;;else put * back on if necessary 731 ;;else put * back on if necessary
728 (setq gdb-expression (concat char gdb-expression))) 732 (setq gdb-expression (concat char gdb-expression)))
729 (setq header-line-format (concat "-- " gdb-expression " %-")))) 733 (if (not header-line-format)
734 (setq header-line-format (concat "-- " gdb-expression " %-")))))
730 ;; 735 ;;
731 ;;-if scalar/string 736 ;;-if scalar/string
732 (if (not (re-search-forward "##" nil t)) 737 (if (not (re-search-forward "##" nil t))
733 (progn 738 (progn
734 (save-excursion 739 (save-excursion
735 (set-buffer gdb-expression-buffer-name) 740 (set-buffer gdb-expression-buffer-name)
736 (setq buffer-read-only nil) 741 (let ((buffer-read-only nil))
737 (delete-region (point-min) (point-max)) 742 (delete-region (point-min) (point-max))
738 (insert-buffer-substring 743 (insert-buffer-substring
739 (gdb-get-buffer 'gdb-partial-output-buffer)) 744 (gdb-get-buffer 'gdb-partial-output-buffer)))))
740 (setq buffer-read-only t)))
741 ;; display expression name... 745 ;; display expression name...
742 (goto-char (point-min)) 746 (goto-char (point-min))
743 (let ((start (progn (point))) 747 (let ((start (progn (point)))
@@ -766,11 +770,10 @@ output from the current command if that happens to be appropriate."
766 (set-buffer gdb-expression-buffer-name) 770 (set-buffer gdb-expression-buffer-name)
767 (if gdb-dive-display-number 771 (if gdb-dive-display-number
768 (progn 772 (progn
769 (setq buffer-read-only nil) 773 (let ((buffer-read-only nil))
770 (goto-char (point-max)) 774 (goto-char (point-max))
771 (insert "\n") 775 (insert "\n")
772 (insert-text-button "[back]" 'type 'gdb-display-back) 776 (insert-text-button "[back]" 'type 'gdb-display-back)))))
773 (setq buffer-read-only t))))
774 (gdb-clear-partial-output) 777 (gdb-clear-partial-output)
775 (gdb-set-output-sink 'user) 778 (gdb-set-output-sink 'user)
776 (setq gdb-display-in-progress nil)) 779 (setq gdb-display-in-progress nil))
@@ -901,19 +904,18 @@ output from the current command if that happens to be appropriate."
901 (num 0)) 904 (num 0))
902 (save-excursion 905 (save-excursion
903 (set-buffer gdb-expression-buffer-name) 906 (set-buffer gdb-expression-buffer-name)
904 (setq buffer-read-only nil) 907 (let ((buffer-read-only nil))
905 (if (string-equal gdb-annotation-arg "\*") (insert "\*")) 908 (if (string-equal gdb-annotation-arg "\*") (insert "\*"))
906 (while (<= num gdb-nesting-level) 909 (while (<= num gdb-nesting-level)
907 (insert "\t") 910 (insert "\t")
908 (setq num (+ num 1))) 911 (setq num (+ num 1)))
909 (insert-buffer-substring (gdb-get-buffer 912 (insert-buffer-substring (gdb-get-buffer
910 'gdb-partial-output-buffer) 913 'gdb-partial-output-buffer)
911 start end) 914 start end)
912 (put-text-property (- (point) (- end start)) (- (point) 1) 915 (put-text-property (- (point) (- end start)) (- (point) 1)
913 'mouse-face 'highlight) 916 'mouse-face 'highlight)
914 (put-text-property (- (point) (- end start)) (- (point) 1) 917 (put-text-property (- (point) (- end start)) (- (point) 1)
915 'local-map gdb-dive-map) 918 'local-map gdb-dive-map)))
916 (setq buffer-read-only t))
917 (delete-region start end))) 919 (delete-region start end)))
918 920
919(defvar gdb-values) 921(defvar gdb-values)
@@ -971,76 +973,75 @@ output from the current command if that happens to be appropriate."
971 973
972(defun gdb-array-format1 () 974(defun gdb-array-format1 ()
973 (setq gdb-display-string "") 975 (setq gdb-display-string "")
974 (setq buffer-read-only nil) 976 (let ((buffer-read-only nil))
975 (delete-region (point-min) (point-max)) 977 (delete-region (point-min) (point-max))
976 (let ((gdb-value-list (split-string gdb-values ", "))) 978 (let ((gdb-value-list (split-string gdb-values ", ")))
977 (string-match "\\({+\\)" (car gdb-value-list)) 979 (string-match "\\({+\\)" (car gdb-value-list))
978 (let* ((depth (- (match-end 1) (match-beginning 1))) 980 (let* ((depth (- (match-end 1) (match-beginning 1)))
979 (indices (make-vector depth '0)) 981 (indices (make-vector depth '0))
980 (index 0) (num 0) (array-start "") 982 (index 0) (num 0) (array-start "")
981 (array-stop "") (array-slice "") (array-range nil) 983 (array-stop "") (array-slice "") (array-range nil)
982 (flag t) (indices-string "")) 984 (flag t) (indices-string ""))
983 (dolist (gdb-value gdb-value-list) 985 (dolist (gdb-value gdb-value-list)
984 (string-match "{*\\([^}]*\\)\\(}*\\)" gdb-value) 986 (string-match "{*\\([^}]*\\)\\(}*\\)" gdb-value)
987 (setq num 0)
988 (while (< num depth)
989 (setq indices-string
990 (concat indices-string
991 "[" (int-to-string (aref indices num)) "]"))
992 (if (not (= (aref gdb-array-start num) -1))
993 (if (or (< (aref indices num) (aref gdb-array-start num))
994 (> (aref indices num) (aref gdb-array-stop num)))
995 (setq flag nil))
996 (aset gdb-array-size num (aref indices num)))
997 (setq num (+ num 1)))
998 (if flag
999 (let ((gdb-display-value (match-string 1 gdb-value)))
1000 (setq gdb-display-string (concat gdb-display-string " "
1001 gdb-display-value))
1002 (insert
1003 (concat indices-string "\t" gdb-display-value "\n"))))
1004 (setq indices-string "")
1005 (setq flag t)
1006 ;; 0<= index < depth, start at right : (- depth 1)
1007 (setq index (- (- depth 1)
1008 (- (match-end 2) (match-beginning 2))))
1009 ;;don't set for very last brackets
1010 (when (>= index 0)
1011 (aset indices index (+ 1 (aref indices index)))
1012 (setq num (+ 1 index))
1013 (while (< num depth)
1014 (aset indices num 0)
1015 (setq num (+ num 1)))))
985 (setq num 0) 1016 (setq num 0)
986 (while (< num depth) 1017 (while (< num depth)
987 (setq indices-string 1018 (if (= (aref gdb-array-start num) -1)
988 (concat indices-string 1019 (progn
989 "[" (int-to-string (aref indices num)) "]")) 1020 (aset gdb-array-start num 0)
990 (if (not (= (aref gdb-array-start num) -1)) 1021 (aset gdb-array-stop num (aref indices num))))
991 (if (or (< (aref indices num) (aref gdb-array-start num)) 1022 (setq array-start (int-to-string (aref gdb-array-start num)))
992 (> (aref indices num) (aref gdb-array-stop num))) 1023 (setq array-stop (int-to-string (aref gdb-array-stop num)))
993 (setq flag nil)) 1024 (setq array-range (concat "[" array-start
994 (aset gdb-array-size num (aref indices num))) 1025 ":" array-stop "]"))
1026 (put-text-property 1 (+ (length array-start)
1027 (length array-stop) 2)
1028 'mouse-face 'highlight array-range)
1029 (put-text-property 1 (+ (length array-start)
1030 (length array-stop) 2)
1031 'local-map gdb-array-slice-map array-range)
1032 (goto-char (point-min))
1033 (setq array-slice (concat array-slice array-range))
995 (setq num (+ num 1))) 1034 (setq num (+ num 1)))
996 (if flag
997 (let ((gdb-display-value (match-string 1 gdb-value)))
998 (setq gdb-display-string (concat gdb-display-string " "
999 gdb-display-value))
1000 (insert
1001 (concat indices-string "\t" gdb-display-value "\n"))))
1002 (setq indices-string "")
1003 (setq flag t)
1004 ;; 0<= index < depth, start at right : (- depth 1)
1005 (setq index (- (- depth 1)
1006 (- (match-end 2) (match-beginning 2))))
1007 ;;don't set for very last brackets
1008 (when (>= index 0)
1009 (aset indices index (+ 1 (aref indices index)))
1010 (setq num (+ 1 index))
1011 (while (< num depth)
1012 (aset indices num 0)
1013 (setq num (+ num 1)))))
1014 (setq num 0)
1015 (while (< num depth)
1016 (if (= (aref gdb-array-start num) -1)
1017 (progn
1018 (aset gdb-array-start num 0)
1019 (aset gdb-array-stop num (aref indices num))))
1020 (setq array-start (int-to-string (aref gdb-array-start num)))
1021 (setq array-stop (int-to-string (aref gdb-array-stop num)))
1022 (setq array-range (concat "[" array-start
1023 ":" array-stop "]"))
1024 (put-text-property 1 (+ (length array-start)
1025 (length array-stop) 2)
1026 'mouse-face 'highlight array-range)
1027 (put-text-property 1 (+ (length array-start)
1028 (length array-stop) 2)
1029 'local-map gdb-array-slice-map array-range)
1030 (goto-char (point-min)) 1035 (goto-char (point-min))
1031 (setq array-slice (concat array-slice array-range)) 1036 (insert "Array Size : ")
1032 (setq num (+ num 1))) 1037 (setq num 0)
1033 (goto-char (point-min)) 1038 (while (< num depth)
1034 (insert "Array Size : ") 1039 (insert
1035 (setq num 0) 1040 (concat "["
1036 (while (< num depth) 1041 (int-to-string (+ (aref gdb-array-size num) 1)) "]"))
1042 (setq num (+ num 1)))
1037 (insert 1043 (insert
1038 (concat "[" 1044 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n"))))))
1039 (int-to-string (+ (aref gdb-array-size num) 1)) "]"))
1040 (setq num (+ num 1)))
1041 (insert
1042 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n"))))
1043 (setq buffer-read-only t))
1044 1045
1045(defun gud-gdba-marker-filter (string) 1046(defun gud-gdba-marker-filter (string)
1046 "A gud marker filter for gdb. Handle a burst of output from GDB." 1047 "A gud marker filter for gdb. Handle a burst of output from GDB."
@@ -1268,8 +1269,11 @@ output from the current command if that happens to be appropriate."
1268 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t) 1269 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
1269 (progn 1270 (progn
1270 (looking-at "\\(\\S-*\\):\\([0-9]+\\)") 1271 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")
1271 (let ((line (match-string 2)) 1272 (let ((line (match-string 2)) (buffer-read-only nil)
1272 (file (match-string 1))) 1273 (file (match-string 1)))
1274 (put-text-property (progn (beginning-of-line) (point))
1275 (progn (end-of-line) (point))
1276 'mouse-face 'highlight)
1273 (save-excursion 1277 (save-excursion
1274 (set-buffer 1278 (set-buffer
1275 (find-file-noselect 1279 (find-file-noselect
@@ -1632,15 +1636,18 @@ the source buffer."
1632 (if (not (memq (string-to-int number) display-list)) 1636 (if (not (memq (string-to-int number) display-list))
1633 (kill-buffer 1637 (kill-buffer
1634 (get-buffer (concat "*display " number "*"))))))))) 1638 (get-buffer (concat "*display " number "*")))))))))
1635 (dolist (frame (frame-list)) 1639 (gdb-delete-frames display-list))))
1636 (let ((frame-name (frame-parameter frame 'name))) 1640
1637 (if (string-match "\\*display \\([0-9]+\\)\\*" frame-name) 1641(defun gdb-delete-frames (display-list)
1638 (progn 1642 (dolist (frame (frame-list))
1639 (let ((number (match-string 1 frame-name))) 1643 (let ((frame-name (frame-parameter frame 'name)))
1640 (if (not (memq (string-to-int number) display-list)) 1644 (if (string-match "\\*display \\([0-9]+\\)\\*" frame-name)
1641 (progn (kill-buffer 1645 (progn
1642 (get-buffer (concat "*display " number "*"))) 1646 (let ((number (match-string 1 frame-name)))
1643 (delete-frame frame))))))))))) 1647 (if (not (memq (string-to-int number) display-list))
1648 (progn (kill-buffer
1649 (get-buffer (concat "*display " number "*")))
1650 (delete-frame frame)))))))))
1644 1651
1645(defvar gdb-display-mode-map 1652(defvar gdb-display-mode-map
1646 (let ((map (make-sparse-keymap)) 1653 (let ((map (make-sparse-keymap))
@@ -1921,6 +1928,7 @@ static char *magick[] = {
1921Use this command to exit a debugging session cleanly and reset 1928Use this command to exit a debugging session cleanly and reset
1922things like the toolbar and margin in the source buffers." 1929things like the toolbar and margin in the source buffers."
1923 (interactive) 1930 (interactive)
1931 (gdb-delete-frames '())
1924 (dolist (buffer (buffer-list)) 1932 (dolist (buffer (buffer-list))
1925 (save-excursion 1933 (save-excursion
1926 (set-buffer buffer) 1934 (set-buffer buffer)
@@ -1961,7 +1969,6 @@ buffers."
1961 (if gdb-many-windows 1969 (if gdb-many-windows
1962 (gdb-setup-windows) 1970 (gdb-setup-windows)
1963 (gdb-display-breakpoints-buffer) 1971 (gdb-display-breakpoints-buffer)
1964 (gdb-display-stack-buffer)
1965 (gdb-display-display-buffer) 1972 (gdb-display-display-buffer)
1966 (delete-other-windows) 1973 (delete-other-windows)
1967 (split-window) 1974 (split-window)
@@ -2221,8 +2228,10 @@ BUFFER nil or omitted means use the current buffer."
2221 (save-excursion 2228 (save-excursion
2222 (set-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)) 2229 (set-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer))
2223 (goto-char (point-min)) 2230 (goto-char (point-min))
2224 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)") 2231 (if (looking-at "^#[0-9]*\\s-*0x\\S-* in \\(\\S-*\\)")
2225 (setq gdb-current-frame (match-string 1))))) 2232 (setq gdb-current-frame (match-string 1))
2233 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)")
2234 (setq gdb-current-frame (match-string 1))))))
2226 2235
2227(provide 'gdb-ui) 2236(provide 'gdb-ui)
2228 2237