aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Roberts2002-12-17 23:40:06 +0000
committerNick Roberts2002-12-17 23:40:06 +0000
commit28a771bf30a88f858a47794a00c9c8c969a8af2e (patch)
tree7985a3dea7efc593a945f6813f4d38ccc8f26dc9
parentfaf9f52eb86cbd695d0aa8318ce5d32dbb7d979c (diff)
downloademacs-28a771bf30a88f858a47794a00c9c8c969a8af2e.tar.gz
emacs-28a771bf30a88f858a47794a00c9c8c969a8af2e.zip
(gdba-marker-filter, gdb-output-burst): Merge and
rename gud-gdba-marker-filter. (gdb-append-to-inferior-io): Only pop up IO buffer if there is output. (gdb-make-instance): Remove (put into gdba). Use gdb-instance-enqueue-input instead of gdb-instance-enqueue-idle-input for user functions. (gdb-instance-target-string): Simplify. (in-gdb-instance-context): Remove. Expand Commentary.
-rw-r--r--lisp/gdb-ui.el88
1 files changed, 35 insertions, 53 deletions
diff --git a/lisp/gdb-ui.el b/lisp/gdb-ui.el
index ffc18a6a6ff..3a3aa023f76 100644
--- a/lisp/gdb-ui.el
+++ b/lisp/gdb-ui.el
@@ -25,7 +25,15 @@
25 25
26;;; Commentary: 26;;; Commentary:
27 27
28;; Extension of gdba.el written by Jim Kingdon from gdb 5.0 28;; This file is based on gdba.el written by Jim Kingdon from GDB 5.0 and uses
29;; GDB's annotation interface. You don't need to know about annotations but
30;; If you are interested developing this mode see the Annotations section in
31;; the GDB info manual).
32;;
33;; It has been extended to use features of Emacs 21 such as the display
34;; margin for breakpoints and the toolbar. It also has new buffers and lots
35;; of other new features such as formatted auto-display of arrays and
36;; structures (see the GDB-UI in the Emacs info manual).
29 37
30;;; Code: 38;;; Code:
31 39
@@ -94,7 +102,7 @@ The following interactive lisp functions help control operation :
94 (gdb command-line) 102 (gdb command-line)
95 103
96 (set (make-local-variable 'gud-minor-mode) 'gdba) 104 (set (make-local-variable 'gud-minor-mode) 'gdba)
97 (set (make-local-variable 'gud-marker-filter) 'gdba-marker-filter) 105 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
98 106
99 (gud-def gud-break (if (not (string-equal mode-name "Assembler")) 107 (gud-def gud-break (if (not (string-equal mode-name "Assembler"))
100 (gud-call "break %f:%l" arg) 108 (gud-call "break %f:%l" arg)
@@ -120,12 +128,14 @@ The following interactive lisp functions help control operation :
120 (setq gdb-display-in-progress nil) 128 (setq gdb-display-in-progress nil)
121 (setq gdb-dive nil) 129 (setq gdb-dive nil)
122 130
123 (gdb-make-instance) 131 (mapc 'make-local-variable gdb-instance-variables)
132 (setq gdb-buffer-type 'gdba)
133
124 (gdb-clear-inferior-io) 134 (gdb-clear-inferior-io)
125 135
126 ;; find source file and compilation directory here 136 ;; find source file and compilation directory here
127 (gdb-instance-enqueue-idle-input (list "server list\n" 'ignore)) 137 (gdb-instance-enqueue-input (list "server list\n" 'ignore))
128 (gdb-instance-enqueue-idle-input (list "server info source\n" 138 (gdb-instance-enqueue-input (list "server info source\n"
129 'gdb-source-info)) 139 'gdb-source-info))
130 140
131 (run-hooks 'gdba-mode-hook)) 141 (run-hooks 'gdba-mode-hook))
@@ -135,16 +145,16 @@ The following interactive lisp functions help control operation :
135 (interactive) 145 (interactive)
136 (save-excursion 146 (save-excursion
137 (let ((expr (gud-find-c-expr))) 147 (let ((expr (gud-find-c-expr)))
138 (gdb-instance-enqueue-idle-input 148 (gdb-instance-enqueue-input
139 (list (concat "server whatis " expr "\n") 149 (list (concat "server whatis " expr "\n")
140 `(lambda () (gud-display1 ,expr))))))) 150 `(lambda () (gud-display1 ,expr)))))))
141 151
142(defun gud-display1 (expr) 152(defun gud-display1 (expr)
143 (goto-char (point-min)) 153 (goto-char (point-min))
144 (if (re-search-forward "\*" nil t) 154 (if (re-search-forward "\*" nil t)
145 (gdb-instance-enqueue-idle-input 155 (gdb-instance-enqueue-input
146 (list (concat "server display* " expr "\n") 'ignore)) 156 (list (concat "server display* " expr "\n") 'ignore))
147 (gdb-instance-enqueue-idle-input 157 (gdb-instance-enqueue-input
148 (list (concat "server display " expr "\n") 'ignore)))) 158 (list (concat "server display " expr "\n") 'ignore))))
149 159
150 160
@@ -228,24 +238,11 @@ Possible values are these symbols:
228 "A list of trigger functions that have run later than their output 238 "A list of trigger functions that have run later than their output
229handlers.") 239handlers.")
230 240
231(defun in-gdb-instance-context (form)
232 "Funcall FORM in the GUD buffer."
233 (with-current-buffer gud-comint-buffer
234 (funcall form)))
235
236;; end of instance vars 241;; end of instance vars
237 242
238(defun gdb-make-instance ()
239 "Create a gdb instance object from the current buffer."
240 (mapc 'make-local-variable gdb-instance-variables)
241 (setq gdb-buffer-type 'gdba))
242
243(defun gdb-instance-target-string () 243(defun gdb-instance-target-string ()
244 "The apparent name of the program being debugged by a gdb instance. 244 (with-current-buffer gud-comint-buffer
245For sure this the root string used in smashing together the gdb 245 gud-target-name))
246buffer's name, even if that doesn't happen to be the name of a
247program."
248 (in-gdb-instance-context (lambda () gud-target-name)))
249 246
250 247
251;; 248;;
@@ -502,10 +499,6 @@ This filter may simply queue output for a later time."
502 :type 'string 499 :type 'string
503 :group 'gud) 500 :group 'gud)
504 501
505(defun gdba-marker-filter (string)
506 "A gud marker filter for gdb."
507 (gdb-output-burst string))
508
509(defvar gdb-annotation-rules 502(defvar gdb-annotation-rules
510 '(("frames-invalid" gdb-invalidate-frame-and-assembler) 503 '(("frames-invalid" gdb-invalidate-frame-and-assembler)
511 ("breakpoints-invalid" gdb-invalidate-breakpoints-and-assembler) 504 ("breakpoints-invalid" gdb-invalidate-breakpoints-and-assembler)
@@ -803,7 +796,7 @@ output from the current command if that happens to be appropriate."
803(defun gdb-display-go-back () 796(defun gdb-display-go-back ()
804 ;; delete display so they don't accumulate and delete buffer 797 ;; delete display so they don't accumulate and delete buffer
805 (let ((number gdb-display-number)) 798 (let ((number gdb-display-number))
806 (gdb-instance-enqueue-idle-input 799 (gdb-instance-enqueue-input
807 (list (concat "server delete display " number "\n") 'ignore)) 800 (list (concat "server delete display " number "\n") 'ignore))
808 (switch-to-buffer (concat "*display " gdb-dive-display-number "*")) 801 (switch-to-buffer (concat "*display " gdb-dive-display-number "*"))
809 (kill-buffer (get-buffer (concat "*display " number "*"))))) 802 (kill-buffer (get-buffer (concat "*display " number "*")))))
@@ -911,7 +904,7 @@ output from the current command if that happens to be appropriate."
911 (setq gdb-full-expression (substring gdb-full-expression 1 nil))) 904 (setq gdb-full-expression (substring gdb-full-expression 1 nil)))
912 (setq gdb-full-expression 905 (setq gdb-full-expression
913 (concat gdb-full-expression gdb-part-expression "." gdb-last-field)) 906 (concat gdb-full-expression gdb-part-expression "." gdb-last-field))
914 (gdb-instance-enqueue-idle-input 907 (gdb-instance-enqueue-input
915 (list (concat "server display" gdb-display-char 908 (list (concat "server display" gdb-display-char
916 " " gdb-full-expression "\n") 909 " " gdb-full-expression "\n")
917 'ignore))))) 910 'ignore)))))
@@ -1063,16 +1056,9 @@ output from the current command if that happens to be appropriate."
1063 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n")))) 1056 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n"))))
1064 (setq buffer-read-only t)) 1057 (setq buffer-read-only t))
1065 1058
1066;; Handle a burst of output from a gdb instance. 1059(defun gud-gdba-marker-filter (string)
1067;; This function is (indirectly) used as a gud-marker-filter. 1060 "A gud marker filter for gdb. Handle a burst of output from a gdb instance.
1068;; It must return output (if any) to be inserted in the gdb 1061It must return output (if any) to be insterted in the gdb buffer."
1069;; buffer.
1070
1071(defun gdb-output-burst (string)
1072 "Handle a burst of output from a gdb instance.
1073This function is (indirectly) used as a gud-marker-filter.
1074It must return output (if any) to be insterted in the gdb
1075buffer."
1076 (save-match-data 1062 (save-match-data
1077 (let ( 1063 (let (
1078 ;; Recall the left over burst from last time 1064 ;; Recall the left over burst from last time
@@ -1164,8 +1150,9 @@ buffer."
1164 (gdb-get-create-instance-buffer 'gdb-inferior-io)) 1150 (gdb-get-create-instance-buffer 'gdb-inferior-io))
1165 (goto-char (point-max)) 1151 (goto-char (point-max))
1166 (insert-before-markers string)) 1152 (insert-before-markers string))
1167 (gdb-display-buffer 1153 (if (not (string-equal string ""))
1168 (gdb-get-create-instance-buffer 'gdb-inferior-io))) 1154 (gdb-display-buffer
1155 (gdb-get-create-instance-buffer 'gdb-inferior-io))))
1169 1156
1170(defun gdb-clear-inferior-io () 1157(defun gdb-clear-inferior-io ()
1171 (save-excursion 1158 (save-excursion
@@ -1391,7 +1378,7 @@ buffer."
1391 (beginning-of-line 1) 1378 (beginning-of-line 1)
1392 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) 1379 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)"))
1393 (error "Not recognized as break/watchpoint line") 1380 (error "Not recognized as break/watchpoint line")
1394 (gdb-instance-enqueue-idle-input 1381 (gdb-instance-enqueue-input
1395 (list 1382 (list
1396 (concat 1383 (concat
1397 (if (eq ?y (char-after (match-beginning 2))) 1384 (if (eq ?y (char-after (match-beginning 2)))
@@ -1407,13 +1394,8 @@ buffer."
1407 (beginning-of-line 1) 1394 (beginning-of-line 1)
1408 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) 1395 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)"))
1409 (error "Not recognized as break/watchpoint line") 1396 (error "Not recognized as break/watchpoint line")
1410 (gdb-instance-enqueue-idle-input 1397 (gdb-instance-enqueue-input
1411 (list 1398 (list (concat "server delete " (match-string 1) "\n") 'ignore))))
1412 (concat
1413 "server delete "
1414 (match-string 1)
1415 "\n")
1416 'ignore))))
1417 1399
1418(defvar gdb-source-window nil) 1400(defvar gdb-source-window nil)
1419 1401
@@ -1515,7 +1497,7 @@ display the source in the source buffer."
1515 (select-window (posn-window (event-end e))) 1497 (select-window (posn-window (event-end e)))
1516 (save-excursion 1498 (save-excursion
1517 (set-buffer gud-comint-buffer) 1499 (set-buffer gud-comint-buffer)
1518 (gdb-instance-enqueue-idle-input 1500 (gdb-instance-enqueue-input
1519 (list (gud-format-command "server frame %p\n" selection) 1501 (list (gud-format-command "server frame %p\n" selection)
1520 'ignore)) 1502 'ignore))
1521 (gud-display-frame)))) 1503 (gud-display-frame))))
@@ -1702,7 +1684,7 @@ display the source in the source buffer."
1702 (beginning-of-line 1) 1684 (beginning-of-line 1)
1703 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) 1685 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
1704 (error "No expression on this line") 1686 (error "No expression on this line")
1705 (gdb-instance-enqueue-idle-input 1687 (gdb-instance-enqueue-input
1706 (list 1688 (list
1707 (concat 1689 (concat
1708 (if (eq ?y (char-after (match-beginning 2))) 1690 (if (eq ?y (char-after (match-beginning 2)))
@@ -1722,7 +1704,7 @@ display the source in the source buffer."
1722 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) 1704 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
1723 (error "No expression on this line") 1705 (error "No expression on this line")
1724 (let ((number (match-string 1))) 1706 (let ((number (match-string 1)))
1725 (gdb-instance-enqueue-idle-input 1707 (gdb-instance-enqueue-input
1726 (list (concat "server delete display " number "\n") 1708 (list (concat "server delete display " number "\n")
1727 'ignore)) 1709 'ignore))
1728 (if (not (display-graphic-p)) 1710 (if (not (display-graphic-p))
@@ -2099,7 +2081,7 @@ BUFFER nil or omitted means use the current buffer."
2099(defun gdb-delete-display () 2081(defun gdb-delete-display ()
2100 "Delete displayed expression and its frame." 2082 "Delete displayed expression and its frame."
2101 (interactive) 2083 (interactive)
2102 (gdb-instance-enqueue-idle-input 2084 (gdb-instance-enqueue-input
2103 (list (concat "server delete display " gdb-display-number "\n") 2085 (list (concat "server delete display " gdb-display-number "\n")
2104 'ignore)) 2086 'ignore))
2105 (kill-buffer nil) 2087 (kill-buffer nil)