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