Mercurial > emacs
annotate lisp/gdb-ui.el @ 48655:06a337e05b08
Don't require imenu.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 04 Dec 2002 11:48:12 +0000 |
parents | da382393fb77 |
children | 4d69c0f01cc0 |
rev | line source |
---|---|
48292 | 1 ;;; gdb-ui.el --- User Interface for running GDB |
2 | |
3 ;; Author: Nick Roberts <nick@nick.uklinux.net> | |
4 ;; Maintainer: FSF | |
5 ;; Keywords: unix, tools | |
6 | |
7 ;; Copyright (C) 2002 Free Software Foundation, Inc. | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; Extension of gdba.el written by Jim Kingdon from gdb 5.0 | |
29 | |
30 ;;; Code: | |
31 | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
32 (require 'gud) |
48292 | 33 |
34 (defvar gdb-main-or-pc nil "Initialisation for Assembler buffer.") | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
35 (defvar gdb-current-address nil) |
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
36 (defvar gdb-display-in-progress nil) |
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
37 (defvar gdb-dive nil) |
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
38 (defvar gdb-first-time nil) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
39 (defvar gdb-proc nil "The process associated with gdb.") |
48292 | 40 |
48639
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
41 ;; Dynamically-bound vars in gud.el |
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
42 (defvar gud-gdb-complete-string) |
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
43 (defvar gud-gdb-complete-break) |
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
44 (defvar gud-gdb-complete-list) |
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
45 (defvar gud-gdb-complete-in-progress) |
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
46 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
47 ;;;###autoload |
48292 | 48 (defun gdba (command-line) |
49 "Run gdb on program FILE in buffer *gdb-FILE*. | |
50 The directory containing FILE becomes the initial working directory | |
51 and source-file directory for your debugger. | |
52 | |
53 If `gdb-many-windows' is set to t this works best in X (depending on the size | |
54 of your monitor) using most of the screen. After a short delay the following | |
55 layout will appear (keybindings given in relevant buffer) : | |
56 | |
57 --------------------------------------------------------------------- | |
58 GDB Toolbar | |
59 --------------------------------------------------------------------- | |
60 GUD buffer (I/O of gdb) | Locals buffer | |
61 | | |
62 | | |
63 | | |
64 --------------------------------------------------------------------- | |
65 Source buffer | Input/Output (of debuggee) buffer | |
66 | (comint-mode) | |
67 | | |
68 | | |
69 | | |
70 | | |
71 | | |
72 | | |
73 --------------------------------------------------------------------- | |
74 Stack buffer | Breakpoints buffer | |
75 \[mouse-2\] gdb-frames-select | SPC gdb-toggle-bp-this-line | |
76 | g gdb-goto-bp-this-line | |
77 | d gdb-delete-bp-this-line | |
78 --------------------------------------------------------------------- | |
79 | |
80 All the buffers share the toolbar and source should always display in the same | |
81 window e.g after typing g on a breakpoint in the breakpoints buffer. Breakpoint | |
82 icons are displayed both by setting a break with gud-break and by typing break | |
83 in the GUD buffer. | |
84 | |
85 Displayed expressions appear in separate frames. Arrays may be displayed | |
86 as slices and visualised using the graph program from plotutils if installed. | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
87 |
48292 | 88 If `gdb-many-windows' is set to nil then gdb starts with just two windows : |
89 the GUD and the source buffer. | |
90 | |
91 The following interactive lisp functions help control operation : | |
92 | |
48600
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
93 `gdb-many-windows' - Toggle the number of windows gdb uses. |
48292 | 94 `gdb-restore-windows' - to restore the layout if its lost. |
95 `gdb-quit' - to delete (most) of the buffers used by gdb." | |
96 | |
97 (interactive (list (gud-query-cmdline 'gdba))) | |
98 | |
48640
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
99 (gdba-common-init command-line nil 'gdba-marker-filter) |
48292 | 100 |
101 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
102 | |
103 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set breakpoint at current line.") | |
104 (gud-def gud-run "run" nil "Run the program.") | |
105 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.") | |
106 (gud-def gud-step "step %p" "\C-s" "Step one source line with display.") | |
107 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).") | |
108 (gud-def gud-finish "finish" "\C-f" "Finish executing current function.") | |
109 (gud-def gud-cont "cont" "\C-r" "Continue with display.") | |
110 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") | |
111 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") | |
112 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") | |
113 (gud-def gud-goto "until %f:%l" "\C-u" "Continue up to current line.") | |
114 | |
115 (define-key gud-mode-map "\C-c\C-b" 'gud-break) | |
116 (define-key global-map "\C-x\C-a\C-b" 'gud-break) | |
117 | |
118 (define-key gud-mode-map "\C-c\C-d" 'gud-remove) | |
119 (define-key global-map "\C-x\C-a\C-d" 'gud-remove) | |
120 | |
121 (local-set-key "\C-i" 'gud-gdb-complete-command) | |
122 | |
123 (setq comint-prompt-regexp "^(.*gdb[+]?) *") | |
124 (setq comint-input-sender 'gdb-send) | |
125 | |
126 ; (re-)initialise | |
127 (setq gdb-main-or-pc "main") | |
128 (setq gdb-current-address nil) | |
129 (setq gdb-display-in-progress nil) | |
130 (setq gdb-dive nil) | |
131 (setq gud-last-last-frame nil) | |
48639
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
132 (setq gud-running nil) |
48292 | 133 |
134 (run-hooks 'gdb-mode-hook) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
135 (setq gdb-proc (get-buffer-process (current-buffer))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
136 (gdb-make-instance) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
137 (if gdb-first-time (gdb-clear-inferior-io)) |
48292 | 138 |
139 ; find source file and compilation directory here | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
140 (gdb-instance-enqueue-idle-input (list "server list\n" 'ignore)) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
141 (gdb-instance-enqueue-idle-input (list "server info source\n" |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
142 'gdb-source-info))) |
48292 | 143 |
144 (defun gud-break (arg) | |
145 "Set breakpoint at current line or address." | |
146 (interactive "p") | |
147 (if (not (string-equal mode-name "Assembler")) | |
148 (gud-call "break %f:%l" arg) | |
149 ;else | |
150 (save-excursion | |
151 (beginning-of-line) | |
152 (forward-char 2) | |
153 (gud-call "break *%a" arg)))) | |
154 | |
155 (defun gud-remove (arg) | |
156 "Remove breakpoint at current line or address." | |
157 (interactive "p") | |
158 (if (not (string-equal mode-name "Assembler")) | |
159 (gud-call "clear %f:%l" arg) | |
160 ;else | |
161 (save-excursion | |
162 (beginning-of-line) | |
163 (forward-char 2) | |
164 (gud-call "clear *%a" arg)))) | |
165 | |
166 (defun gud-display () | |
167 "Display (possibly dereferenced) C expression at point." | |
168 (interactive) | |
169 (save-excursion | |
170 (let ((expr (gud-find-c-expr))) | |
171 (gdb-instance-enqueue-idle-input | |
172 (list (concat "server whatis " expr "\n") | |
173 `(lambda () (gud-display1 ,expr))))))) | |
174 | |
175 (defun gud-display1 (expr) | |
176 (goto-char (point-min)) | |
177 (if (re-search-forward "\*" nil t) | |
178 (gdb-instance-enqueue-idle-input | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
179 (list (concat "server display* " expr "\n") 'ignore)) |
48292 | 180 ;else |
181 (gdb-instance-enqueue-idle-input | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
182 (list (concat "server display " expr "\n") 'ignore)))) |
48292 | 183 |
184 | |
185 ;; The completion process filter is installed temporarily to slurp the | |
186 ;; output of GDB up to the next prompt and build the completion list. | |
187 ;; It must also handle annotations. | |
188 (defun gdba-complete-filter (string) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
189 (gdb-output-burst string) |
48292 | 190 (while (string-match "\n\032\032\\(.*\\)\n" string) |
191 (setq string (concat (substring string 0 (match-beginning 0)) | |
192 (substring string (match-end 0))))) | |
193 (setq string (concat gud-gdb-complete-string string)) | |
194 (while (string-match "\n" string) | |
195 (setq gud-gdb-complete-list | |
196 (cons (substring string gud-gdb-complete-break (match-beginning 0)) | |
197 gud-gdb-complete-list)) | |
198 (setq string (substring string (match-end 0)))) | |
199 (if (string-match comint-prompt-regexp string) | |
200 (progn | |
201 (setq gud-gdb-complete-in-progress nil) | |
202 string) | |
203 (progn | |
204 (setq gud-gdb-complete-string string) | |
205 ""))) | |
206 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
207 (defvar gdb-target-name "--unknown--" |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
208 "The apparent name of the program being debugged in a gud buffer.") |
48292 | 209 |
210 (defun gdba-common-init (command-line massage-args marker-filter &optional find-file) | |
211 | |
212 (let* ((words (split-string command-line)) | |
213 (program (car words)) | |
214 | |
215 ;; Extract the file name from WORDS | |
216 ;; and put t in its place. | |
217 ;; Later on we will put the modified file name arg back there. | |
218 (file-word (let ((w (cdr words))) | |
219 (while (and w (= ?- (aref (car w) 0))) | |
220 (setq w (cdr w))) | |
221 (and w | |
222 (prog1 (car w) | |
223 (setcar w t))))) | |
224 (file-subst | |
225 (and file-word (substitute-in-file-name file-word))) | |
226 | |
227 (args (cdr words)) | |
228 | |
229 ;; If a directory was specified, expand the file name. | |
230 ;; Otherwise, don't expand it, so GDB can use the PATH. | |
231 ;; A file name without directory is literally valid | |
232 ;; only if the file exists in ., and in that case, | |
233 ;; omitting the expansion here has no visible effect. | |
234 (file (and file-word | |
235 (if (file-name-directory file-subst) | |
236 (expand-file-name file-subst) | |
237 file-subst))) | |
238 (filepart (and file-word (file-name-nondirectory file))) | |
239 (buffer-name (concat "*gdb-" filepart "*"))) | |
240 | |
241 (setq gdb-first-time (not (get-buffer-process buffer-name))) | |
242 | |
243 (switch-to-buffer buffer-name) | |
244 ;; Set default-directory to the file's directory. | |
245 (and file-word | |
246 gud-chdir-before-run | |
247 ;; Don't set default-directory if no directory was specified. | |
248 ;; In that case, either the file is found in the current directory, | |
249 ;; in which case this setq is a no-op, | |
250 ;; or it is found by searching PATH, | |
251 ;; in which case we don't know what directory it was found in. | |
252 (file-name-directory file) | |
253 (setq default-directory (file-name-directory file))) | |
254 (or (bolp) (newline)) | |
255 (insert "Current directory is " default-directory "\n") | |
256 ;; Put the substituted and expanded file name back in its place. | |
257 (let ((w args)) | |
258 (while (and w (not (eq (car w) t))) | |
259 (setq w (cdr w))) | |
260 (if w | |
261 (setcar w file))) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
262 (apply 'make-comint (concat "gdb-" filepart) program nil args) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
263 (gud-mode) |
48292 | 264 (setq gdb-target-name filepart)) |
265 (make-local-variable 'gud-marker-filter) | |
266 (setq gud-marker-filter marker-filter) | |
267 (if find-file (set (make-local-variable 'gud-find-file) find-file)) | |
268 | |
269 (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter) | |
270 (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel) | |
271 (gud-set-buffer)) | |
272 | |
273 | |
274 ;; ====================================================================== | |
275 ;; | |
276 ;; In this world, there are gdb instance objects (of unspecified | |
277 ;; representation) and buffers associated with those objects. | |
278 ;; | |
279 | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
280 ;; |
48292 | 281 ;; gdb-instance objects |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
282 ;; |
48292 | 283 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
284 (defvar gdb-instance-variables '() |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
285 "A list of variables that are local to the GUD buffer associated |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
286 with a gdb instance.") |
48292 | 287 |
288 ;;; The list of instance variables is built up by the expansions of | |
289 ;;; DEF-GDB-VARIABLE | |
290 ;;; | |
291 | |
292 (defmacro def-gdb-var (root-symbol &optional default doc) | |
293 (let* ((root (symbol-name root-symbol)) | |
294 (accessor (intern (concat "gdb-instance-" root))) | |
295 (setter (intern (concat "set-gdb-instance-" root))) | |
48640
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
296 (name (intern (concat "gdb-" root)))) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
297 `(progn |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
298 (defvar ,name ,default ,doc) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
299 (if (not (memq ',name gdb-instance-variables)) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
300 (push ',name gdb-instance-variables)) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
301 ,(and accessor |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
302 `(defun ,accessor () |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
303 (let ((buffer (gdb-get-instance-buffer 'gdba))) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
304 (and buffer (buffer-local-value ',name buffer))))) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
305 ,(and setter |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
306 `(defun ,setter (val) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
307 (let ((buffer (gdb-get-instance-buffer 'gdba))) |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
308 (and buffer (with-current-buffer buffer |
7bc8b0b65a02
(gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48639
diff
changeset
|
309 (setq ,name val))))))))) |
48292 | 310 |
311 (def-gdb-var buffer-type nil | |
312 "One of the symbols bound in gdb-instance-buffer-rules") | |
313 | |
314 (def-gdb-var burst "" | |
315 "A string of characters from gdb that have not yet been processed.") | |
316 | |
317 (def-gdb-var input-queue () | |
318 "A list of high priority gdb command objects.") | |
319 | |
320 (def-gdb-var idle-input-queue () | |
321 "A list of low priority gdb command objects.") | |
322 | |
323 (def-gdb-var prompting nil | |
324 "True when gdb is idle with no pending input.") | |
325 | |
326 (def-gdb-var output-sink 'user | |
327 "The disposition of the output of the current gdb command. | |
328 Possible values are these symbols: | |
329 | |
330 user -- gdb output should be copied to the GUD buffer | |
331 for the user to see. | |
332 | |
333 inferior -- gdb output should be copied to the inferior-io buffer | |
334 | |
335 pre-emacs -- output should be ignored util the post-prompt | |
336 annotation is received. Then the output-sink | |
337 becomes:... | |
338 emacs -- output should be collected in the partial-output-buffer | |
339 for subsequent processing by a command. This is the | |
340 disposition of output generated by commands that | |
341 gdb mode sends to gdb on its own behalf. | |
342 post-emacs -- ignore input until the prompt annotation is | |
343 received, then go to USER disposition. | |
344 ") | |
345 | |
346 (def-gdb-var current-item nil | |
347 "The most recent command item sent to gdb.") | |
348 | |
349 (def-gdb-var pending-triggers '() | |
350 "A list of trigger functions that have run later than their output | |
351 handlers.") | |
352 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
353 (defun in-gdb-instance-context (form) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
354 "Funcall FORM in the GUD buffer." |
48292 | 355 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
356 (set-buffer (gdb-get-instance-buffer 'gdba)) |
48292 | 357 (funcall form))) |
358 | |
359 ;; end of instance vars | |
360 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
361 (defun gdb-make-instance () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
362 "Create a gdb instance object from a gdb process." |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
363 (with-current-buffer (process-buffer gdb-proc) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
364 (progn |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
365 (mapc 'make-local-variable gdb-instance-variables) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
366 (setq gdb-buffer-type 'gdba)))) |
48292 | 367 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
368 (defun gdb-instance-target-string () |
48292 | 369 "The apparent name of the program being debugged by a gdb instance. |
370 For sure this the root string used in smashing together the gdb | |
371 buffer's name, even if that doesn't happen to be the name of a | |
372 program." | |
373 (in-gdb-instance-context | |
374 (function (lambda () gdb-target-name)))) | |
375 | |
376 | |
377 ;; | |
378 ;; Instance Buffers. | |
379 ;; | |
380 | |
381 ;; More than one buffer can be associated with a gdb instance. | |
382 ;; | |
383 ;; Each buffer has a TYPE -- a symbol that identifies the function | |
384 ;; of that particular buffer. | |
385 ;; | |
386 ;; The usual gdb interaction buffer is given the type `gdb' and | |
387 ;; is constructed specially. | |
388 ;; | |
389 ;; Others are constructed by gdb-get-create-instance-buffer and | |
390 ;; named according to the rules set forth in the gdb-instance-buffer-rules-assoc | |
391 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
392 (defvar gdb-instance-buffer-rules-assoc '()) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
393 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
394 (defun gdb-get-instance-buffer (key) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
395 "Return the instance buffer tagged with type KEY. |
48292 | 396 The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." |
397 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
398 (gdb-look-for-tagged-buffer key (buffer-list)))) |
48292 | 399 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
400 (defun gdb-get-create-instance-buffer (key) |
48292 | 401 "Create a new gdb instance buffer of the type specified by KEY. |
402 The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
403 (or (gdb-get-instance-buffer key) |
48292 | 404 (let* ((rules (assoc key gdb-instance-buffer-rules-assoc)) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
405 (name (funcall (gdb-rules-name-maker rules))) |
48292 | 406 (new (get-buffer-create name))) |
407 (save-excursion | |
408 (set-buffer new) | |
409 (make-variable-buffer-local 'gdb-buffer-type) | |
410 (setq gdb-buffer-type key) | |
411 (if (cdr (cdr rules)) | |
412 (funcall (car (cdr (cdr rules))))) | |
413 new)))) | |
414 | |
415 (defun gdb-rules-name-maker (rules) (car (cdr rules))) | |
416 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
417 (defun gdb-look-for-tagged-buffer (key bufs) |
48292 | 418 (let ((retval nil)) |
419 (while (and (not retval) bufs) | |
420 (set-buffer (car bufs)) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
421 (if (eq gdb-buffer-type key) |
48292 | 422 (setq retval (car bufs))) |
423 (setq bufs (cdr bufs))) | |
424 retval)) | |
425 | |
426 ;; | |
427 ;; This assoc maps buffer type symbols to rules. Each rule is a list of | |
428 ;; at least one and possible more functions. The functions have these | |
429 ;; roles in defining a buffer type: | |
430 ;; | |
431 ;; NAME - take an instance, return a name for this type buffer for that | |
432 ;; instance. | |
433 ;; The remaining function(s) are optional: | |
434 ;; | |
435 ;; MODE - called in new new buffer with no arguments, should establish | |
436 ;; the proper mode for the buffer. | |
437 ;; | |
438 | |
439 (defun gdb-set-instance-buffer-rules (buffer-type &rest rules) | |
440 (let ((binding (assoc buffer-type gdb-instance-buffer-rules-assoc))) | |
441 (if binding | |
442 (setcdr binding rules) | |
443 (setq gdb-instance-buffer-rules-assoc | |
444 (cons (cons buffer-type rules) | |
445 gdb-instance-buffer-rules-assoc))))) | |
446 | |
447 ; GUD buffers are an exception to the rules | |
448 (gdb-set-instance-buffer-rules 'gdba 'error) | |
449 | |
450 ;; | |
451 ;; partial-output buffers | |
452 ;; | |
453 ;; These accumulate output from a command executed on | |
454 ;; behalf of emacs (rather than the user). | |
455 ;; | |
456 | |
457 (gdb-set-instance-buffer-rules 'gdb-partial-output-buffer | |
458 'gdb-partial-output-name) | |
459 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
460 (defun gdb-partial-output-name () |
48292 | 461 (concat "*partial-output-" |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
462 (gdb-instance-target-string) |
48292 | 463 "*")) |
464 | |
465 | |
466 (gdb-set-instance-buffer-rules 'gdb-inferior-io | |
467 'gdb-inferior-io-name | |
468 'gdb-inferior-io-mode) | |
469 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
470 (defun gdb-inferior-io-name () |
48292 | 471 (concat "*input/output of " |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
472 (gdb-instance-target-string) |
48292 | 473 "*")) |
474 | |
475 (defvar gdb-inferior-io-mode-map (copy-keymap comint-mode-map)) | |
476 (define-key comint-mode-map "\C-c\C-c" 'gdb-inferior-io-interrupt) | |
477 (define-key comint-mode-map "\C-c\C-z" 'gdb-inferior-io-stop) | |
478 (define-key comint-mode-map "\C-c\C-\\" 'gdb-inferior-io-quit) | |
479 (define-key comint-mode-map "\C-c\C-d" 'gdb-inferior-io-eof) | |
480 | |
481 (defun gdb-inferior-io-mode () | |
482 "Major mode for gdb inferior-io. | |
483 | |
484 \\{comint-mode-map}" | |
485 ;; We want to use comint because it has various nifty and familiar | |
486 ;; features. We don't need a process, but comint wants one, so create | |
487 ;; a dummy one. | |
488 (make-comint (substring (buffer-name) 1 (- (length (buffer-name)) 1)) | |
489 "/bin/cat") | |
490 (setq major-mode 'gdb-inferior-io-mode) | |
491 (setq mode-name "Debuggee I/O") | |
492 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
493 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
494 (setq comint-input-sender 'gdb-inferior-io-sender)) | |
495 | |
496 (defun gdb-inferior-io-sender (proc string) | |
497 (save-excursion | |
498 (set-buffer (process-buffer proc)) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
499 (set-buffer (gdb-get-instance-buffer 'gdba)) |
48292 | 500 (process-send-string gdb-proc string) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
501 (process-send-string gdb-proc "\n"))) |
48292 | 502 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
503 (defun gdb-inferior-io-interrupt () |
48292 | 504 "Interrupt the program being debugged." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
505 (interactive (list gdb-proc)) |
48292 | 506 (interrupt-process |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
507 (get-buffer-process (gdb-get-instance-buffer 'gdba)) comint-ptyp)) |
48292 | 508 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
509 (defun gdb-inferior-io-quit () |
48292 | 510 "Send quit signal to the program being debugged." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
511 (interactive (list gdb-proc)) |
48292 | 512 (quit-process |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
513 (get-buffer-process (gdb-get-instance-buffer 'gdba)) comint-ptyp)) |
48292 | 514 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
515 (defun gdb-inferior-io-stop () |
48292 | 516 "Stop the program being debugged." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
517 (interactive (list gdb-proc)) |
48292 | 518 (stop-process |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
519 (get-buffer-process (gdb-get-instance-buffer 'gdba)) comint-ptyp)) |
48292 | 520 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
521 (defun gdb-inferior-io-eof () |
48292 | 522 "Send end-of-file to the program being debugged." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
523 (interactive (list gdb-proc)) |
48292 | 524 (process-send-eof |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
525 (get-buffer-process (gdb-get-instance-buffer 'gdba)))) |
48292 | 526 |
527 | |
528 ;; | |
529 ;; gdb communications | |
530 ;; | |
531 | |
532 ;; INPUT: things sent to gdb | |
533 ;; | |
534 ;; Each instance has a high and low priority | |
535 ;; input queue. Low priority input is sent only | |
536 ;; when the high priority queue is idle. | |
537 ;; | |
538 ;; The queues are lists. Each element is either | |
539 ;; a string (indicating user or user-like input) | |
540 ;; or a list of the form: | |
541 ;; | |
542 ;; (INPUT-STRING HANDLER-FN) | |
543 ;; | |
544 ;; | |
545 ;; The handler function will be called from the | |
546 ;; partial-output buffer when the command completes. | |
547 ;; This is the way to write commands which | |
548 ;; invoke gdb commands autonomously. | |
549 ;; | |
550 ;; These lists are consumed tail first. | |
551 ;; | |
552 | |
553 (defun gdb-send (proc string) | |
554 "A comint send filter for gdb. | |
555 This filter may simply queue output for a later time." | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
556 (gdb-instance-enqueue-input (concat string "\n"))) |
48292 | 557 |
558 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it | |
559 ;; is a query, or other non-top-level prompt. To guarantee stuff will get | |
560 ;; sent to the top-level prompt, currently it must be put in the idle queue. | |
561 ;; ^^^^^^^^^ | |
562 ;; [This should encourage gdb extensions that invoke gdb commands to let | |
563 ;; the user go first; it is not a bug. -t] | |
564 ;; | |
565 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
566 (defun gdb-instance-enqueue-input (item) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
567 (if (gdb-instance-prompting) |
48292 | 568 (progn |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
569 (gdb-send-item item) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
570 (set-gdb-instance-prompting nil)) |
48292 | 571 (set-gdb-instance-input-queue |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
572 (cons item (gdb-instance-input-queue))))) |
48292 | 573 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
574 (defun gdb-instance-dequeue-input () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
575 (let ((queue (gdb-instance-input-queue))) |
48292 | 576 (and queue |
577 (if (not (cdr queue)) | |
578 (let ((answer (car queue))) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
579 (set-gdb-instance-input-queue '()) |
48292 | 580 answer) |
581 (gdb-take-last-elt queue))))) | |
582 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
583 (defun gdb-instance-enqueue-idle-input (item) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
584 (if (and (gdb-instance-prompting) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
585 (not (gdb-instance-input-queue))) |
48292 | 586 (progn |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
587 (gdb-send-item item) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
588 (set-gdb-instance-prompting nil)) |
48292 | 589 (set-gdb-instance-idle-input-queue |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
590 (cons item (gdb-instance-idle-input-queue))))) |
48292 | 591 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
592 (defun gdb-instance-dequeue-idle-input () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
593 (let ((queue (gdb-instance-idle-input-queue))) |
48292 | 594 (and queue |
595 (if (not (cdr queue)) | |
596 (let ((answer (car queue))) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
597 (set-gdb-instance-idle-input-queue '()) |
48292 | 598 answer) |
599 (gdb-take-last-elt queue))))) | |
600 | |
601 ; Don't use this in general. | |
602 (defun gdb-take-last-elt (l) | |
603 (if (cdr (cdr l)) | |
604 (gdb-take-last-elt (cdr l)) | |
605 (let ((answer (car (cdr l)))) | |
606 (setcdr l '()) | |
607 answer))) | |
608 | |
609 | |
610 ;; | |
611 ;; output -- things gdb prints to emacs | |
612 ;; | |
613 ;; GDB output is a stream interrupted by annotations. | |
614 ;; Annotations can be recognized by their beginning | |
615 ;; with \C-j\C-z\C-z<tag><opt>\C-j | |
616 ;; | |
617 ;; The tag is a string obeying symbol syntax. | |
618 ;; | |
619 ;; The optional part `<opt>' can be either the empty string | |
620 ;; or a space followed by more data relating to the annotation. | |
621 ;; For example, the SOURCE annotation is followed by a filename, | |
622 ;; line number and various useless goo. This data must not include | |
623 ;; any newlines. | |
624 ;; | |
625 | |
626 (defcustom gud-gdba-command-name "gdb -annotate=2" | |
627 "Default command to execute an executable under the GDB debugger (gdb-ui.el)." | |
628 :type 'string | |
629 :group 'gud) | |
630 | |
631 (defun gdba-marker-filter (string) | |
632 "A gud marker filter for gdb." | |
633 ;; Bogons don't tell us the process except through scoping crud. | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
634 (gdb-output-burst string)) |
48292 | 635 |
636 (defvar gdb-annotation-rules | |
637 '(("frames-invalid" gdb-invalidate-frame-and-assembler) | |
638 ("breakpoints-invalid" gdb-invalidate-breakpoints-and-assembler) | |
639 ("pre-prompt" gdb-pre-prompt) | |
640 ("prompt" gdb-prompt) | |
641 ("commands" gdb-subprompt) | |
642 ("overload-choice" gdb-subprompt) | |
643 ("query" gdb-subprompt) | |
644 ("prompt-for-continue" gdb-subprompt) | |
645 ("post-prompt" gdb-post-prompt) | |
646 ("source" gdb-source) | |
647 ("starting" gdb-starting) | |
648 ("exited" gdb-stopping) | |
649 ("signalled" gdb-stopping) | |
650 ("signal" gdb-stopping) | |
651 ("breakpoint" gdb-stopping) | |
652 ("watchpoint" gdb-stopping) | |
653 ("frame-begin" gdb-frame-begin) | |
654 ("stopped" gdb-stopped) | |
655 ("display-begin" gdb-display-begin) | |
656 ("display-end" gdb-display-end) | |
657 ("display-number-end" gdb-display-number-end) | |
658 ("array-section-begin" gdb-array-section-begin) | |
659 ("array-section-end" gdb-array-section-end) | |
660 ; ("elt" gdb-elt) | |
661 ("field-begin" gdb-field-begin) | |
662 ("field-end" gdb-field-end) | |
663 ) "An assoc mapping annotation tags to functions which process them.") | |
664 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
665 (defun gdb-ignore-annotation (args) |
48292 | 666 nil) |
667 | |
668 (defconst gdb-source-spec-regexp | |
669 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)") | |
670 | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
671 ;; Do not use this except as an annotation handler. |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
672 (defun gdb-source (args) |
48292 | 673 (string-match gdb-source-spec-regexp args) |
674 ;; Extract the frame position from the marker. | |
675 (setq gud-last-frame | |
676 (cons | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
677 (match-string 1 args) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
678 (string-to-int (match-string 2 args)))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
679 (setq gdb-current-address (match-string 3 args)) |
48292 | 680 (setq gdb-main-or-pc gdb-current-address) |
681 ;update with new frame for machine code if necessary | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
682 (gdb-invalidate-assembler)) |
48292 | 683 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
684 (defun gdb-prompt (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
685 "An annotation handler for `prompt'. |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
686 This sends the next command (if any) to gdb." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
687 (let ((sink (gdb-instance-output-sink))) |
48292 | 688 (cond |
689 ((eq sink 'user) t) | |
690 ((eq sink 'post-emacs) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
691 (set-gdb-instance-output-sink 'user)) |
48292 | 692 (t |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
693 (set-gdb-instance-output-sink 'user) |
48292 | 694 (error "Phase error in gdb-prompt (got %s)" sink)))) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
695 (let ((highest (gdb-instance-dequeue-input))) |
48292 | 696 (if highest |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
697 (gdb-send-item highest) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
698 (let ((lowest (gdb-instance-dequeue-idle-input))) |
48292 | 699 (if lowest |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
700 (gdb-send-item lowest) |
48292 | 701 (progn |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
702 (set-gdb-instance-prompting t) |
48292 | 703 (gud-display-frame))))))) |
704 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
705 (defun gdb-subprompt (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
706 "An annotation handler for non-top-level prompts." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
707 (let ((highest (gdb-instance-dequeue-input))) |
48292 | 708 (if highest |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
709 (gdb-send-item highest) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
710 (set-gdb-instance-prompting t)))) |
48292 | 711 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
712 (defun gdb-send-item (item) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
713 (set-gdb-instance-current-item item) |
48292 | 714 (if (stringp item) |
715 (progn | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
716 (set-gdb-instance-output-sink 'user) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
717 (process-send-string gdb-proc item)) |
48292 | 718 (progn |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
719 (gdb-clear-partial-output) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
720 (set-gdb-instance-output-sink 'pre-emacs) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
721 (process-send-string gdb-proc (car item))))) |
48292 | 722 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
723 (defun gdb-pre-prompt (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
724 "An annotation handler for `pre-prompt'. This terminates the collection of |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
725 output from a previous command if that happens to be in effect." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
726 (let ((sink (gdb-instance-output-sink))) |
48292 | 727 (cond |
728 ((eq sink 'user) t) | |
729 ((eq sink 'emacs) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
730 (set-gdb-instance-output-sink 'post-emacs) |
48292 | 731 (let ((handler |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
732 (car (cdr (gdb-instance-current-item))))) |
48292 | 733 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
734 (set-buffer (gdb-get-create-instance-buffer |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
735 'gdb-partial-output-buffer)) |
48292 | 736 (funcall handler)))) |
737 (t | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
738 (set-gdb-instance-output-sink 'user) |
48292 | 739 (error "Output sink phase error 1"))))) |
740 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
741 (defun gdb-starting (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
742 "An annotation handler for `starting'. This says that I/O for the |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
743 subprocess is now the program being debugged, not GDB." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
744 (let ((sink (gdb-instance-output-sink))) |
48292 | 745 (cond |
746 ((eq sink 'user) | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
747 (progn |
48639
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
748 (setq gud-running t) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
749 (set-gdb-instance-output-sink 'inferior))) |
48292 | 750 (t (error "Unexpected `starting' annotation"))))) |
751 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
752 (defun gdb-stopping (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
753 "An annotation handler for `exited' and other annotations which say that I/O |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
754 for the subprocess is now GDB, not the program being debugged." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
755 (let ((sink (gdb-instance-output-sink))) |
48292 | 756 (cond |
757 ((eq sink 'inferior) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
758 (set-gdb-instance-output-sink 'user)) |
48292 | 759 (t (error "Unexpected stopping annotation"))))) |
760 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
761 (defun gdb-stopped (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
762 "An annotation handler for `stopped'. It is just like gdb-stopping, except |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
763 that if we already set the output sink to 'user in gdb-stopping, that is fine." |
48639
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
764 (setq gud-running nil) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
765 (let ((sink (gdb-instance-output-sink))) |
48292 | 766 (cond |
767 ((eq sink 'inferior) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
768 (set-gdb-instance-output-sink 'user)) |
48292 | 769 ((eq sink 'user) t) |
770 (t (error "Unexpected stopped annotation"))))) | |
771 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
772 (defun gdb-frame-begin (ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
773 (let ((sink (gdb-instance-output-sink))) |
48292 | 774 (cond |
775 ((eq sink 'inferior) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
776 (set-gdb-instance-output-sink 'user)) |
48292 | 777 ((eq sink 'user) t) |
778 ((eq sink 'emacs) t) | |
779 (t (error "Unexpected frame-begin annotation (%S)" sink))))) | |
780 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
781 (defun gdb-post-prompt (ignored) |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
782 "An annotation handler for `post-prompt'. This begins the collection of |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
783 output from the current command if that happens to be appropriate." |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
784 (if (not (gdb-instance-pending-triggers)) |
48292 | 785 (progn |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
786 (gdb-invalidate-registers ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
787 (gdb-invalidate-locals ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
788 (gdb-invalidate-display ignored))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
789 (let ((sink (gdb-instance-output-sink))) |
48292 | 790 (cond |
791 ((eq sink 'user) t) | |
792 ((eq sink 'pre-emacs) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
793 (set-gdb-instance-output-sink 'emacs)) |
48292 | 794 (t |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
795 (set-gdb-instance-output-sink 'user) |
48292 | 796 (error "Output sink phase error 3"))))) |
797 | |
798 ;; If we get an error whilst evaluating one of the expressions | |
799 ;; we won't get the display-end annotation. Set the sink back to | |
800 ;; user to make sure that the error message is seen | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
801 (defun gdb-error-begin (ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
802 (set-gdb-instance-output-sink 'user)) |
48292 | 803 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
804 (defun gdb-display-begin (ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
805 (if (gdb-get-instance-buffer 'gdb-display-buffer) |
48292 | 806 (progn |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
807 (set-gdb-instance-output-sink 'emacs) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
808 (gdb-clear-partial-output) |
48292 | 809 (setq gdb-display-in-progress t)) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
810 (set-gdb-instance-output-sink 'user))) |
48292 | 811 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
812 (defvar gdb-expression-buffer-name) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
813 (defvar gdb-display-number) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
814 (defvar gdb-dive-display-number) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
815 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
816 (defun gdb-display-number-end (ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
817 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 818 (setq gdb-display-number (buffer-string)) |
819 (setq gdb-expression-buffer-name | |
820 (concat "*display " gdb-display-number "*")) | |
821 (save-excursion | |
822 (if (progn | |
823 (set-buffer (window-buffer)) | |
824 gdb-dive) | |
825 (progn | |
826 (let ((number gdb-display-number)) | |
827 (switch-to-buffer | |
828 (set-buffer (get-buffer-create gdb-expression-buffer-name))) | |
829 (gdb-expressions-mode) | |
830 (setq gdb-dive-display-number number))) | |
831 ;else | |
832 (set-buffer (get-buffer-create gdb-expression-buffer-name)) | |
833 (if (and (display-graphic-p) (not gdb-dive)) | |
834 (catch 'frame-exists | |
835 (let ((frames (frame-list))) | |
836 (while frames | |
837 (if (string-equal (frame-parameter (car frames) 'name) | |
838 gdb-expression-buffer-name) | |
839 (throw 'frame-exists nil)) | |
840 (setq frames (cdr frames))) | |
841 (if (not frames) | |
842 (progn | |
843 (gdb-expressions-mode) | |
844 (make-frame '((height . 20) (width . 40) | |
845 (tool-bar-lines . nil) | |
846 (menu-bar-lines . nil) | |
847 (minibuffer . nil)))))))))) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
848 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 849 (setq gdb-dive nil)) |
850 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
851 (defvar gdb-current-frame nil) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
852 (defvar gdb-nesting-level) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
853 (defvar gdb-expression) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
854 (defvar gdb-point) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
855 (defvar gdb-annotation-arg) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
856 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
857 (defun gdb-display-end (ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
858 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 859 (goto-char (point-min)) |
860 (search-forward ": ") | |
861 (looking-at "\\(.*?\\) =") | |
862 (let ((char "") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
863 (gdb-temp-value (match-string 1))) |
48292 | 864 ;move * to front of expression if necessary |
865 (if (looking-at ".*\\*") | |
866 (progn | |
867 (setq char "*") | |
868 (setq gdb-temp-value (substring gdb-temp-value 1 nil)))) | |
869 (save-excursion | |
870 (set-buffer gdb-expression-buffer-name) | |
871 (setq gdb-expression gdb-temp-value) | |
872 (if (not (string-match "::" gdb-expression)) | |
873 (setq gdb-expression (concat char gdb-current-frame | |
874 "::" gdb-expression)) | |
875 ;else put * back on if necessary | |
876 (setq gdb-expression (concat char gdb-expression))) | |
877 (setq header-line-format (concat "-- " gdb-expression " %-")))) | |
878 | |
879 ;-if scalar/string | |
880 (if (not (re-search-forward "##" nil t)) | |
881 (progn | |
882 (save-excursion | |
883 (set-buffer gdb-expression-buffer-name) | |
884 (setq buffer-read-only nil) | |
885 (delete-region (point-min) (point-max)) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
886 (insert-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 887 (setq buffer-read-only t))) |
888 ; else | |
889 ; display expression name... | |
890 (goto-char (point-min)) | |
891 (let ((start (progn (point))) | |
892 (end (progn (end-of-line) (point)))) | |
893 (save-excursion | |
894 (set-buffer gdb-expression-buffer-name) | |
895 (setq buffer-read-only nil) | |
896 (delete-region (point-min) (point-max)) | |
897 (insert-buffer-substring (gdb-get-instance-buffer | |
898 'gdb-partial-output-buffer) | |
899 start end) | |
900 (insert "\n"))) | |
901 (goto-char (point-min)) | |
902 (re-search-forward "##" nil t) | |
903 (setq gdb-nesting-level 0) | |
904 (if (looking-at "array-section-begin") | |
905 (progn | |
906 (gdb-delete-line) | |
907 (beginning-of-line) | |
908 (setq gdb-point (point)) | |
909 (gdb-array-format))) | |
910 (if (looking-at "field-begin \\(.\\)") | |
911 (progn | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
912 (setq gdb-annotation-arg (match-string 1)) |
48292 | 913 (gdb-field-format-begin)))) |
914 (save-excursion | |
915 (set-buffer gdb-expression-buffer-name) | |
916 (if gdb-dive-display-number | |
917 (progn | |
918 (setq buffer-read-only nil) | |
919 (goto-char (point-max)) | |
920 (insert "\n") | |
921 (insert-text-button "[back]" 'type 'gdb-display-back) | |
922 (setq buffer-read-only t)))) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
923 (gdb-clear-partial-output) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
924 (set-gdb-instance-output-sink 'user) |
48292 | 925 (setq gdb-display-in-progress nil)) |
926 | |
927 (define-button-type 'gdb-display-back | |
928 'help-echo (purecopy "mouse-2, RET: go back to previous display buffer") | |
929 'action (lambda (button) (gdb-display-go-back))) | |
930 | |
931 (defun gdb-display-go-back () | |
932 ; delete display so they don't accumulate and delete buffer | |
933 (let ((number gdb-display-number)) | |
934 (gdb-instance-enqueue-idle-input | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
935 (list (concat "server delete display " number "\n") 'ignore)) |
48292 | 936 (switch-to-buffer (concat "*display " gdb-dive-display-number "*")) |
937 (kill-buffer (get-buffer (concat "*display " number "*"))))) | |
938 | |
939 ; prefix annotations with ## and process whole output in one chunk | |
940 ; in gdb-partial-output-buffer (to allow recursion). | |
941 | |
942 ; array-section flags are just removed again but after counting. They | |
943 ; might also be useful for arrays of structures and structures with arrays. | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
944 (defun gdb-array-section-begin (args) |
48292 | 945 (if gdb-display-in-progress |
946 (progn | |
947 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
948 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 949 (goto-char (point-max)) |
950 (insert (concat "\n##array-section-begin " args "\n")))))) | |
951 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
952 (defun gdb-array-section-end (ignored) |
48292 | 953 (if gdb-display-in-progress |
954 (progn | |
955 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
956 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 957 (goto-char (point-max)) |
958 (insert "\n##array-section-end\n"))))) | |
959 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
960 (defun gdb-field-begin (args) |
48292 | 961 (if gdb-display-in-progress |
962 (progn | |
963 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
964 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 965 (goto-char (point-max)) |
966 (insert (concat "\n##field-begin " args "\n")))))) | |
967 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
968 (defun gdb-field-end (ignored) |
48292 | 969 (if gdb-display-in-progress |
970 (progn | |
971 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
972 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 973 (goto-char (point-max)) |
974 (insert "\n##field-end\n"))))) | |
975 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
976 (defun gdb-elt (ignored) |
48292 | 977 (if gdb-display-in-progress |
978 (progn | |
979 (goto-char (point-max)) | |
980 (insert "\n##elt\n")))) | |
981 | |
982 (defun gdb-field-format-begin () | |
983 ; get rid of ##field-begin | |
984 (gdb-delete-line) | |
985 (gdb-insert-field) | |
986 (setq gdb-nesting-level (+ gdb-nesting-level 1)) | |
987 (while (re-search-forward "##" nil t) | |
988 ; keep making recursive calls... | |
989 (if (looking-at "field-begin \\(.\\)") | |
990 (progn | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
991 (setq gdb-annotation-arg (match-string 1)) |
48292 | 992 (gdb-field-format-begin))) |
993 ; until field-end. | |
994 (if (looking-at "field-end") (gdb-field-format-end)))) | |
995 | |
996 (defun gdb-field-format-end () | |
997 ; get rid of ##field-end and `,' or `}' | |
998 (gdb-delete-line) | |
999 (gdb-delete-line) | |
1000 (setq gdb-nesting-level (- gdb-nesting-level 1))) | |
1001 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1002 (defvar gdb-dive-map nil) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1003 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1004 (setq gdb-dive-map (make-keymap)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1005 (define-key gdb-dive-map [mouse-2] 'gdb-dive) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1006 (define-key gdb-dive-map [S-mouse-2] 'gdb-dive-new-frame) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1007 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1008 (defun gdb-dive (event) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1009 "Dive into structure." |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1010 (interactive "e") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1011 (setq gdb-dive t) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1012 (gdb-dive-new-frame event)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1013 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1014 (defun gdb-dive-new-frame (event) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1015 "Dive into structure and display in a new frame." |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1016 (interactive "e") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1017 (save-excursion |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1018 (mouse-set-point event) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1019 (let ((point (point)) (gdb-full-expression gdb-expression) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1020 (end (progn (end-of-line) (point))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1021 (gdb-part-expression "") (gdb-last-field nil) (gdb-display-char nil)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1022 (beginning-of-line) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1023 (if (looking-at "\*") (setq gdb-display-char "*")) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1024 (re-search-forward "\\(\\S-+\\) = " end t) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1025 (setq gdb-last-field (match-string-no-properties 1)) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1026 (goto-char (match-beginning 1)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1027 (let ((last-column (current-column))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1028 (while (re-search-backward "\\s-\\(\\S-+\\) = {" nil t) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1029 (goto-char (match-beginning 1)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1030 (if (and (< (current-column) last-column) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1031 (> (count-lines 1 (point)) 1)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1032 (progn |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1033 (setq gdb-part-expression |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1034 (concat "." (match-string-no-properties 1) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1035 gdb-part-expression)) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1036 (setq last-column (current-column)))))) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1037 ;; * not needed for components of a pointer to a structure in gdb |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1038 (if (string-equal "*" (substring gdb-full-expression 0 1)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1039 (setq gdb-full-expression (substring gdb-full-expression 1 nil))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1040 (setq gdb-full-expression |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1041 (concat gdb-full-expression gdb-part-expression "." gdb-last-field)) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1042 (gdb-instance-enqueue-idle-input |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1043 (list (concat "server display" gdb-display-char |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1044 " " gdb-full-expression "\n") |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1045 'ignore))))) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1046 |
48292 | 1047 (defun gdb-insert-field () |
1048 (let ((start (progn (point))) | |
1049 (end (progn (next-line) (point))) | |
1050 (num 0)) | |
1051 (save-excursion | |
1052 (set-buffer gdb-expression-buffer-name) | |
1053 (setq buffer-read-only nil) | |
1054 (if (string-equal gdb-annotation-arg "\*") (insert "\*")) | |
1055 (while (<= num gdb-nesting-level) | |
1056 (insert "\t") | |
1057 (setq num (+ num 1))) | |
1058 (insert-buffer-substring (gdb-get-instance-buffer | |
1059 'gdb-partial-output-buffer) | |
1060 start end) | |
1061 (put-text-property (- (point) (- end start)) (- (point) 1) | |
1062 'mouse-face 'highlight) | |
1063 (put-text-property (- (point) (- end start)) (- (point) 1) | |
1064 'local-map gdb-dive-map) | |
1065 (setq buffer-read-only t)) | |
1066 (delete-region start end))) | |
1067 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1068 (defvar gdb-values) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1069 |
48292 | 1070 (defun gdb-array-format () |
1071 (while (re-search-forward "##" nil t) | |
1072 ; keep making recursive calls... | |
1073 (if (looking-at "array-section-begin") | |
1074 (progn | |
1075 ;get rid of ##array-section-begin | |
1076 (gdb-delete-line) | |
1077 (setq gdb-nesting-level (+ gdb-nesting-level 1)) | |
1078 (gdb-array-format))) | |
1079 ;until *matching* array-section-end is found | |
1080 (if (looking-at "array-section-end") | |
1081 (if (eq gdb-nesting-level 0) | |
1082 (progn | |
1083 (let ((values (buffer-substring gdb-point (- (point) 2)))) | |
1084 (save-excursion | |
1085 (set-buffer gdb-expression-buffer-name) | |
1086 (setq gdb-values | |
1087 (concat "{" (replace-regexp-in-string "\n" "" values) | |
1088 "}")) | |
1089 (gdb-array-format1)))) | |
1090 ;else get rid of ##array-section-end etc | |
1091 (gdb-delete-line) | |
1092 (setq gdb-nesting-level (- gdb-nesting-level 1)) | |
1093 (gdb-array-format))))) | |
1094 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1095 (defvar gdb-array-start) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1096 (defvar gdb-array-stop) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1097 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1098 (defvar gdb-array-slice-map nil) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1099 (setq gdb-array-slice-map (make-keymap)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1100 (define-key gdb-array-slice-map [mouse-2] 'gdb-array-slice) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1101 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1102 (defun gdb-array-slice (event) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1103 "Select an array slice to display." |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1104 (interactive "e") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1105 (mouse-set-point event) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1106 (save-excursion |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1107 (let ((n -1) (stop 0) (start 0) (point (point))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1108 (beginning-of-line) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1109 (while (search-forward "[" point t) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1110 (setq n (+ n 1))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1111 (setq start (string-to-int (read-string "Start index: "))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1112 (aset gdb-array-start n start) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1113 (setq stop (string-to-int (read-string "Stop index: "))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1114 (aset gdb-array-stop n stop))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1115 (gdb-array-format1)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1116 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1117 (defvar gdb-display-string) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1118 (defvar gdb-array-size) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1119 |
48292 | 1120 (defun gdb-array-format1 () |
1121 (setq gdb-display-string "") | |
1122 (setq buffer-read-only nil) | |
1123 (delete-region (point-min) (point-max)) | |
1124 (let ((gdb-value-list (split-string gdb-values ", "))) | |
1125 (string-match "\\({+\\)" (car gdb-value-list)) | |
1126 (let* ((depth (- (match-end 1) (match-beginning 1))) | |
1127 (indices (make-vector depth '0)) | |
1128 (index 0) (num 0) (array-start "") | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1129 (array-stop "") (array-slice "") (array-range nil) |
48292 | 1130 (flag t) (indices-string "")) |
1131 (while gdb-value-list | |
1132 (string-match "{*\\([^}]*\\)\\(}*\\)" (car gdb-value-list)) | |
1133 (setq num 0) | |
1134 (while (< num depth) | |
1135 (setq indices-string | |
1136 (concat indices-string | |
1137 "[" (int-to-string (aref indices num)) "]")) | |
1138 (if (not (= (aref gdb-array-start num) -1)) | |
1139 (if (or (< (aref indices num) (aref gdb-array-start num)) | |
1140 (> (aref indices num) (aref gdb-array-stop num))) | |
1141 (setq flag nil)) | |
1142 (aset gdb-array-size num (aref indices num))) | |
1143 (setq num (+ num 1))) | |
1144 (if flag | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1145 (let ((gdb-display-value (match-string 1 (car gdb-value-list)))) |
48292 | 1146 (setq gdb-display-string (concat gdb-display-string " " |
1147 gdb-display-value)) | |
1148 (insert | |
1149 (concat indices-string "\t" gdb-display-value "\n")))) | |
1150 (setq indices-string "") | |
1151 (setq flag t) | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1152 ; 0<= index < depth, start at right : (- depth 1) |
48292 | 1153 (setq index (- (- depth 1) |
1154 (- (match-end 2) (match-beginning 2)))) | |
1155 ;don't set for very last brackets | |
1156 (if (>= index 0) | |
1157 (progn | |
1158 (aset indices index (+ 1 (aref indices index))) | |
1159 (setq num (+ 1 index)) | |
1160 (while (< num depth) | |
1161 (aset indices num 0) | |
1162 (setq num (+ num 1))))) | |
1163 (setq gdb-value-list (cdr gdb-value-list))) | |
1164 (setq num 0) | |
1165 (while (< num depth) | |
1166 (if (= (aref gdb-array-start num) -1) | |
1167 (progn | |
1168 (aset gdb-array-start num 0) | |
1169 (aset gdb-array-stop num (aref indices num)))) | |
1170 (setq array-start (int-to-string (aref gdb-array-start num))) | |
1171 (setq array-stop (int-to-string (aref gdb-array-stop num))) | |
1172 (setq array-range (concat "[" array-start | |
1173 ":" array-stop "]")) | |
1174 (put-text-property 1 (+ (length array-start) | |
1175 (length array-stop) 2) | |
1176 'mouse-face 'highlight array-range) | |
1177 (put-text-property 1 (+ (length array-start) | |
1178 (length array-stop) 2) | |
1179 'local-map gdb-array-slice-map array-range) | |
1180 (goto-char (point-min)) | |
1181 (setq array-slice (concat array-slice array-range)) | |
1182 (setq num (+ num 1))) | |
1183 (goto-char (point-min)) | |
1184 (insert "Array Size : ") | |
1185 (setq num 0) | |
1186 (while (< num depth) | |
1187 (insert | |
1188 (concat "[" | |
1189 (int-to-string (+ (aref gdb-array-size num) 1)) "]")) | |
1190 (setq num (+ num 1))) | |
1191 (insert | |
1192 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n")))) | |
1193 (setq buffer-read-only t)) | |
1194 | |
1195 ;; Handle a burst of output from a gdb instance. | |
1196 ;; This function is (indirectly) used as a gud-marker-filter. | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1197 ;; It must return output (if any) to be inserted in the gdb |
48292 | 1198 ;; buffer. |
1199 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1200 (defun gdb-output-burst (string) |
48292 | 1201 "Handle a burst of output from a gdb instance. |
1202 This function is (indirectly) used as a gud-marker-filter. | |
1203 It must return output (if any) to be insterted in the gdb | |
1204 buffer." | |
1205 (save-match-data | |
1206 (let ( | |
1207 ;; Recall the left over burst from last time | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1208 (burst (concat (gdb-instance-burst) string)) |
48292 | 1209 ;; Start accumulating output for the GUD buffer |
1210 (output "")) | |
1211 | |
1212 ;; Process all the complete markers in this chunk. | |
1213 (while (string-match "\n\032\032\\(.*\\)\n" burst) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1214 (let ((annotation (match-string 1 burst))) |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1215 |
48292 | 1216 ;; Stuff prior to the match is just ordinary output. |
1217 ;; It is either concatenated to OUTPUT or directed | |
1218 ;; elsewhere. | |
1219 (setq output | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1220 (gdb-concat-output |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1221 output |
48292 | 1222 (substring burst 0 (match-beginning 0)))) |
1223 | |
1224 ;; Take that stuff off the burst. | |
1225 (setq burst (substring burst (match-end 0))) | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1226 |
48292 | 1227 ;; Parse the tag from the annotation, and maybe its arguments. |
1228 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1229 (let* ((annotation-type (match-string 1 annotation)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1230 (annotation-arguments (match-string 2 annotation)) |
48292 | 1231 (annotation-rule (assoc annotation-type |
1232 gdb-annotation-rules))) | |
1233 ;; Call the handler for this annotation. | |
1234 (if annotation-rule | |
1235 (funcall (car (cdr annotation-rule)) | |
1236 annotation-arguments) | |
1237 ;; Else the annotation is not recognized. Ignore it silently, | |
1238 ;; so that GDB can add new annotations without causing | |
1239 ;; us to blow up. | |
1240 )))) | |
1241 | |
1242 ;; Does the remaining text end in a partial line? | |
1243 ;; If it does, then keep part of the burst until we get more. | |
1244 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" | |
1245 burst) | |
1246 (progn | |
1247 ;; Everything before the potential marker start can be output. | |
1248 (setq output | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1249 (gdb-concat-output output |
48292 | 1250 (substring burst 0 (match-beginning 0)))) |
1251 | |
1252 ;; Everything after, we save, to combine with later input. | |
1253 (setq burst (substring burst (match-beginning 0)))) | |
1254 | |
1255 ;; In case we know the burst contains no partial annotations: | |
1256 (progn | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1257 (setq output (gdb-concat-output output burst)) |
48292 | 1258 (setq burst ""))) |
1259 | |
1260 ;; Save the remaining burst for the next call to this function. | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1261 (set-gdb-instance-burst burst) |
48292 | 1262 output))) |
1263 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1264 (defun gdb-concat-output (so-far new) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1265 (let ((sink (gdb-instance-output-sink ))) |
48292 | 1266 (cond |
1267 ((eq sink 'user) (concat so-far new)) | |
1268 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) | |
1269 ((eq sink 'emacs) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1270 (gdb-append-to-partial-output new) |
48292 | 1271 so-far) |
1272 ((eq sink 'inferior) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1273 (gdb-append-to-inferior-io new) |
48292 | 1274 so-far) |
1275 (t (error "Bogon output sink %S" sink))))) | |
1276 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1277 (defun gdb-append-to-partial-output (string) |
48292 | 1278 (save-excursion |
1279 (set-buffer | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1280 (gdb-get-create-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 1281 (goto-char (point-max)) |
1282 (insert string))) | |
1283 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1284 (defun gdb-clear-partial-output () |
48292 | 1285 (save-excursion |
1286 (set-buffer | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1287 (gdb-get-create-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 1288 (delete-region (point-min) (point-max)))) |
1289 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1290 (defun gdb-append-to-inferior-io (string) |
48292 | 1291 (save-excursion |
1292 (set-buffer | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1293 (gdb-get-create-instance-buffer 'gdb-inferior-io)) |
48292 | 1294 (goto-char (point-max)) |
1295 (insert-before-markers string)) | |
1296 (gdb-display-buffer | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1297 (gdb-get-create-instance-buffer 'gdb-inferior-io))) |
48292 | 1298 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1299 (defun gdb-clear-inferior-io () |
48292 | 1300 (save-excursion |
1301 (set-buffer | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1302 (gdb-get-create-instance-buffer 'gdb-inferior-io)) |
48292 | 1303 (delete-region (point-min) (point-max)))) |
1304 | |
1305 | |
1306 ;; One trick is to have a command who's output is always available in | |
1307 ;; a buffer of it's own, and is always up to date. We build several | |
1308 ;; buffers of this type. | |
1309 ;; | |
1310 ;; There are two aspects to this: gdb has to tell us when the output | |
1311 ;; for that command might have changed, and we have to be able to run | |
1312 ;; the command behind the user's back. | |
1313 ;; | |
1314 ;; The idle input queue and the output phasing associated with | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1315 ;; the instance variable `(gdb-instance-output-sink)' help |
48292 | 1316 ;; us to run commands behind the user's back. |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1317 ;; |
48292 | 1318 ;; Below is the code for specificly managing buffers of output from one |
1319 ;; command. | |
1320 ;; | |
1321 | |
1322 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES | |
1323 ;; It adds an idle input for the command we are tracking. It should be the | |
1324 ;; annotation rule binding of whatever gdb sends to tell us this command | |
1325 ;; might have changed it's output. | |
1326 ;; | |
1327 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed. | |
1328 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the | |
1329 ;; input in the input queue (see comment about ``gdb communications'' above). | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1330 |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1331 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1332 output-handler) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1333 `(defun ,name (&optional ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1334 (if (and (,demand-predicate) |
48292 | 1335 (not (member ',name |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1336 (gdb-instance-pending-triggers)))) |
48292 | 1337 (progn |
1338 (gdb-instance-enqueue-idle-input | |
1339 (list ,gdb-command ',output-handler)) | |
1340 (set-gdb-instance-pending-triggers | |
1341 (cons ',name | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1342 (gdb-instance-pending-triggers))))))) |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1343 |
48292 | 1344 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) |
1345 `(defun ,name () | |
1346 (set-gdb-instance-pending-triggers | |
1347 (delq ',trigger | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1348 (gdb-instance-pending-triggers))) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1349 (let ((buf (gdb-get-instance-buffer ',buf-key))) |
48292 | 1350 (and buf |
1351 (save-excursion | |
1352 (set-buffer buf) | |
1353 (let ((p (point)) | |
1354 (buffer-read-only nil)) | |
1355 (delete-region (point-min) (point-max)) | |
1356 (insert-buffer (gdb-get-create-instance-buffer | |
1357 'gdb-partial-output-buffer)) | |
1358 (goto-char p))))) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1359 ;; put customisation here |
48292 | 1360 (,custom-defun))) |
1361 | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1362 (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1363 output-handler-name custom-defun) |
48292 | 1364 `(progn |
1365 (def-gdb-auto-update-trigger ,trigger-name | |
1366 ;; The demand predicate: | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1367 (lambda () (gdb-get-instance-buffer ',buffer-key)) |
48292 | 1368 ,gdb-command |
1369 ,output-handler-name) | |
1370 (def-gdb-auto-update-handler ,output-handler-name | |
1371 ,trigger-name ,buffer-key ,custom-defun))) | |
1372 | |
1373 | |
1374 ;; | |
1375 ;; Breakpoint buffers | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1376 ;; |
48292 | 1377 ;; These display the output of `info breakpoints'. |
1378 ;; | |
1379 | |
1380 (gdb-set-instance-buffer-rules 'gdb-breakpoints-buffer | |
1381 'gdb-breakpoints-buffer-name | |
1382 'gdb-breakpoints-mode) | |
1383 | |
1384 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer | |
1385 ;; This defines the auto update rule for buffers of type | |
1386 ;; `gdb-breakpoints-buffer'. | |
1387 ;; | |
1388 ;; It defines a function to serve as the annotation handler that | |
1389 ;; handles the `foo-invalidated' message. That function is called: | |
1390 gdb-invalidate-breakpoints | |
1391 | |
1392 ;; To update the buffer, this command is sent to gdb. | |
1393 "server info breakpoints\n" | |
1394 | |
1395 ;; This also defines a function to be the handler for the output | |
1396 ;; from the command above. That function will copy the output into | |
1397 ;; the appropriately typed buffer. That function will be called: | |
1398 gdb-info-breakpoints-handler | |
1399 ;; buffer specific functions | |
1400 gdb-info-breakpoints-custom) | |
1401 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1402 (defvar gdb-cdir nil "Compilation directory.") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1403 (defvar breakpoint-enabled-icon |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1404 "Icon for enabled breakpoint in display margin") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1405 (defvar breakpoint-disabled-icon |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1406 "Icon for disabled breakpoint in display margin") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1407 |
48292 | 1408 ;-put breakpoint icons in relevant margins (even those set in the GUD buffer) |
1409 (defun gdb-info-breakpoints-custom () | |
1410 (let ((flag)(address)) | |
1411 | |
1412 ; remove all breakpoint-icons in source buffers but not assembler buffer | |
1413 (let ((buffers (buffer-list))) | |
1414 (save-excursion | |
1415 (while buffers | |
1416 (set-buffer (car buffers)) | |
1417 (if (and (eq gud-minor-mode 'gdba) | |
1418 (not (string-match "^\*" (buffer-name)))) | |
1419 (if (display-graphic-p) | |
1420 (remove-images (point-min) (point-max)) | |
1421 (remove-strings (point-min) (point-max)))) | |
1422 (setq buffers (cdr buffers))))) | |
1423 | |
1424 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1425 (set-buffer (gdb-get-instance-buffer 'gdb-breakpoints-buffer)) |
48292 | 1426 (save-excursion |
1427 (goto-char (point-min)) | |
1428 (while (< (point) (- (point-max) 1)) | |
1429 (forward-line 1) | |
1430 (if (looking-at "[^\t].*breakpoint") | |
1431 (progn | |
1432 (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)") | |
1433 (setq flag (char-after (match-beginning 2))) | |
1434 (beginning-of-line) | |
1435 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+") | |
1436 (looking-at "\\(\\S-*\\):\\([0-9]+\\)") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1437 (let ((line (match-string 2)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1438 (file (match-string 1))) |
48292 | 1439 (save-excursion |
1440 (set-buffer | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1441 (find-file-noselect (if (file-exists-p file) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1442 file |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1443 (expand-file-name file gdb-cdir)))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1444 (save-current-buffer |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1445 (set (make-local-variable 'gud-minor-mode) 'gdba) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1446 (set (make-local-variable 'tool-bar-map) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1447 gud-tool-bar-map) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1448 (setq left-margin-width 2) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1449 (if (get-buffer-window (current-buffer)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1450 (set-window-margins (get-buffer-window |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1451 (current-buffer)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1452 left-margin-width |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1453 right-margin-width))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1454 ;; only want one breakpoint icon at each location |
48292 | 1455 (save-excursion |
1456 (goto-line (string-to-number line)) | |
1457 (let ((start (progn (beginning-of-line) (- (point) 1))) | |
1458 (end (progn (end-of-line) (+ (point) 1)))) | |
1459 (if (display-graphic-p) | |
1460 (progn | |
1461 (remove-images start end) | |
1462 (if (eq ?y flag) | |
1463 (put-image breakpoint-enabled-icon (point) | |
1464 "breakpoint icon enabled" | |
1465 'left-margin) | |
1466 (put-image breakpoint-disabled-icon (point) | |
1467 "breakpoint icon disabled" | |
1468 'left-margin))) | |
1469 (remove-strings start end) | |
1470 (if (eq ?y flag) | |
1471 (put-string "B" (point) "enabled" | |
1472 'left-margin) | |
1473 (put-string "b" (point) "disabled" | |
1474 'left-margin))))))))) | |
1475 (end-of-line)))))) | |
1476 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1477 (defun gdb-breakpoints-buffer-name () |
48292 | 1478 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1479 (set-buffer (process-buffer gdb-proc)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1480 (concat "*breakpoints of " (gdb-instance-target-string) "*"))) |
48292 | 1481 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1482 (defun gdb-display-breakpoints-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1483 (interactive (list gdb-proc)) |
48292 | 1484 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1485 (gdb-get-create-instance-buffer 'gdb-breakpoints-buffer))) |
48292 | 1486 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1487 (defun gdb-frame-breakpoints-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1488 (interactive (list gdb-proc)) |
48292 | 1489 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1490 (gdb-get-create-instance-buffer 'gdb-breakpoints-buffer))) |
48292 | 1491 |
1492 (defvar gdb-breakpoints-mode-map nil) | |
1493 (setq gdb-breakpoints-mode-map (make-keymap)) | |
1494 (suppress-keymap gdb-breakpoints-mode-map) | |
1495 | |
1496 (define-key gdb-breakpoints-mode-map [menu-bar breakpoints] | |
1497 (cons "Breakpoints" (make-sparse-keymap "Breakpoints"))) | |
1498 (define-key gdb-breakpoints-mode-map [menu-bar breakpoints toggle] | |
1499 '("Toggle" . gdb-toggle-bp-this-line)) | |
1500 (define-key gdb-breakpoints-mode-map [menu-bar breakpoints delete] | |
1501 '("Delete" . gdb-delete-bp-this-line)) | |
1502 (define-key gdb-breakpoints-mode-map [menu-bar breakpoints goto] | |
1503 '("Goto" . gdb-goto-bp-this-line)) | |
1504 | |
1505 (define-key gdb-breakpoints-mode-map " " 'gdb-toggle-bp-this-line) | |
1506 (define-key gdb-breakpoints-mode-map "d" 'gdb-delete-bp-this-line) | |
1507 (define-key gdb-breakpoints-mode-map "g" 'gdb-goto-bp-this-line) | |
1508 | |
1509 (defun gdb-breakpoints-mode () | |
1510 "Major mode for gdb breakpoints. | |
1511 | |
1512 \\{gdb-breakpoints-mode-map}" | |
1513 (setq major-mode 'gdb-breakpoints-mode) | |
1514 (setq mode-name "Breakpoints") | |
1515 (use-local-map gdb-breakpoints-mode-map) | |
1516 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1517 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
1518 (setq buffer-read-only t) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1519 (gdb-invalidate-breakpoints)) |
48292 | 1520 |
1521 (defun gdb-toggle-bp-this-line () | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1522 "Enable/disable the breakpoint on this line." |
48292 | 1523 (interactive) |
1524 (save-excursion | |
1525 (beginning-of-line 1) | |
1526 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | |
1527 (error "Not recognized as break/watchpoint line") | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1528 (gdb-instance-enqueue-idle-input |
48292 | 1529 (list |
1530 (concat | |
1531 (if (eq ?y (char-after (match-beginning 2))) | |
1532 "server disable " | |
1533 "server enable ") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1534 (match-string 1) |
48292 | 1535 "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1536 'ignore))))) |
48292 | 1537 |
1538 (defun gdb-delete-bp-this-line () | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1539 "Delete the breakpoint on this line." |
48292 | 1540 (interactive) |
1541 (beginning-of-line 1) | |
1542 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | |
1543 (error "Not recognized as break/watchpoint line") | |
1544 (gdb-instance-enqueue-idle-input | |
1545 (list | |
1546 (concat | |
1547 "server delete " | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1548 (match-string 1) |
48292 | 1549 "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1550 'ignore)))) |
48292 | 1551 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1552 (defvar gdb-source-window nil) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1553 |
48292 | 1554 (defun gdb-goto-bp-this-line () |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1555 "Display the file at the specified breakpoint." |
48292 | 1556 (interactive) |
1557 (save-excursion | |
1558 (beginning-of-line 1) | |
1559 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+") | |
1560 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1561 (let ((line (match-string 2)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1562 (file (match-string 1))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1563 (set-window-buffer gdb-source-window |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1564 (find-file-noselect |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1565 (if (file-exists-p file) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1566 file |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1567 (expand-file-name file gdb-cdir)))) |
48292 | 1568 (goto-line (string-to-number line)))) |
1569 | |
1570 ;; | |
1571 ;; Frames buffers. These display a perpetually correct bactracktrace | |
1572 ;; (from the command `where'). | |
1573 ;; | |
1574 ;; Alas, if your stack is deep, they are costly. | |
1575 ;; | |
1576 | |
1577 (gdb-set-instance-buffer-rules 'gdb-stack-buffer | |
1578 'gdb-stack-buffer-name | |
1579 'gdb-frames-mode) | |
1580 | |
1581 (def-gdb-auto-updated-buffer gdb-stack-buffer | |
1582 gdb-invalidate-frames | |
1583 "server where\n" | |
1584 gdb-info-frames-handler | |
1585 gdb-info-frames-custom) | |
1586 | |
1587 (defun gdb-info-frames-custom () | |
1588 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1589 (set-buffer (gdb-get-instance-buffer 'gdb-stack-buffer)) |
48292 | 1590 (let ((buffer-read-only nil)) |
1591 (goto-char (point-min)) | |
1592 (looking-at "\\S-*\\s-*\\(\\S-*\\)") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1593 (setq gdb-current-frame (match-string 1)) |
48292 | 1594 (while (< (point) (point-max)) |
1595 (put-text-property (progn (beginning-of-line) (point)) | |
1596 (progn (end-of-line) (point)) | |
1597 'mouse-face 'highlight) | |
1598 (forward-line 1))))) | |
1599 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1600 (defun gdb-stack-buffer-name () |
48292 | 1601 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1602 (set-buffer (process-buffer gdb-proc)) |
48292 | 1603 (concat "*stack frames of " |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1604 (gdb-instance-target-string) "*"))) |
48292 | 1605 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1606 (defun gdb-display-stack-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1607 (interactive (list gdb-proc)) |
48292 | 1608 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1609 (gdb-get-create-instance-buffer 'gdb-stack-buffer))) |
48292 | 1610 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1611 (defun gdb-frame-stack-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1612 (interactive (list gdb-proc)) |
48292 | 1613 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1614 (gdb-get-create-instance-buffer 'gdb-stack-buffer))) |
48292 | 1615 |
1616 (defvar gdb-frames-mode-map nil) | |
1617 (setq gdb-frames-mode-map (make-keymap)) | |
1618 (suppress-keymap gdb-frames-mode-map) | |
1619 (define-key gdb-frames-mode-map [mouse-2] | |
1620 'gdb-frames-select-by-mouse) | |
1621 | |
1622 (defun gdb-frames-mode () | |
1623 "Major mode for gdb frames. | |
1624 | |
1625 \\{gdb-frames-mode-map}" | |
1626 (setq major-mode 'gdb-frames-mode) | |
1627 (setq mode-name "Frames") | |
1628 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1629 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
1630 (setq buffer-read-only t) | |
1631 (use-local-map gdb-frames-mode-map) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1632 (gdb-invalidate-frames)) |
48292 | 1633 |
1634 (defun gdb-get-frame-number () | |
1635 (save-excursion | |
1636 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t)) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1637 (n (or (and pos (string-to-int (match-string 1))) 0))) |
48292 | 1638 n))) |
1639 | |
1640 (defun gdb-frames-select-by-mouse (e) | |
1641 "Display the source of the selected frame." | |
1642 (interactive "e") | |
1643 (let (selection) | |
1644 (save-excursion | |
1645 (set-buffer (window-buffer (posn-window (event-end e)))) | |
1646 (save-excursion | |
1647 (goto-char (posn-point (event-end e))) | |
1648 (setq selection (gdb-get-frame-number)))) | |
1649 (select-window (posn-window (event-end e))) | |
1650 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1651 (set-buffer (gdb-get-instance-buffer 'gdba)) |
48292 | 1652 (gdb-instance-enqueue-idle-input |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1653 (list (gud-format-command "server frame %p\n" selection) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1654 'ignore)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1655 (gud-display-frame)))) |
48292 | 1656 |
1657 | |
1658 ;; | |
1659 ;; Registers buffers | |
1660 ;; | |
1661 | |
1662 (def-gdb-auto-updated-buffer gdb-registers-buffer | |
1663 gdb-invalidate-registers | |
1664 "server info registers\n" | |
1665 gdb-info-registers-handler | |
1666 gdb-info-registers-custom) | |
1667 | |
1668 (defun gdb-info-registers-custom ()) | |
1669 | |
1670 (gdb-set-instance-buffer-rules 'gdb-registers-buffer | |
1671 'gdb-registers-buffer-name | |
1672 'gdb-registers-mode) | |
1673 | |
1674 (defvar gdb-registers-mode-map nil) | |
1675 (setq gdb-registers-mode-map (make-keymap)) | |
1676 (suppress-keymap gdb-registers-mode-map) | |
1677 | |
1678 (defun gdb-registers-mode () | |
1679 "Major mode for gdb registers. | |
1680 | |
1681 \\{gdb-registers-mode-map}" | |
1682 (setq major-mode 'gdb-registers-mode) | |
1683 (setq mode-name "Registers") | |
1684 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1685 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
1686 (setq buffer-read-only t) | |
1687 (use-local-map gdb-registers-mode-map) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1688 (gdb-invalidate-registers)) |
48292 | 1689 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1690 (defun gdb-registers-buffer-name () |
48292 | 1691 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1692 (set-buffer (process-buffer gdb-proc)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1693 (concat "*registers of " (gdb-instance-target-string) "*"))) |
48292 | 1694 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1695 (defun gdb-display-registers-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1696 (interactive (list gdb-proc)) |
48292 | 1697 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1698 (gdb-get-create-instance-buffer 'gdb-registers-buffer))) |
48292 | 1699 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1700 (defun gdb-frame-registers-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1701 (interactive (list gdb-proc)) |
48292 | 1702 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1703 (gdb-get-create-instance-buffer 'gdb-registers-buffer))) |
48292 | 1704 |
1705 ;; | |
1706 ;; Locals buffers | |
1707 ;; | |
1708 | |
1709 (def-gdb-auto-updated-buffer gdb-locals-buffer | |
1710 gdb-invalidate-locals | |
1711 "server info locals\n" | |
1712 gdb-info-locals-handler | |
1713 gdb-info-locals-custom) | |
1714 | |
1715 | |
1716 ;Abbreviate for arrays and structures. These can be expanded using gud-display | |
1717 (defun gdb-info-locals-handler nil | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1718 (set-gdb-instance-pending-triggers (delq 'gdb-invalidate-locals |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1719 (gdb-instance-pending-triggers))) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1720 (let ((buf (gdb-get-instance-buffer 'gdb-partial-output-buffer))) |
48292 | 1721 (save-excursion |
1722 (set-buffer buf) | |
1723 (goto-char (point-min)) | |
1724 (replace-regexp "^ .*\n" "") | |
1725 (goto-char (point-min)) | |
1726 (replace-regexp "{[-0-9, {}\]*\n" "(array);\n"))) | |
1727 (goto-char (point-min)) | |
1728 (replace-regexp "{.*=.*\n" "(structure);\n") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1729 (let ((buf (gdb-get-instance-buffer 'gdb-locals-buffer))) |
48292 | 1730 (and buf (save-excursion |
1731 (set-buffer buf) | |
1732 (let ((p (point)) | |
1733 (buffer-read-only nil)) | |
1734 (delete-region (point-min) (point-max)) | |
1735 (insert-buffer (gdb-get-create-instance-buffer | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1736 'gdb-partial-output-buffer)) |
48292 | 1737 (goto-char p))))) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1738 (run-hooks 'gdb-info-locals-hook)) |
48292 | 1739 |
1740 (defun gdb-info-locals-custom () | |
1741 nil) | |
1742 | |
1743 (gdb-set-instance-buffer-rules 'gdb-locals-buffer | |
1744 'gdb-locals-buffer-name | |
1745 'gdb-locals-mode) | |
1746 | |
1747 (defvar gdb-locals-mode-map nil) | |
1748 (setq gdb-locals-mode-map (make-keymap)) | |
1749 (suppress-keymap gdb-locals-mode-map) | |
1750 | |
1751 (defun gdb-locals-mode () | |
1752 "Major mode for gdb locals. | |
1753 | |
1754 \\{gdb-locals-mode-map}" | |
1755 (setq major-mode 'gdb-locals-mode) | |
1756 (setq mode-name "Locals") | |
1757 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1758 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
1759 (setq buffer-read-only t) | |
1760 (use-local-map gdb-locals-mode-map) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1761 (gdb-invalidate-locals)) |
48292 | 1762 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1763 (defun gdb-locals-buffer-name () |
48292 | 1764 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1765 (set-buffer (process-buffer gdb-proc)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1766 (concat "*locals of " (gdb-instance-target-string) "*"))) |
48292 | 1767 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1768 (defun gdb-display-locals-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1769 (interactive (list gdb-proc)) |
48292 | 1770 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1771 (gdb-get-create-instance-buffer 'gdb-locals-buffer))) |
48292 | 1772 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1773 (defun gdb-frame-locals-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1774 (interactive (list gdb-proc)) |
48292 | 1775 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1776 (gdb-get-create-instance-buffer 'gdb-locals-buffer))) |
48292 | 1777 ;; |
1778 ;; Display expression buffers (just allow one to start with) | |
1779 ;; | |
1780 (gdb-set-instance-buffer-rules 'gdb-display-buffer | |
1781 'gdb-display-buffer-name | |
1782 'gdb-display-mode) | |
1783 | |
1784 (def-gdb-auto-updated-buffer gdb-display-buffer | |
1785 ;; `gdb-display-buffer'. | |
1786 gdb-invalidate-display | |
1787 "server info display\n" | |
1788 gdb-info-display-handler | |
1789 gdb-info-display-custom) | |
1790 | |
1791 (defun gdb-info-display-custom () | |
1792 ; TODO: ensure frames of expressions that have been deleted are also deleted | |
1793 ; these can be missed currently eg through GUD buffer, restarting a | |
1794 ; recompiled program. | |
1795 ) | |
1796 | |
1797 (defvar gdb-display-mode-map nil) | |
1798 (setq gdb-display-mode-map (make-keymap)) | |
1799 (suppress-keymap gdb-display-mode-map) | |
1800 | |
1801 (define-key gdb-display-mode-map [menu-bar display] | |
1802 (cons "Display" (make-sparse-keymap "Display"))) | |
1803 (define-key gdb-display-mode-map [menu-bar display toggle] | |
1804 '("Toggle" . gdb-toggle-disp-this-line)) | |
1805 (define-key gdb-display-mode-map [menu-bar display delete] | |
1806 '("Delete" . gdb-delete-disp-this-line)) | |
1807 | |
1808 (define-key gdb-display-mode-map " " 'gdb-toggle-disp-this-line) | |
1809 (define-key gdb-display-mode-map "d" 'gdb-delete-disp-this-line) | |
1810 | |
1811 (defun gdb-display-mode () | |
1812 "Major mode for gdb display. | |
1813 | |
1814 \\{gdb-display-mode-map}" | |
1815 (setq major-mode 'gdb-display-mode) | |
1816 (setq mode-name "Display") | |
1817 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1818 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
1819 (setq buffer-read-only t) | |
1820 (use-local-map gdb-display-mode-map) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1821 (gdb-invalidate-display)) |
48292 | 1822 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1823 (defun gdb-display-buffer-name () |
48292 | 1824 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1825 (set-buffer (process-buffer gdb-proc)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1826 (concat "*Displayed expressions of " (gdb-instance-target-string) "*"))) |
48292 | 1827 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1828 (defun gdb-display-display-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1829 (interactive (list gdb-proc)) |
48292 | 1830 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1831 (gdb-get-create-instance-buffer 'gdb-display-buffer))) |
48292 | 1832 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1833 (defun gdb-frame-display-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1834 (interactive (list gdb-proc)) |
48292 | 1835 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1836 (gdb-get-create-instance-buffer 'gdb-display-buffer))) |
48292 | 1837 |
1838 (defun gdb-toggle-disp-this-line () | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1839 "Enable/disable the displayed expression on this line." |
48292 | 1840 (interactive) |
1841 (save-excursion | |
1842 (beginning-of-line 1) | |
1843 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) | |
1844 (error "No expression on this line") | |
1845 (gdb-instance-enqueue-idle-input | |
1846 (list | |
1847 (concat | |
1848 (if (eq ?y (char-after (match-beginning 2))) | |
1849 "server disable display " | |
1850 "server enable display ") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1851 (match-string 1) |
48292 | 1852 "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1853 'ignore))))) |
48292 | 1854 |
1855 (defun gdb-delete-disp-this-line () | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1856 "Delete the displayed expression on this line." |
48292 | 1857 (interactive) |
1858 (save-excursion | |
1859 (set-buffer | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1860 (gdb-get-instance-buffer 'gdb-display-buffer)) |
48292 | 1861 (beginning-of-line 1) |
1862 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) | |
1863 (error "No expression on this line") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1864 (let ((number (match-string 1))) |
48292 | 1865 (gdb-instance-enqueue-idle-input |
1866 (list (concat "server delete display " number "\n") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1867 'ignore)) |
48292 | 1868 (if (not (display-graphic-p)) |
1869 (kill-buffer (get-buffer (concat "*display " number "*"))) | |
1870 ;else | |
1871 (catch 'frame-found | |
1872 (let ((frames (frame-list))) | |
1873 (while frames | |
1874 (if (string-equal (frame-parameter (car frames) 'name) | |
1875 (concat "*display " number "*")) | |
1876 (progn (kill-buffer | |
1877 (get-buffer (concat "*display " number "*"))) | |
1878 (delete-frame (car frames)) | |
1879 (throw 'frame-found nil))) | |
1880 (setq frames (cdr frames)))))))))) | |
1881 | |
1882 (defvar gdb-expressions-mode-map nil) | |
1883 (setq gdb-expressions-mode-map (make-keymap)) | |
1884 (suppress-keymap gdb-expressions-mode-map) | |
1885 | |
1886 (defvar gdb-expressions-mode-menu | |
1887 '("GDB Expressions Commands" | |
1888 "----" | |
1889 ["Visualise" gdb-array-visualise t] | |
1890 ["Delete" gdb-delete-display t]) | |
1891 "Menu for `gdb-expressions-mode'.") | |
1892 | |
1893 (define-key gdb-expressions-mode-map "v" 'gdb-array-visualise) | |
1894 (define-key gdb-expressions-mode-map "q" 'gdb-delete-display) | |
1895 (define-key gdb-expressions-mode-map [mouse-3] 'gdb-expressions-popup-menu) | |
1896 | |
1897 (defun gdb-expressions-popup-menu (event) | |
1898 "Explicit Popup menu as this buffer doesn't have a menubar." | |
1899 (interactive "@e") | |
1900 (mouse-set-point event) | |
1901 (popup-menu gdb-expressions-mode-menu)) | |
1902 | |
1903 (defun gdb-expressions-mode () | |
1904 "Major mode for display expressions. | |
1905 | |
1906 \\{gdb-expressions-mode-map}" | |
1907 (setq major-mode 'gdb-expressions-mode) | |
1908 (setq mode-name "Expressions") | |
1909 (use-local-map gdb-expressions-mode-map) | |
1910 (make-local-variable 'gdb-display-number) | |
1911 (make-local-variable 'gdb-values) | |
1912 (make-local-variable 'gdb-expression) | |
1913 (set (make-local-variable 'gdb-display-string) nil) | |
1914 (set (make-local-variable 'gdb-dive-display-number) nil) | |
1915 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1916 (set (make-local-variable 'gdb-array-start) (make-vector 16 '-1)) | |
1917 (set (make-local-variable 'gdb-array-stop) (make-vector 16 '-1)) | |
1918 (set (make-local-variable 'gdb-array-size) (make-vector 16 '-1)) | |
1919 (setq buffer-read-only t)) | |
1920 | |
1921 | |
1922 ;;;; Window management | |
1923 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1924 ;;; FIXME: This should only return true for buffers in the current gdb-proc |
48292 | 1925 (defun gdb-protected-buffer-p (buffer) |
1926 "Is BUFFER a buffer which we want to leave displayed?" | |
1927 (save-excursion | |
1928 (set-buffer buffer) | |
1929 (or gdb-buffer-type | |
1930 overlay-arrow-position))) | |
1931 | |
1932 ;;; The way we abuse the dedicated-p flag is pretty gross, but seems | |
1933 ;;; to do the right thing. Seeing as there is no way for Lisp code to | |
1934 ;;; get at the use_time field of a window, I'm not sure there exists a | |
1935 ;;; more elegant solution without writing C code. | |
1936 | |
1937 (defun gdb-display-buffer (buf &optional size) | |
1938 (let ((must-split nil) | |
1939 (answer nil)) | |
1940 (unwind-protect | |
1941 (progn | |
1942 (walk-windows | |
1943 '(lambda (win) | |
1944 (if (gdb-protected-buffer-p (window-buffer win)) | |
1945 (set-window-dedicated-p win t)))) | |
1946 (setq answer (get-buffer-window buf)) | |
1947 (if (not answer) | |
1948 (let ((window (get-lru-window))) | |
1949 (if window | |
1950 (progn | |
1951 (set-window-buffer window buf) | |
1952 (setq answer window)) | |
1953 (setq must-split t))))) | |
1954 (walk-windows | |
1955 '(lambda (win) | |
1956 (if (gdb-protected-buffer-p (window-buffer win)) | |
1957 (set-window-dedicated-p win nil))))) | |
1958 (if must-split | |
1959 (let* ((largest (get-largest-window)) | |
1960 (cur-size (window-height largest)) | |
1961 (new-size (and size (< size cur-size) (- cur-size size)))) | |
1962 (setq answer (split-window largest new-size)) | |
1963 (set-window-buffer answer buf))) | |
1964 answer)) | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1965 |
48292 | 1966 (defun gdb-display-source-buffer (buffer) |
1967 (set-window-buffer gdb-source-window buffer)) | |
1968 | |
1969 | |
1970 ;;; Shared keymap initialization: | |
1971 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1972 (defun gdb-display-gdb-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1973 (interactive (list gdb-proc)) |
48292 | 1974 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1975 (gdb-get-create-instance-buffer 'gdba))) |
48292 | 1976 |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1977 (defun gdb-make-windows-menu (map) |
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1978 ;; FIXME: This adds to the DBX, PerlDB, ... menu as well :-( |
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1979 ;; Probably we should create gdb-many-windows-map and put those menus |
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1980 ;; on that map. |
48292 | 1981 (define-key map [menu-bar displays] |
1982 (cons "GDB-Windows" (make-sparse-keymap "GDB-Windows"))) | |
1983 (define-key map [menu-bar displays gdb] | |
1984 '("Gdb" . gdb-display-gdb-buffer)) | |
1985 (define-key map [menu-bar displays locals] | |
1986 '("Locals" . gdb-display-locals-buffer)) | |
1987 (define-key map [menu-bar displays registers] | |
1988 '("Registers" . gdb-display-registers-buffer)) | |
1989 (define-key map [menu-bar displays frames] | |
1990 '("Stack" . gdb-display-stack-buffer)) | |
1991 (define-key map [menu-bar displays breakpoints] | |
1992 '("Breakpoints" . gdb-display-breakpoints-buffer)) | |
1993 (define-key map [menu-bar displays display] | |
1994 '("Display" . gdb-display-display-buffer)) | |
1995 (define-key map [menu-bar displays assembler] | |
1996 '("Assembler" . gdb-display-assembler-buffer))) | |
1997 | |
1998 (define-key gud-minor-mode-map "\C-c\M-\C-r" 'gdb-display-registers-buffer) | |
1999 (define-key gud-minor-mode-map "\C-c\M-\C-f" 'gdb-display-stack-buffer) | |
2000 (define-key gud-minor-mode-map "\C-c\M-\C-b" 'gdb-display-breakpoints-buffer) | |
2001 | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2002 (gdb-make-windows-menu gud-minor-mode-map) |
48292 | 2003 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2004 (defun gdb-frame-gdb-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2005 (interactive (list gdb-proc)) |
48292 | 2006 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2007 (gdb-get-create-instance-buffer 'gdba))) |
48292 | 2008 |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2009 (defun gdb-make-frames-menu (map) |
48292 | 2010 (define-key map [menu-bar frames] |
2011 (cons "GDB-Frames" (make-sparse-keymap "GDB-Frames"))) | |
2012 (define-key map [menu-bar frames gdb] | |
2013 '("Gdb" . gdb-frame-gdb-buffer)) | |
2014 (define-key map [menu-bar frames locals] | |
2015 '("Locals" . gdb-frame-locals-buffer)) | |
2016 (define-key map [menu-bar frames registers] | |
2017 '("Registers" . gdb-frame-registers-buffer)) | |
2018 (define-key map [menu-bar frames frames] | |
2019 '("Stack" . gdb-frame-stack-buffer)) | |
2020 (define-key map [menu-bar frames breakpoints] | |
2021 '("Breakpoints" . gdb-frame-breakpoints-buffer)) | |
2022 (define-key map [menu-bar frames display] | |
2023 '("Display" . gdb-frame-display-buffer)) | |
2024 (define-key map [menu-bar frames assembler] | |
2025 '("Assembler" . gdb-frame-assembler-buffer))) | |
2026 | |
2027 (if (display-graphic-p) | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2028 (gdb-make-frames-menu gud-minor-mode-map)) |
48292 | 2029 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2030 (defvar gdb-main-file nil "Source file from which program execution begins.") |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2031 |
48292 | 2032 ;; layout for all the windows |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2033 (defun gdb-setup-windows () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2034 (gdb-display-locals-buffer) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2035 (gdb-display-stack-buffer) |
48292 | 2036 (delete-other-windows) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2037 (gdb-display-breakpoints-buffer) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2038 (gdb-display-display-buffer) |
48292 | 2039 (delete-other-windows) |
2040 (split-window nil ( / ( * (window-height) 3) 4)) | |
2041 (split-window nil ( / (window-height) 3)) | |
2042 (split-window-horizontally) | |
2043 (other-window 1) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2044 (switch-to-buffer (gdb-locals-buffer-name)) |
48292 | 2045 (other-window 1) |
2046 (switch-to-buffer | |
2047 (if gud-last-last-frame | |
2048 (gud-find-file (car gud-last-last-frame)) | |
2049 (gud-find-file gdb-main-file))) | |
2050 (setq gdb-source-window (get-buffer-window (current-buffer))) | |
2051 (split-window-horizontally) | |
2052 (other-window 1) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2053 (switch-to-buffer (gdb-inferior-io-name)) |
48292 | 2054 (other-window 1) |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2055 (switch-to-buffer (gdb-stack-buffer-name)) |
48292 | 2056 (split-window-horizontally) |
2057 (other-window 1) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2058 (switch-to-buffer (gdb-breakpoints-buffer-name)) |
48292 | 2059 (other-window 1)) |
2060 | |
48600
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
2061 (define-minor-mode gdb-many-windows |
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
2062 "Toggle the number of windows in the basic arrangement." |
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
2063 :group 'gud |
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
2064 :init-value t |
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
2065 (gdb-restore-windows)) |
88be03de9df4
(gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents:
48570
diff
changeset
|
2066 |
48292 | 2067 (defun gdb-restore-windows () |
2068 "Restore the basic arrangement of windows used by gdba. | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2069 This arrangement depends on the value of `gdb-many-windows'." |
48292 | 2070 (interactive) |
2071 (if gdb-many-windows | |
2072 (progn | |
2073 (switch-to-buffer gud-comint-buffer) | |
2074 (delete-other-windows) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2075 (gdb-setup-windows)) |
48292 | 2076 ;else |
2077 (switch-to-buffer gud-comint-buffer) | |
2078 (delete-other-windows) | |
2079 (split-window) | |
2080 (other-window 1) | |
2081 (switch-to-buffer | |
2082 (if gud-last-last-frame | |
2083 (gud-find-file (car gud-last-last-frame)) | |
2084 (gud-find-file gdb-main-file))) | |
2085 (other-window 1))) | |
2086 | |
2087 (defconst breakpoint-xpm-data "/* XPM */ | |
2088 static char *magick[] = { | |
2089 /* columns rows colors chars-per-pixel */ | |
2090 \"12 12 2 1\", | |
2091 \" c red\", | |
2092 \"+ c None\", | |
2093 /* pixels */ | |
2094 \"+++++ +++++\", | |
2095 \"+++ +++\", | |
2096 \"++ ++\", | |
2097 \"+ +\", | |
2098 \"+ +\", | |
2099 \" \", | |
2100 \" \", | |
2101 \"+ +\", | |
2102 \"+ +\", | |
2103 \"++ ++\", | |
2104 \"+++ +++\", | |
2105 \"+++++ +++++\" | |
2106 };" | |
2107 "XPM file used for breakpoint icon.") | |
2108 | |
2109 (setq breakpoint-enabled-icon (find-image | |
2110 `((:type xpm :data ,breakpoint-xpm-data)))) | |
2111 (setq breakpoint-disabled-icon (find-image | |
2112 `((:type xpm :data ,breakpoint-xpm-data | |
2113 :conversion laplace)))) | |
2114 | |
2115 (defun gdb-quit () | |
2116 "Kill the GUD and ancillary (including source) buffers. | |
2117 Just the partial-output buffer is left." | |
2118 (interactive) | |
2119 (let ((buffers (buffer-list))) | |
2120 (save-excursion | |
2121 (while buffers | |
2122 (set-buffer (car buffers)) | |
2123 (if (eq gud-minor-mode 'gdba) | |
2124 (if (string-match "^\*" (buffer-name)) | |
2125 (kill-buffer nil) | |
2126 (if (display-graphic-p) | |
2127 (remove-images (point-min) (point-max)) | |
2128 (remove-strings (point-min) (point-max))) | |
2129 (setq left-margin-width 0) | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
2130 (setq gud-minor-mode nil) |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
2131 (kill-local-variable 'tool-bar-map) |
48639
00993d9b9cb7
(gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48600
diff
changeset
|
2132 (setq gud-running nil) |
48292 | 2133 (if (get-buffer-window (current-buffer)) |
2134 (set-window-margins (get-buffer-window | |
2135 (current-buffer)) | |
2136 left-margin-width | |
2137 right-margin-width)))) | |
2138 (setq buffers (cdr buffers))))) | |
2139 (if (eq (selected-window) (minibuffer-window)) | |
2140 (other-window 1)) | |
2141 (delete-other-windows)) | |
2142 | |
2143 (defun gdb-source-info () | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2144 "Find the source file where the program starts and displays it with related |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
2145 buffers." |
48292 | 2146 (goto-char (point-min)) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2147 (search-forward "directory is ") |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2148 (looking-at "\\S-*") |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2149 (setq gdb-cdir (match-string 0)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2150 (search-forward "Located in ") |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2151 (looking-at "\\S-*") |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2152 (setq gdb-main-file (match-string 0)) |
48292 | 2153 ;; Make sure we are not in the minibuffer window when we try to delete |
2154 ;; all other windows. | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2155 (if (window-minibuffer-p (selected-window)) |
48292 | 2156 (other-window 1)) |
2157 (delete-other-windows) | |
2158 (if gdb-many-windows | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2159 (gdb-setup-windows) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2160 (gdb-display-breakpoints-buffer) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2161 (gdb-display-display-buffer) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2162 (gdb-display-stack-buffer) |
48292 | 2163 (delete-other-windows) |
2164 (split-window) | |
2165 (other-window 1) | |
2166 (switch-to-buffer (gud-find-file gdb-main-file)) | |
2167 (other-window 1) | |
2168 (setq gdb-source-window (get-buffer-window (current-buffer))))) | |
2169 | |
2170 ;from put-image | |
2171 (defun put-string (putstring pos &optional string area) | |
2172 "Put string PUTSTRING in front of POS in the current buffer. | |
2173 PUTSTRING is displayed by putting an overlay into the current buffer with a | |
2174 `before-string' STRING that has a `display' property whose value is | |
2175 PUTSTRING. STRING is defaulted if you omit it. | |
2176 POS may be an integer or marker. | |
2177 AREA is where to display the string. AREA nil or omitted means | |
2178 display it in the text area, a value of `left-margin' means | |
2179 display it in the left marginal area, a value of `right-margin' | |
2180 means display it in the right marginal area." | |
2181 (unless string (setq string "x")) | |
2182 (let ((buffer (current-buffer))) | |
2183 (unless (or (null area) (memq area '(left-margin right-margin))) | |
2184 (error "Invalid area %s" area)) | |
2185 (setq string (copy-sequence string)) | |
2186 (let ((overlay (make-overlay pos pos buffer)) | |
2187 (prop (if (null area) putstring (list (list 'margin area) putstring)))) | |
2188 (put-text-property 0 (length string) 'display prop string) | |
2189 (overlay-put overlay 'put-text t) | |
2190 (overlay-put overlay 'before-string string)))) | |
2191 | |
2192 ;from remove-images | |
2193 (defun remove-strings (start end &optional buffer) | |
2194 "Remove strings between START and END in BUFFER. | |
2195 Remove only images that were put in BUFFER with calls to `put-string'. | |
2196 BUFFER nil or omitted means use the current buffer." | |
2197 (unless buffer | |
2198 (setq buffer (current-buffer))) | |
2199 (let ((overlays (overlays-in start end))) | |
2200 (while overlays | |
2201 (let ((overlay (car overlays))) | |
2202 (when (overlay-get overlay 'put-text) | |
2203 (delete-overlay overlay))) | |
2204 (setq overlays (cdr overlays))))) | |
2205 | |
2206 (defun put-arrow (putstring pos &optional string area) | |
2207 "Put arrow string PUTSTRING in front of POS in the current buffer. | |
2208 PUTSTRING is displayed by putting an overlay into the current buffer with a | |
2209 `before-string' \"gdb-arrow\" that has a `display' property whose value is | |
2210 PUTSTRING. STRING is defaulted if you omit it. | |
2211 POS may be an integer or marker. | |
2212 AREA is where to display the string. AREA nil or omitted means | |
2213 display it in the text area, a value of `left-margin' means | |
2214 display it in the left marginal area, a value of `right-margin' | |
2215 means display it in the right marginal area." | |
2216 (setq string "gdb-arrow") | |
2217 (let ((buffer (current-buffer))) | |
2218 (unless (or (null area) (memq area '(left-margin right-margin))) | |
2219 (error "Invalid area %s" area)) | |
2220 (setq string (copy-sequence string)) | |
2221 (let ((overlay (make-overlay pos pos buffer)) | |
2222 (prop (if (null area) putstring (list (list 'margin area) putstring)))) | |
2223 (put-text-property 0 (length string) 'display prop string) | |
2224 (overlay-put overlay 'put-text t) | |
2225 (overlay-put overlay 'before-string string)))) | |
2226 | |
2227 (defun remove-arrow (&optional buffer) | |
2228 "Remove arrow in BUFFER. | |
2229 Remove only images that were put in BUFFER with calls to `put-arrow'. | |
2230 BUFFER nil or omitted means use the current buffer." | |
2231 (unless buffer | |
2232 (setq buffer (current-buffer))) | |
2233 (let ((overlays (overlays-in (point-min) (point-max)))) | |
2234 (while overlays | |
2235 (let ((overlay (car overlays))) | |
2236 (when (string-equal (overlay-get overlay 'before-string) "gdb-arrow") | |
2237 (delete-overlay overlay))) | |
2238 (setq overlays (cdr overlays))))) | |
2239 | |
2240 (defun gdb-array-visualise () | |
2241 "Visualise arrays and slices using graph program from plotutils." | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2242 (interactive) |
48292 | 2243 (if (and (display-graphic-p) gdb-display-string) |
2244 (let ((n 0) m) | |
2245 (catch 'multi-dimensional | |
2246 (while (eq (aref gdb-array-start n) (aref gdb-array-stop n)) | |
2247 (setq n (+ n 1))) | |
2248 (setq m (+ n 1)) | |
2249 (while (< m (length gdb-array-start)) | |
2250 (if (not (eq (aref gdb-array-start m) (aref gdb-array-stop m))) | |
2251 (progn | |
2252 (x-popup-dialog | |
2253 t `(,(concat "Only one dimensional data can be visualised.\n" | |
2254 "Use an array slice to reduce the number of\n" | |
2255 "dimensions") ("OK" t))) | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2256 (throw 'multi-dimensional nil)) |
48292 | 2257 (setq m (+ m 1)))) |
2258 (shell-command (concat "echo" gdb-display-string " | graph -a 1 " | |
2259 (int-to-string (aref gdb-array-start n)) | |
2260 " -x " | |
2261 (int-to-string (aref gdb-array-start n)) | |
2262 " " | |
2263 (int-to-string (aref gdb-array-stop n)) | |
2264 " 1 -T X")))))) | |
2265 | |
2266 (defun gdb-delete-display () | |
2267 "Delete displayed expression and its frame." | |
2268 (interactive) | |
2269 (gdb-instance-enqueue-idle-input | |
2270 (list (concat "server delete display " gdb-display-number "\n") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2271 'ignore)) |
48292 | 2272 (kill-buffer nil) |
2273 (delete-frame)) | |
2274 | |
2275 ;; | |
2276 ;; Assembler buffer | |
2277 ;; | |
2278 | |
2279 (def-gdb-auto-updated-buffer gdb-assembler-buffer | |
2280 gdb-invalidate-assembler | |
2281 (concat "server disassemble " gdb-main-or-pc "\n") | |
2282 gdb-assembler-handler | |
2283 gdb-assembler-custom) | |
2284 | |
2285 (defun gdb-assembler-custom () | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2286 (let ((buffer (gdb-get-instance-buffer 'gdb-assembler-buffer)) |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
2287 (gdb-arrow-position) (address) (flag)) |
48292 | 2288 (if gdb-current-address |
2289 (progn | |
2290 (save-excursion | |
2291 (set-buffer buffer) | |
2292 (remove-arrow) | |
2293 (goto-char (point-min)) | |
2294 (re-search-forward gdb-current-address) | |
2295 (setq gdb-arrow-position (point)) | |
2296 (put-arrow "=>" gdb-arrow-position nil 'left-margin)))) | |
2297 | |
2298 ; remove all breakpoint-icons in assembler buffer before updating. | |
2299 (save-excursion | |
2300 (set-buffer buffer) | |
2301 (if (display-graphic-p) | |
2302 (remove-images (point-min) (point-max)) | |
2303 (remove-strings (point-min) (point-max)))) | |
2304 (save-excursion | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2305 (set-buffer (gdb-get-instance-buffer 'gdb-breakpoints-buffer)) |
48292 | 2306 (goto-char (point-min)) |
2307 (while (< (point) (- (point-max) 1)) | |
2308 (forward-line 1) | |
2309 (if (looking-at "[^\t].*breakpoint") | |
2310 (progn | |
2311 (looking-at | |
2312 "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x0\\(\\S-*\\)") | |
2313 ; info break gives '0x0' (8 digit) while dump gives '0x' (7 digit) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2314 (setq address (concat "0x" (match-string 3))) |
48292 | 2315 (setq flag (char-after (match-beginning 2))) |
2316 (save-excursion | |
2317 (set-buffer buffer) | |
2318 (goto-char (point-min)) | |
2319 (if (re-search-forward address nil t) | |
2320 (let ((start (progn (beginning-of-line) (- (point) 1))) | |
2321 (end (progn (end-of-line) (+ (point) 1)))) | |
2322 (if (display-graphic-p) | |
2323 (progn | |
2324 (remove-images start end) | |
2325 (if (eq ?y flag) | |
2326 (put-image breakpoint-enabled-icon (point) | |
2327 "breakpoint icon enabled" | |
2328 'left-margin) | |
2329 (put-image breakpoint-disabled-icon (point) | |
2330 "breakpoint icon disabled" | |
2331 'left-margin))) | |
2332 (remove-strings start end) | |
2333 (if (eq ?y flag) | |
2334 (put-string "B" (point) "enabled" 'left-margin) | |
2335 (put-string "b" (point) "disabled" | |
2336 'left-margin)))))))))) | |
2337 (if gdb-current-address | |
2338 (set-window-point (get-buffer-window buffer) gdb-arrow-position)))) | |
2339 | |
2340 (gdb-set-instance-buffer-rules 'gdb-assembler-buffer | |
2341 'gdb-assembler-buffer-name | |
2342 'gdb-assembler-mode) | |
2343 | |
2344 (defvar gdb-assembler-mode-map nil) | |
2345 (setq gdb-assembler-mode-map (make-keymap)) | |
2346 (suppress-keymap gdb-assembler-mode-map) | |
2347 | |
2348 (defun gdb-assembler-mode () | |
2349 "Major mode for viewing code assembler. | |
2350 | |
2351 \\{gdb-assembler-mode-map}" | |
2352 (setq major-mode 'gdb-assembler-mode) | |
2353 (setq mode-name "Assembler") | |
2354 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
2355 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2356 (setq left-margin-width 2) |
48292 | 2357 (setq buffer-read-only t) |
2358 (use-local-map gdb-assembler-mode-map) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2359 (gdb-invalidate-assembler) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2360 (gdb-invalidate-breakpoints)) |
48292 | 2361 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2362 (defun gdb-assembler-buffer-name () |
48292 | 2363 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2364 (set-buffer (process-buffer gdb-proc)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2365 (concat "*Machine Code " (gdb-instance-target-string) "*"))) |
48292 | 2366 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2367 (defun gdb-display-assembler-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2368 (interactive (list gdb-proc)) |
48292 | 2369 (gdb-display-buffer |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2370 (gdb-get-create-instance-buffer 'gdb-assembler-buffer))) |
48292 | 2371 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2372 (defun gdb-frame-assembler-buffer () |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2373 (interactive (list gdb-proc)) |
48292 | 2374 (switch-to-buffer-other-frame |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2375 (gdb-get-create-instance-buffer 'gdb-assembler-buffer))) |
48292 | 2376 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2377 (defun gdb-invalidate-frame-and-assembler (&optional ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2378 (gdb-invalidate-frames) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2379 (gdb-invalidate-assembler)) |
48292 | 2380 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2381 (defun gdb-invalidate-breakpoints-and-assembler (&optional ignored) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2382 (gdb-invalidate-breakpoints) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2383 (gdb-invalidate-assembler)) |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2384 |
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2385 (defvar gdb-prev-main-or-pc nil) |
48292 | 2386 |
2387 ; modified because if gdb-main-or-pc has changed value a new command | |
2388 ; must be enqueued to update the buffer with the new output | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2389 (defun gdb-invalidate-assembler (&optional ignored) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2390 (if (and (gdb-get-instance-buffer 'gdb-assembler-buffer) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2391 (or (not (member 'gdb-invalidate-assembler |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2392 (gdb-instance-pending-triggers))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2393 (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc)))) |
48292 | 2394 (progn |
2395 | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2396 ;; take previous disassemble command off the queue |
48292 | 2397 (save-excursion |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2398 (set-buffer (gdb-get-instance-buffer 'gdba)) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2399 (let ((queue gdb-idle-input-queue) (item)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2400 (while queue |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2401 (setq item (car queue)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2402 (if (equal (cdr item) '(gdb-assembler-handler)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2403 (delete item gdb-idle-input-queue)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2404 (setq queue (cdr queue))))) |
48292 | 2405 |
2406 (gdb-instance-enqueue-idle-input | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
2407 (list (concat "server disassemble " gdb-main-or-pc "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2408 'gdb-assembler-handler)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2409 (set-gdb-instance-pending-triggers |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2410 (cons 'gdb-invalidate-assembler |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2411 (gdb-instance-pending-triggers))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
2412 (setq gdb-prev-main-or-pc gdb-main-or-pc)))) |
48292 | 2413 |
2414 (defun gdb-delete-line () | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
2415 "Delete the current line." |
48292 | 2416 (interactive) |
2417 (let ((start (progn (beginning-of-line) (point))) | |
2418 (end (progn (end-of-line) (+ (point) 1)))) | |
2419 (delete-region start end))) | |
2420 | |
2421 (provide 'gdb-ui) | |
2422 | |
2423 ;;; gdb-ui.el ends here |