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