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