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