Mercurial > emacs
annotate lisp/gdb-ui.el @ 48715:1e0c7ad65f05
(describe-register-1): Use window-width
to truncate string in a register. Check whether the string
in a register is an empty string or a sequence of white spaces.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 07 Dec 2002 21:29:35 +0000 |
parents | 19bf840bede8 |
children | 81dc78298a54 |
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 | |
68 \[mouse-2\] gdb-frames-select | SPC gdb-toggle-bp-this-line | |
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 ;; | |
259 ;; The usual gdb interaction buffer is given the type `gdb' and | |
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)) | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
758 (insert-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 759 (setq buffer-read-only t))) |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
760 ;; display expression name... |
48292 | 761 (goto-char (point-min)) |
762 (let ((start (progn (point))) | |
763 (end (progn (end-of-line) (point)))) | |
764 (save-excursion | |
765 (set-buffer gdb-expression-buffer-name) | |
766 (setq buffer-read-only nil) | |
767 (delete-region (point-min) (point-max)) | |
768 (insert-buffer-substring (gdb-get-instance-buffer | |
769 'gdb-partial-output-buffer) | |
770 start end) | |
771 (insert "\n"))) | |
772 (goto-char (point-min)) | |
773 (re-search-forward "##" nil t) | |
774 (setq gdb-nesting-level 0) | |
775 (if (looking-at "array-section-begin") | |
776 (progn | |
777 (gdb-delete-line) | |
778 (setq gdb-point (point)) | |
779 (gdb-array-format))) | |
780 (if (looking-at "field-begin \\(.\\)") | |
781 (progn | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
782 (setq gdb-annotation-arg (match-string 1)) |
48292 | 783 (gdb-field-format-begin)))) |
784 (save-excursion | |
785 (set-buffer gdb-expression-buffer-name) | |
786 (if gdb-dive-display-number | |
787 (progn | |
788 (setq buffer-read-only nil) | |
789 (goto-char (point-max)) | |
790 (insert "\n") | |
791 (insert-text-button "[back]" 'type 'gdb-display-back) | |
792 (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
|
793 (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
|
794 (set-gdb-instance-output-sink 'user) |
48292 | 795 (setq gdb-display-in-progress nil)) |
796 | |
797 (define-button-type 'gdb-display-back | |
798 'help-echo (purecopy "mouse-2, RET: go back to previous display buffer") | |
799 'action (lambda (button) (gdb-display-go-back))) | |
800 | |
801 (defun gdb-display-go-back () | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
802 ;; delete display so they don't accumulate and delete buffer |
48292 | 803 (let ((number gdb-display-number)) |
804 (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
|
805 (list (concat "server delete display " number "\n") 'ignore)) |
48292 | 806 (switch-to-buffer (concat "*display " gdb-dive-display-number "*")) |
807 (kill-buffer (get-buffer (concat "*display " number "*"))))) | |
808 | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
809 ;; 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
|
810 ;; in gdb-partial-output-buffer (to allow recursion). |
48292 | 811 |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
812 ;; 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
|
813 ;; 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
|
814 (defun gdb-array-section-begin (args) |
48292 | 815 (if gdb-display-in-progress |
816 (progn | |
817 (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
|
818 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 819 (goto-char (point-max)) |
820 (insert (concat "\n##array-section-begin " args "\n")))))) | |
821 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
822 (defun gdb-array-section-end (ignored) |
48292 | 823 (if gdb-display-in-progress |
824 (progn | |
825 (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
|
826 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 827 (goto-char (point-max)) |
828 (insert "\n##array-section-end\n"))))) | |
829 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
830 (defun gdb-field-begin (args) |
48292 | 831 (if gdb-display-in-progress |
832 (progn | |
833 (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
|
834 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 835 (goto-char (point-max)) |
836 (insert (concat "\n##field-begin " args "\n")))))) | |
837 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
838 (defun gdb-field-end (ignored) |
48292 | 839 (if gdb-display-in-progress |
840 (progn | |
841 (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
|
842 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 843 (goto-char (point-max)) |
844 (insert "\n##field-end\n"))))) | |
845 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
846 (defun gdb-elt (ignored) |
48292 | 847 (if gdb-display-in-progress |
848 (progn | |
849 (goto-char (point-max)) | |
850 (insert "\n##elt\n")))) | |
851 | |
852 (defun gdb-field-format-begin () | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
853 ;; get rid of ##field-begin |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
854 (gdb-delete-line) |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
855 (gdb-insert-field) |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
856 (setq gdb-nesting-level (+ gdb-nesting-level 1)) |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
857 (while (re-search-forward "##" nil t) |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
858 ;; keep making recursive calls... |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
859 (if (looking-at "field-begin \\(.\\)") |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
860 (progn |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
861 (setq gdb-annotation-arg (match-string 1)) |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
862 (gdb-field-format-begin))) |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
863 ;; until field-end. |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
864 (if (looking-at "field-end") (gdb-field-format-end)))) |
48292 | 865 |
866 (defun gdb-field-format-end () | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
867 ;; get rid of ##field-end and `,' or `}' |
48292 | 868 (gdb-delete-line) |
869 (gdb-delete-line) | |
870 (setq gdb-nesting-level (- gdb-nesting-level 1))) | |
871 | |
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
|
872 (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
|
873 (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
|
874 (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
|
875 (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
|
876 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
|
877 |
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 (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
|
879 "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
|
880 (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
|
881 (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
|
882 (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
|
883 |
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 (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
|
885 "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
|
886 (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
|
887 (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
|
888 (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
|
889 (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
|
890 (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
|
891 (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
|
892 (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
|
893 (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
|
894 (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
|
895 (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
|
896 (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
|
897 (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
|
898 (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
|
899 (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
|
900 (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
|
901 (> (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
|
902 (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
|
903 (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
|
904 (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
|
905 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
|
906 (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
|
907 ;; * 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
|
908 (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
|
909 (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
|
910 (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
|
911 (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
|
912 (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
|
913 (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
|
914 " " gdb-full-expression "\n") |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
915 '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
|
916 |
48292 | 917 (defun gdb-insert-field () |
918 (let ((start (progn (point))) | |
919 (end (progn (next-line) (point))) | |
920 (num 0)) | |
921 (save-excursion | |
922 (set-buffer gdb-expression-buffer-name) | |
923 (setq buffer-read-only nil) | |
924 (if (string-equal gdb-annotation-arg "\*") (insert "\*")) | |
925 (while (<= num gdb-nesting-level) | |
926 (insert "\t") | |
927 (setq num (+ num 1))) | |
928 (insert-buffer-substring (gdb-get-instance-buffer | |
929 'gdb-partial-output-buffer) | |
930 start end) | |
931 (put-text-property (- (point) (- end start)) (- (point) 1) | |
932 'mouse-face 'highlight) | |
933 (put-text-property (- (point) (- end start)) (- (point) 1) | |
934 'local-map gdb-dive-map) | |
935 (setq buffer-read-only t)) | |
936 (delete-region start end))) | |
937 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
938 (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
|
939 |
48292 | 940 (defun gdb-array-format () |
941 (while (re-search-forward "##" nil t) | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
942 ;; keep making recursive calls... |
48292 | 943 (if (looking-at "array-section-begin") |
944 (progn | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
945 ;;get rid of ##array-section-begin |
48292 | 946 (gdb-delete-line) |
947 (setq gdb-nesting-level (+ gdb-nesting-level 1)) | |
948 (gdb-array-format))) | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
949 ;;until *matching* array-section-end is found |
48292 | 950 (if (looking-at "array-section-end") |
951 (if (eq gdb-nesting-level 0) | |
952 (progn | |
953 (let ((values (buffer-substring gdb-point (- (point) 2)))) | |
954 (save-excursion | |
955 (set-buffer gdb-expression-buffer-name) | |
956 (setq gdb-values | |
957 (concat "{" (replace-regexp-in-string "\n" "" values) | |
958 "}")) | |
959 (gdb-array-format1)))) | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
960 ;;else get rid of ##array-section-end etc |
48292 | 961 (gdb-delete-line) |
962 (setq gdb-nesting-level (- gdb-nesting-level 1)) | |
963 (gdb-array-format))))) | |
964 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
965 (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
|
966 (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
|
967 |
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
|
968 (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
|
969 (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
|
970 (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
|
971 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
|
972 |
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 (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
|
974 "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
|
975 (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
|
976 (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
|
977 (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
|
978 (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
|
979 (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
|
980 (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
|
981 (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
|
982 (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
|
983 (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
|
984 (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
|
985 (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
|
986 (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
|
987 |
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 (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
|
989 (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
|
990 |
48292 | 991 (defun gdb-array-format1 () |
992 (setq gdb-display-string "") | |
993 (setq buffer-read-only nil) | |
994 (delete-region (point-min) (point-max)) | |
995 (let ((gdb-value-list (split-string gdb-values ", "))) | |
996 (string-match "\\({+\\)" (car gdb-value-list)) | |
997 (let* ((depth (- (match-end 1) (match-beginning 1))) | |
998 (indices (make-vector depth '0)) | |
999 (index 0) (num 0) (array-start "") | |
48498
8fdedd7dca85
General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents:
48300
diff
changeset
|
1000 (array-stop "") (array-slice "") (array-range nil) |
48292 | 1001 (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
|
1002 (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
|
1003 (string-match "{*\\([^}]*\\)\\(}*\\)" gdb-value) |
48292 | 1004 (setq num 0) |
1005 (while (< num depth) | |
1006 (setq indices-string | |
1007 (concat indices-string | |
1008 "[" (int-to-string (aref indices num)) "]")) | |
1009 (if (not (= (aref gdb-array-start num) -1)) | |
1010 (if (or (< (aref indices num) (aref gdb-array-start num)) | |
1011 (> (aref indices num) (aref gdb-array-stop num))) | |
1012 (setq flag nil)) | |
1013 (aset gdb-array-size num (aref indices num))) | |
1014 (setq num (+ num 1))) | |
1015 (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
|
1016 (let ((gdb-display-value (match-string 1 gdb-value))) |
48292 | 1017 (setq gdb-display-string (concat gdb-display-string " " |
1018 gdb-display-value)) | |
1019 (insert | |
1020 (concat indices-string "\t" gdb-display-value "\n")))) | |
1021 (setq indices-string "") | |
1022 (setq flag t) | |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1023 ;; 0<= index < depth, start at right : (- depth 1) |
48292 | 1024 (setq index (- (- depth 1) |
1025 (- (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
|
1026 ;;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
|
1027 (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
|
1028 (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
|
1029 (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
|
1030 (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
|
1031 (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
|
1032 (setq num (+ num 1))))) |
48292 | 1033 (setq num 0) |
1034 (while (< num depth) | |
1035 (if (= (aref gdb-array-start num) -1) | |
1036 (progn | |
1037 (aset gdb-array-start num 0) | |
1038 (aset gdb-array-stop num (aref indices num)))) | |
1039 (setq array-start (int-to-string (aref gdb-array-start num))) | |
1040 (setq array-stop (int-to-string (aref gdb-array-stop num))) | |
1041 (setq array-range (concat "[" array-start | |
1042 ":" array-stop "]")) | |
1043 (put-text-property 1 (+ (length array-start) | |
1044 (length array-stop) 2) | |
1045 'mouse-face 'highlight array-range) | |
1046 (put-text-property 1 (+ (length array-start) | |
1047 (length array-stop) 2) | |
1048 'local-map gdb-array-slice-map array-range) | |
1049 (goto-char (point-min)) | |
1050 (setq array-slice (concat array-slice array-range)) | |
1051 (setq num (+ num 1))) | |
1052 (goto-char (point-min)) | |
1053 (insert "Array Size : ") | |
1054 (setq num 0) | |
1055 (while (< num depth) | |
1056 (insert | |
1057 (concat "[" | |
1058 (int-to-string (+ (aref gdb-array-size num) 1)) "]")) | |
1059 (setq num (+ num 1))) | |
1060 (insert | |
1061 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n")))) | |
1062 (setq buffer-read-only t)) | |
1063 | |
1064 ;; Handle a burst of output from a gdb instance. | |
1065 ;; 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
|
1066 ;; It must return output (if any) to be inserted in the gdb |
48292 | 1067 ;; buffer. |
1068 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1069 (defun gdb-output-burst (string) |
48292 | 1070 "Handle a burst of output from a gdb instance. |
1071 This function is (indirectly) used as a gud-marker-filter. | |
1072 It must return output (if any) to be insterted in the gdb | |
1073 buffer." | |
1074 (save-match-data | |
1075 (let ( | |
1076 ;; 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
|
1077 (burst (concat (gdb-instance-burst) string)) |
48292 | 1078 ;; Start accumulating output for the GUD buffer |
1079 (output "")) | |
1080 | |
1081 ;; Process all the complete markers in this chunk. | |
1082 (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
|
1083 (let ((annotation (match-string 1 burst))) |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1084 |
48292 | 1085 ;; Stuff prior to the match is just ordinary output. |
1086 ;; It is either concatenated to OUTPUT or directed | |
1087 ;; elsewhere. | |
1088 (setq output | |
48570
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1089 (gdb-concat-output |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1090 output |
48292 | 1091 (substring burst 0 (match-beginning 0)))) |
1092 | |
1093 ;; Take that stuff off the burst. | |
1094 (setq burst (substring burst (match-end 0))) | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1095 |
48292 | 1096 ;; Parse the tag from the annotation, and maybe its arguments. |
1097 (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
|
1098 (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
|
1099 (annotation-arguments (match-string 2 annotation)) |
48292 | 1100 (annotation-rule (assoc annotation-type |
1101 gdb-annotation-rules))) | |
1102 ;; Call the handler for this annotation. | |
1103 (if annotation-rule | |
1104 (funcall (car (cdr annotation-rule)) | |
1105 annotation-arguments) | |
1106 ;; Else the annotation is not recognized. Ignore it silently, | |
1107 ;; so that GDB can add new annotations without causing | |
1108 ;; us to blow up. | |
1109 )))) | |
1110 | |
1111 ;; Does the remaining text end in a partial line? | |
1112 ;; If it does, then keep part of the burst until we get more. | |
1113 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" | |
1114 burst) | |
1115 (progn | |
1116 ;; Everything before the potential marker start can be output. | |
1117 (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
|
1118 (gdb-concat-output output |
48292 | 1119 (substring burst 0 (match-beginning 0)))) |
1120 | |
1121 ;; Everything after, we save, to combine with later input. | |
1122 (setq burst (substring burst (match-beginning 0)))) | |
1123 | |
1124 ;; In case we know the burst contains no partial annotations: | |
1125 (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
|
1126 (setq output (gdb-concat-output output burst)) |
48292 | 1127 (setq burst ""))) |
1128 | |
1129 ;; 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
|
1130 (set-gdb-instance-burst burst) |
48292 | 1131 output))) |
1132 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1133 (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
|
1134 (let ((sink (gdb-instance-output-sink ))) |
48292 | 1135 (cond |
1136 ((eq sink 'user) (concat so-far new)) | |
1137 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) | |
1138 ((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
|
1139 (gdb-append-to-partial-output new) |
48292 | 1140 so-far) |
1141 ((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
|
1142 (gdb-append-to-inferior-io new) |
48292 | 1143 so-far) |
1144 (t (error "Bogon output sink %S" sink))))) | |
1145 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1146 (defun gdb-append-to-partial-output (string) |
48292 | 1147 (save-excursion |
1148 (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
|
1149 (gdb-get-create-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 1150 (goto-char (point-max)) |
1151 (insert string))) | |
1152 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1153 (defun gdb-clear-partial-output () |
48292 | 1154 (save-excursion |
1155 (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
|
1156 (gdb-get-create-instance-buffer 'gdb-partial-output-buffer)) |
48292 | 1157 (delete-region (point-min) (point-max)))) |
1158 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1159 (defun gdb-append-to-inferior-io (string) |
48292 | 1160 (save-excursion |
1161 (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
|
1162 (gdb-get-create-instance-buffer 'gdb-inferior-io)) |
48292 | 1163 (goto-char (point-max)) |
1164 (insert-before-markers string)) | |
1165 (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
|
1166 (gdb-get-create-instance-buffer 'gdb-inferior-io))) |
48292 | 1167 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1168 (defun gdb-clear-inferior-io () |
48292 | 1169 (save-excursion |
1170 (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
|
1171 (gdb-get-create-instance-buffer 'gdb-inferior-io)) |
48292 | 1172 (delete-region (point-min) (point-max)))) |
1173 | |
1174 | |
1175 ;; One trick is to have a command who's output is always available in | |
1176 ;; a buffer of it's own, and is always up to date. We build several | |
1177 ;; buffers of this type. | |
1178 ;; | |
1179 ;; There are two aspects to this: gdb has to tell us when the output | |
1180 ;; for that command might have changed, and we have to be able to run | |
1181 ;; the command behind the user's back. | |
1182 ;; | |
1183 ;; 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
|
1184 ;; the instance variable `(gdb-instance-output-sink)' help |
48292 | 1185 ;; 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
|
1186 ;; |
48292 | 1187 ;; Below is the code for specificly managing buffers of output from one |
1188 ;; command. | |
1189 ;; | |
1190 | |
1191 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES | |
1192 ;; It adds an idle input for the command we are tracking. It should be the | |
1193 ;; annotation rule binding of whatever gdb sends to tell us this command | |
1194 ;; might have changed it's output. | |
1195 ;; | |
1196 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed. | |
1197 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the | |
1198 ;; 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
|
1199 |
4934b8352621
(gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents:
48515
diff
changeset
|
1200 (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
|
1201 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
|
1202 `(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
|
1203 (if (and (,demand-predicate) |
48292 | 1204 (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
|
1205 (gdb-instance-pending-triggers)))) |
48292 | 1206 (progn |
1207 (gdb-instance-enqueue-idle-input | |
1208 (list ,gdb-command ',output-handler)) | |
1209 (set-gdb-instance-pending-triggers | |
1210 (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
|
1211 (gdb-instance-pending-triggers))))))) |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1212 |
48292 | 1213 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) |
1214 `(defun ,name () | |
1215 (set-gdb-instance-pending-triggers | |
1216 (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
|
1217 (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
|
1218 (let ((buf (gdb-get-instance-buffer ',buf-key))) |
48292 | 1219 (and buf |
1220 (save-excursion | |
1221 (set-buffer buf) | |
1222 (let ((p (point)) | |
1223 (buffer-read-only nil)) | |
1224 (delete-region (point-min) (point-max)) | |
1225 (insert-buffer (gdb-get-create-instance-buffer | |
1226 'gdb-partial-output-buffer)) | |
1227 (goto-char p))))) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1228 ;; put customisation here |
48292 | 1229 (,custom-defun))) |
1230 | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1231 (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
|
1232 output-handler-name custom-defun) |
48292 | 1233 `(progn |
1234 (def-gdb-auto-update-trigger ,trigger-name | |
1235 ;; The demand predicate: | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1236 (lambda () (gdb-get-instance-buffer ',buffer-key)) |
48292 | 1237 ,gdb-command |
1238 ,output-handler-name) | |
1239 (def-gdb-auto-update-handler ,output-handler-name | |
1240 ,trigger-name ,buffer-key ,custom-defun))) | |
1241 | |
1242 | |
1243 ;; | |
1244 ;; Breakpoint buffers | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1245 ;; |
48292 | 1246 ;; These display the output of `info breakpoints'. |
1247 ;; | |
1248 | |
1249 (gdb-set-instance-buffer-rules 'gdb-breakpoints-buffer | |
1250 'gdb-breakpoints-buffer-name | |
1251 'gdb-breakpoints-mode) | |
1252 | |
1253 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer | |
1254 ;; This defines the auto update rule for buffers of type | |
1255 ;; `gdb-breakpoints-buffer'. | |
1256 ;; | |
1257 ;; It defines a function to serve as the annotation handler that | |
1258 ;; handles the `foo-invalidated' message. That function is called: | |
1259 gdb-invalidate-breakpoints | |
1260 | |
1261 ;; To update the buffer, this command is sent to gdb. | |
1262 "server info breakpoints\n" | |
1263 | |
1264 ;; This also defines a function to be the handler for the output | |
1265 ;; from the command above. That function will copy the output into | |
1266 ;; the appropriately typed buffer. That function will be called: | |
1267 gdb-info-breakpoints-handler | |
1268 ;; buffer specific functions | |
1269 gdb-info-breakpoints-custom) | |
1270 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1271 (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
|
1272 (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
|
1273 (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
|
1274 |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
1275 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer) |
48292 | 1276 (defun gdb-info-breakpoints-custom () |
1277 (let ((flag)(address)) | |
1278 | |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1279 ;; remove all breakpoint-icons in source buffers but not assembler buffer |
48292 | 1280 (let ((buffers (buffer-list))) |
1281 (save-excursion | |
1282 (while buffers | |
1283 (set-buffer (car buffers)) | |
1284 (if (and (eq gud-minor-mode 'gdba) | |
1285 (not (string-match "^\*" (buffer-name)))) | |
1286 (if (display-graphic-p) | |
1287 (remove-images (point-min) (point-max)) | |
1288 (remove-strings (point-min) (point-max)))) | |
1289 (setq buffers (cdr buffers))))) | |
1290 | |
1291 (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
|
1292 (set-buffer (gdb-get-instance-buffer 'gdb-breakpoints-buffer)) |
48292 | 1293 (save-excursion |
1294 (goto-char (point-min)) | |
1295 (while (< (point) (- (point-max) 1)) | |
1296 (forward-line 1) | |
1297 (if (looking-at "[^\t].*breakpoint") | |
1298 (progn | |
1299 (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)") | |
1300 (setq flag (char-after (match-beginning 2))) | |
1301 (beginning-of-line) | |
1302 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+") | |
1303 (looking-at "\\(\\S-*\\):\\([0-9]+\\)") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1304 (let ((line (match-string 2)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1305 (file (match-string 1))) |
48292 | 1306 (save-excursion |
1307 (set-buffer | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1308 (find-file-noselect (if (file-exists-p file) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1309 file |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1310 (expand-file-name file gdb-cdir)))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1311 (save-current-buffer |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1312 (set (make-local-variable 'gud-minor-mode) 'gdba) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1313 (set (make-local-variable 'tool-bar-map) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1314 gud-tool-bar-map) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1315 (setq left-margin-width 2) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1316 (if (get-buffer-window (current-buffer)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1317 (set-window-margins (get-buffer-window |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1318 (current-buffer)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1319 left-margin-width |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1320 right-margin-width))) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1321 ;; only want one breakpoint icon at each location |
48292 | 1322 (save-excursion |
1323 (goto-line (string-to-number line)) | |
1324 (let ((start (progn (beginning-of-line) (- (point) 1))) | |
1325 (end (progn (end-of-line) (+ (point) 1)))) | |
1326 (if (display-graphic-p) | |
1327 (progn | |
1328 (remove-images start end) | |
1329 (if (eq ?y flag) | |
1330 (put-image breakpoint-enabled-icon (point) | |
1331 "breakpoint icon enabled" | |
1332 'left-margin) | |
1333 (put-image breakpoint-disabled-icon (point) | |
1334 "breakpoint icon disabled" | |
1335 'left-margin))) | |
1336 (remove-strings start end) | |
1337 (if (eq ?y flag) | |
1338 (put-string "B" (point) "enabled" | |
1339 'left-margin) | |
1340 (put-string "b" (point) "disabled" | |
1341 'left-margin))))))))) | |
1342 (end-of-line)))))) | |
1343 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1344 (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
|
1345 (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
|
1346 (concat "*breakpoints of " (gdb-instance-target-string) "*"))) |
48292 | 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-display-breakpoints-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1349 (interactive) |
48292 | 1350 (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
|
1351 (gdb-get-create-instance-buffer 'gdb-breakpoints-buffer))) |
48292 | 1352 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1353 (defun gdb-frame-breakpoints-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1354 (interactive) |
48292 | 1355 (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
|
1356 (gdb-get-create-instance-buffer 'gdb-breakpoints-buffer))) |
48292 | 1357 |
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
|
1358 (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
|
1359 (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
|
1360 (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
|
1361 (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
|
1362 (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
|
1363 (define-key menu [goto] '("Goto" . gdb-goto-bp-this-line)) |
48292 | 1364 |
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
|
1365 (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
|
1366 (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
|
1367 (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
|
1368 (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
|
1369 (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
|
1370 map)) |
48292 | 1371 |
1372 (defun gdb-breakpoints-mode () | |
1373 "Major mode for gdb breakpoints. | |
1374 | |
1375 \\{gdb-breakpoints-mode-map}" | |
1376 (setq major-mode 'gdb-breakpoints-mode) | |
1377 (setq mode-name "Breakpoints") | |
1378 (use-local-map gdb-breakpoints-mode-map) | |
1379 (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
|
1380 (gdb-invalidate-breakpoints)) |
48292 | 1381 |
1382 (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
|
1383 "Enable/disable the breakpoint on this line." |
48292 | 1384 (interactive) |
1385 (save-excursion | |
1386 (beginning-of-line 1) | |
1387 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | |
1388 (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
|
1389 (gdb-instance-enqueue-idle-input |
48292 | 1390 (list |
1391 (concat | |
1392 (if (eq ?y (char-after (match-beginning 2))) | |
1393 "server disable " | |
1394 "server enable ") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1395 (match-string 1) |
48292 | 1396 "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1397 'ignore))))) |
48292 | 1398 |
1399 (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
|
1400 "Delete the breakpoint on this line." |
48292 | 1401 (interactive) |
1402 (beginning-of-line 1) | |
1403 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | |
1404 (error "Not recognized as break/watchpoint line") | |
1405 (gdb-instance-enqueue-idle-input | |
1406 (list | |
1407 (concat | |
1408 "server delete " | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1409 (match-string 1) |
48292 | 1410 "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1411 'ignore)))) |
48292 | 1412 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1413 (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
|
1414 |
48292 | 1415 (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
|
1416 "Display the file at the specified breakpoint." |
48292 | 1417 (interactive) |
1418 (save-excursion | |
1419 (beginning-of-line 1) | |
1420 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+") | |
1421 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")) | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1422 (let ((line (match-string 2)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1423 (file (match-string 1))) |
48685
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1424 (save-selected-window |
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1425 (select-window gdb-source-window) |
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1426 (switch-to-buffer (find-file-noselect |
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1427 (if (file-exists-p file) |
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1428 file |
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1429 (expand-file-name file gdb-cdir)))) |
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1430 (goto-line (string-to-number line))))) |
48292 | 1431 |
1432 ;; | |
1433 ;; Frames buffers. These display a perpetually correct bactracktrace | |
1434 ;; (from the command `where'). | |
1435 ;; | |
1436 ;; Alas, if your stack is deep, they are costly. | |
1437 ;; | |
1438 | |
1439 (gdb-set-instance-buffer-rules 'gdb-stack-buffer | |
1440 'gdb-stack-buffer-name | |
1441 'gdb-frames-mode) | |
1442 | |
1443 (def-gdb-auto-updated-buffer gdb-stack-buffer | |
1444 gdb-invalidate-frames | |
1445 "server where\n" | |
1446 gdb-info-frames-handler | |
1447 gdb-info-frames-custom) | |
1448 | |
1449 (defun gdb-info-frames-custom () | |
1450 (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
|
1451 (set-buffer (gdb-get-instance-buffer 'gdb-stack-buffer)) |
48292 | 1452 (let ((buffer-read-only nil)) |
1453 (goto-char (point-min)) | |
1454 (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
|
1455 (setq gdb-current-frame (match-string 1)) |
48292 | 1456 (while (< (point) (point-max)) |
1457 (put-text-property (progn (beginning-of-line) (point)) | |
1458 (progn (end-of-line) (point)) | |
1459 'mouse-face 'highlight) | |
1460 (forward-line 1))))) | |
1461 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1462 (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
|
1463 (with-current-buffer gud-comint-buffer |
48292 | 1464 (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
|
1465 (gdb-instance-target-string) "*"))) |
48292 | 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-display-stack-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1468 (interactive) |
48292 | 1469 (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
|
1470 (gdb-get-create-instance-buffer 'gdb-stack-buffer))) |
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-frame-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 (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
|
1475 (gdb-get-create-instance-buffer 'gdb-stack-buffer))) |
48292 | 1476 |
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
|
1477 (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
|
1478 (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
|
1479 (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
|
1480 (define-key map [mouse-2]'gdb-frames-select-by-mouse) |
b092bff770ec
Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48659
diff
changeset
|
1481 map)) |
48292 | 1482 |
1483 (defun gdb-frames-mode () | |
1484 "Major mode for gdb frames. | |
1485 | |
1486 \\{gdb-frames-mode-map}" | |
1487 (setq major-mode 'gdb-frames-mode) | |
1488 (setq mode-name "Frames") | |
1489 (setq buffer-read-only t) | |
1490 (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
|
1491 (gdb-invalidate-frames)) |
48292 | 1492 |
1493 (defun gdb-get-frame-number () | |
1494 (save-excursion | |
1495 (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
|
1496 (n (or (and pos (string-to-int (match-string 1))) 0))) |
48292 | 1497 n))) |
1498 | |
1499 (defun gdb-frames-select-by-mouse (e) | |
1500 "Display the source of the selected frame." | |
1501 (interactive "e") | |
1502 (let (selection) | |
1503 (save-excursion | |
1504 (set-buffer (window-buffer (posn-window (event-end e)))) | |
1505 (save-excursion | |
1506 (goto-char (posn-point (event-end e))) | |
1507 (setq selection (gdb-get-frame-number)))) | |
1508 (select-window (posn-window (event-end e))) | |
1509 (save-excursion | |
48685
19bf840bede8
Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48682
diff
changeset
|
1510 (set-buffer gud-comint-buffer) |
48292 | 1511 (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
|
1512 (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
|
1513 'ignore)) |
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1514 (gud-display-frame)))) |
48292 | 1515 |
1516 | |
1517 ;; | |
1518 ;; Registers buffers | |
1519 ;; | |
1520 | |
1521 (def-gdb-auto-updated-buffer gdb-registers-buffer | |
1522 gdb-invalidate-registers | |
1523 "server info registers\n" | |
1524 gdb-info-registers-handler | |
1525 gdb-info-registers-custom) | |
1526 | |
1527 (defun gdb-info-registers-custom ()) | |
1528 | |
1529 (gdb-set-instance-buffer-rules 'gdb-registers-buffer | |
1530 'gdb-registers-buffer-name | |
1531 'gdb-registers-mode) | |
1532 | |
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
|
1533 (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
|
1534 (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
|
1535 (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
|
1536 map)) |
48292 | 1537 |
1538 (defun gdb-registers-mode () | |
1539 "Major mode for gdb registers. | |
1540 | |
1541 \\{gdb-registers-mode-map}" | |
1542 (setq major-mode 'gdb-registers-mode) | |
1543 (setq mode-name "Registers") | |
1544 (setq buffer-read-only t) | |
1545 (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
|
1546 (gdb-invalidate-registers)) |
48292 | 1547 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1548 (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
|
1549 (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
|
1550 (concat "*registers of " (gdb-instance-target-string) "*"))) |
48292 | 1551 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1552 (defun gdb-display-registers-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1553 (interactive) |
48292 | 1554 (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
|
1555 (gdb-get-create-instance-buffer 'gdb-registers-buffer))) |
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-frame-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 (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
|
1560 (gdb-get-create-instance-buffer 'gdb-registers-buffer))) |
48292 | 1561 |
1562 ;; | |
1563 ;; Locals buffers | |
1564 ;; | |
1565 | |
1566 (def-gdb-auto-updated-buffer gdb-locals-buffer | |
1567 gdb-invalidate-locals | |
1568 "server info locals\n" | |
1569 gdb-info-locals-handler | |
1570 gdb-info-locals-custom) | |
1571 | |
1572 | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
1573 ;;Abbreviate for arrays and structures. These can be expanded using gud-display |
48292 | 1574 (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
|
1575 (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
|
1576 (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
|
1577 (let ((buf (gdb-get-instance-buffer 'gdb-partial-output-buffer))) |
48292 | 1578 (save-excursion |
1579 (set-buffer buf) | |
1580 (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
|
1581 (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
|
1582 (replace-match "" nil nil)) |
48292 | 1583 (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
|
1584 (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
|
1585 (replace-match "(array);\n" nil nil)) |
48292 | 1586 (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
|
1587 (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
|
1588 (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
|
1589 (let ((buf (gdb-get-instance-buffer 'gdb-locals-buffer))) |
48292 | 1590 (and buf (save-excursion |
1591 (set-buffer buf) | |
1592 (let ((p (point)) | |
1593 (buffer-read-only nil)) | |
1594 (delete-region (point-min) (point-max)) | |
1595 (insert-buffer (gdb-get-create-instance-buffer | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1596 'gdb-partial-output-buffer)) |
48292 | 1597 (goto-char p))))) |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1598 (run-hooks 'gdb-info-locals-hook)) |
48292 | 1599 |
1600 (defun gdb-info-locals-custom () | |
1601 nil) | |
1602 | |
1603 (gdb-set-instance-buffer-rules 'gdb-locals-buffer | |
1604 'gdb-locals-buffer-name | |
1605 'gdb-locals-mode) | |
1606 | |
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
|
1607 (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
|
1608 (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
|
1609 (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
|
1610 map)) |
48292 | 1611 |
1612 (defun gdb-locals-mode () | |
1613 "Major mode for gdb locals. | |
1614 | |
1615 \\{gdb-locals-mode-map}" | |
1616 (setq major-mode 'gdb-locals-mode) | |
1617 (setq mode-name "Locals") | |
1618 (setq buffer-read-only t) | |
1619 (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
|
1620 (gdb-invalidate-locals)) |
48292 | 1621 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1622 (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
|
1623 (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
|
1624 (concat "*locals of " (gdb-instance-target-string) "*"))) |
48292 | 1625 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1626 (defun gdb-display-locals-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1627 (interactive) |
48292 | 1628 (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
|
1629 (gdb-get-create-instance-buffer 'gdb-locals-buffer))) |
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-frame-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 (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
|
1634 (gdb-get-create-instance-buffer 'gdb-locals-buffer))) |
48292 | 1635 ;; |
1636 ;; Display expression buffers (just allow one to start with) | |
1637 ;; | |
1638 (gdb-set-instance-buffer-rules 'gdb-display-buffer | |
1639 'gdb-display-buffer-name | |
1640 'gdb-display-mode) | |
1641 | |
1642 (def-gdb-auto-updated-buffer gdb-display-buffer | |
1643 ;; `gdb-display-buffer'. | |
1644 gdb-invalidate-display | |
1645 "server info display\n" | |
1646 gdb-info-display-handler | |
1647 gdb-info-display-custom) | |
1648 | |
1649 (defun gdb-info-display-custom () | |
48662
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
1650 ;; 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
|
1651 ;; 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
|
1652 ;; recompiled program. |
d29870d63092
Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48661
diff
changeset
|
1653 ) |
48292 | 1654 |
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
|
1655 (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
|
1656 (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
|
1657 (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
|
1658 (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
|
1659 (define-key menu [delete] '("Delete" . gdb-delete-disp-this-line)) |
48292 | 1660 |
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
|
1661 (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
|
1662 (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
|
1663 (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
|
1664 (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
|
1665 map)) |
48292 | 1666 |
1667 (defun gdb-display-mode () | |
1668 "Major mode for gdb display. | |
1669 | |
1670 \\{gdb-display-mode-map}" | |
1671 (setq major-mode 'gdb-display-mode) | |
1672 (setq mode-name "Display") | |
1673 (setq buffer-read-only t) | |
1674 (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
|
1675 (gdb-invalidate-display)) |
48292 | 1676 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1677 (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
|
1678 (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
|
1679 (concat "*Displayed expressions of " (gdb-instance-target-string) "*"))) |
48292 | 1680 |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1681 (defun gdb-display-display-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1682 (interactive) |
48292 | 1683 (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
|
1684 (gdb-get-create-instance-buffer 'gdb-display-buffer))) |
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-frame-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 (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
|
1689 (gdb-get-create-instance-buffer 'gdb-display-buffer))) |
48292 | 1690 |
1691 (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
|
1692 "Enable/disable the displayed expression on this line." |
48292 | 1693 (interactive) |
1694 (save-excursion | |
1695 (beginning-of-line 1) | |
1696 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) | |
1697 (error "No expression on this line") | |
1698 (gdb-instance-enqueue-idle-input | |
1699 (list | |
1700 (concat | |
1701 (if (eq ?y (char-after (match-beginning 2))) | |
1702 "server disable display " | |
1703 "server enable display ") | |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1704 (match-string 1) |
48292 | 1705 "\n") |
48641
da382393fb77
Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48640
diff
changeset
|
1706 'ignore))))) |
48292 | 1707 |
1708 (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
|
1709 "Delete the displayed expression on this line." |
48292 | 1710 (interactive) |
1711 (save-excursion | |
1712 (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
|
1713 (gdb-get-instance-buffer 'gdb-display-buffer)) |
48292 | 1714 (beginning-of-line 1) |
1715 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) | |
1716 (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
|
1717 (let ((number (match-string 1))) |
48292 | 1718 (gdb-instance-enqueue-idle-input |
1719 (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
|
1720 'ignore)) |
48292 | 1721 (if (not (display-graphic-p)) |
1722 (kill-buffer (get-buffer (concat "*display " number "*"))) | |
1723 (catch 'frame-found | |
1724 (let ((frames (frame-list))) | |
1725 (while frames | |
1726 (if (string-equal (frame-parameter (car frames) 'name) | |
1727 (concat "*display " number "*")) | |
1728 (progn (kill-buffer | |
1729 (get-buffer (concat "*display " number "*"))) | |
1730 (delete-frame (car frames)) | |
1731 (throw 'frame-found nil))) | |
1732 (setq frames (cdr frames)))))))))) | |
1733 | |
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
|
1734 (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
|
1735 (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
|
1736 (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
|
1737 (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
|
1738 (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
|
1739 (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
|
1740 map)) |
48292 | 1741 |
1742 (defvar gdb-expressions-mode-menu | |
1743 '("GDB Expressions Commands" | |
1744 "----" | |
1745 ["Visualise" gdb-array-visualise t] | |
1746 ["Delete" gdb-delete-display t]) | |
1747 "Menu for `gdb-expressions-mode'.") | |
1748 | |
1749 (defun gdb-expressions-popup-menu (event) | |
1750 "Explicit Popup menu as this buffer doesn't have a menubar." | |
1751 (interactive "@e") | |
1752 (mouse-set-point event) | |
1753 (popup-menu gdb-expressions-mode-menu)) | |
1754 | |
1755 (defun gdb-expressions-mode () | |
1756 "Major mode for display expressions. | |
1757 | |
1758 \\{gdb-expressions-mode-map}" | |
1759 (setq major-mode 'gdb-expressions-mode) | |
1760 (setq mode-name "Expressions") | |
1761 (use-local-map gdb-expressions-mode-map) | |
1762 (make-local-variable 'gdb-display-number) | |
1763 (make-local-variable 'gdb-values) | |
1764 (make-local-variable 'gdb-expression) | |
1765 (set (make-local-variable 'gdb-display-string) nil) | |
1766 (set (make-local-variable 'gdb-dive-display-number) nil) | |
1767 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1768 (set (make-local-variable 'gdb-array-start) (make-vector 16 '-1)) | |
1769 (set (make-local-variable 'gdb-array-stop) (make-vector 16 '-1)) | |
1770 (set (make-local-variable 'gdb-array-size) (make-vector 16 '-1)) | |
1771 (setq buffer-read-only t)) | |
1772 | |
1773 | |
1774 ;;;; Window management | |
1775 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1776 ;;; FIXME: This should only return true for buffers in the current gdb-proc |
48292 | 1777 (defun gdb-protected-buffer-p (buffer) |
1778 "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
|
1779 (with-current-buffer buffer |
a74dd42cf01d
(gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48662
diff
changeset
|
1780 (or gdb-buffer-type overlay-arrow-position))) |
48292 | 1781 |
1782 ;;; The way we abuse the dedicated-p flag is pretty gross, but seems | |
1783 ;;; to do the right thing. Seeing as there is no way for Lisp code to | |
1784 ;;; get at the use_time field of a window, I'm not sure there exists a | |
1785 ;;; more elegant solution without writing C code. | |
1786 | |
1787 (defun gdb-display-buffer (buf &optional size) | |
1788 (let ((must-split nil) | |
1789 (answer nil)) | |
1790 (unwind-protect | |
1791 (progn | |
1792 (walk-windows | |
1793 '(lambda (win) | |
1794 (if (gdb-protected-buffer-p (window-buffer win)) | |
1795 (set-window-dedicated-p win t)))) | |
1796 (setq answer (get-buffer-window buf)) | |
1797 (if (not answer) | |
1798 (let ((window (get-lru-window))) | |
1799 (if window | |
1800 (progn | |
1801 (set-window-buffer window buf) | |
1802 (setq answer window)) | |
1803 (setq must-split t))))) | |
1804 (walk-windows | |
1805 '(lambda (win) | |
1806 (if (gdb-protected-buffer-p (window-buffer win)) | |
1807 (set-window-dedicated-p win nil))))) | |
1808 (if must-split | |
1809 (let* ((largest (get-largest-window)) | |
1810 (cur-size (window-height largest)) | |
1811 (new-size (and size (< size cur-size) (- cur-size size)))) | |
1812 (setq answer (split-window largest new-size)) | |
1813 (set-window-buffer answer buf))) | |
1814 answer)) | |
48300
69646014abb3
Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents:
48292
diff
changeset
|
1815 |
48292 | 1816 (defun gdb-display-source-buffer (buffer) |
1817 (set-window-buffer gdb-source-window buffer)) | |
1818 | |
1819 | |
1820 ;;; Shared keymap initialization: | |
1821 | |
48515
3216cd45d6d2
Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents:
48498
diff
changeset
|
1822 (defun gdb-display-gdb-buffer () |
48659
4d69c0f01cc0
(gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48641
diff
changeset
|
1823 (interactive) |
48292 | 1824 (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
|
1825 (gdb-get-create-instance-buffer 'gdba))) |
48292 | 1826 |
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
|
1827 ;; FIXME: changing GUD's behavior: bad bad bad!!! |
48292 | 1828 (define-key gud-minor-mode-map "\C-c\M-\C-r" 'gdb-display-registers-buffer) |
1829 (define-key gud-minor-mode-map "\C-c\M-\C-f" 'gdb-display-stack-buffer) | |
1830 (define-key gud-minor-mode-map "\C-c\M-\C-b" 'gdb-display-breakpoints-buffer) | |
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] |
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
|
1834 `(menu-item "GDB-Windows" ,menu :visible (memq gud-minor-mode '(gdba)))) |
b092bff770ec
Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48659
diff
changeset
|
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] |
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
|
1850 `(menu-item "GDB-Frames" ,menu :visible (memq gud-minor-mode '(gdba)))) |
b092bff770ec
Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48659
diff
changeset
|
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 |