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