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