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