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