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