Mercurial > emacs
annotate lisp/progmodes/gdb-ui.el @ 55513:6bdc57e42324
(compile): Add universal prefix arg.
(compilation-error-regexp-alist-alist): Add edg patterns.
author | Daniel Pfeiffer <occitan@esperanto.org> |
---|---|
date | Mon, 10 May 2004 21:00:00 +0000 |
parents | e266c6d6bd7a |
children | ed6e91c53c82 |
rev | line source |
---|---|
54538 | 1 ;;; gdb-ui.el --- User Interface for running GDB |
2 | |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
3 ;; Author: Nick Roberts <nickrob@gnu.org> |
54538 | 4 ;; Maintainer: FSF |
5 ;; Keywords: unix, tools | |
6 | |
7 ;; Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; This mode acts as a graphical user interface to GDB. You can interact with | |
29 ;; GDB through the GUD buffer in the usual way, but there are also further | |
30 ;; buffers which control the execution and describe the state of your program. | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
31 ;; It separates the input/output of your program from that of GDB, if |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
32 ;; required, and displays expressions and their current values in their own |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
33 ;; buffers. It also uses features of Emacs 21 such as the display margin for |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
34 ;; breakpoints, and the toolbar (see the GDB Graphical Interface section in |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
35 ;; the Emacs info manual). |
54538 | 36 |
37 ;; Start the debugger with M-x gdba. | |
38 | |
39 ;; This file has evolved from gdba.el from GDB 5.0 written by Tom Lord and Jim | |
40 ;; Kingdon and uses GDB's annotation interface. You don't need to know about | |
41 ;; annotations to use this mode as a debugger, but if you are interested | |
42 ;; developing the mode itself, then see the Annotations section in the GDB | |
43 ;; info manual. Some GDB/MI commands are also used through th CLI command | |
44 ;; 'interpreter mi <mi-command>'. | |
45 ;; | |
46 ;; Known Bugs: | |
47 ;; | |
48 | |
49 ;;; Code: | |
50 | |
51 (require 'gud) | |
52 | |
53 (defvar gdb-current-address "main" "Initialisation for Assembler buffer.") | |
54 (defvar gdb-previous-address nil) | |
55 (defvar gdb-previous-frame nil) | |
56 (defvar gdb-current-frame "main") | |
57 (defvar gdb-current-language nil) | |
58 (defvar gdb-view-source t "Non-nil means that source code can be viewed.") | |
59 (defvar gdb-selected-view 'source "Code type that user wishes to view.") | |
60 (defvar gdb-var-list nil "List of variables in watch window") | |
61 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.") | |
62 (defvar gdb-buffer-type nil) | |
63 (defvar gdb-overlay-arrow-position nil) | |
64 (defvar gdb-variables '() | |
65 "A list of variables that are local to the GUD buffer.") | |
66 | |
67 ;;;###autoload | |
68 (defun gdba (command-line) | |
69 "Run gdb on program FILE in buffer *gud-FILE*. | |
70 The directory containing FILE becomes the initial working directory | |
71 and source-file directory for your debugger. | |
72 | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
73 If `gdb-many-windows' is nil (the default value) then gdb just |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
74 pops up the GUD buffer unless `gdb-show-main' is t. In this case |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
75 it starts with two windows: one displaying the GUD buffer and the |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
76 other with the source file with the main routine of the debugee. |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
77 |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
78 If `gdb-many-windows' is t, regardless of the value of |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
79 `gdb-show-main', the layout below will appear unless |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
80 `gdb-use-inferior-io-buffer' is nil when the source buffer |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
81 occupies the full width of the frame. Keybindings are given in |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
82 relevant buffer. |
54538 | 83 |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
84 Watch expressions appear in the speedbar/slowbar. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
85 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
86 The following interactive lisp functions help control operation : |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
87 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
88 `gdb-many-windows' - Toggle the number of windows gdb uses. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
89 `gdb-restore-windows' - To restore the window layout. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
90 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
91 See Info node `(emacs)GDB Graphical Interface' for a more |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
92 detailed description of this mode. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
93 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
94 |
54538 | 95 --------------------------------------------------------------------- |
96 GDB Toolbar | |
97 --------------------------------------------------------------------- | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
98 GUD buffer (I/O of GDB) | Locals buffer |
54538 | 99 | |
100 | | |
101 | | |
102 --------------------------------------------------------------------- | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
103 Source buffer | Input/Output (of debugee) buffer |
54538 | 104 | (comint-mode) |
105 | | |
106 | | |
107 | | |
108 | | |
109 | | |
110 | | |
111 --------------------------------------------------------------------- | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
112 Stack buffer | Breakpoints buffer |
54538 | 113 RET gdb-frames-select | SPC gdb-toggle-breakpoint |
114 | RET gdb-goto-breakpoint | |
115 | d gdb-delete-breakpoint | |
116 --------------------------------------------------------------------- | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
117 " |
54538 | 118 ;; |
119 (interactive (list (gud-query-cmdline 'gdba))) | |
120 ;; | |
121 ;; Let's start with a basic gud-gdb buffer and then modify it a bit. | |
122 (gdb command-line) | |
123 (gdb-ann3)) | |
124 | |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
125 (defvar gdb-debug-log nil) |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
126 |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
127 (defcustom gdb-enable-debug-log nil |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
128 "Non-nil means record the process input and output in `gdb-debug-log'." |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
129 :type 'boolean |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
130 :group 'gud) |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
131 |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
132 (defcustom gdb-use-inferior-io-buffer nil |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
133 "Non-nil means display output from the inferior in a separate buffer." |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
134 :type 'boolean |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
135 :group 'gud) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
136 |
54538 | 137 (defun gdb-ann3 () |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
138 (setq gdb-debug-log nil) |
54538 | 139 (set (make-local-variable 'gud-minor-mode) 'gdba) |
140 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter) | |
141 ;; | |
142 (gud-def gud-break (if (not (string-equal mode-name "Machine")) | |
143 (gud-call "break %f:%l" arg) | |
144 (save-excursion | |
145 (beginning-of-line) | |
146 (forward-char 2) | |
147 (gud-call "break *%a" arg))) | |
148 "\C-b" "Set breakpoint at current line or address.") | |
149 ;; | |
150 (gud-def gud-remove (if (not (string-equal mode-name "Machine")) | |
151 (gud-call "clear %f:%l" arg) | |
152 (save-excursion | |
153 (beginning-of-line) | |
154 (forward-char 2) | |
155 (gud-call "clear *%a" arg))) | |
156 "\C-d" "Remove breakpoint at current line or address.") | |
157 ;; | |
158 (gud-def gud-until (if (not (string-equal mode-name "Machine")) | |
159 (gud-call "until %f:%l" arg) | |
160 (save-excursion | |
161 (beginning-of-line) | |
162 (forward-char 2) | |
163 (gud-call "until *%a" arg))) | |
164 "\C-u" "Continue to current line or address.") | |
165 | |
166 (define-key gud-minor-mode-map [left-margin mouse-1] | |
167 'gdb-mouse-toggle-breakpoint) | |
168 (define-key gud-minor-mode-map [left-fringe mouse-1] | |
169 'gdb-mouse-toggle-breakpoint) | |
170 | |
171 (setq comint-input-sender 'gdb-send) | |
172 ;; | |
173 ;; (re-)initialise | |
174 (setq gdb-current-address "main") | |
175 (setq gdb-previous-address nil) | |
176 (setq gdb-previous-frame nil) | |
177 (setq gdb-current-frame "main") | |
178 (setq gdb-view-source t) | |
179 (setq gdb-selected-view 'source) | |
180 (setq gdb-var-list nil) | |
181 (setq gdb-var-changed nil) | |
182 (setq gdb-first-prompt nil) | |
183 ;; | |
184 (mapc 'make-local-variable gdb-variables) | |
185 (setq gdb-buffer-type 'gdba) | |
186 ;; | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
187 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) |
54538 | 188 ;; |
189 (if (eq window-system 'w32) | |
190 (gdb-enqueue-input (list "set new-console off\n" 'ignore))) | |
191 (gdb-enqueue-input (list "set height 0\n" 'ignore)) | |
192 ;; find source file and compilation directory here | |
193 (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program | |
194 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program | |
195 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) | |
196 ;; | |
197 (run-hooks 'gdba-mode-hook)) | |
198 | |
199 (defcustom gdb-use-colon-colon-notation nil | |
200 "Non-nil means use FUNCTION::VARIABLE format to display variables in the | |
201 speedbar." | |
202 :type 'boolean | |
203 :group 'gud) | |
204 | |
205 (defun gud-watch () | |
206 "Watch expression at point." | |
207 (interactive) | |
208 (require 'tooltip) | |
209 (let ((expr (tooltip-identifier-from-point (point)))) | |
210 (if (and (string-equal gdb-current-language "c") | |
211 gdb-use-colon-colon-notation) | |
212 (setq expr (concat gdb-current-frame "::" expr))) | |
213 (catch 'already-watched | |
214 (dolist (var gdb-var-list) | |
215 (if (string-equal expr (car var)) (throw 'already-watched nil))) | |
216 (set-text-properties 0 (length expr) nil expr) | |
217 (gdb-enqueue-input | |
218 (list (concat "server interpreter mi \"-var-create - * " expr "\"\n") | |
219 `(lambda () (gdb-var-create-handler ,expr)))))) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
220 (select-window (get-buffer-window gud-comint-buffer 'visible))) |
54538 | 221 |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
222 (defun gdb-goto-info () |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
223 "Go to Emacs info node: GDB Graphical Interface." |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
224 (interactive) |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
225 (select-frame (make-frame)) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
226 (require 'info) |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
227 (Info-goto-node "(emacs)GDB Graphical Interface")) |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
228 |
54538 | 229 (defconst gdb-var-create-regexp |
230 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"") | |
231 | |
232 (defun gdb-var-create-handler (expr) | |
233 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
234 (goto-char (point-min)) | |
235 (if (re-search-forward gdb-var-create-regexp nil t) | |
236 (let ((var (list expr | |
237 (match-string 1) | |
238 (match-string 2) | |
239 (match-string 3) | |
240 nil nil))) | |
241 (push var gdb-var-list) | |
242 (setq speedbar-update-flag t) | |
243 (speedbar 1) | |
244 (if (equal (nth 2 var) "0") | |
245 (gdb-enqueue-input | |
246 (list (concat "server interpreter mi \"-var-evaluate-expression " | |
247 (nth 1 var) "\"\n") | |
248 `(lambda () (gdb-var-evaluate-expression-handler | |
249 ,(nth 1 var) nil)))) | |
250 (setq gdb-var-changed t))) | |
251 (if (re-search-forward "Undefined command" nil t) | |
252 (message "Watching expressions requires gdb 6.0 onwards") | |
253 (message "No symbol %s in current context." expr))))) | |
254 | |
255 (defun gdb-var-evaluate-expression-handler (varnum changed) | |
256 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
257 (goto-char (point-min)) | |
258 (re-search-forward ".*value=\"\\(.*?\\)\"" nil t) | |
259 (catch 'var-found | |
260 (let ((var-list nil) (num 0)) | |
261 (dolist (var gdb-var-list) | |
262 (if (string-equal varnum (cadr var)) | |
263 (progn | |
264 (if changed (setcar (nthcdr 5 var) t)) | |
265 (setcar (nthcdr 4 var) (match-string 1)) | |
266 (setcar (nthcdr num gdb-var-list) var) | |
267 (throw 'var-found nil))) | |
268 (setq num (+ num 1)))))) | |
269 (setq gdb-var-changed t)) | |
270 | |
271 (defun gdb-var-list-children (varnum) | |
272 (gdb-enqueue-input | |
273 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n") | |
274 `(lambda () (gdb-var-list-children-handler ,varnum))))) | |
275 | |
276 (defconst gdb-var-list-children-regexp | |
277 "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\"") | |
278 | |
279 (defun gdb-var-list-children-handler (varnum) | |
280 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
281 (goto-char (point-min)) | |
282 (let ((var-list nil)) | |
283 (catch 'child-already-watched | |
284 (dolist (var gdb-var-list) | |
285 (if (string-equal varnum (cadr var)) | |
286 (progn | |
287 (push var var-list) | |
288 (while (re-search-forward gdb-var-list-children-regexp nil t) | |
289 (let ((varchild (list (match-string 2) | |
290 (match-string 1) | |
291 (match-string 3) | |
292 nil nil nil))) | |
293 (if (looking-at ",type=\"\\(.*?\\)\"") | |
294 (setcar (nthcdr 3 varchild) (match-string 1))) | |
295 (dolist (var1 gdb-var-list) | |
296 (if (string-equal (cadr var1) (cadr varchild)) | |
297 (throw 'child-already-watched nil))) | |
298 (push varchild var-list) | |
299 (if (equal (nth 2 varchild) "0") | |
300 (gdb-enqueue-input | |
301 (list | |
302 (concat | |
303 "server interpreter mi \"-var-evaluate-expression " | |
304 (nth 1 varchild) "\"\n") | |
305 `(lambda () (gdb-var-evaluate-expression-handler | |
306 ,(nth 1 varchild) nil)))))))) | |
307 (push var var-list))) | |
308 (setq gdb-var-list (nreverse var-list)))))) | |
309 | |
310 (defun gdb-var-update () | |
311 (if (not (member 'gdb-var-update (gdb-get-pending-triggers))) | |
312 (progn | |
313 (gdb-enqueue-input (list "server interpreter mi \"-var-update *\"\n" | |
314 'gdb-var-update-handler)) | |
315 (gdb-set-pending-triggers (cons 'gdb-var-update | |
316 (gdb-get-pending-triggers)))))) | |
317 | |
318 (defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"") | |
319 | |
320 (defun gdb-var-update-handler () | |
321 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
322 (goto-char (point-min)) | |
323 (while (re-search-forward gdb-var-update-regexp nil t) | |
324 (let ((varnum (match-string 1))) | |
325 (gdb-enqueue-input | |
326 (list (concat "server interpreter mi \"-var-evaluate-expression " | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
327 varnum "\"\n") |
54538 | 328 `(lambda () (gdb-var-evaluate-expression-handler |
329 ,varnum t))))))) | |
330 (gdb-set-pending-triggers | |
331 (delq 'gdb-var-update (gdb-get-pending-triggers)))) | |
332 | |
333 (defun gdb-var-delete () | |
334 "Delete watched expression from the speedbar." | |
335 (interactive) | |
336 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)) | |
337 (let ((text (speedbar-line-text))) | |
338 (string-match "\\(\\S-+\\)" text) | |
339 (let* ((expr (match-string 1 text)) | |
340 (var (assoc expr gdb-var-list)) | |
341 (varnum (cadr var))) | |
342 (unless (string-match "\\." varnum) | |
343 (gdb-enqueue-input | |
344 (list (concat "server interpreter mi \"-var-delete " | |
345 varnum "\"\n") | |
346 'ignore)) | |
347 (setq gdb-var-list (delq var gdb-var-list)) | |
348 (dolist (varchild gdb-var-list) | |
349 (if (string-match (concat (nth 1 var) "\\.") (nth 1 varchild)) | |
350 (setq gdb-var-list (delq varchild gdb-var-list)))) | |
351 (setq gdb-var-changed t)))))) | |
352 | |
353 (defun gdb-edit-value (text token indent) | |
354 "Assign a value to a variable displayed in the speedbar" | |
355 (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list)) | |
356 (varnum (cadr var)) (value)) | |
357 (setq value (read-string "New value: ")) | |
358 (gdb-enqueue-input | |
359 (list (concat "server interpreter mi \"-var-assign " | |
360 varnum " " value "\"\n") | |
361 'ignore)))) | |
362 | |
363 (defcustom gdb-show-changed-values t | |
364 "Non-nil means use font-lock-warning-face to display values that have | |
365 recently changed in the speedbar." | |
366 :type 'boolean | |
367 :group 'gud) | |
368 | |
369 (defun gdb-speedbar-expand-node (text token indent) | |
370 "Expand the node the user clicked on. | |
371 TEXT is the text of the button we clicked on, a + or - item. | |
372 TOKEN is data related to this node. | |
373 INDENT is the current indentation depth." | |
374 (cond ((string-match "+" text) ;expand this node | |
375 (gdb-var-list-children token)) | |
376 ((string-match "-" text) ;contract this node | |
377 (dolist (var gdb-var-list) | |
378 (if (string-match (concat token "\\.") (nth 1 var)) | |
379 (setq gdb-var-list (delq var gdb-var-list)))) | |
380 (setq gdb-var-changed t)))) | |
381 | |
382 | |
383 ;; ====================================================================== | |
384 ;; | |
385 ;; In this world, there are gdb variables (of unspecified | |
386 ;; representation) and buffers associated with those objects. | |
387 ;; The list of variables is built up by the expansions of | |
388 ;; def-gdb-variable | |
389 | |
390 (defmacro def-gdb-var (root-symbol &optional default doc) | |
391 (let* ((root (symbol-name root-symbol)) | |
392 (accessor (intern (concat "gdb-get-" root))) | |
393 (setter (intern (concat "gdb-set-" root))) | |
394 (name (intern (concat "gdb-" root)))) | |
395 `(progn | |
396 (defvar ,name ,default ,doc) | |
397 (if (not (memq ',name gdb-variables)) | |
398 (push ',name gdb-variables)) | |
399 (defun ,accessor () | |
400 (buffer-local-value ',name gud-comint-buffer)) | |
401 (defun ,setter (val) | |
402 (with-current-buffer gud-comint-buffer | |
403 (setq ,name val)))))) | |
404 | |
405 (def-gdb-var buffer-type nil | |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
406 "One of the symbols bound in `gdb-buffer-rules'.") |
54538 | 407 |
408 (def-gdb-var burst "" | |
409 "A string of characters from gdb that have not yet been processed.") | |
410 | |
411 (def-gdb-var input-queue () | |
412 "A list of gdb command objects.") | |
413 | |
414 (def-gdb-var prompting nil | |
415 "True when gdb is idle with no pending input.") | |
416 | |
417 (def-gdb-var output-sink 'user | |
418 "The disposition of the output of the current gdb command. | |
419 Possible values are these symbols: | |
420 | |
421 user -- gdb output should be copied to the GUD buffer | |
422 for the user to see. | |
423 | |
424 inferior -- gdb output should be copied to the inferior-io buffer | |
425 | |
426 pre-emacs -- output should be ignored util the post-prompt | |
427 annotation is received. Then the output-sink | |
428 becomes:... | |
429 emacs -- output should be collected in the partial-output-buffer | |
430 for subsequent processing by a command. This is the | |
431 disposition of output generated by commands that | |
432 gdb mode sends to gdb on its own behalf. | |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
433 post-emacs -- ignore output until the prompt annotation is |
54538 | 434 received, then go to USER disposition. |
435 ") | |
436 | |
437 (def-gdb-var current-item nil | |
438 "The most recent command item sent to gdb.") | |
439 | |
440 (def-gdb-var pending-triggers '() | |
441 "A list of trigger functions that have run later than their output | |
442 handlers.") | |
443 | |
444 ;; end of gdb variables | |
445 | |
446 (defun gdb-get-target-string () | |
447 (with-current-buffer gud-comint-buffer | |
448 gud-target-name)) | |
449 | |
450 | |
451 ;; | |
452 ;; gdb buffers. | |
453 ;; | |
454 ;; Each buffer has a TYPE -- a symbol that identifies the function | |
455 ;; of that particular buffer. | |
456 ;; | |
457 ;; The usual gdb interaction buffer is given the type `gdba' and | |
458 ;; is constructed specially. | |
459 ;; | |
460 ;; Others are constructed by gdb-get-create-buffer and | |
461 ;; named according to the rules set forth in the gdb-buffer-rules-assoc | |
462 | |
463 (defvar gdb-buffer-rules-assoc '()) | |
464 | |
465 (defun gdb-get-buffer (key) | |
466 "Return the gdb buffer tagged with type KEY. | |
467 The key should be one of the cars in `gdb-buffer-rules-assoc'." | |
468 (save-excursion | |
469 (gdb-look-for-tagged-buffer key (buffer-list)))) | |
470 | |
471 (defun gdb-get-create-buffer (key) | |
472 "Create a new gdb buffer of the type specified by KEY. | |
473 The key should be one of the cars in `gdb-buffer-rules-assoc'." | |
474 (or (gdb-get-buffer key) | |
475 (let* ((rules (assoc key gdb-buffer-rules-assoc)) | |
476 (name (funcall (gdb-rules-name-maker rules))) | |
477 (new (get-buffer-create name))) | |
478 (with-current-buffer new | |
479 ;; FIXME: This should be set after calling the function, since the | |
480 ;; function should run kill-all-local-variables. | |
481 (set (make-local-variable 'gdb-buffer-type) key) | |
482 (if (cdr (cdr rules)) | |
483 (funcall (car (cdr (cdr rules))))) | |
484 (set (make-local-variable 'gud-comint-buffer) gud-comint-buffer) | |
485 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
486 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | |
487 new)))) | |
488 | |
489 (defun gdb-rules-name-maker (rules) (car (cdr rules))) | |
490 | |
491 (defun gdb-look-for-tagged-buffer (key bufs) | |
492 (let ((retval nil)) | |
493 (while (and (not retval) bufs) | |
494 (set-buffer (car bufs)) | |
495 (if (eq gdb-buffer-type key) | |
496 (setq retval (car bufs))) | |
497 (setq bufs (cdr bufs))) | |
498 retval)) | |
499 | |
500 ;; | |
501 ;; This assoc maps buffer type symbols to rules. Each rule is a list of | |
502 ;; at least one and possible more functions. The functions have these | |
503 ;; roles in defining a buffer type: | |
504 ;; | |
505 ;; NAME - Return a name for this buffer type. | |
506 ;; | |
507 ;; The remaining function(s) are optional: | |
508 ;; | |
509 ;; MODE - called in a new buffer with no arguments, should establish | |
510 ;; the proper mode for the buffer. | |
511 ;; | |
512 | |
513 (defun gdb-set-buffer-rules (buffer-type &rest rules) | |
514 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc))) | |
515 (if binding | |
516 (setcdr binding rules) | |
517 (push (cons buffer-type rules) | |
518 gdb-buffer-rules-assoc)))) | |
519 | |
520 ;; GUD buffers are an exception to the rules | |
521 (gdb-set-buffer-rules 'gdba 'error) | |
522 | |
523 ;; | |
524 ;; Partial-output buffer : This accumulates output from a command executed on | |
525 ;; behalf of emacs (rather than the user). | |
526 ;; | |
527 (gdb-set-buffer-rules 'gdb-partial-output-buffer | |
528 'gdb-partial-output-name) | |
529 | |
530 (defun gdb-partial-output-name () | |
531 (concat "*partial-output-" | |
532 (gdb-get-target-string) | |
533 "*")) | |
534 | |
535 | |
536 (gdb-set-buffer-rules 'gdb-inferior-io | |
537 'gdb-inferior-io-name | |
538 'gdb-inferior-io-mode) | |
539 | |
540 (defun gdb-inferior-io-name () | |
541 (concat "*input/output of " | |
542 (gdb-get-target-string) | |
543 "*")) | |
544 | |
545 (defvar gdb-inferior-io-mode-map | |
546 (let ((map (make-sparse-keymap))) | |
547 (define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt) | |
548 (define-key map "\C-c\C-z" 'gdb-inferior-io-stop) | |
549 (define-key map "\C-c\C-\\" 'gdb-inferior-io-quit) | |
550 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof) | |
551 map)) | |
552 | |
553 (define-derived-mode gdb-inferior-io-mode comint-mode "Debuggee I/O" | |
554 "Major mode for gdb inferior-io." | |
555 :syntax-table nil :abbrev-table nil | |
556 ;; We want to use comint because it has various nifty and familiar | |
557 ;; features. We don't need a process, but comint wants one, so create | |
558 ;; a dummy one. | |
559 (make-comint-in-buffer | |
560 (substring (buffer-name) 1 (- (length (buffer-name)) 1)) | |
561 (current-buffer) "hexl") | |
562 (setq comint-input-sender 'gdb-inferior-io-sender)) | |
563 | |
564 (defun gdb-inferior-io-sender (proc string) | |
565 ;; PROC is the pseudo-process created to satisfy comint. | |
566 (with-current-buffer (process-buffer proc) | |
567 (setq proc (get-buffer-process gud-comint-buffer)) | |
568 (process-send-string proc string) | |
569 (process-send-string proc "\n"))) | |
570 | |
571 (defun gdb-inferior-io-interrupt () | |
572 "Interrupt the program being debugged." | |
573 (interactive) | |
574 (interrupt-process | |
575 (get-buffer-process gud-comint-buffer) comint-ptyp)) | |
576 | |
577 (defun gdb-inferior-io-quit () | |
578 "Send quit signal to the program being debugged." | |
579 (interactive) | |
580 (quit-process | |
581 (get-buffer-process gud-comint-buffer) comint-ptyp)) | |
582 | |
583 (defun gdb-inferior-io-stop () | |
584 "Stop the program being debugged." | |
585 (interactive) | |
586 (stop-process | |
587 (get-buffer-process gud-comint-buffer) comint-ptyp)) | |
588 | |
589 (defun gdb-inferior-io-eof () | |
590 "Send end-of-file to the program being debugged." | |
591 (interactive) | |
592 (process-send-eof | |
593 (get-buffer-process gud-comint-buffer))) | |
594 | |
595 | |
596 ;; | |
597 ;; gdb communications | |
598 ;; | |
599 | |
600 ;; INPUT: things sent to gdb | |
601 ;; | |
602 ;; The queues are lists. Each element is either a string (indicating user or | |
603 ;; user-like input) or a list of the form: | |
604 ;; | |
605 ;; (INPUT-STRING HANDLER-FN) | |
606 ;; | |
607 ;; The handler function will be called from the partial-output buffer when the | |
608 ;; command completes. This is the way to write commands which invoke gdb | |
609 ;; commands autonomously. | |
610 ;; | |
611 ;; These lists are consumed tail first. | |
612 ;; | |
613 | |
614 (defun gdb-send (proc string) | |
615 "A comint send filter for gdb. | |
616 This filter may simply queue output for a later time." | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
617 (if gud-running |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
618 (process-send-string proc (concat string "\n")) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
619 (gdb-enqueue-input (concat string "\n")))) |
54538 | 620 |
621 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it | |
622 ;; is a query, or other non-top-level prompt. | |
623 | |
624 (defun gdb-enqueue-input (item) | |
625 (if (gdb-get-prompting) | |
626 (progn | |
627 (gdb-send-item item) | |
628 (gdb-set-prompting nil)) | |
629 (gdb-set-input-queue | |
630 (cons item (gdb-get-input-queue))))) | |
631 | |
632 (defun gdb-dequeue-input () | |
633 (let ((queue (gdb-get-input-queue))) | |
634 (and queue | |
635 (let ((last (car (last queue)))) | |
636 (unless (nbutlast queue) (gdb-set-input-queue '())) | |
637 last)))) | |
638 | |
639 | |
640 ;; | |
641 ;; output -- things gdb prints to emacs | |
642 ;; | |
643 ;; GDB output is a stream interrupted by annotations. | |
644 ;; Annotations can be recognized by their beginning | |
645 ;; with \C-j\C-z\C-z<tag><opt>\C-j | |
646 ;; | |
647 ;; The tag is a string obeying symbol syntax. | |
648 ;; | |
649 ;; The optional part `<opt>' can be either the empty string | |
650 ;; or a space followed by more data relating to the annotation. | |
651 ;; For example, the SOURCE annotation is followed by a filename, | |
652 ;; line number and various useless goo. This data must not include | |
653 ;; any newlines. | |
654 ;; | |
655 | |
656 (defcustom gud-gdba-command-name "gdb -annotate=3" | |
657 "Default command to execute an executable under the GDB-UI debugger." | |
658 :type 'string | |
659 :group 'gud) | |
660 | |
661 (defvar gdb-annotation-rules | |
662 '(("pre-prompt" gdb-pre-prompt) | |
663 ("prompt" gdb-prompt) | |
664 ("commands" gdb-subprompt) | |
665 ("overload-choice" gdb-subprompt) | |
666 ("query" gdb-subprompt) | |
55507
e266c6d6bd7a
(gdb-annotation-rules): Add nquery annotation
Nick Roberts <nickrob@snap.net.nz>
parents:
55400
diff
changeset
|
667 ("nquery" gdb-subprompt) |
54538 | 668 ("prompt-for-continue" gdb-subprompt) |
669 ("post-prompt" gdb-post-prompt) | |
670 ("source" gdb-source) | |
671 ("starting" gdb-starting) | |
672 ("exited" gdb-stopping) | |
673 ("signalled" gdb-stopping) | |
674 ("signal" gdb-stopping) | |
675 ("breakpoint" gdb-stopping) | |
676 ("watchpoint" gdb-stopping) | |
677 ("frame-begin" gdb-frame-begin) | |
678 ("stopped" gdb-stopped) | |
679 ) "An assoc mapping annotation tags to functions which process them.") | |
680 | |
681 (defconst gdb-source-spec-regexp | |
682 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)") | |
683 | |
684 ;; Do not use this except as an annotation handler. | |
685 (defun gdb-source (args) | |
686 (string-match gdb-source-spec-regexp args) | |
687 ;; Extract the frame position from the marker. | |
688 (setq gud-last-frame | |
689 (cons | |
690 (match-string 1 args) | |
691 (string-to-int (match-string 2 args)))) | |
692 (setq gdb-current-address (match-string 3 args)) | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
693 (setq gdb-view-source t) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
694 ;; cover for auto-display output which comes *before* |
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
695 ;; stopped annotation |
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
696 (if (eq (gdb-get-output-sink) 'inferior) (gdb-set-output-sink 'user))) |
54538 | 697 |
698 (defun gdb-send-item (item) | |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
699 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) |
54538 | 700 (gdb-set-current-item item) |
701 (if (stringp item) | |
702 (progn | |
703 (gdb-set-output-sink 'user) | |
704 (process-send-string (get-buffer-process gud-comint-buffer) item)) | |
705 (progn | |
706 (gdb-clear-partial-output) | |
707 (gdb-set-output-sink 'pre-emacs) | |
708 (process-send-string (get-buffer-process gud-comint-buffer) | |
709 (car item))))) | |
710 | |
711 (defun gdb-pre-prompt (ignored) | |
712 "An annotation handler for `pre-prompt'. This terminates the collection of | |
713 output from a previous command if that happens to be in effect." | |
714 (let ((sink (gdb-get-output-sink))) | |
715 (cond | |
716 ((eq sink 'user) t) | |
717 ((eq sink 'emacs) | |
718 (gdb-set-output-sink 'post-emacs)) | |
719 (t | |
720 (gdb-set-output-sink 'user) | |
721 (error "Phase error in gdb-pre-prompt (got %s)" sink))))) | |
722 | |
723 (defun gdb-prompt (ignored) | |
724 "An annotation handler for `prompt'. | |
725 This sends the next command (if any) to gdb." | |
726 (when gdb-first-prompt (gdb-ann3)) | |
727 (let ((sink (gdb-get-output-sink))) | |
728 (cond | |
729 ((eq sink 'user) t) | |
730 ((eq sink 'post-emacs) | |
731 (gdb-set-output-sink 'user) | |
732 (let ((handler | |
733 (car (cdr (gdb-get-current-item))))) | |
734 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
735 (funcall handler)))) | |
736 (t | |
737 (gdb-set-output-sink 'user) | |
738 (error "Phase error in gdb-prompt (got %s)" sink)))) | |
739 (let ((input (gdb-dequeue-input))) | |
740 (if input | |
741 (gdb-send-item input) | |
742 (progn | |
743 (gdb-set-prompting t) | |
744 (gud-display-frame))))) | |
745 | |
746 (defun gdb-subprompt (ignored) | |
747 "An annotation handler for non-top-level prompts." | |
748 (gdb-set-prompting t)) | |
749 | |
750 (defun gdb-starting (ignored) | |
751 "An annotation handler for `starting'. This says that I/O for the | |
752 subprocess is now the program being debugged, not GDB." | |
753 (let ((sink (gdb-get-output-sink))) | |
754 (cond | |
755 ((eq sink 'user) | |
756 (progn | |
757 (setq gud-running t) | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
758 (if gdb-use-inferior-io-buffer |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
759 (gdb-set-output-sink 'inferior)))) |
54538 | 760 (t (error "Unexpected `starting' annotation"))))) |
761 | |
762 (defun gdb-stopping (ignored) | |
763 "An annotation handler for `exited' and other annotations which say that I/O | |
764 for the subprocess is now GDB, not the program being debugged." | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
765 (if gdb-use-inferior-io-buffer |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
766 (let ((sink (gdb-get-output-sink))) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
767 (cond |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
768 ((eq sink 'inferior) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
769 (gdb-set-output-sink 'user)) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
770 (t (error "Unexpected stopping annotation")))))) |
54538 | 771 |
772 (defun gdb-frame-begin (ignored) | |
773 (let ((sink (gdb-get-output-sink))) | |
774 (cond | |
775 ((eq sink 'inferior) | |
776 (gdb-set-output-sink 'user)) | |
777 ((eq sink 'user) t) | |
778 ((eq sink 'emacs) t) | |
779 (t (error "Unexpected frame-begin annotation (%S)" sink))))) | |
780 | |
781 (defun gdb-stopped (ignored) | |
782 "An annotation handler for `stopped'. It is just like gdb-stopping, except | |
783 that if we already set the output sink to 'user in gdb-stopping, that is fine." | |
784 (setq gud-running nil) | |
785 (let ((sink (gdb-get-output-sink))) | |
786 (cond | |
787 ((eq sink 'inferior) | |
788 (gdb-set-output-sink 'user)) | |
789 ((eq sink 'user) t) | |
790 (t (error "Unexpected stopped annotation"))))) | |
791 | |
792 (defun gdb-post-prompt (ignored) | |
793 "An annotation handler for `post-prompt'. This begins the collection of | |
794 output from the current command if that happens to be appropriate." | |
795 (if (not (gdb-get-pending-triggers)) | |
796 (progn | |
797 (gdb-get-current-frame) | |
798 (gdb-invalidate-frames) | |
799 (gdb-invalidate-breakpoints) | |
800 (gdb-invalidate-assembler) | |
801 (gdb-invalidate-registers) | |
802 (gdb-invalidate-locals) | |
803 (gdb-invalidate-threads) | |
54617
9049edac1117
(gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54616
diff
changeset
|
804 (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3. |
9049edac1117
(gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54616
diff
changeset
|
805 ;; FIXME: with GDB-6 on Darwin, this might very well work. |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
806 (dolist (frame (frame-list)) |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
807 (when (string-equal (frame-parameter frame 'name) "Speedbar") |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
808 (setq gdb-var-changed t) ; force update |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
809 (dolist (var gdb-var-list) |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
810 (setcar (nthcdr 5 var) nil)))) |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
811 (gdb-var-update)))) |
54538 | 812 (let ((sink (gdb-get-output-sink))) |
813 (cond | |
814 ((eq sink 'user) t) | |
815 ((eq sink 'pre-emacs) | |
816 (gdb-set-output-sink 'emacs)) | |
817 (t | |
818 (gdb-set-output-sink 'user) | |
819 (error "Phase error in gdb-post-prompt (got %s)" sink))))) | |
820 | |
821 (defun gud-gdba-marker-filter (string) | |
822 "A gud marker filter for gdb. Handle a burst of output from GDB." | |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
823 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log)) |
54538 | 824 ;; Recall the left over gud-marker-acc from last time |
825 (setq gud-marker-acc (concat gud-marker-acc string)) | |
826 ;; Start accumulating output for the GUD buffer | |
827 (let ((output "")) | |
828 ;; | |
829 ;; Process all the complete markers in this chunk. | |
830 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc) | |
831 (let ((annotation (match-string 1 gud-marker-acc))) | |
832 ;; | |
833 ;; Stuff prior to the match is just ordinary output. | |
834 ;; It is either concatenated to OUTPUT or directed | |
835 ;; elsewhere. | |
836 (setq output | |
837 (gdb-concat-output | |
838 output | |
839 (substring gud-marker-acc 0 (match-beginning 0)))) | |
840 ;; | |
841 ;; Take that stuff off the gud-marker-acc. | |
842 (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) | |
843 ;; | |
844 ;; Parse the tag from the annotation, and maybe its arguments. | |
845 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) | |
846 (let* ((annotation-type (match-string 1 annotation)) | |
847 (annotation-arguments (match-string 2 annotation)) | |
848 (annotation-rule (assoc annotation-type | |
849 gdb-annotation-rules))) | |
850 ;; Call the handler for this annotation. | |
851 (if annotation-rule | |
852 (funcall (car (cdr annotation-rule)) | |
853 annotation-arguments) | |
854 ;; Else the annotation is not recognized. Ignore it silently, | |
855 ;; so that GDB can add new annotations without causing | |
856 ;; us to blow up. | |
857 )))) | |
858 ;; | |
859 ;; Does the remaining text end in a partial line? | |
860 ;; If it does, then keep part of the gud-marker-acc until we get more. | |
861 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" | |
862 gud-marker-acc) | |
863 (progn | |
864 ;; Everything before the potential marker start can be output. | |
865 (setq output | |
866 (gdb-concat-output output | |
867 (substring gud-marker-acc 0 | |
868 (match-beginning 0)))) | |
869 ;; | |
870 ;; Everything after, we save, to combine with later input. | |
871 (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0)))) | |
872 ;; | |
873 ;; In case we know the gud-marker-acc contains no partial annotations: | |
874 (progn | |
875 (setq output (gdb-concat-output output gud-marker-acc)) | |
876 (setq gud-marker-acc ""))) | |
877 output)) | |
878 | |
879 (defun gdb-concat-output (so-far new) | |
880 (let ((sink (gdb-get-output-sink ))) | |
881 (cond | |
882 ((eq sink 'user) (concat so-far new)) | |
883 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) | |
884 ((eq sink 'emacs) | |
885 (gdb-append-to-partial-output new) | |
886 so-far) | |
887 ((eq sink 'inferior) | |
888 (gdb-append-to-inferior-io new) | |
889 so-far) | |
890 (t (error "Bogon output sink %S" sink))))) | |
891 | |
892 (defun gdb-append-to-partial-output (string) | |
893 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
894 (goto-char (point-max)) | |
895 (insert string))) | |
896 | |
897 (defun gdb-clear-partial-output () | |
898 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
899 (erase-buffer))) | |
900 | |
901 (defun gdb-append-to-inferior-io (string) | |
902 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io) | |
903 (goto-char (point-max)) | |
904 (insert-before-markers string)) | |
905 (if (not (string-equal string "")) | |
906 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))) | |
907 | |
908 (defun gdb-clear-inferior-io () | |
909 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io) | |
910 (erase-buffer))) | |
911 | |
912 | |
913 ;; One trick is to have a command who's output is always available in a buffer | |
914 ;; of it's own, and is always up to date. We build several buffers of this | |
915 ;; type. | |
916 ;; | |
917 ;; There are two aspects to this: gdb has to tell us when the output for that | |
918 ;; command might have changed, and we have to be able to run the command | |
919 ;; behind the user's back. | |
920 ;; | |
921 ;; The output phasing associated with the variable gdb-output-sink | |
922 ;; help us to run commands behind the user's back. | |
923 ;; | |
924 ;; Below is the code for specificly managing buffers of output from one | |
925 ;; command. | |
926 ;; | |
927 | |
928 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES | |
929 ;; It adds an input for the command we are tracking. It should be the | |
930 ;; annotation rule binding of whatever gdb sends to tell us this command | |
931 ;; might have changed it's output. | |
932 ;; | |
933 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed. | |
934 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the | |
935 ;; input in the input queue (see comment about ``gdb communications'' above). | |
936 | |
937 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command | |
938 output-handler) | |
939 `(defun ,name (&optional ignored) | |
940 (if (and (,demand-predicate) | |
941 (not (member ',name | |
942 (gdb-get-pending-triggers)))) | |
943 (progn | |
944 (gdb-enqueue-input | |
945 (list ,gdb-command ',output-handler)) | |
946 (gdb-set-pending-triggers | |
947 (cons ',name | |
948 (gdb-get-pending-triggers))))))) | |
949 | |
950 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) | |
951 `(defun ,name () | |
952 (gdb-set-pending-triggers | |
953 (delq ',trigger | |
954 (gdb-get-pending-triggers))) | |
955 (let ((buf (gdb-get-buffer ',buf-key))) | |
956 (and buf | |
957 (with-current-buffer buf | |
958 (let ((p (point)) | |
959 (buffer-read-only nil)) | |
960 (erase-buffer) | |
961 (insert-buffer-substring (gdb-get-create-buffer | |
962 'gdb-partial-output-buffer)) | |
963 (goto-char p))))) | |
964 ;; put customisation here | |
965 (,custom-defun))) | |
966 | |
967 (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command | |
968 output-handler-name custom-defun) | |
969 `(progn | |
970 (def-gdb-auto-update-trigger ,trigger-name | |
971 ;; The demand predicate: | |
972 (lambda () (gdb-get-buffer ',buffer-key)) | |
973 ,gdb-command | |
974 ,output-handler-name) | |
975 (def-gdb-auto-update-handler ,output-handler-name | |
976 ,trigger-name ,buffer-key ,custom-defun))) | |
977 | |
978 | |
979 ;; | |
980 ;; Breakpoint buffer : This displays the output of `info breakpoints'. | |
981 ;; | |
982 (gdb-set-buffer-rules 'gdb-breakpoints-buffer | |
983 'gdb-breakpoints-buffer-name | |
984 'gdb-breakpoints-mode) | |
985 | |
986 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer | |
987 ;; This defines the auto update rule for buffers of type | |
988 ;; `gdb-breakpoints-buffer'. | |
989 ;; | |
990 ;; It defines a function to serve as the annotation handler that | |
991 ;; handles the `foo-invalidated' message. That function is called: | |
992 gdb-invalidate-breakpoints | |
993 ;; | |
994 ;; To update the buffer, this command is sent to gdb. | |
995 "server info breakpoints\n" | |
996 ;; | |
997 ;; This also defines a function to be the handler for the output | |
998 ;; from the command above. That function will copy the output into | |
999 ;; the appropriately typed buffer. That function will be called: | |
1000 gdb-info-breakpoints-handler | |
1001 ;; buffer specific functions | |
1002 gdb-info-breakpoints-custom) | |
1003 | |
1004 (defvar gdb-cdir nil "Compilation directory.") | |
1005 | |
1006 (defconst breakpoint-xpm-data "/* XPM */ | |
1007 static char *magick[] = { | |
1008 /* columns rows colors chars-per-pixel */ | |
1009 \"10 10 2 1\", | |
1010 \" c red\", | |
1011 \"+ c None\", | |
1012 /* pixels */ | |
1013 \"+++ +++\", | |
1014 \"++ ++\", | |
1015 \"+ +\", | |
1016 \" \", | |
1017 \" \", | |
1018 \" \", | |
1019 \" \", | |
1020 \"+ +\", | |
1021 \"++ ++\", | |
1022 \"+++ +++\", | |
1023 };" | |
1024 "XPM data used for breakpoint icon.") | |
1025 | |
1026 (defconst breakpoint-enabled-pbm-data | |
1027 "P1 | |
1028 10 10\", | |
1029 0 0 0 0 1 1 1 1 0 0 0 0 | |
1030 0 0 0 1 1 1 1 1 1 0 0 0 | |
1031 0 0 1 1 1 1 1 1 1 1 0 0 | |
1032 0 1 1 1 1 1 1 1 1 1 1 0 | |
1033 0 1 1 1 1 1 1 1 1 1 1 0 | |
1034 0 1 1 1 1 1 1 1 1 1 1 0 | |
1035 0 1 1 1 1 1 1 1 1 1 1 0 | |
1036 0 0 1 1 1 1 1 1 1 1 0 0 | |
1037 0 0 0 1 1 1 1 1 1 0 0 0 | |
1038 0 0 0 0 1 1 1 1 0 0 0 0" | |
1039 "PBM data used for enabled breakpoint icon.") | |
1040 | |
1041 (defconst breakpoint-disabled-pbm-data | |
1042 "P1 | |
1043 10 10\", | |
1044 0 0 1 0 1 0 1 0 0 0 | |
1045 0 1 0 1 0 1 0 1 0 0 | |
1046 1 0 1 0 1 0 1 0 1 0 | |
1047 0 1 0 1 0 1 0 1 0 1 | |
1048 1 0 1 0 1 0 1 0 1 0 | |
1049 0 1 0 1 0 1 0 1 0 1 | |
1050 1 0 1 0 1 0 1 0 1 0 | |
1051 0 1 0 1 0 1 0 1 0 1 | |
1052 0 0 1 0 1 0 1 0 1 0 | |
1053 0 0 0 1 0 1 0 1 0 0" | |
1054 "PBM data used for disabled breakpoint icon.") | |
1055 | |
1056 (defvar breakpoint-enabled-icon nil | |
1057 "Icon for enabled breakpoint in display margin") | |
1058 | |
1059 (defvar breakpoint-disabled-icon nil | |
1060 "Icon for disabled breakpoint in display margin") | |
1061 | |
1062 (defvar breakpoint-bitmap nil | |
1063 "Bitmap for breakpoint in fringe") | |
1064 | |
1065 (defface breakpoint-enabled-bitmap-face | |
1066 '((t | |
1067 :inherit fringe | |
1068 :foreground "red")) | |
1069 "Face for enabled breakpoint icon in fringe.") | |
1070 | |
1071 (defface breakpoint-disabled-bitmap-face | |
1072 '((t | |
1073 :inherit fringe | |
1074 :foreground "grey60")) | |
1075 "Face for disabled breakpoint icon in fringe.") | |
1076 | |
1077 | |
1078 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer) | |
1079 (defun gdb-info-breakpoints-custom () | |
1080 (let ((flag)(address)) | |
1081 ;; | |
1082 ;; remove all breakpoint-icons in source buffers but not assembler buffer | |
1083 (dolist (buffer (buffer-list)) | |
1084 (with-current-buffer buffer | |
1085 (if (and (eq gud-minor-mode 'gdba) | |
1086 (not (string-match "^\*" (buffer-name)))) | |
1087 (gdb-remove-breakpoint-icons (point-min) (point-max))))) | |
1088 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer) | |
1089 (save-excursion | |
1090 (goto-char (point-min)) | |
1091 (while (< (point) (- (point-max) 1)) | |
1092 (forward-line 1) | |
1093 (if (looking-at "[^\t].*breakpoint") | |
1094 (progn | |
1095 (looking-at "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)") | |
1096 (setq flag (char-after (match-beginning 1))) | |
1097 (beginning-of-line) | |
1098 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t) | |
1099 (progn | |
1100 (looking-at "\\(\\S-*\\):\\([0-9]+\\)") | |
1101 (let ((line (match-string 2)) (buffer-read-only nil) | |
1102 (file (match-string 1))) | |
1103 (add-text-properties (point-at-bol) (point-at-eol) | |
1104 '(mouse-face highlight | |
1105 help-echo "mouse-2, RET: visit breakpoint")) | |
1106 (with-current-buffer | |
1107 (find-file-noselect | |
1108 (if (file-exists-p file) file | |
1109 (expand-file-name file gdb-cdir))) | |
1110 (save-current-buffer | |
1111 (set (make-local-variable 'gud-minor-mode) 'gdba) | |
1112 (set (make-local-variable 'tool-bar-map) | |
1113 gud-tool-bar-map)) | |
1114 ;; only want one breakpoint icon at each location | |
1115 (save-excursion | |
1116 (goto-line (string-to-number line)) | |
1117 (gdb-put-breakpoint-icon (eq flag ?y))))))))) | |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1118 (end-of-line))))) |
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1119 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) |
54538 | 1120 |
1121 (defun gdb-mouse-toggle-breakpoint (event) | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1122 "Toggle breakpoint in left fringe/margin with mouse click" |
54538 | 1123 (interactive "e") |
1124 (mouse-minibuffer-check event) | |
1125 (let ((posn (event-end event))) | |
1126 (if (numberp (posn-point posn)) | |
1127 (with-selected-window (posn-window posn) | |
1128 (save-excursion | |
1129 (goto-char (posn-point posn)) | |
1130 (if (or (posn-object posn) | |
1131 (and breakpoint-bitmap | |
1132 (eq (car (fringe-bitmaps-at-pos (posn-point posn))) | |
1133 breakpoint-bitmap))) | |
1134 (gud-remove nil) | |
1135 (gud-break nil))))))) | |
1136 | |
1137 (defun gdb-breakpoints-buffer-name () | |
1138 (with-current-buffer gud-comint-buffer | |
1139 (concat "*breakpoints of " (gdb-get-target-string) "*"))) | |
1140 | |
1141 (defun gdb-display-breakpoints-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1142 "Display status of user-settable breakpoints." |
54538 | 1143 (interactive) |
1144 (gdb-display-buffer | |
1145 (gdb-get-create-buffer 'gdb-breakpoints-buffer))) | |
1146 | |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1147 (defconst gdb-frame-parameters |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1148 '((height . 12) (width . 60) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1149 (unsplittable . t) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1150 (tool-bar-lines . nil) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1151 (menu-bar-lines . nil) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1152 (minibuffer . nil))) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1153 |
54538 | 1154 (defun gdb-frame-breakpoints-buffer () |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1155 "Display status of user-settable breakpoints in a new frame." |
54538 | 1156 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1157 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1158 (switch-to-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1159 (set-window-dedicated-p (selected-window) t)) |
54538 | 1160 |
1161 (defvar gdb-breakpoints-mode-map | |
1162 (let ((map (make-sparse-keymap)) | |
1163 (menu (make-sparse-keymap "Breakpoints"))) | |
1164 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint)) | |
1165 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint)) | |
1166 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint)) | |
1167 | |
1168 (suppress-keymap map) | |
1169 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu)) | |
1170 (define-key map " " 'gdb-toggle-breakpoint) | |
1171 (define-key map "d" 'gdb-delete-breakpoint) | |
1172 (define-key map "\r" 'gdb-goto-breakpoint) | |
1173 (define-key map [mouse-2] 'gdb-mouse-goto-breakpoint) | |
1174 map)) | |
1175 | |
1176 (defun gdb-breakpoints-mode () | |
1177 "Major mode for gdb breakpoints. | |
1178 | |
1179 \\{gdb-breakpoints-mode-map}" | |
1180 (setq major-mode 'gdb-breakpoints-mode) | |
1181 (setq mode-name "Breakpoints") | |
1182 (use-local-map gdb-breakpoints-mode-map) | |
1183 (setq buffer-read-only t) | |
1184 (gdb-invalidate-breakpoints)) | |
1185 | |
1186 (defun gdb-toggle-breakpoint () | |
1187 "Enable/disable the breakpoint at current line." | |
1188 (interactive) | |
1189 (save-excursion | |
1190 (beginning-of-line 1) | |
1191 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | |
1192 (error "Not recognized as break/watchpoint line") | |
1193 (gdb-enqueue-input | |
1194 (list | |
1195 (concat | |
1196 (if (eq ?y (char-after (match-beginning 2))) | |
1197 "server disable " | |
1198 "server enable ") | |
1199 (match-string 1) "\n") | |
1200 'ignore))))) | |
1201 | |
1202 (defun gdb-delete-breakpoint () | |
1203 "Delete the breakpoint at current line." | |
1204 (interactive) | |
1205 (beginning-of-line 1) | |
1206 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | |
1207 (error "Not recognized as break/watchpoint line") | |
1208 (gdb-enqueue-input | |
1209 (list (concat "server delete " (match-string 1) "\n") 'ignore)))) | |
1210 | |
1211 (defun gdb-goto-breakpoint () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1212 "Display the breakpoint location specified at current line." |
54538 | 1213 (interactive) |
1214 (save-excursion | |
1215 (beginning-of-line 1) | |
1216 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t) | |
1217 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")) | |
1218 (if (match-string 2) | |
1219 (let ((line (match-string 2)) | |
1220 (file (match-string 1))) | |
1221 (save-selected-window | |
55330
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1222 (let* ((buf (find-file-noselect (if (file-exists-p file) |
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1223 file |
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1224 (expand-file-name file gdb-cdir)))) |
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1225 (window (gdb-display-buffer buf))) |
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1226 (with-current-buffer buf |
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1227 (goto-line (string-to-number line)) |
df2107598877
(gdb-goto-breakpoint): Make buffer display file at breakpoint.
Nick Roberts <nickrob@snap.net.nz>
parents:
55328
diff
changeset
|
1228 (set-window-point window (point)))))))) |
54538 | 1229 |
1230 (defun gdb-mouse-goto-breakpoint (event) | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1231 "Display the breakpoint location that you click on." |
54538 | 1232 (interactive "e") |
1233 (mouse-set-point event) | |
1234 (gdb-goto-breakpoint)) | |
1235 | |
1236 ;; | |
1237 ;; Frames buffer. This displays a perpetually correct bactracktrace | |
1238 ;; (from the command `where'). | |
1239 ;; | |
1240 ;; Alas, if your stack is deep, it is costly. | |
1241 ;; | |
1242 (gdb-set-buffer-rules 'gdb-stack-buffer | |
1243 'gdb-stack-buffer-name | |
1244 'gdb-frames-mode) | |
1245 | |
1246 (def-gdb-auto-updated-buffer gdb-stack-buffer | |
1247 gdb-invalidate-frames | |
1248 "server where\n" | |
1249 gdb-info-frames-handler | |
1250 gdb-info-frames-custom) | |
1251 | |
1252 (defun gdb-info-frames-custom () | |
1253 (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer) | |
1254 (save-excursion | |
1255 (let ((buffer-read-only nil)) | |
1256 (goto-char (point-min)) | |
1257 (while (< (point) (point-max)) | |
1258 (add-text-properties (point-at-bol) (point-at-eol) | |
1259 '(mouse-face highlight | |
1260 help-echo "mouse-2, RET: Select frame")) | |
1261 (beginning-of-line) | |
1262 (when (and (or (looking-at "^#[0-9]*\\s-*\\S-* in \\(\\S-*\\)") | |
1263 (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)")) | |
1264 (equal (match-string 1) gdb-current-frame)) | |
1265 (put-text-property (point-at-bol) (point-at-eol) | |
1266 'face '(:inverse-video t))) | |
1267 (forward-line 1)))))) | |
1268 | |
1269 (defun gdb-stack-buffer-name () | |
1270 (with-current-buffer gud-comint-buffer | |
1271 (concat "*stack frames of " (gdb-get-target-string) "*"))) | |
1272 | |
1273 (defun gdb-display-stack-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1274 "Display backtrace of current stack." |
54538 | 1275 (interactive) |
1276 (gdb-display-buffer | |
1277 (gdb-get-create-buffer 'gdb-stack-buffer))) | |
1278 | |
1279 (defun gdb-frame-stack-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1280 "Display backtrace of current stack in a new frame." |
54538 | 1281 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1282 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1283 (switch-to-buffer (gdb-get-create-buffer 'gdb-stack-buffer)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1284 (set-window-dedicated-p (selected-window) t)) |
54538 | 1285 |
1286 (defvar gdb-frames-mode-map | |
1287 (let ((map (make-sparse-keymap))) | |
1288 (suppress-keymap map) | |
1289 (define-key map "\r" 'gdb-frames-select) | |
1290 (define-key map [mouse-2] 'gdb-frames-mouse-select) | |
1291 map)) | |
1292 | |
1293 (defun gdb-frames-mode () | |
1294 "Major mode for gdb frames. | |
1295 | |
1296 \\{gdb-frames-mode-map}" | |
1297 (setq major-mode 'gdb-frames-mode) | |
1298 (setq mode-name "Frames") | |
1299 (setq buffer-read-only t) | |
1300 (use-local-map gdb-frames-mode-map) | |
1301 (font-lock-mode -1) | |
1302 (gdb-invalidate-frames)) | |
1303 | |
1304 (defun gdb-get-frame-number () | |
1305 (save-excursion | |
1306 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t)) | |
1307 (n (or (and pos (match-string-no-properties 1)) "0"))) | |
1308 n))) | |
1309 | |
1310 (defun gdb-frames-select () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1311 "Select the frame and display the relevant source." |
54538 | 1312 (interactive) |
1313 (gdb-enqueue-input | |
1314 (list (concat "server frame " (gdb-get-frame-number) "\n") 'ignore)) | |
1315 (gud-display-frame)) | |
1316 | |
1317 (defun gdb-frames-mouse-select (event) | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1318 "Select the frame you click on and display the relevant source." |
54538 | 1319 (interactive "e") |
1320 (mouse-set-point event) | |
1321 (gdb-frames-select)) | |
1322 | |
1323 ;; | |
1324 ;; Threads buffer. This displays a selectable thread list. | |
1325 ;; | |
1326 (gdb-set-buffer-rules 'gdb-threads-buffer | |
1327 'gdb-threads-buffer-name | |
1328 'gdb-threads-mode) | |
1329 | |
1330 (def-gdb-auto-updated-buffer gdb-threads-buffer | |
1331 gdb-invalidate-threads | |
1332 "server info threads\n" | |
1333 gdb-info-threads-handler | |
1334 gdb-info-threads-custom) | |
1335 | |
1336 (defun gdb-info-threads-custom () | |
1337 (with-current-buffer (gdb-get-buffer 'gdb-threads-buffer) | |
1338 (let ((buffer-read-only nil)) | |
1339 (goto-char (point-min)) | |
1340 (while (< (point) (point-max)) | |
1341 (add-text-properties (point-at-bol) (point-at-eol) | |
1342 '(mouse-face highlight | |
1343 help-echo "mouse-2, RET: select thread")) | |
1344 (forward-line 1))))) | |
1345 | |
1346 (defun gdb-threads-buffer-name () | |
1347 (with-current-buffer gud-comint-buffer | |
1348 (concat "*threads of " (gdb-get-target-string) "*"))) | |
1349 | |
1350 (defun gdb-display-threads-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1351 "Display IDs of currently known threads." |
54538 | 1352 (interactive) |
1353 (gdb-display-buffer | |
1354 (gdb-get-create-buffer 'gdb-threads-buffer))) | |
1355 | |
1356 (defun gdb-frame-threads-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1357 "Display IDs of currently known threads in a new frame." |
54538 | 1358 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1359 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1360 (switch-to-buffer (gdb-get-create-buffer 'gdb-threads-buffer)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1361 (set-window-dedicated-p (selected-window) t)) |
54538 | 1362 |
1363 (defvar gdb-threads-mode-map | |
1364 (let ((map (make-sparse-keymap))) | |
1365 (suppress-keymap map) | |
1366 (define-key map "\r" 'gdb-threads-select) | |
1367 (define-key map [mouse-2] 'gdb-threads-mouse-select) | |
1368 map)) | |
1369 | |
1370 (defun gdb-threads-mode () | |
1371 "Major mode for gdb frames. | |
1372 | |
1373 \\{gdb-frames-mode-map}" | |
1374 (setq major-mode 'gdb-threads-mode) | |
1375 (setq mode-name "Threads") | |
1376 (setq buffer-read-only t) | |
1377 (use-local-map gdb-threads-mode-map) | |
1378 (gdb-invalidate-threads)) | |
1379 | |
1380 (defun gdb-get-thread-number () | |
1381 (save-excursion | |
1382 (re-search-backward "^\\s-*\\([0-9]*\\)" nil t) | |
1383 (match-string-no-properties 1))) | |
1384 | |
1385 (defun gdb-threads-select () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1386 "Select the thread and display the relevant source." |
54538 | 1387 (interactive) |
1388 (gdb-enqueue-input | |
1389 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore)) | |
1390 (gud-display-frame)) | |
1391 | |
1392 (defun gdb-threads-mouse-select (event) | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1393 "Select the thread you click on and display the relevant source." |
54538 | 1394 (interactive "e") |
1395 (mouse-set-point event) | |
1396 (gdb-threads-select)) | |
1397 | |
1398 ;; | |
1399 ;; Registers buffer. | |
1400 ;; | |
1401 (gdb-set-buffer-rules 'gdb-registers-buffer | |
1402 'gdb-registers-buffer-name | |
1403 'gdb-registers-mode) | |
1404 | |
1405 (def-gdb-auto-updated-buffer gdb-registers-buffer | |
1406 gdb-invalidate-registers | |
1407 "server info registers\n" | |
1408 gdb-info-registers-handler | |
1409 gdb-info-registers-custom) | |
1410 | |
1411 (defun gdb-info-registers-custom ()) | |
1412 | |
1413 (defvar gdb-registers-mode-map | |
1414 (let ((map (make-sparse-keymap))) | |
1415 (suppress-keymap map) | |
1416 map)) | |
1417 | |
1418 (defun gdb-registers-mode () | |
1419 "Major mode for gdb registers. | |
1420 | |
1421 \\{gdb-registers-mode-map}" | |
1422 (setq major-mode 'gdb-registers-mode) | |
1423 (setq mode-name "Registers") | |
1424 (setq buffer-read-only t) | |
1425 (use-local-map gdb-registers-mode-map) | |
1426 (gdb-invalidate-registers)) | |
1427 | |
1428 (defun gdb-registers-buffer-name () | |
1429 (with-current-buffer gud-comint-buffer | |
1430 (concat "*registers of " (gdb-get-target-string) "*"))) | |
1431 | |
1432 (defun gdb-display-registers-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1433 "Display integer register contents." |
54538 | 1434 (interactive) |
1435 (gdb-display-buffer | |
1436 (gdb-get-create-buffer 'gdb-registers-buffer))) | |
1437 | |
1438 (defun gdb-frame-registers-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1439 "Display integer register contents in a new frame." |
54538 | 1440 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1441 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1442 (switch-to-buffer (gdb-get-create-buffer 'gdb-registers-buffer)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1443 (set-window-dedicated-p (selected-window) t)) |
54538 | 1444 |
1445 ;; | |
1446 ;; Locals buffer. | |
1447 ;; | |
1448 (gdb-set-buffer-rules 'gdb-locals-buffer | |
1449 'gdb-locals-buffer-name | |
1450 'gdb-locals-mode) | |
1451 | |
1452 (def-gdb-auto-updated-buffer gdb-locals-buffer | |
1453 gdb-invalidate-locals | |
1454 "server info locals\n" | |
1455 gdb-info-locals-handler | |
1456 gdb-info-locals-custom) | |
1457 | |
1458 ;; Abbreviate for arrays and structures. | |
1459 ;; These can be expanded using gud-display. | |
1460 (defun gdb-info-locals-handler nil | |
1461 (gdb-set-pending-triggers (delq 'gdb-invalidate-locals | |
1462 (gdb-get-pending-triggers))) | |
1463 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer))) | |
1464 (with-current-buffer buf | |
1465 (goto-char (point-min)) | |
1466 (while (re-search-forward "^ .*\n" nil t) | |
1467 (replace-match "" nil nil)) | |
1468 (goto-char (point-min)) | |
1469 (while (re-search-forward "{[-0-9, {}\]*\n" nil t) | |
1470 (replace-match "(array);\n" nil nil)) | |
1471 (goto-char (point-min)) | |
1472 (while (re-search-forward "{.*=.*\n" nil t) | |
1473 (replace-match "(structure);\n" nil nil)))) | |
1474 (let ((buf (gdb-get-buffer 'gdb-locals-buffer))) | |
1475 (and buf (with-current-buffer buf | |
1476 (let ((p (point)) | |
1477 (buffer-read-only nil)) | |
1478 (delete-region (point-min) (point-max)) | |
1479 (insert-buffer-substring (gdb-get-create-buffer | |
1480 'gdb-partial-output-buffer)) | |
1481 (goto-char p))))) | |
1482 (run-hooks 'gdb-info-locals-hook)) | |
1483 | |
1484 (defun gdb-info-locals-custom () | |
1485 nil) | |
1486 | |
1487 (defvar gdb-locals-mode-map | |
1488 (let ((map (make-sparse-keymap))) | |
1489 (suppress-keymap map) | |
1490 map)) | |
1491 | |
1492 (defun gdb-locals-mode () | |
1493 "Major mode for gdb locals. | |
1494 | |
1495 \\{gdb-locals-mode-map}" | |
1496 (setq major-mode 'gdb-locals-mode) | |
1497 (setq mode-name "Locals") | |
1498 (setq buffer-read-only t) | |
1499 (use-local-map gdb-locals-mode-map) | |
1500 (gdb-invalidate-locals)) | |
1501 | |
1502 (defun gdb-locals-buffer-name () | |
1503 (with-current-buffer gud-comint-buffer | |
1504 (concat "*locals of " (gdb-get-target-string) "*"))) | |
1505 | |
1506 (defun gdb-display-locals-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1507 "Display local variables of current stack and their values." |
54538 | 1508 (interactive) |
1509 (gdb-display-buffer | |
1510 (gdb-get-create-buffer 'gdb-locals-buffer))) | |
1511 | |
1512 (defun gdb-frame-locals-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1513 "Display local variables of current stack and their values in a new frame." |
54538 | 1514 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1515 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1516 (switch-to-buffer (gdb-get-create-buffer 'gdb-locals-buffer)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1517 (set-window-dedicated-p (selected-window) t)) |
54538 | 1518 |
1519 | |
1520 ;;;; Window management | |
1521 | |
1522 ;;; The way we abuse the dedicated-p flag is pretty gross, but seems | |
1523 ;;; to do the right thing. Seeing as there is no way for Lisp code to | |
1524 ;;; get at the use_time field of a window, I'm not sure there exists a | |
1525 ;;; more elegant solution without writing C code. | |
1526 | |
1527 (defun gdb-display-buffer (buf &optional size) | |
1528 (let ((must-split nil) | |
1529 (answer nil)) | |
1530 (unwind-protect | |
1531 (progn | |
1532 (walk-windows | |
1533 #'(lambda (win) | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1534 (if (eq gud-comint-buffer (window-buffer win)) |
54538 | 1535 (set-window-dedicated-p win t)))) |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1536 (setq answer (get-buffer-window buf 'visible)) |
54538 | 1537 (if (not answer) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1538 (let ((window (get-lru-window 'visible))) |
54538 | 1539 (if window |
1540 (progn | |
1541 (set-window-buffer window buf) | |
1542 (setq answer window)) | |
1543 (setq must-split t))))) | |
1544 (walk-windows | |
1545 #'(lambda (win) | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1546 (if (eq gud-comint-buffer (window-buffer win)) |
54538 | 1547 (set-window-dedicated-p win nil))))) |
1548 (if must-split | |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1549 (let* ((largest (get-largest-window 'visible)) |
54538 | 1550 (cur-size (window-height largest)) |
1551 (new-size (and size (< size cur-size) (- cur-size size)))) | |
1552 (setq answer (split-window largest new-size)) | |
1553 (set-window-buffer answer buf))) | |
1554 answer)) | |
1555 | |
1556 (defun gdb-display-source-buffer (buffer) | |
1557 (if (eq gdb-selected-view 'source) | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1558 (gdb-display-buffer buffer) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1559 (gdb-display-buffer (gdb-get-buffer 'gdb-assembler-buffer))) |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1560 (get-buffer-window buffer 'visible)) |
54538 | 1561 |
1562 | |
1563 ;;; Shared keymap initialization: | |
1564 | |
1565 (let ((menu (make-sparse-keymap "GDB-Frames"))) | |
1566 (define-key gud-menu-map [frames] | |
1567 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba))) | |
1568 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer)) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1569 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer)) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1570 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer)) |
54538 | 1571 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer)) |
1572 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer)) | |
1573 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)) | |
1574 ; (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer)) | |
1575 ) | |
1576 | |
1577 (let ((menu (make-sparse-keymap "GDB-Windows"))) | |
1578 (define-key gud-menu-map [displays] | |
1579 `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba))) | |
1580 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer)) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1581 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer)) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1582 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer)) |
54538 | 1583 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) |
1584 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer)) | |
1585 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)) | |
1586 ; (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer)) | |
1587 ) | |
1588 | |
1589 (let ((menu (make-sparse-keymap "View"))) | |
1590 (define-key gud-menu-map [view] | |
1591 `(menu-item "View" ,menu :visible (eq gud-minor-mode 'gdba))) | |
1592 ; (define-key menu [both] '(menu-item "Both" gdb-view-both | |
1593 ; :help "Display both source and assembler" | |
1594 ; :button (:radio . (eq gdb-selected-view 'both)))) | |
1595 (define-key menu [assembler] '(menu-item "Machine" gdb-view-assembler | |
1596 :help "Display assembler only" | |
1597 :button (:radio . (eq gdb-selected-view 'assembler)))) | |
1598 (define-key menu [source] '(menu-item "Source" gdb-view-source-function | |
1599 :help "Display source only" | |
1600 :button (:radio . (eq gdb-selected-view 'source))))) | |
1601 | |
1602 (let ((menu (make-sparse-keymap "GDB-UI"))) | |
1603 (define-key gud-menu-map [ui] | |
1604 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba))) | |
1605 (define-key menu [gdb-restore-windows] | |
1606 '("Restore window layout" . gdb-restore-windows)) | |
1607 (define-key menu [gdb-many-windows] | |
1608 (menu-bar-make-toggle gdb-many-windows gdb-many-windows | |
1609 "Display other windows" "Many Windows %s" | |
1610 "Display locals, stack and breakpoint information"))) | |
1611 | |
1612 (defun gdb-frame-gdb-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1613 "Display GUD buffer in a new frame." |
54538 | 1614 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1615 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1616 (switch-to-buffer (gdb-get-create-buffer 'gdba)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1617 (set-window-dedicated-p (selected-window) t)) |
54538 | 1618 |
1619 (defun gdb-display-gdb-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1620 "Display GUD buffer." |
54538 | 1621 (interactive) |
1622 (gdb-display-buffer | |
1623 (gdb-get-create-buffer 'gdba))) | |
1624 | |
1625 (defvar gdb-main-file nil "Source file from which program execution begins.") | |
1626 | |
1627 (defun gdb-view-source-function () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1628 "Select source view." |
54538 | 1629 (interactive) |
1630 (if gdb-view-source | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1631 (gdb-display-buffer |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1632 (if gud-last-last-frame |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1633 (gud-find-file (car gud-last-last-frame)) |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1634 (gud-find-file gdb-main-file)))) |
54538 | 1635 (setq gdb-selected-view 'source)) |
1636 | |
1637 (defun gdb-view-assembler() | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1638 "Select disassembly view." |
54538 | 1639 (interactive) |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1640 (gdb-display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1641 (gdb-invalidate-assembler) |
54538 | 1642 (setq gdb-selected-view 'assembler)) |
1643 | |
1644 ;(defun gdb-view-both() | |
1645 ;(interactive) | |
1646 ;(setq gdb-selected-view 'both)) | |
1647 | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1648 (defcustom gdb-show-main nil |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1649 "Nil means don't display source file containing the main routine." |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1650 :type 'boolean |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1651 :group 'gud) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1652 |
54538 | 1653 (defun gdb-setup-windows () |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1654 "Layout the window pattern for gdb-many-windows." |
54538 | 1655 (gdb-display-locals-buffer) |
1656 (gdb-display-stack-buffer) | |
1657 (delete-other-windows) | |
1658 (gdb-display-breakpoints-buffer) | |
1659 (delete-other-windows) | |
1660 (switch-to-buffer gud-comint-buffer) | |
1661 (split-window nil ( / ( * (window-height) 3) 4)) | |
1662 (split-window nil ( / (window-height) 3)) | |
1663 (split-window-horizontally) | |
1664 (other-window 1) | |
1665 (switch-to-buffer (gdb-locals-buffer-name)) | |
1666 (other-window 1) | |
1667 (switch-to-buffer | |
1668 (if (and gdb-view-source | |
1669 (eq gdb-selected-view 'source)) | |
1670 (if gud-last-last-frame | |
1671 (gud-find-file (car gud-last-last-frame)) | |
1672 (gud-find-file gdb-main-file)) | |
1673 (gdb-get-create-buffer 'gdb-assembler-buffer))) | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
1674 (when gdb-use-inferior-io-buffer |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
1675 (split-window-horizontally) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
1676 (other-window 1) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
1677 (switch-to-buffer (gdb-inferior-io-name))) |
54538 | 1678 (other-window 1) |
1679 (switch-to-buffer (gdb-stack-buffer-name)) | |
1680 (split-window-horizontally) | |
1681 (other-window 1) | |
1682 (switch-to-buffer (gdb-breakpoints-buffer-name)) | |
1683 (other-window 1)) | |
1684 | |
1685 (defcustom gdb-many-windows nil | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
1686 "Nil (the default value) means just pop up the GUD buffer |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1687 unless `gdb-show-main' is t. In this case it starts with two |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1688 windows: one displaying the GUD buffer and the other with the |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1689 source file with the main routine of the debugee. Non-nil means |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1690 display the layout shown for `gdba'." |
54538 | 1691 :type 'boolean |
1692 :group 'gud) | |
1693 | |
1694 (defun gdb-many-windows (arg) | |
1695 "Toggle the number of windows in the basic arrangement." | |
1696 (interactive "P") | |
1697 (setq gdb-many-windows | |
1698 (if (null arg) | |
1699 (not gdb-many-windows) | |
1700 (> (prefix-numeric-value arg) 0))) | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1701 (condition-case nil |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1702 (gdb-restore-windows) |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
1703 (error nil))) |
54538 | 1704 |
1705 (defun gdb-restore-windows () | |
1706 "Restore the basic arrangement of windows used by gdba. | |
1707 This arrangement depends on the value of `gdb-many-windows'." | |
1708 (interactive) | |
1709 (if gdb-many-windows | |
1710 (progn | |
1711 (switch-to-buffer gud-comint-buffer) | |
1712 (delete-other-windows) | |
1713 (gdb-setup-windows)) | |
1714 (switch-to-buffer gud-comint-buffer) | |
1715 (delete-other-windows) | |
1716 (split-window) | |
1717 (other-window 1) | |
1718 (switch-to-buffer | |
1719 (if (and gdb-view-source | |
1720 (eq gdb-selected-view 'source)) | |
1721 (if gud-last-last-frame | |
1722 (gud-find-file (car gud-last-last-frame)) | |
1723 (gud-find-file gdb-main-file)) | |
1724 (gdb-get-create-buffer 'gdb-assembler-buffer))) | |
1725 (other-window 1))) | |
1726 | |
1727 (defun gdb-reset () | |
1728 "Exit a debugging session cleanly by killing the gdb buffers and resetting | |
1729 the source buffers." | |
1730 (dolist (buffer (buffer-list)) | |
1731 (if (not (eq buffer gud-comint-buffer)) | |
1732 (with-current-buffer buffer | |
1733 (if (memq gud-minor-mode '(gdba pdb)) | |
1734 (if (string-match "^\*.+*$" (buffer-name)) | |
1735 (kill-buffer nil) | |
1736 (gdb-remove-breakpoint-icons (point-min) (point-max) t) | |
1737 (setq gud-minor-mode nil) | |
1738 (kill-local-variable 'tool-bar-map) | |
1739 (setq gud-running nil)))))) | |
1740 (when (markerp gdb-overlay-arrow-position) | |
1741 (move-marker gdb-overlay-arrow-position nil) | |
1742 (setq gdb-overlay-arrow-position nil)) | |
1743 (setq overlay-arrow-variable-list | |
1744 (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list))) | |
1745 | |
1746 (defun gdb-source-info () | |
1747 "Find the source file where the program starts and displays it with related | |
1748 buffers." | |
1749 (goto-char (point-min)) | |
1750 (if (search-forward "directory is " nil t) | |
1751 (if (looking-at "\\S-*:\\(\\S-*\\)") | |
1752 (setq gdb-cdir (match-string 1)) | |
1753 (looking-at "\\S-*") | |
1754 (setq gdb-cdir (match-string 0)))) | |
1755 (if (search-forward "Located in " nil t) | |
1756 (if (looking-at "\\S-*") | |
1757 (setq gdb-main-file (match-string 0))) | |
1758 (setq gdb-view-source nil)) | |
1759 (if gdb-many-windows | |
1760 (gdb-setup-windows) | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1761 (gdb-get-create-buffer 'gdb-breakpoints-buffer) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1762 (when gdb-show-main |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1763 (switch-to-buffer gud-comint-buffer) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1764 (delete-other-windows) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1765 (split-window) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1766 (other-window 1) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1767 (switch-to-buffer |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1768 (if gdb-view-source |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1769 (gud-find-file gdb-main-file) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1770 (gdb-get-create-buffer 'gdb-assembler-buffer))) |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1771 (other-window 1)))) |
54538 | 1772 |
1773 ;;from put-image | |
1774 (defun gdb-put-string (putstring pos &optional dprop) | |
1775 "Put string PUTSTRING in front of POS in the current buffer. | |
1776 PUTSTRING is displayed by putting an overlay into the current buffer with a | |
1777 `before-string' STRING that has a `display' property whose value is | |
1778 PUTSTRING." | |
1779 (let ((gdb-string "x") | |
1780 (buffer (current-buffer))) | |
1781 (let ((overlay (make-overlay pos pos buffer)) | |
1782 (prop (or dprop | |
1783 (list (list 'margin 'left-margin) putstring)))) | |
1784 (put-text-property 0 (length gdb-string) 'display prop gdb-string) | |
1785 (overlay-put overlay 'put-break t) | |
1786 (overlay-put overlay 'before-string gdb-string)))) | |
1787 | |
1788 ;;from remove-images | |
1789 (defun gdb-remove-strings (start end &optional buffer) | |
1790 "Remove strings between START and END in BUFFER. | |
1791 Remove only strings that were put in BUFFER with calls to `gdb-put-string'. | |
1792 BUFFER nil or omitted means use the current buffer." | |
1793 (unless buffer | |
1794 (setq buffer (current-buffer))) | |
1795 (let ((overlays (overlays-in start end))) | |
1796 (while overlays | |
1797 (let ((overlay (car overlays))) | |
1798 (when (overlay-get overlay 'put-break) | |
1799 (delete-overlay overlay))) | |
1800 (setq overlays (cdr overlays))))) | |
1801 | |
1802 (defun gdb-put-breakpoint-icon (enabled) | |
1803 (let ((start (progn (beginning-of-line) (- (point) 1))) | |
1804 (end (progn (end-of-line) (+ (point) 1)))) | |
1805 (gdb-remove-breakpoint-icons start end) | |
1806 (if (display-images-p) | |
1807 (if (>= (car (window-fringes)) 8) | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1808 (gdb-put-string |
54538 | 1809 nil (1+ start) |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1810 `(left-fringe |
54538 | 1811 ,(or breakpoint-bitmap |
1812 (setq breakpoint-bitmap | |
1813 (define-fringe-bitmap | |
1814 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))) | |
1815 ,(if enabled | |
1816 'breakpoint-enabled-bitmap-face | |
1817 'breakpoint-disabled-bitmap-face))) | |
1818 (when (< left-margin-width 2) | |
1819 (save-current-buffer | |
1820 (setq left-margin-width 2) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1821 (if (get-buffer-window (current-buffer) 'visible) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1822 (set-window-margins |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1823 (get-buffer-window (current-buffer) 'visible) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1824 left-margin-width right-margin-width)))) |
54538 | 1825 (put-image |
1826 (if enabled | |
1827 (or breakpoint-enabled-icon | |
1828 (setq breakpoint-enabled-icon | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
1829 (find-image `((:type xpm :data |
54538 | 1830 ,breakpoint-xpm-data |
1831 :ascent 100 :pointer hand) | |
1832 (:type pbm :data | |
1833 ,breakpoint-enabled-pbm-data | |
1834 :ascent 100 :pointer hand))))) | |
1835 (or breakpoint-disabled-icon | |
1836 (setq breakpoint-disabled-icon | |
1837 (find-image `((:type xpm :data | |
1838 ,breakpoint-xpm-data | |
1839 :conversion disabled | |
1840 :ascent 100) | |
1841 (:type pbm :data | |
1842 ,breakpoint-disabled-pbm-data | |
1843 :ascent 100)))))) | |
1844 (+ start 1) nil 'left-margin)) | |
1845 (when (< left-margin-width 2) | |
1846 (save-current-buffer | |
1847 (setq left-margin-width 2) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1848 (if (get-buffer-window (current-buffer) 'visible) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1849 (set-window-margins |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1850 (get-buffer-window (current-buffer) 'visible) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1851 left-margin-width right-margin-width)))) |
54538 | 1852 (gdb-put-string (if enabled "B" "b") (1+ start))))) |
1853 | |
1854 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin) | |
1855 (gdb-remove-strings start end) | |
1856 (if (display-images-p) | |
1857 (remove-images start end)) | |
1858 (when remove-margin | |
1859 (setq left-margin-width 0) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1860 (if (get-buffer-window (current-buffer) 'visible) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1861 (set-window-margins |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1862 (get-buffer-window (current-buffer) 'visible) |
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1863 left-margin-width right-margin-width)))) |
54538 | 1864 |
1865 | |
1866 ;; | |
1867 ;; Assembler buffer. | |
1868 ;; | |
1869 (gdb-set-buffer-rules 'gdb-assembler-buffer | |
1870 'gdb-assembler-buffer-name | |
1871 'gdb-assembler-mode) | |
1872 | |
1873 (def-gdb-auto-updated-buffer gdb-assembler-buffer | |
1874 gdb-invalidate-assembler | |
1875 (concat "server disassemble " gdb-current-address "\n") | |
1876 gdb-assembler-handler | |
1877 gdb-assembler-custom) | |
1878 | |
1879 (defun gdb-assembler-custom () | |
1880 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer)) | |
1881 (pos 1) (address) (flag)) | |
1882 (with-current-buffer buffer | |
1883 (if (not (equal gdb-current-address "main")) | |
1884 (progn | |
1885 (goto-char (point-min)) | |
1886 (if (re-search-forward gdb-current-address nil t) | |
1887 (progn | |
1888 (setq pos (point)) | |
1889 (beginning-of-line) | |
1890 (or gdb-overlay-arrow-position | |
1891 (setq gdb-overlay-arrow-position (make-marker))) | |
1892 (set-marker gdb-overlay-arrow-position | |
1893 (point) (current-buffer)))))) | |
1894 ;; remove all breakpoint-icons in assembler buffer before updating. | |
1895 (gdb-remove-breakpoint-icons (point-min) (point-max))) | |
1896 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer) | |
1897 (goto-char (point-min)) | |
1898 (while (< (point) (- (point-max) 1)) | |
1899 (forward-line 1) | |
1900 (if (looking-at "[^\t].*breakpoint") | |
1901 (progn | |
1902 (looking-at | |
1903 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)") | |
1904 (setq flag (char-after (match-beginning 1))) | |
1905 (setq address (match-string 2)) | |
1906 ;; remove leading 0s from output of info break. | |
1907 (if (string-match "^0+\\(.*\\)" address) | |
1908 (setq address (match-string 1 address))) | |
1909 (with-current-buffer buffer | |
1910 (goto-char (point-min)) | |
1911 (if (re-search-forward address nil t) | |
1912 (gdb-put-breakpoint-icon (eq flag ?y)))))))) | |
1913 (if (not (equal gdb-current-address "main")) | |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
1914 (set-window-point (get-buffer-window buffer 'visible) pos)))) |
54538 | 1915 |
1916 (defvar gdb-assembler-mode-map | |
1917 (let ((map (make-sparse-keymap))) | |
1918 (suppress-keymap map) | |
1919 map)) | |
1920 | |
1921 (defun gdb-assembler-mode () | |
1922 "Major mode for viewing code assembler. | |
1923 | |
1924 \\{gdb-assembler-mode-map}" | |
1925 (setq major-mode 'gdb-assembler-mode) | |
1926 (setq mode-name "Machine") | |
1927 (setq gdb-overlay-arrow-position nil) | |
1928 (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position) | |
1929 (put 'gdb-overlay-arrow-position 'overlay-arrow-string "=>") | |
1930 (setq fringes-outside-margins t) | |
1931 (setq buffer-read-only t) | |
1932 (use-local-map gdb-assembler-mode-map) | |
1933 (gdb-invalidate-assembler)) | |
1934 | |
1935 (defun gdb-assembler-buffer-name () | |
1936 (with-current-buffer gud-comint-buffer | |
1937 (concat "*Machine Code " (gdb-get-target-string) "*"))) | |
1938 | |
1939 (defun gdb-display-assembler-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1940 "Display disassembly view." |
54538 | 1941 (interactive) |
1942 (gdb-display-buffer | |
1943 (gdb-get-create-buffer 'gdb-assembler-buffer))) | |
1944 | |
1945 (defun gdb-frame-assembler-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1946 "Display disassembly view in a new frame." |
54538 | 1947 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1948 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1949 (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
1950 (set-window-dedicated-p (selected-window) t)) |
54538 | 1951 |
1952 ;; modified because if gdb-current-address has changed value a new command | |
1953 ;; must be enqueued to update the buffer with the new output | |
1954 (defun gdb-invalidate-assembler (&optional ignored) | |
1955 (if (gdb-get-buffer 'gdb-assembler-buffer) | |
1956 (progn | |
1957 (unless (string-equal gdb-current-frame gdb-previous-frame) | |
1958 (if (or (not (member 'gdb-invalidate-assembler | |
1959 (gdb-get-pending-triggers))) | |
1960 (not (string-equal gdb-current-address | |
1961 gdb-previous-address))) | |
1962 (progn | |
1963 ;; take previous disassemble command off the queue | |
1964 (with-current-buffer gud-comint-buffer | |
1965 (let ((queue (gdb-get-input-queue)) (item)) | |
1966 (dolist (item queue) | |
1967 (if (equal (cdr item) '(gdb-assembler-handler)) | |
1968 (gdb-set-input-queue | |
1969 (delete item (gdb-get-input-queue))))))) | |
1970 (gdb-enqueue-input | |
1971 (list (concat "server disassemble " gdb-current-address "\n") | |
1972 'gdb-assembler-handler)) | |
1973 (gdb-set-pending-triggers | |
1974 (cons 'gdb-invalidate-assembler | |
1975 (gdb-get-pending-triggers))) | |
1976 (setq gdb-previous-address gdb-current-address) | |
1977 (setq gdb-previous-frame gdb-current-frame))))))) | |
1978 | |
1979 (defun gdb-get-current-frame () | |
1980 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers))) | |
1981 (progn | |
1982 (gdb-enqueue-input | |
1983 (list (concat "server info frame\n") 'gdb-frame-handler)) | |
1984 (gdb-set-pending-triggers | |
1985 (cons 'gdb-get-current-frame | |
1986 (gdb-get-pending-triggers)))))) | |
1987 | |
1988 (defun gdb-frame-handler () | |
1989 (gdb-set-pending-triggers | |
1990 (delq 'gdb-get-current-frame (gdb-get-pending-triggers))) | |
1991 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
1992 (goto-char (point-min)) | |
1993 (forward-line) | |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1994 (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ") |
54538 | 1995 (progn |
1996 (setq gdb-current-frame (match-string 2)) | |
1997 (let ((address (match-string 1))) | |
1998 ;; remove leading 0s from output of info frame command. | |
1999 (if (string-match "^0+\\(.*\\)" address) | |
2000 (setq gdb-current-address | |
2001 (concat "0x" (match-string 1 address))) | |
2002 (setq gdb-current-address (concat "0x" address)))) | |
2003 (if (or (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t)) | |
2004 (progn (setq gdb-view-source nil) t)) | |
2005 (eq gdb-selected-view 'assembler)) | |
2006 (progn | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
2007 (gdb-display-buffer |
54538 | 2008 (gdb-get-create-buffer 'gdb-assembler-buffer)) |
2009 ;;update with new frame for machine code if necessary | |
2010 (gdb-invalidate-assembler)))))) | |
2011 (if (re-search-forward " source language \\(\\S-*\\)\." nil t) | |
2012 (setq gdb-current-language (match-string 1)))) | |
2013 | |
2014 (provide 'gdb-ui) | |
2015 | |
2016 ;;; arch-tag: e9fb00c5-74ef-469f-a088-37384caae352 | |
2017 ;;; gdb-ui.el ends here |