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