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