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