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