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