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