Mercurial > emacs
annotate lisp/progmodes/gdb-ui.el @ 62257:89b47aae4ff5
*** empty log message ***
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Thu, 12 May 2005 11:14:42 +0000 |
parents | 327af4f748d5 |
children | dd9b63b29d80 6fef25c75847 62afea0771d8 |
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 | |
59922
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
7 ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
54538 | 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 |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
36 ;; By default, M-x gdb will start the debugger. However, if you have customised |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
37 ;; gud-gdb-command-name, then start it with M-x gdba. |
54538 | 38 |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
39 ;; This file has evolved from gdba.el that was included with GDB 5.0 and |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
40 ;; written by Tom Lord and Jim Kingdon. It uses GDB's annotation interface. |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
41 ;; You don't need to know about annotations to use this mode as a debugger, |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
42 ;; but if you are interested developing the mode itself, then see the |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
43 ;; Annotations section in the GDB info manual. |
55850
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
44 ;; |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
45 ;; 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
|
46 ;; 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
|
47 ;; it. Some GDB/MI commands are used in this file through the CLI command |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
48 ;; 'interpreter mi <mi-command>'. A file called gdb-mi.el is included with |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
49 ;; GDB (6.2 onwards) that uses GDB/MI as the primary interface to GDB. It is |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
50 ;; still under development and is part of a process to migrate Emacs from |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
51 ;; annotations to GDB/MI. |
54538 | 52 ;; |
53 ;; Known Bugs: | |
54 ;; | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
55 ;; TODO: |
59808 | 56 ;; 1) Use MI command -data-read-memory for memory window. |
57 ;; 2) Highlight changed register values (use MI commands | |
58 ;; -data-list-register-values and -data-list-changed-registers instead | |
59 ;; of 'info registers'. | |
60 ;; 3) Use tree-widget.el instead of the speedbar for watch-expressions? | |
61 ;; 4) Mark breakpoint locations on scroll-bar of source buffer? | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
62 ;; 5) After release of 22.1 use '-var-list-children --all-values' |
59808 | 63 ;; and '-stack-list-locals 2' which need GDB 6.1 onwards. |
54538 | 64 |
65 ;;; Code: | |
66 | |
67 (require 'gud) | |
68 | |
69 (defvar gdb-current-address "main" "Initialisation for Assembler buffer.") | |
70 (defvar gdb-previous-address nil) | |
59808 | 71 (defvar gdb-memory-address "main") |
54538 | 72 (defvar gdb-previous-frame nil) |
55850
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
73 (defvar gdb-current-frame nil) |
58049
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
74 (defvar gdb-current-stack-level nil) |
54538 | 75 (defvar gdb-current-language nil) |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
76 (defvar gdb-var-list nil "List of variables in watch window.") |
54538 | 77 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.") |
78 (defvar gdb-buffer-type nil) | |
79 (defvar gdb-overlay-arrow-position nil) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
80 (defvar gdb-server-prefix nil) |
58431
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
81 (defvar gdb-flush-pending-output nil) |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
82 (defvar gdb-location-alist nil |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
83 "Alist of breakpoint numbers and full filenames.") |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
84 (defvar gdb-find-file-unhook nil) |
61896
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
85 (defvar gdb-active-process nil "GUD tooltips display variable values when t, \ |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
86 and #define directives otherwise.") |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
87 (defvar gdb-macro-info nil |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
88 "Non-nil if GDB knows that the inferior includes preprocessor macro info.") |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
89 |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
90 (defvar gdb-buffer-type nil |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
91 "One of the symbols bound in `gdb-buffer-rules'.") |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
92 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
93 (defvar gdb-input-queue () |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
94 "A list of gdb command objects.") |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
95 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
96 (defvar gdb-prompting nil |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
97 "True when gdb is idle with no pending input.") |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
98 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
99 (defvar gdb-output-sink 'user |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
100 "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
|
101 Possible values are these symbols: |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
102 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
103 `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
|
104 for the user to see. |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
105 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
106 `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
|
107 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
108 `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
|
109 annotation is received. Then the output-sink |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
110 becomes:... |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
111 `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
|
112 for subsequent processing by a command. This is the |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
113 disposition of output generated by commands that |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
114 gdb mode sends to gdb on its own behalf. |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
115 `post-emacs' -- ignore output until the prompt annotation is |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
116 received, then go to USER disposition. |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
117 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
118 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
|
119 \(`user' and `emacs').") |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
120 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
121 (defvar gdb-current-item nil |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
122 "The most recent command item sent to gdb.") |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
123 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
124 (defvar gdb-pending-triggers '() |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
125 "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
|
126 handlers.") |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
127 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
128 ;; end of gdb variables |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
129 |
54538 | 130 ;;;###autoload |
131 (defun gdba (command-line) | |
132 "Run gdb on program FILE in buffer *gud-FILE*. | |
133 The directory containing FILE becomes the initial working directory | |
134 and source-file directory for your debugger. | |
135 | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 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
|
140 |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
141 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
|
142 `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
|
143 `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
|
144 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
|
145 relevant buffer. |
54538 | 146 |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
147 Watch expressions appear in the speedbar/slowbar. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
148 |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
149 The following commands help control operation : |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
150 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
151 `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
|
152 `gdb-restore-windows' - To restore the window layout. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
153 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
154 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
|
155 detailed description of this mode. |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
156 |
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
157 |
54538 | 158 --------------------------------------------------------------------- |
159 GDB Toolbar | |
160 --------------------------------------------------------------------- | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
161 GUD buffer (I/O of GDB) | Locals buffer |
54538 | 162 | |
163 | | |
164 | | |
165 --------------------------------------------------------------------- | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
166 Source buffer | Input/Output (of inferior) buffer |
54538 | 167 | (comint-mode) |
168 | | |
169 | | |
170 | | |
171 | | |
172 | | |
173 | | |
174 --------------------------------------------------------------------- | |
54901
fa4feb8b3c34
(gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
54760
diff
changeset
|
175 Stack buffer | Breakpoints buffer |
54538 | 176 RET gdb-frames-select | SPC gdb-toggle-breakpoint |
177 | RET gdb-goto-breakpoint | |
178 | d gdb-delete-breakpoint | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
179 ---------------------------------------------------------------------" |
54538 | 180 ;; |
181 (interactive (list (gud-query-cmdline 'gdba))) | |
182 ;; | |
183 ;; Let's start with a basic gud-gdb buffer and then modify it a bit. | |
184 (gdb command-line) | |
185 (gdb-ann3)) | |
186 | |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
187 (defvar gdb-debug-log nil) |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
188 |
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
189 (defcustom gdb-enable-debug-log nil |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
190 "Non-nil means record the process input and output in `gdb-debug-log'." |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
191 :type 'boolean |
57851
67b88e92a24d
(gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents:
57791
diff
changeset
|
192 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
193 :version "22.1") |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
194 |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
195 (defcustom gdb-use-inferior-io-buffer nil |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
196 "Non-nil means display output from the inferior in a separate buffer." |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
197 :type 'boolean |
57851
67b88e92a24d
(gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents:
57791
diff
changeset
|
198 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
199 :version "22.1") |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
200 |
62115
515e18600ed2
(gdb-cpp-define-alist-program): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
62065
diff
changeset
|
201 (defcustom gdb-cpp-define-alist-program "gcc -E -dM -" |
515e18600ed2
(gdb-cpp-define-alist-program): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
62065
diff
changeset
|
202 "Shell command for generating a list of defined macros in a source file. |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
203 This list is used to display the #define directive associated |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
204 with an identifier as a tooltip. It works in a debug session with |
62136
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
205 GDB, when gud-tooltip-mode is t. |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
206 |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
207 Set `gdb-cpp-define-alist-flags' for any include paths or |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
208 predefined macros." |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
209 :type 'string |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
210 :group 'gud |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
211 :version "22.1") |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
212 |
62065
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
213 (defcustom gdb-cpp-define-alist-flags "" |
62136
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
214 "*Preprocessor flags for `gdb-cpp-define-alist-program'." |
62065
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
215 :type 'string |
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
216 :group 'gud |
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
217 :version "22.1") |
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
218 |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
219 (defvar gdb-define-alist nil "Alist of #define directives for GUD tooltips.") |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
220 |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
221 (defun gdb-create-define-alist () |
62065
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
222 "Create an alist of #define directives for GUD tooltips." |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
223 (let* ((file (buffer-file-name)) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
224 (output |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
225 (with-output-to-string |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
226 (with-current-buffer standard-output |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
227 (call-process shell-file-name |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
228 (if (file-exists-p file) file nil) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
229 (list t nil) nil "-c" |
62065
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
230 (concat gdb-cpp-define-alist-program " " |
115b0152e8bb
(gdb-cpp-define-alist-flags): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62050
diff
changeset
|
231 gdb-cpp-define-alist-flags))))) |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
232 (define-list (split-string output "\n" t)) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
233 (name)) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
234 (setq gdb-define-alist nil) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
235 (dolist (define define-list) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
236 (setq name (nth 1 (split-string define "[( ]"))) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
237 (push (cons name define) gdb-define-alist)))) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
238 |
62136
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
239 (defun gdb-tooltip-print () |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
240 (tooltip-show |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
241 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
242 (let ((string (buffer-string))) |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
243 ;; remove newline for gud-tooltip-echo-area |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
244 (substring string 0 (- (length string) 1)))) |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
245 gud-tooltip-echo-area)) |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
246 |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
247 ;; If expr is a macro for a function don't print because of possible dangerous |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
248 ;; side-effects. Also printing a function within a tooltip generates an |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
249 ;; unexpected starting annotation (phase error). |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
250 (defun gdb-tooltip-print-1 (expr) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
251 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
252 (goto-char (point-min)) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
253 (if (search-forward "expands to: " nil t) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
254 (unless (looking-at "\\S+.*(.*).*") |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
255 (gdb-enqueue-input |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
256 (list (concat gdb-server-prefix "print " expr "\n") |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
257 'gdb-tooltip-print)))))) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
258 |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
259 (defun gdb-set-gud-minor-mode (buffer) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
260 "Set gud-minor-mode from find-file if appropriate." |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
261 (goto-char (point-min)) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
262 (unless (search-forward "No source file named " nil t) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
263 (condition-case nil |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
264 (gdb-enqueue-input |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
265 (list (concat gdb-server-prefix "info source\n") |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
266 `(lambda () (gdb-set-gud-minor-mode-1 ,buffer)))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
267 (error (setq gdb-find-file-unhook t))))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
268 |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
269 (defun gdb-set-gud-minor-mode-1 (buffer) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
270 (goto-char (point-min)) |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
271 (when (and (search-forward "Located in " nil t) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
272 (looking-at "\\S-*") |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
273 (string-equal (buffer-file-name buffer) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
274 (match-string 0))) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
275 (with-current-buffer buffer |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
276 (set (make-local-variable 'gud-minor-mode) 'gdba) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
277 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) |
62136
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
278 (when gud-tooltip-mode |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
279 (make-local-variable 'gdb-define-alist) |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
280 (gdb-create-define-alist) |
69b9edc69fe5
(gdb-tooltip-print): Moved from tooltip.el.
Nick Roberts <nickrob@snap.net.nz>
parents:
62115
diff
changeset
|
281 (add-hook 'after-save-hook 'gdb-create-define-alist nil t))))) |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
282 |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
283 (defun gdb-set-gud-minor-mode-existing-buffers () |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
284 (dolist (buffer (buffer-list)) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
285 (let ((file (buffer-file-name buffer))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
286 (if file |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
287 (progn |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
288 (gdb-enqueue-input |
60124
106946a8423d
(gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents:
60073
diff
changeset
|
289 (list (concat gdb-server-prefix "list " |
106946a8423d
(gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents:
60073
diff
changeset
|
290 (file-name-nondirectory file) ":1\n") |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
291 `(lambda () (gdb-set-gud-minor-mode ,buffer))))))))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
292 |
54538 | 293 (defun gdb-ann3 () |
54616
47c4cb867a84
(gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents:
54538
diff
changeset
|
294 (setq gdb-debug-log nil) |
54538 | 295 (set (make-local-variable 'gud-minor-mode) 'gdba) |
296 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter) | |
297 ;; | |
298 (gud-def gud-break (if (not (string-equal mode-name "Machine")) | |
299 (gud-call "break %f:%l" arg) | |
300 (save-excursion | |
301 (beginning-of-line) | |
302 (forward-char 2) | |
303 (gud-call "break *%a" arg))) | |
304 "\C-b" "Set breakpoint at current line or address.") | |
305 ;; | |
306 (gud-def gud-remove (if (not (string-equal mode-name "Machine")) | |
307 (gud-call "clear %f:%l" arg) | |
308 (save-excursion | |
309 (beginning-of-line) | |
310 (forward-char 2) | |
311 (gud-call "clear *%a" arg))) | |
312 "\C-d" "Remove breakpoint at current line or address.") | |
313 ;; | |
314 (gud-def gud-until (if (not (string-equal mode-name "Machine")) | |
315 (gud-call "until %f:%l" arg) | |
316 (save-excursion | |
317 (beginning-of-line) | |
318 (forward-char 2) | |
319 (gud-call "until *%a" arg))) | |
320 "\C-u" "Continue to current line or address.") | |
321 | |
322 (define-key gud-minor-mode-map [left-margin mouse-1] | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
323 'gdb-mouse-set-clear-breakpoint) |
54538 | 324 (define-key gud-minor-mode-map [left-fringe mouse-1] |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
325 'gdb-mouse-set-clear-breakpoint) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
326 (define-key gud-minor-mode-map [left-margin mouse-3] |
54538 | 327 'gdb-mouse-toggle-breakpoint) |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
328 ; Currently only works in margin. |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
329 ; (define-key gud-minor-mode-map [left-fringe mouse-3] |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
330 ; 'gdb-mouse-toggle-breakpoint) |
54538 | 331 |
332 (setq comint-input-sender 'gdb-send) | |
333 ;; | |
57664
4d6eec4c1ef8
* progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents:
57661
diff
changeset
|
334 ;; (re-)initialize |
54538 | 335 (setq gdb-current-address "main") |
336 (setq gdb-previous-address nil) | |
59808 | 337 (setq gdb-memory-address "main") |
54538 | 338 (setq gdb-previous-frame nil) |
55850
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
339 (setq gdb-current-frame nil) |
58049
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
340 (setq gdb-current-stack-level nil) |
54538 | 341 (setq gdb-var-list nil) |
342 (setq gdb-var-changed nil) | |
343 (setq gdb-first-prompt nil) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
344 (setq gdb-prompting nil) |
57350
11b8de2051f3
(gdb-ann3): (Re-)initialise gdb-input-queue.
Nick Roberts <nickrob@snap.net.nz>
parents:
57262
diff
changeset
|
345 (setq gdb-input-queue nil) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
346 (setq gdb-current-item nil) |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
347 (setq gdb-pending-triggers nil) |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
348 (setq gdb-output-sink 'user) |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
349 (setq gdb-server-prefix "server ") |
58431
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
350 (setq gdb-flush-pending-output nil) |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
351 (setq gdb-location-alist nil) |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
352 (setq gdb-find-file-unhook nil) |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
353 (setq gdb-macro-info nil) |
54538 | 354 ;; |
355 (setq gdb-buffer-type 'gdba) | |
356 ;; | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
357 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) |
54538 | 358 ;; |
359 (if (eq window-system 'w32) | |
360 (gdb-enqueue-input (list "set new-console off\n" 'ignore))) | |
361 (gdb-enqueue-input (list "set height 0\n" 'ignore)) | |
59998
c2d7ae01e91d
(gdb-ann3): Re-instate GDB command "set
Nick Roberts <nickrob@snap.net.nz>
parents:
59996
diff
changeset
|
362 (gdb-enqueue-input (list "set width 0\n" 'ignore)) |
54538 | 363 ;; find source file and compilation directory here |
364 (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program | |
365 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program | |
366 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) | |
367 ;; | |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
368 (gdb-set-gud-minor-mode-existing-buffers) |
54538 | 369 (run-hooks 'gdba-mode-hook)) |
370 | |
371 (defcustom gdb-use-colon-colon-notation nil | |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
372 "If non-nil use FUN::VAR format to display variables in the speedbar." |
54538 | 373 :type 'boolean |
57851
67b88e92a24d
(gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents:
57791
diff
changeset
|
374 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
375 :version "22.1") |
54538 | 376 |
377 (defun gud-watch () | |
378 "Watch expression at point." | |
379 (interactive) | |
380 (require 'tooltip) | |
381 (let ((expr (tooltip-identifier-from-point (point)))) | |
382 (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
|
383 gdb-use-colon-colon-notation gdb-current-frame) |
54538 | 384 (setq expr (concat gdb-current-frame "::" expr))) |
385 (catch 'already-watched | |
386 (dolist (var gdb-var-list) | |
387 (if (string-equal expr (car var)) (throw 'already-watched nil))) | |
388 (set-text-properties 0 (length expr) nil expr) | |
389 (gdb-enqueue-input | |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
390 (list |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
391 (if (eq gud-minor-mode 'gdba) |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
392 (concat "server interpreter mi \"-var-create - * " expr "\"\n") |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
393 (concat"-var-create - * " expr "\n")) |
54538 | 394 `(lambda () (gdb-var-create-handler ,expr)))))) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
395 (select-window (get-buffer-window gud-comint-buffer 0))) |
54538 | 396 |
397 (defconst gdb-var-create-regexp | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
398 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"") |
54538 | 399 |
400 (defun gdb-var-create-handler (expr) | |
401 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
402 (goto-char (point-min)) | |
403 (if (re-search-forward gdb-var-create-regexp nil t) | |
404 (let ((var (list expr | |
405 (match-string 1) | |
406 (match-string 2) | |
407 (match-string 3) | |
408 nil nil))) | |
409 (push var gdb-var-list) | |
410 (speedbar 1) | |
411 (if (equal (nth 2 var) "0") | |
412 (gdb-enqueue-input | |
60477
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
413 (list |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
414 (if (with-current-buffer |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
415 gud-comint-buffer (eq gud-minor-mode 'gdba)) |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
416 (concat "server interpreter mi \"-var-evaluate-expression " |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
417 (nth 1 var) "\"\n") |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
418 (concat "-var-evaluate-expression " (nth 1 var) "\n")) |
54538 | 419 `(lambda () (gdb-var-evaluate-expression-handler |
420 ,(nth 1 var) nil)))) | |
421 (setq gdb-var-changed t))) | |
422 (if (re-search-forward "Undefined command" nil t) | |
60541
fbf903562871
(gdb-var-create-handler, gdb-get-location):
Nick Roberts <nickrob@snap.net.nz>
parents:
60477
diff
changeset
|
423 (message-box "Watching expressions requires gdb 6.0 onwards") |
54538 | 424 (message "No symbol %s in current context." expr))))) |
425 | |
426 (defun gdb-var-evaluate-expression-handler (varnum changed) | |
427 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
428 (goto-char (point-min)) | |
429 (re-search-forward ".*value=\"\\(.*?\\)\"" nil t) | |
430 (catch 'var-found | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
431 (let ((num 0)) |
54538 | 432 (dolist (var gdb-var-list) |
433 (if (string-equal varnum (cadr var)) | |
434 (progn | |
435 (if changed (setcar (nthcdr 5 var) t)) | |
436 (setcar (nthcdr 4 var) (match-string 1)) | |
437 (setcar (nthcdr num gdb-var-list) var) | |
438 (throw 'var-found nil))) | |
439 (setq num (+ num 1)))))) | |
440 (setq gdb-var-changed t)) | |
441 | |
442 (defun gdb-var-list-children (varnum) | |
443 (gdb-enqueue-input | |
60477
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
444 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n") |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
445 `(lambda () (gdb-var-list-children-handler ,varnum))))) |
54538 | 446 |
447 (defconst gdb-var-list-children-regexp | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
448 "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\"") |
54538 | 449 |
450 (defun gdb-var-list-children-handler (varnum) | |
451 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
452 (goto-char (point-min)) | |
453 (let ((var-list nil)) | |
454 (catch 'child-already-watched | |
455 (dolist (var gdb-var-list) | |
456 (if (string-equal varnum (cadr var)) | |
457 (progn | |
458 (push var var-list) | |
459 (while (re-search-forward gdb-var-list-children-regexp nil t) | |
460 (let ((varchild (list (match-string 2) | |
461 (match-string 1) | |
462 (match-string 3) | |
463 nil nil nil))) | |
464 (if (looking-at ",type=\"\\(.*?\\)\"") | |
465 (setcar (nthcdr 3 varchild) (match-string 1))) | |
466 (dolist (var1 gdb-var-list) | |
467 (if (string-equal (cadr var1) (cadr varchild)) | |
468 (throw 'child-already-watched nil))) | |
469 (push varchild var-list) | |
470 (if (equal (nth 2 varchild) "0") | |
471 (gdb-enqueue-input | |
472 (list | |
473 (concat | |
474 "server interpreter mi \"-var-evaluate-expression " | |
475 (nth 1 varchild) "\"\n") | |
476 `(lambda () (gdb-var-evaluate-expression-handler | |
477 ,(nth 1 varchild) nil)))))))) | |
478 (push var var-list))) | |
479 (setq gdb-var-list (nreverse var-list)))))) | |
480 | |
481 (defun gdb-var-update () | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
482 (if (not (member 'gdb-var-update gdb-pending-triggers)) |
54538 | 483 (progn |
55764
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
484 (gdb-enqueue-input |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
485 (list |
55764
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
486 (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
|
487 "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
|
488 "-var-update *\n") |
54538 | 489 'gdb-var-update-handler)) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
490 (push 'gdb-var-update gdb-pending-triggers)))) |
54538 | 491 |
492 (defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"") | |
493 | |
494 (defun gdb-var-update-handler () | |
495 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
496 (goto-char (point-min)) | |
497 (while (re-search-forward gdb-var-update-regexp nil t) | |
498 (let ((varnum (match-string 1))) | |
499 (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
|
500 (list |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
501 (if (with-current-buffer gud-comint-buffer |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
502 (eq gud-minor-mode 'gdba)) |
55764
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
503 (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
|
504 varnum "\"\n") |
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
505 (concat "-var-evaluate-expression " varnum "\n")) |
54538 | 506 `(lambda () (gdb-var-evaluate-expression-handler |
507 ,varnum t))))))) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
508 (setq gdb-pending-triggers |
60153
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
509 (delq 'gdb-var-update gdb-pending-triggers)) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
510 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
511 ;; dummy command to update speedbar at right time |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
512 (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn)) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
513 ;; keep gdb-pending-triggers non-nil till end |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
514 (push 'gdb-speedbar-timer gdb-pending-triggers))) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
515 |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
516 (defun gdb-speedbar-timer-fn () |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
517 (setq gdb-pending-triggers |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
518 (delq 'gdb-speedbar-timer gdb-pending-triggers)) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
519 (with-current-buffer gud-comint-buffer |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
520 (speedbar-timer-fn))) |
54538 | 521 |
522 (defun gdb-var-delete () | |
523 "Delete watched expression from the speedbar." | |
524 (interactive) | |
525 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)) | |
526 (let ((text (speedbar-line-text))) | |
527 (string-match "\\(\\S-+\\)" text) | |
528 (let* ((expr (match-string 1 text)) | |
529 (var (assoc expr gdb-var-list)) | |
530 (varnum (cadr var))) | |
531 (unless (string-match "\\." varnum) | |
532 (gdb-enqueue-input | |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
533 (list |
55764
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
534 (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
|
535 (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
|
536 (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
|
537 (concat "-var-delete " varnum "\n")) |
54538 | 538 'ignore)) |
539 (setq gdb-var-list (delq var gdb-var-list)) | |
540 (dolist (varchild gdb-var-list) | |
541 (if (string-match (concat (nth 1 var) "\\.") (nth 1 varchild)) | |
542 (setq gdb-var-list (delq varchild gdb-var-list)))) | |
543 (setq gdb-var-changed t)))))) | |
544 | |
545 (defun gdb-edit-value (text token indent) | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
546 "Assign a value to a variable displayed in the speedbar." |
54538 | 547 (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list)) |
548 (varnum (cadr var)) (value)) | |
549 (setq value (read-string "New value: ")) | |
550 (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
|
551 (list |
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
552 (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
|
553 (eq gud-minor-mode 'gdba)) |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
554 (concat "server interpreter mi \"-var-assign " |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
555 varnum " " value "\"\n") |
55764
25f133a490aa
(gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents:
55762
diff
changeset
|
556 (concat "-var-assign " varnum " " value "\n")) |
54538 | 557 'ignore)))) |
558 | |
559 (defcustom gdb-show-changed-values t | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
560 "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
|
561 The highlighting is done with `font-lock-warning-face'." |
54538 | 562 :type 'boolean |
58049
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
563 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
564 :version "22.1") |
54538 | 565 |
566 (defun gdb-speedbar-expand-node (text token indent) | |
567 "Expand the node the user clicked on. | |
568 TEXT is the text of the button we clicked on, a + or - item. | |
569 TOKEN is data related to this node. | |
570 INDENT is the current indentation depth." | |
571 (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
|
572 (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
|
573 (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
|
574 (gdbmi-var-list-children token))) |
54538 | 575 ((string-match "-" text) ;contract this node |
576 (dolist (var gdb-var-list) | |
577 (if (string-match (concat token "\\.") (nth 1 var)) | |
578 (setq gdb-var-list (delq var gdb-var-list)))) | |
579 (setq gdb-var-changed t)))) | |
580 | |
581 (defun gdb-get-target-string () | |
582 (with-current-buffer gud-comint-buffer | |
583 gud-target-name)) | |
584 | |
585 | |
586 ;; | |
587 ;; gdb buffers. | |
588 ;; | |
589 ;; Each buffer has a TYPE -- a symbol that identifies the function | |
590 ;; of that particular buffer. | |
591 ;; | |
592 ;; The usual gdb interaction buffer is given the type `gdba' and | |
593 ;; is constructed specially. | |
594 ;; | |
595 ;; Others are constructed by gdb-get-create-buffer and | |
596 ;; named according to the rules set forth in the gdb-buffer-rules-assoc | |
597 | |
598 (defvar gdb-buffer-rules-assoc '()) | |
599 | |
600 (defun gdb-get-buffer (key) | |
601 "Return the gdb buffer tagged with type KEY. | |
602 The key should be one of the cars in `gdb-buffer-rules-assoc'." | |
603 (save-excursion | |
604 (gdb-look-for-tagged-buffer key (buffer-list)))) | |
605 | |
606 (defun gdb-get-create-buffer (key) | |
607 "Create a new gdb buffer of the type specified by KEY. | |
608 The key should be one of the cars in `gdb-buffer-rules-assoc'." | |
609 (or (gdb-get-buffer key) | |
610 (let* ((rules (assoc key gdb-buffer-rules-assoc)) | |
611 (name (funcall (gdb-rules-name-maker rules))) | |
612 (new (get-buffer-create name))) | |
613 (with-current-buffer new | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
614 (let ((trigger)) |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
615 (if (cdr (cdr rules)) |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
616 (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
|
617 (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
|
618 (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
|
619 (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
|
620 (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
|
621 (if trigger (funcall trigger))) |
54538 | 622 new)))) |
623 | |
624 (defun gdb-rules-name-maker (rules) (car (cdr rules))) | |
625 | |
626 (defun gdb-look-for-tagged-buffer (key bufs) | |
627 (let ((retval nil)) | |
628 (while (and (not retval) bufs) | |
629 (set-buffer (car bufs)) | |
630 (if (eq gdb-buffer-type key) | |
631 (setq retval (car bufs))) | |
632 (setq bufs (cdr bufs))) | |
633 retval)) | |
634 | |
635 ;; | |
636 ;; This assoc maps buffer type symbols to rules. Each rule is a list of | |
637 ;; at least one and possible more functions. The functions have these | |
638 ;; roles in defining a buffer type: | |
639 ;; | |
640 ;; NAME - Return a name for this buffer type. | |
641 ;; | |
642 ;; The remaining function(s) are optional: | |
643 ;; | |
644 ;; MODE - called in a new buffer with no arguments, should establish | |
645 ;; the proper mode for the buffer. | |
646 ;; | |
647 | |
648 (defun gdb-set-buffer-rules (buffer-type &rest rules) | |
649 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc))) | |
650 (if binding | |
651 (setcdr binding rules) | |
652 (push (cons buffer-type rules) | |
653 gdb-buffer-rules-assoc)))) | |
654 | |
655 ;; GUD buffers are an exception to the rules | |
656 (gdb-set-buffer-rules 'gdba 'error) | |
657 | |
658 ;; | |
659 ;; Partial-output buffer : This accumulates output from a command executed on | |
660 ;; behalf of emacs (rather than the user). | |
661 ;; | |
662 (gdb-set-buffer-rules 'gdb-partial-output-buffer | |
663 'gdb-partial-output-name) | |
664 | |
665 (defun gdb-partial-output-name () | |
666 (concat "*partial-output-" | |
667 (gdb-get-target-string) | |
668 "*")) | |
669 | |
670 | |
671 (gdb-set-buffer-rules 'gdb-inferior-io | |
672 'gdb-inferior-io-name | |
673 'gdb-inferior-io-mode) | |
674 | |
675 (defun gdb-inferior-io-name () | |
676 (concat "*input/output of " | |
677 (gdb-get-target-string) | |
678 "*")) | |
679 | |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
680 (defun gdb-display-inferior-io-buffer () |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
681 "Display IO of inferior in a separate window." |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
682 (interactive) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
683 (if gdb-use-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
684 (gdb-display-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
685 (gdb-get-create-buffer 'gdb-inferior-io)))) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
686 |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
687 (defun gdb-frame-inferior-io-buffer () |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
688 "Display IO of inferior in a new frame." |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
689 (interactive) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
690 (if gdb-use-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
691 (let ((special-display-regexps (append special-display-regexps '(".*"))) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
692 (special-display-frame-alist gdb-frame-parameters)) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
693 (display-buffer (gdb-get-create-buffer 'gdb-inferior-io))))) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
694 |
54538 | 695 (defvar gdb-inferior-io-mode-map |
696 (let ((map (make-sparse-keymap))) | |
697 (define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt) | |
698 (define-key map "\C-c\C-z" 'gdb-inferior-io-stop) | |
699 (define-key map "\C-c\C-\\" 'gdb-inferior-io-quit) | |
700 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof) | |
701 map)) | |
702 | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
703 (define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O" |
54538 | 704 "Major mode for gdb inferior-io." |
705 :syntax-table nil :abbrev-table nil | |
706 ;; We want to use comint because it has various nifty and familiar | |
707 ;; features. We don't need a process, but comint wants one, so create | |
708 ;; a dummy one. | |
709 (make-comint-in-buffer | |
710 (substring (buffer-name) 1 (- (length (buffer-name)) 1)) | |
711 (current-buffer) "hexl") | |
712 (setq comint-input-sender 'gdb-inferior-io-sender)) | |
713 | |
714 (defun gdb-inferior-io-sender (proc string) | |
715 ;; PROC is the pseudo-process created to satisfy comint. | |
716 (with-current-buffer (process-buffer proc) | |
717 (setq proc (get-buffer-process gud-comint-buffer)) | |
718 (process-send-string proc string) | |
719 (process-send-string proc "\n"))) | |
720 | |
721 (defun gdb-inferior-io-interrupt () | |
722 "Interrupt the program being debugged." | |
723 (interactive) | |
724 (interrupt-process | |
725 (get-buffer-process gud-comint-buffer) comint-ptyp)) | |
726 | |
727 (defun gdb-inferior-io-quit () | |
728 "Send quit signal to the program being debugged." | |
729 (interactive) | |
730 (quit-process | |
731 (get-buffer-process gud-comint-buffer) comint-ptyp)) | |
732 | |
733 (defun gdb-inferior-io-stop () | |
734 "Stop the program being debugged." | |
735 (interactive) | |
736 (stop-process | |
737 (get-buffer-process gud-comint-buffer) comint-ptyp)) | |
738 | |
739 (defun gdb-inferior-io-eof () | |
740 "Send end-of-file to the program being debugged." | |
741 (interactive) | |
742 (process-send-eof | |
743 (get-buffer-process gud-comint-buffer))) | |
744 | |
745 | |
746 ;; | |
747 ;; gdb communications | |
748 ;; | |
749 | |
750 ;; INPUT: things sent to gdb | |
751 ;; | |
752 ;; The queues are lists. Each element is either a string (indicating user or | |
753 ;; user-like input) or a list of the form: | |
754 ;; | |
755 ;; (INPUT-STRING HANDLER-FN) | |
756 ;; | |
757 ;; The handler function will be called from the partial-output buffer when the | |
758 ;; command completes. This is the way to write commands which invoke gdb | |
759 ;; commands autonomously. | |
760 ;; | |
761 ;; These lists are consumed tail first. | |
762 ;; | |
763 | |
764 (defun gdb-send (proc string) | |
765 "A comint send filter for gdb. | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
766 This filter may simply queue input for a later time." |
60477
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
767 (let ((item (concat string "\n"))) |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
768 (if gud-running |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
769 (progn |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
770 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
771 (process-send-string proc item)) |
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
772 (gdb-enqueue-input item)))) |
54538 | 773 |
774 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it | |
775 ;; is a query, or other non-top-level prompt. | |
776 | |
777 (defun gdb-enqueue-input (item) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
778 (if gdb-prompting |
54538 | 779 (progn |
780 (gdb-send-item item) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
781 (setq gdb-prompting nil)) |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
782 (push item gdb-input-queue))) |
54538 | 783 |
784 (defun gdb-dequeue-input () | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
785 (let ((queue gdb-input-queue)) |
54538 | 786 (and queue |
787 (let ((last (car (last queue)))) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
788 (unless (nbutlast queue) (setq gdb-input-queue '())) |
54538 | 789 last)))) |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
790 |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
791 (defun gdb-send-item (item) |
58431
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
792 (setq gdb-flush-pending-output nil) |
60477
2b7513e741b1
(gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents:
60326
diff
changeset
|
793 (if gdb-enable-debug-log (push (cons 'send-item item) gdb-debug-log)) |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
794 (setq gdb-current-item item) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
795 (with-current-buffer gud-comint-buffer |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
796 (if (eq gud-minor-mode 'gdba) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
797 (if (stringp item) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
798 (progn |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
799 (setq gdb-output-sink 'user) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
800 (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
|
801 (progn |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
802 (gdb-clear-partial-output) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
803 (setq gdb-output-sink 'pre-emacs) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
804 (process-send-string (get-buffer-process gud-comint-buffer) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
805 (car item)))) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
806 ;; case: eq gud-minor-mode 'gdbmi |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
807 (gdb-clear-partial-output) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
808 (setq gdb-output-sink 'emacs) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
809 (process-send-string (get-buffer-process gud-comint-buffer) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
810 (car item))))) |
54538 | 811 |
812 ;; | |
813 ;; output -- things gdb prints to emacs | |
814 ;; | |
815 ;; GDB output is a stream interrupted by annotations. | |
816 ;; Annotations can be recognized by their beginning | |
817 ;; with \C-j\C-z\C-z<tag><opt>\C-j | |
818 ;; | |
819 ;; The tag is a string obeying symbol syntax. | |
820 ;; | |
821 ;; The optional part `<opt>' can be either the empty string | |
822 ;; or a space followed by more data relating to the annotation. | |
823 ;; For example, the SOURCE annotation is followed by a filename, | |
824 ;; line number and various useless goo. This data must not include | |
825 ;; any newlines. | |
826 ;; | |
827 | |
828 (defcustom gud-gdba-command-name "gdb -annotate=3" | |
829 "Default command to execute an executable under the GDB-UI debugger." | |
830 :type 'string | |
57851
67b88e92a24d
(gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents:
57791
diff
changeset
|
831 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
832 :version "22.1") |
54538 | 833 |
834 (defvar gdb-annotation-rules | |
835 '(("pre-prompt" gdb-pre-prompt) | |
836 ("prompt" gdb-prompt) | |
837 ("commands" gdb-subprompt) | |
838 ("overload-choice" gdb-subprompt) | |
839 ("query" gdb-subprompt) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
840 ;; 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
|
841 ("nquery" gdb-subprompt) |
54538 | 842 ("prompt-for-continue" gdb-subprompt) |
843 ("post-prompt" gdb-post-prompt) | |
844 ("source" gdb-source) | |
845 ("starting" gdb-starting) | |
61896
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
846 ("exited" gdb-exited) |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
847 ("signalled" gdb-exited) |
54538 | 848 ("signal" gdb-stopping) |
849 ("breakpoint" gdb-stopping) | |
850 ("watchpoint" gdb-stopping) | |
851 ("frame-begin" gdb-frame-begin) | |
852 ("stopped" gdb-stopped) | |
853 ) "An assoc mapping annotation tags to functions which process them.") | |
854 | |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
855 (defun gdb-resync() |
58431
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
856 (setq gdb-flush-pending-output t) |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
857 (setq gud-running nil) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
858 (setq gdb-output-sink 'user) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
859 (setq gdb-input-queue nil) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
860 (setq gdb-pending-triggers nil) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
861 (setq gdb-prompting t)) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
862 |
54538 | 863 (defconst gdb-source-spec-regexp |
864 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)") | |
865 | |
866 ;; Do not use this except as an annotation handler. | |
867 (defun gdb-source (args) | |
868 (string-match gdb-source-spec-regexp args) | |
869 ;; Extract the frame position from the marker. | |
870 (setq gud-last-frame | |
871 (cons | |
872 (match-string 1 args) | |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
873 (string-to-number (match-string 2 args)))) |
54538 | 874 (setq gdb-current-address (match-string 3 args)) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
875 ;; cover for auto-display output which comes *before* |
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
876 ;; stopped annotation |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
877 (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user))) |
54538 | 878 |
879 (defun gdb-pre-prompt (ignored) | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
880 "An annotation handler for `pre-prompt'. |
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
881 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
|
882 happens to be in effect." |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
883 (let ((sink gdb-output-sink)) |
54538 | 884 (cond |
885 ((eq sink 'user) t) | |
886 ((eq sink 'emacs) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
887 (setq gdb-output-sink 'post-emacs)) |
54538 | 888 (t |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
889 (gdb-resync) |
54538 | 890 (error "Phase error in gdb-pre-prompt (got %s)" sink))))) |
891 | |
892 (defun gdb-prompt (ignored) | |
893 "An annotation handler for `prompt'. | |
894 This sends the next command (if any) to gdb." | |
895 (when gdb-first-prompt (gdb-ann3)) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
896 (let ((sink gdb-output-sink)) |
54538 | 897 (cond |
898 ((eq sink 'user) t) | |
899 ((eq sink 'post-emacs) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
900 (setq gdb-output-sink 'user) |
54538 | 901 (let ((handler |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
902 (car (cdr gdb-current-item)))) |
54538 | 903 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) |
904 (funcall handler)))) | |
905 (t | |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
906 (gdb-resync) |
54538 | 907 (error "Phase error in gdb-prompt (got %s)" sink)))) |
908 (let ((input (gdb-dequeue-input))) | |
909 (if input | |
910 (gdb-send-item input) | |
911 (progn | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
912 (setq gdb-prompting t) |
54538 | 913 (gud-display-frame))))) |
914 | |
915 (defun gdb-subprompt (ignored) | |
916 "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
|
917 (setq gdb-prompting t)) |
54538 | 918 |
919 (defun gdb-starting (ignored) | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
920 "An annotation handler for `starting'. |
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
921 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
|
922 not GDB." |
61896
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
923 (setq gdb-active-process t) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
924 (let ((sink gdb-output-sink)) |
54538 | 925 (cond |
926 ((eq sink 'user) | |
927 (progn | |
928 (setq gud-running t) | |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
929 (if gdb-use-inferior-io-buffer |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
930 (setq gdb-output-sink 'inferior)))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
931 (t |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
932 (gdb-resync) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
933 (error "Unexpected `starting' annotation"))))) |
54538 | 934 |
935 (defun gdb-stopping (ignored) | |
61896
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
936 "An annotation handler for `breakpoint' and other annotations. |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
937 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
|
938 being debugged." |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
939 (if gdb-use-inferior-io-buffer |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
940 (let ((sink gdb-output-sink)) |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
941 (cond |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
942 ((eq sink 'inferior) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
943 (setq gdb-output-sink 'user)) |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
944 (t |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
945 (gdb-resync) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
946 (error "Unexpected stopping annotation")))))) |
54538 | 947 |
61896
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
948 (defun gdb-exited (ignored) |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
949 "An annotation handler for `exited' and `signalled'. |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
950 They say that I/O for the subprocess is now GDB, not the program |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
951 being debugged and that the program is no longer running. This |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
952 function is used to change the focus of GUD tooltips to #define |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
953 directives." |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
954 (setq gdb-active-process nil) |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
955 (gdb-stopping ignored)) |
e8b38798dd7b
(gdb-active-process): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
61870
diff
changeset
|
956 |
54538 | 957 (defun gdb-frame-begin (ignored) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
958 (let ((sink gdb-output-sink)) |
54538 | 959 (cond |
960 ((eq sink 'inferior) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
961 (setq gdb-output-sink 'user)) |
54538 | 962 ((eq sink 'user) t) |
963 ((eq sink 'emacs) t) | |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
964 (t |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
965 (gdb-resync) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
966 (error "Unexpected frame-begin annotation (%S)" sink))))) |
54538 | 967 |
968 (defun gdb-stopped (ignored) | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
969 "An annotation handler for `stopped'. |
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
970 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
|
971 sink to `user' in `gdb-stopping', that is fine." |
54538 | 972 (setq gud-running nil) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
973 (let ((sink gdb-output-sink)) |
54538 | 974 (cond |
975 ((eq sink 'inferior) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
976 (setq gdb-output-sink 'user)) |
54538 | 977 ((eq sink 'user) t) |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
978 (t |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
979 (gdb-resync) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
980 (error "Unexpected stopped annotation"))))) |
54538 | 981 |
982 (defun gdb-post-prompt (ignored) | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
983 "An annotation handler for `post-prompt'. |
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
984 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
|
985 happens to be appropriate." |
60326
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
986 (unless gdb-pending-triggers |
54538 | 987 (gdb-get-current-frame) |
988 (gdb-invalidate-frames) | |
989 (gdb-invalidate-breakpoints) | |
990 (gdb-invalidate-assembler) | |
991 (gdb-invalidate-registers) | |
59808 | 992 (gdb-invalidate-memory) |
54538 | 993 (gdb-invalidate-locals) |
994 (gdb-invalidate-threads) | |
54617
9049edac1117
(gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54616
diff
changeset
|
995 (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
|
996 ;; FIXME: with GDB-6 on Darwin, this might very well work. |
60153
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
997 ;; only needed/used with speedbar/watch expressions |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
998 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
999 (setq gdb-var-changed t) ; force update |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
1000 (dolist (var gdb-var-list) |
10993bad7aee
(gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents:
60124
diff
changeset
|
1001 (setcar (nthcdr 5 var) nil)) |
60326
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
1002 (gdb-var-update)))) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1003 (let ((sink gdb-output-sink)) |
54538 | 1004 (cond |
1005 ((eq sink 'user) t) | |
1006 ((eq sink 'pre-emacs) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1007 (setq gdb-output-sink 'emacs)) |
54538 | 1008 (t |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
1009 (gdb-resync) |
54538 | 1010 (error "Phase error in gdb-post-prompt (got %s)" sink))))) |
1011 | |
1012 (defun gud-gdba-marker-filter (string) | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
1013 "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
|
1014 (if gdb-flush-pending-output |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1015 nil |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1016 (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
|
1017 ;; 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
|
1018 (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
|
1019 ;; Start accumulating output for the GUD buffer |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1020 (let ((output "")) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1021 ;; |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1022 ;; 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
|
1023 (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
|
1024 (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
|
1025 ;; |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1026 ;; 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
|
1027 ;; 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
|
1028 ;; elsewhere. |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1029 (setq output |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1030 (gdb-concat-output |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1031 output |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1032 (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
|
1033 ;; |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1034 ;; 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
|
1035 (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
|
1036 ;; |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1037 ;; 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
|
1038 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1039 (let* ((annotation-type (match-string 1 annotation)) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1040 (annotation-arguments (match-string 2 annotation)) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1041 (annotation-rule (assoc annotation-type |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1042 gdb-annotation-rules))) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1043 ;; Call the handler for this annotation. |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1044 (if annotation-rule |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1045 (funcall (car (cdr annotation-rule)) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1046 annotation-arguments) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1047 ;; 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
|
1048 ;; 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
|
1049 ;; us to blow up. |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1050 )))) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1051 ;; |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1052 ;; 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
|
1053 ;; 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
|
1054 (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
|
1055 gud-marker-acc) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1056 (progn |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1057 ;; 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
|
1058 (setq output |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1059 (gdb-concat-output output |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1060 (substring gud-marker-acc 0 |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1061 (match-beginning 0)))) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1062 ;; |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1063 ;; Everything after, we save, to combine with later input. |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1064 (setq gud-marker-acc (substring gud-marker-acc |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1065 (match-beginning 0)))) |
54538 | 1066 ;; |
58431
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1067 ;; In case we know the gud-marker-acc contains no partial annotations: |
54538 | 1068 (progn |
58431
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1069 (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
|
1070 (setq gud-marker-acc ""))) |
da65edef151e
(gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
58420
diff
changeset
|
1071 output))) |
54538 | 1072 |
1073 (defun gdb-concat-output (so-far new) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1074 (let ((sink gdb-output-sink)) |
54538 | 1075 (cond |
1076 ((eq sink 'user) (concat so-far new)) | |
1077 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) | |
1078 ((eq sink 'emacs) | |
1079 (gdb-append-to-partial-output new) | |
1080 so-far) | |
1081 ((eq sink 'inferior) | |
1082 (gdb-append-to-inferior-io new) | |
1083 so-far) | |
58420
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
1084 (t |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
1085 (gdb-resync) |
97e4fc5c7297
(gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents:
58049
diff
changeset
|
1086 (error "Bogon output sink %S" sink))))) |
54538 | 1087 |
1088 (defun gdb-append-to-partial-output (string) | |
1089 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
1090 (goto-char (point-max)) | |
1091 (insert string))) | |
1092 | |
1093 (defun gdb-clear-partial-output () | |
1094 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | |
1095 (erase-buffer))) | |
1096 | |
1097 (defun gdb-append-to-inferior-io (string) | |
1098 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io) | |
1099 (goto-char (point-max)) | |
1100 (insert-before-markers string)) | |
1101 (if (not (string-equal string "")) | |
1102 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))) | |
1103 | |
1104 (defun gdb-clear-inferior-io () | |
1105 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io) | |
1106 (erase-buffer))) | |
1107 | |
1108 | |
1109 ;; One trick is to have a command who's output is always available in a buffer | |
1110 ;; of it's own, and is always up to date. We build several buffers of this | |
1111 ;; type. | |
1112 ;; | |
1113 ;; There are two aspects to this: gdb has to tell us when the output for that | |
1114 ;; command might have changed, and we have to be able to run the command | |
1115 ;; behind the user's back. | |
1116 ;; | |
1117 ;; The output phasing associated with the variable gdb-output-sink | |
1118 ;; help us to run commands behind the user's back. | |
1119 ;; | |
1120 ;; Below is the code for specificly managing buffers of output from one | |
1121 ;; command. | |
1122 ;; | |
1123 | |
1124 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES | |
1125 ;; It adds an input for the command we are tracking. It should be the | |
1126 ;; annotation rule binding of whatever gdb sends to tell us this command | |
1127 ;; might have changed it's output. | |
1128 ;; | |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1129 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed. |
54538 | 1130 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the |
1131 ;; input in the input queue (see comment about ``gdb communications'' above). | |
1132 | |
1133 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command | |
1134 output-handler) | |
1135 `(defun ,name (&optional ignored) | |
1136 (if (and (,demand-predicate) | |
1137 (not (member ',name | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1138 gdb-pending-triggers))) |
54538 | 1139 (progn |
1140 (gdb-enqueue-input | |
1141 (list ,gdb-command ',output-handler)) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1142 (push ',name gdb-pending-triggers))))) |
54538 | 1143 |
1144 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) | |
1145 `(defun ,name () | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1146 (setq gdb-pending-triggers |
54538 | 1147 (delq ',trigger |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1148 gdb-pending-triggers)) |
54538 | 1149 (let ((buf (gdb-get-buffer ',buf-key))) |
1150 (and buf | |
1151 (with-current-buffer buf | |
1152 (let ((p (point)) | |
1153 (buffer-read-only nil)) | |
1154 (erase-buffer) | |
1155 (insert-buffer-substring (gdb-get-create-buffer | |
1156 'gdb-partial-output-buffer)) | |
1157 (goto-char p))))) | |
1158 ;; put customisation here | |
1159 (,custom-defun))) | |
1160 | |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1161 (defmacro def-gdb-auto-updated-buffer (buffer-key |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1162 trigger-name gdb-command |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1163 output-handler-name custom-defun) |
54538 | 1164 `(progn |
1165 (def-gdb-auto-update-trigger ,trigger-name | |
1166 ;; The demand predicate: | |
1167 (lambda () (gdb-get-buffer ',buffer-key)) | |
1168 ,gdb-command | |
1169 ,output-handler-name) | |
1170 (def-gdb-auto-update-handler ,output-handler-name | |
1171 ,trigger-name ,buffer-key ,custom-defun))) | |
1172 | |
1173 | |
1174 ;; | |
1175 ;; Breakpoint buffer : This displays the output of `info breakpoints'. | |
1176 ;; | |
1177 (gdb-set-buffer-rules 'gdb-breakpoints-buffer | |
1178 'gdb-breakpoints-buffer-name | |
1179 'gdb-breakpoints-mode) | |
1180 | |
1181 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer | |
1182 ;; This defines the auto update rule for buffers of type | |
1183 ;; `gdb-breakpoints-buffer'. | |
1184 ;; | |
1185 ;; It defines a function to serve as the annotation handler that | |
1186 ;; handles the `foo-invalidated' message. That function is called: | |
1187 gdb-invalidate-breakpoints | |
1188 ;; | |
1189 ;; To update the buffer, this command is sent to gdb. | |
1190 "server info breakpoints\n" | |
1191 ;; | |
1192 ;; This also defines a function to be the handler for the output | |
1193 ;; from the command above. That function will copy the output into | |
1194 ;; the appropriately typed buffer. That function will be called: | |
1195 gdb-info-breakpoints-handler | |
1196 ;; buffer specific functions | |
1197 gdb-info-breakpoints-custom) | |
1198 | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1199 (defconst breakpoint-xpm-data |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1200 "/* XPM */ |
54538 | 1201 static char *magick[] = { |
1202 /* columns rows colors chars-per-pixel */ | |
1203 \"10 10 2 1\", | |
1204 \" c red\", | |
1205 \"+ c None\", | |
1206 /* pixels */ | |
1207 \"+++ +++\", | |
1208 \"++ ++\", | |
1209 \"+ +\", | |
1210 \" \", | |
1211 \" \", | |
1212 \" \", | |
1213 \" \", | |
1214 \"+ +\", | |
1215 \"++ ++\", | |
1216 \"+++ +++\", | |
1217 };" | |
1218 "XPM data used for breakpoint icon.") | |
1219 | |
1220 (defconst breakpoint-enabled-pbm-data | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1221 "P1 |
54538 | 1222 10 10\", |
1223 0 0 0 0 1 1 1 1 0 0 0 0 | |
1224 0 0 0 1 1 1 1 1 1 0 0 0 | |
1225 0 0 1 1 1 1 1 1 1 1 0 0 | |
1226 0 1 1 1 1 1 1 1 1 1 1 0 | |
1227 0 1 1 1 1 1 1 1 1 1 1 0 | |
1228 0 1 1 1 1 1 1 1 1 1 1 0 | |
1229 0 1 1 1 1 1 1 1 1 1 1 0 | |
1230 0 0 1 1 1 1 1 1 1 1 0 0 | |
1231 0 0 0 1 1 1 1 1 1 0 0 0 | |
1232 0 0 0 0 1 1 1 1 0 0 0 0" | |
1233 "PBM data used for enabled breakpoint icon.") | |
1234 | |
1235 (defconst breakpoint-disabled-pbm-data | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1236 "P1 |
54538 | 1237 10 10\", |
1238 0 0 1 0 1 0 1 0 0 0 | |
1239 0 1 0 1 0 1 0 1 0 0 | |
1240 1 0 1 0 1 0 1 0 1 0 | |
1241 0 1 0 1 0 1 0 1 0 1 | |
1242 1 0 1 0 1 0 1 0 1 0 | |
1243 0 1 0 1 0 1 0 1 0 1 | |
1244 1 0 1 0 1 0 1 0 1 0 | |
1245 0 1 0 1 0 1 0 1 0 1 | |
1246 0 0 1 0 1 0 1 0 1 0 | |
1247 0 0 0 1 0 1 0 1 0 0" | |
1248 "PBM data used for disabled breakpoint icon.") | |
1249 | |
1250 (defvar breakpoint-enabled-icon nil | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
1251 "Icon for enabled breakpoint in display margin.") |
54538 | 1252 |
1253 (defvar breakpoint-disabled-icon nil | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
1254 "Icon for disabled breakpoint in display margin.") |
54538 | 1255 |
57262
df4b0ff293d8
(breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents:
56330
diff
changeset
|
1256 ;; 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
|
1257 (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
|
1258 (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
|
1259 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c")) |
54538 | 1260 |
60760
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
1261 (defface breakpoint-enabled |
60869
88ef15014617
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents:
60839
diff
changeset
|
1262 '((t |
88ef15014617
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents:
60839
diff
changeset
|
1263 :foreground "red" |
88ef15014617
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents:
60839
diff
changeset
|
1264 :weight bold)) |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
1265 "Face for enabled breakpoint icon in fringe." |
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
1266 :group 'gud) |
60760
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
1267 ;; compatibility alias for old name |
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
1268 (put 'breakpoint-enabled-bitmap-face 'face-alias 'breakpoint-enabled) |
54538 | 1269 |
60760
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
1270 (defface breakpoint-disabled |
60810
6eef5fcb0572
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-199
Miles Bader <miles@gnu.org>
parents:
60760
diff
changeset
|
1271 ;; We use different values of grey for different background types, |
6eef5fcb0572
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-199
Miles Bader <miles@gnu.org>
parents:
60760
diff
changeset
|
1272 ;; so that on low-color displays it will end up as something visible |
60839
7a4f7626e4dc
(breakpoint-enabled, breakpoint-disabled):
Kim F. Storm <storm@cua.dk>
parents:
60810
diff
changeset
|
1273 ;; if it has to be approximated. |
60869
88ef15014617
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents:
60839
diff
changeset
|
1274 '((((background dark)) :foreground "grey60") |
88ef15014617
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents:
60839
diff
changeset
|
1275 (((background light)) :foreground "grey40")) |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
1276 "Face for disabled breakpoint icon in fringe." |
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
1277 :group 'gud) |
60760
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
1278 ;; compatibility alias for old name |
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
1279 (put 'breakpoint-disabled-bitmap-face 'face-alias 'breakpoint-disabled) |
54538 | 1280 |
1281 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer) | |
1282 (defun gdb-info-breakpoints-custom () | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1283 (let ((flag) (bptno)) |
54538 | 1284 ;; remove all breakpoint-icons in source buffers but not assembler buffer |
1285 (dolist (buffer (buffer-list)) | |
1286 (with-current-buffer buffer | |
1287 (if (and (eq gud-minor-mode 'gdba) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1288 (not (string-match "\\`\\*.+\\*\\'" (buffer-name)))) |
54538 | 1289 (gdb-remove-breakpoint-icons (point-min) (point-max))))) |
1290 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer) | |
1291 (save-excursion | |
1292 (goto-char (point-min)) | |
1293 (while (< (point) (- (point-max) 1)) | |
1294 (forward-line 1) | |
1295 (if (looking-at "[^\t].*breakpoint") | |
1296 (progn | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1297 (looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)") |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1298 (setq bptno (match-string 1)) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1299 (setq flag (char-after (match-beginning 2))) |
54538 | 1300 (beginning-of-line) |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
1301 (if (re-search-forward " in .* at\\s-+" nil t) |
54538 | 1302 (progn |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1303 (looking-at "\\(\\S-+\\):\\([0-9]+\\)") |
54538 | 1304 (let ((line (match-string 2)) (buffer-read-only nil) |
1305 (file (match-string 1))) | |
1306 (add-text-properties (point-at-bol) (point-at-eol) | |
1307 '(mouse-face highlight | |
1308 help-echo "mouse-2, RET: visit breakpoint")) | |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
1309 (unless (file-exists-p file) |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1310 (setq file (cdr (assoc bptno gdb-location-alist)))) |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1311 (if (and file |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1312 (not (string-equal file "File not found"))) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1313 (with-current-buffer (find-file-noselect file) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1314 (set (make-local-variable 'gud-minor-mode) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1315 'gdba) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1316 (set (make-local-variable 'tool-bar-map) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1317 gud-tool-bar-map) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1318 ;; only want one breakpoint icon at each |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1319 ;; location |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1320 (save-excursion |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1321 (goto-line (string-to-number line)) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1322 (gdb-put-breakpoint-icon (eq flag ?y) bptno))) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1323 (gdb-enqueue-input |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1324 (list |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1325 (concat "list " |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1326 (match-string-no-properties 1) ":1\n") |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1327 'ignore)) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1328 (gdb-enqueue-input |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1329 (list "info source\n" |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1330 `(lambda () (gdb-get-location |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
1331 ,bptno ,line ,flag)))))))))) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1332 (end-of-line))))) |
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
1333 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) |
54538 | 1334 |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1335 (defun gdb-mouse-set-clear-breakpoint (event) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1336 "Set/clear breakpoint in left fringe/margin with mouse click." |
54538 | 1337 (interactive "e") |
1338 (mouse-minibuffer-check event) | |
1339 (let ((posn (event-end event))) | |
1340 (if (numberp (posn-point posn)) | |
1341 (with-selected-window (posn-window posn) | |
1342 (save-excursion | |
1343 (goto-char (posn-point posn)) | |
1344 (if (or (posn-object posn) | |
57262
df4b0ff293d8
(breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents:
56330
diff
changeset
|
1345 (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
|
1346 'breakpoint)) |
54538 | 1347 (gud-remove nil) |
1348 (gud-break nil))))))) | |
1349 | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1350 (defun gdb-mouse-toggle-breakpoint (event) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1351 "Enable/disable breakpoint in left fringe/margin with mouse click." |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1352 (interactive "e") |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1353 (mouse-minibuffer-check event) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1354 (let ((posn (event-end event))) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1355 (if (numberp (posn-point posn)) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1356 (with-selected-window (posn-window posn) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1357 (save-excursion |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1358 (goto-char (posn-point posn)) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
1359 (if |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1360 ; (or |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1361 (posn-object posn) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1362 ; (eq (car (fringe-bitmaps-at-pos (posn-point posn))) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1363 ; 'breakpoint)) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1364 (gdb-enqueue-input |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1365 (list |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1366 (let ((bptno (get-text-property |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1367 0 'gdb-bptno (car (posn-string posn))))) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1368 (concat |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1369 (if (get-text-property |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1370 0 'gdb-enabled (car (posn-string posn))) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1371 "disable " |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1372 "enable ") |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1373 bptno "\n")) 'ignore)))))))) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1374 |
54538 | 1375 (defun gdb-breakpoints-buffer-name () |
1376 (with-current-buffer gud-comint-buffer | |
1377 (concat "*breakpoints of " (gdb-get-target-string) "*"))) | |
1378 | |
1379 (defun gdb-display-breakpoints-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1380 "Display status of user-settable breakpoints." |
54538 | 1381 (interactive) |
1382 (gdb-display-buffer | |
1383 (gdb-get-create-buffer 'gdb-breakpoints-buffer))) | |
1384 | |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1385 (defconst gdb-frame-parameters |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1386 '((height . 14) (width . 80) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1387 (unsplittable . t) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1388 (tool-bar-lines . nil) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1389 (menu-bar-lines . nil) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1390 (minibuffer . nil))) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
1391 |
54538 | 1392 (defun gdb-frame-breakpoints-buffer () |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1393 "Display status of user-settable breakpoints in a new frame." |
54538 | 1394 (interactive) |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1395 (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
|
1396 (special-display-frame-alist gdb-frame-parameters)) |
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1397 (display-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer)))) |
54538 | 1398 |
1399 (defvar gdb-breakpoints-mode-map | |
1400 (let ((map (make-sparse-keymap)) | |
1401 (menu (make-sparse-keymap "Breakpoints"))) | |
60946
a44ce059d2d1
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
60869
diff
changeset
|
1402 (define-key menu [quit] '("Quit" . kill-this-buffer)) |
a44ce059d2d1
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
60869
diff
changeset
|
1403 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint)) |
54538 | 1404 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint)) |
60946
a44ce059d2d1
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
60869
diff
changeset
|
1405 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint)) |
54538 | 1406 (suppress-keymap map) |
1407 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu)) | |
1408 (define-key map " " 'gdb-toggle-breakpoint) | |
1409 (define-key map "d" 'gdb-delete-breakpoint) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
1410 (define-key map "q" 'kill-this-buffer) |
54538 | 1411 (define-key map "\r" 'gdb-goto-breakpoint) |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1412 (define-key map [mouse-2] 'gdb-goto-breakpoint) |
60946
a44ce059d2d1
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
60869
diff
changeset
|
1413 (define-key map [follow-link] 'mouse-face) |
54538 | 1414 map)) |
1415 | |
1416 (defun gdb-breakpoints-mode () | |
1417 "Major mode for gdb breakpoints. | |
1418 | |
1419 \\{gdb-breakpoints-mode-map}" | |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1420 (kill-all-local-variables) |
54538 | 1421 (setq major-mode 'gdb-breakpoints-mode) |
1422 (setq mode-name "Breakpoints") | |
1423 (use-local-map gdb-breakpoints-mode-map) | |
1424 (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
|
1425 (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
|
1426 (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
|
1427 'gdb-invalidate-breakpoints |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1428 'gdbmi-invalidate-breakpoints)) |
54538 | 1429 |
1430 (defun gdb-toggle-breakpoint () | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
1431 "Enable/disable breakpoint at current line." |
54538 | 1432 (interactive) |
1433 (save-excursion | |
1434 (beginning-of-line 1) | |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1435 (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
|
1436 (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
|
1437 (looking-at |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1438 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\S-*:[0-9]+")) |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1439 (gdb-enqueue-input |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1440 (list |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1441 (concat gdb-server-prefix |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1442 (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
|
1443 "disable " |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1444 "enable ") |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1445 (match-string 1) "\n") 'ignore)) |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1446 (error "Not recognized as break/watchpoint line")))) |
54538 | 1447 |
1448 (defun gdb-delete-breakpoint () | |
1449 "Delete the breakpoint at current line." | |
1450 (interactive) | |
1451 (beginning-of-line 1) | |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1452 (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
|
1453 (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
|
1454 (looking-at |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1455 "\\([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
|
1456 (gdb-enqueue-input |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1457 (list |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1458 (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
|
1459 (error "Not recognized as break/watchpoint line"))) |
54538 | 1460 |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1461 (defun gdb-goto-breakpoint (&optional event) |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1462 "Display the breakpoint location specified at current line." |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1463 (interactive (list last-input-event)) |
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1464 (if event (mouse-set-point event)) |
54538 | 1465 (save-excursion |
1466 (beginning-of-line 1) | |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1467 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)) |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
1468 (looking-at "\\([0-9]+\\) .* in .* at\\s-+\\(\\S-*\\):\\([0-9]+\\)") |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1469 (looking-at |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1470 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\ |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1471 \\(\\S-*\\):\\([0-9]+\\)")) |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
1472 (let ((bptno (match-string 1)) |
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
1473 (file (match-string 2)) |
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
1474 (line (match-string 3))) |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1475 (save-selected-window |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1476 (let* ((buf (find-file-noselect |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1477 (if (file-exists-p file) file |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1478 (cdr (assoc bptno gdb-location-alist))))) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
1479 (window (display-buffer buf))) |
56330
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1480 (with-current-buffer buf |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1481 (goto-line (string-to-number line)) |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1482 (set-window-point window (point)))))) |
a76e88488fd7
(gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents:
56285
diff
changeset
|
1483 (error "Not recognized as break/watchpoint line")))) |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1484 |
54538 | 1485 |
1486 ;; Frames buffer. This displays a perpetually correct bactracktrace | |
1487 ;; (from the command `where'). | |
1488 ;; | |
1489 ;; Alas, if your stack is deep, it is costly. | |
1490 ;; | |
1491 (gdb-set-buffer-rules 'gdb-stack-buffer | |
1492 'gdb-stack-buffer-name | |
1493 'gdb-frames-mode) | |
1494 | |
1495 (def-gdb-auto-updated-buffer gdb-stack-buffer | |
1496 gdb-invalidate-frames | |
1497 "server where\n" | |
1498 gdb-info-frames-handler | |
1499 gdb-info-frames-custom) | |
1500 | |
1501 (defun gdb-info-frames-custom () | |
1502 (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer) | |
1503 (save-excursion | |
1504 (let ((buffer-read-only nil)) | |
1505 (goto-char (point-min)) | |
1506 (while (< (point) (point-max)) | |
1507 (add-text-properties (point-at-bol) (point-at-eol) | |
1508 '(mouse-face highlight | |
1509 help-echo "mouse-2, RET: Select frame")) | |
1510 (beginning-of-line) | |
58049
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
1511 (when (and (looking-at "^#\\([0-9]+\\)") |
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
1512 (equal (match-string 1) gdb-current-stack-level)) |
54538 | 1513 (put-text-property (point-at-bol) (point-at-eol) |
1514 'face '(:inverse-video t))) | |
1515 (forward-line 1)))))) | |
1516 | |
1517 (defun gdb-stack-buffer-name () | |
1518 (with-current-buffer gud-comint-buffer | |
1519 (concat "*stack frames of " (gdb-get-target-string) "*"))) | |
1520 | |
1521 (defun gdb-display-stack-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1522 "Display backtrace of current stack." |
54538 | 1523 (interactive) |
1524 (gdb-display-buffer | |
1525 (gdb-get-create-buffer 'gdb-stack-buffer))) | |
1526 | |
1527 (defun gdb-frame-stack-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1528 "Display backtrace of current stack in a new frame." |
54538 | 1529 (interactive) |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1530 (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
|
1531 (special-display-frame-alist gdb-frame-parameters)) |
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1532 (display-buffer (gdb-get-create-buffer 'gdb-stack-buffer)))) |
54538 | 1533 |
1534 (defvar gdb-frames-mode-map | |
1535 (let ((map (make-sparse-keymap))) | |
1536 (suppress-keymap map) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
1537 (define-key map "q" 'kill-this-buffer) |
54538 | 1538 (define-key map "\r" 'gdb-frames-select) |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1539 (define-key map [mouse-2] 'gdb-frames-select) |
60946
a44ce059d2d1
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
60869
diff
changeset
|
1540 (define-key map [follow-link] 'mouse-face) |
54538 | 1541 map)) |
1542 | |
1543 (defun gdb-frames-mode () | |
1544 "Major mode for gdb frames. | |
1545 | |
1546 \\{gdb-frames-mode-map}" | |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1547 (kill-all-local-variables) |
54538 | 1548 (setq major-mode 'gdb-frames-mode) |
1549 (setq mode-name "Frames") | |
1550 (setq buffer-read-only t) | |
1551 (use-local-map gdb-frames-mode-map) | |
1552 (font-lock-mode -1) | |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1553 (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
|
1554 (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
|
1555 'gdb-invalidate-frames |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1556 'gdbmi-invalidate-frames)) |
54538 | 1557 |
1558 (defun gdb-get-frame-number () | |
1559 (save-excursion | |
55850
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
1560 (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t)) |
54538 | 1561 (n (or (and pos (match-string-no-properties 1)) "0"))) |
1562 n))) | |
1563 | |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1564 (defun gdb-frames-select (&optional event) |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1565 "Select the frame and display the relevant source." |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1566 (interactive (list last-input-event)) |
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1567 (if event (mouse-set-point event)) |
54538 | 1568 (gdb-enqueue-input |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1569 (list (concat gdb-server-prefix "frame " |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
1570 (gdb-get-frame-number) "\n") 'ignore)) |
54538 | 1571 (gud-display-frame)) |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1572 |
54538 | 1573 |
1574 ;; Threads buffer. This displays a selectable thread list. | |
1575 ;; | |
1576 (gdb-set-buffer-rules 'gdb-threads-buffer | |
1577 'gdb-threads-buffer-name | |
1578 'gdb-threads-mode) | |
1579 | |
1580 (def-gdb-auto-updated-buffer gdb-threads-buffer | |
1581 gdb-invalidate-threads | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1582 (concat gdb-server-prefix "info threads\n") |
54538 | 1583 gdb-info-threads-handler |
1584 gdb-info-threads-custom) | |
1585 | |
1586 (defun gdb-info-threads-custom () | |
1587 (with-current-buffer (gdb-get-buffer 'gdb-threads-buffer) | |
1588 (let ((buffer-read-only nil)) | |
1589 (goto-char (point-min)) | |
1590 (while (< (point) (point-max)) | |
1591 (add-text-properties (point-at-bol) (point-at-eol) | |
1592 '(mouse-face highlight | |
1593 help-echo "mouse-2, RET: select thread")) | |
1594 (forward-line 1))))) | |
1595 | |
1596 (defun gdb-threads-buffer-name () | |
1597 (with-current-buffer gud-comint-buffer | |
1598 (concat "*threads of " (gdb-get-target-string) "*"))) | |
1599 | |
1600 (defun gdb-display-threads-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1601 "Display IDs of currently known threads." |
54538 | 1602 (interactive) |
1603 (gdb-display-buffer | |
1604 (gdb-get-create-buffer 'gdb-threads-buffer))) | |
1605 | |
1606 (defun gdb-frame-threads-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1607 "Display IDs of currently known threads in a new frame." |
54538 | 1608 (interactive) |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1609 (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
|
1610 (special-display-frame-alist gdb-frame-parameters)) |
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1611 (display-buffer (gdb-get-create-buffer 'gdb-threads-buffer)))) |
54538 | 1612 |
1613 (defvar gdb-threads-mode-map | |
1614 (let ((map (make-sparse-keymap))) | |
1615 (suppress-keymap map) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
1616 (define-key map "q" 'kill-this-buffer) |
54538 | 1617 (define-key map "\r" 'gdb-threads-select) |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1618 (define-key map [mouse-2] 'gdb-threads-select) |
54538 | 1619 map)) |
1620 | |
1621 (defun gdb-threads-mode () | |
1622 "Major mode for gdb frames. | |
1623 | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1624 \\{gdb-threads-mode-map}" |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1625 (kill-all-local-variables) |
54538 | 1626 (setq major-mode 'gdb-threads-mode) |
1627 (setq mode-name "Threads") | |
1628 (setq buffer-read-only t) | |
1629 (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
|
1630 (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
|
1631 'gdb-invalidate-threads) |
54538 | 1632 |
1633 (defun gdb-get-thread-number () | |
1634 (save-excursion | |
1635 (re-search-backward "^\\s-*\\([0-9]*\\)" nil t) | |
1636 (match-string-no-properties 1))) | |
1637 | |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1638 (defun gdb-threads-select (&optional event) |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1639 "Select the thread and display the relevant source." |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1640 (interactive (list last-input-event)) |
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1641 (if event (mouse-set-point event)) |
54538 | 1642 (gdb-enqueue-input |
1643 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore)) | |
1644 (gud-display-frame)) | |
59708
9ce7d8f69f2c
(gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents:
59635
diff
changeset
|
1645 |
54538 | 1646 |
1647 ;; Registers buffer. | |
1648 ;; | |
1649 (gdb-set-buffer-rules 'gdb-registers-buffer | |
1650 'gdb-registers-buffer-name | |
1651 'gdb-registers-mode) | |
1652 | |
1653 (def-gdb-auto-updated-buffer gdb-registers-buffer | |
1654 gdb-invalidate-registers | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1655 (concat gdb-server-prefix "info registers\n") |
54538 | 1656 gdb-info-registers-handler |
1657 gdb-info-registers-custom) | |
1658 | |
1659 (defun gdb-info-registers-custom ()) | |
1660 | |
1661 (defvar gdb-registers-mode-map | |
1662 (let ((map (make-sparse-keymap))) | |
1663 (suppress-keymap map) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
1664 (define-key map "q" 'kill-this-buffer) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
1665 map)) |
54538 | 1666 |
1667 (defun gdb-registers-mode () | |
1668 "Major mode for gdb registers. | |
1669 | |
1670 \\{gdb-registers-mode-map}" | |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
1671 (kill-all-local-variables) |
54538 | 1672 (setq major-mode 'gdb-registers-mode) |
1673 (setq mode-name "Registers") | |
1674 (setq buffer-read-only t) | |
1675 (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
|
1676 (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
|
1677 'gdb-invalidate-registers) |
54538 | 1678 |
1679 (defun gdb-registers-buffer-name () | |
1680 (with-current-buffer gud-comint-buffer | |
1681 (concat "*registers of " (gdb-get-target-string) "*"))) | |
1682 | |
1683 (defun gdb-display-registers-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1684 "Display integer register contents." |
54538 | 1685 (interactive) |
1686 (gdb-display-buffer | |
1687 (gdb-get-create-buffer 'gdb-registers-buffer))) | |
1688 | |
1689 (defun gdb-frame-registers-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
1690 "Display integer register contents in a new frame." |
54538 | 1691 (interactive) |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1692 (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
|
1693 (special-display-frame-alist gdb-frame-parameters)) |
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
1694 (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer)))) |
59808 | 1695 |
1696 ;; Memory buffer. | |
1697 ;; | |
1698 (defcustom gdb-memory-repeat-count 32 | |
1699 "Number of data items in memory window." | |
1700 :type 'integer | |
1701 :group 'gud | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
1702 :version "22.1") |
59808 | 1703 |
1704 (defcustom gdb-memory-format "x" | |
1705 "Display format of data items in memory window." | |
1706 :type '(choice (const :tag "Hexadecimal" "x") | |
1707 (const :tag "Signed decimal" "d") | |
1708 (const :tag "Unsigned decimal" "u") | |
1709 (const :tag "Octal" "o") | |
1710 (const :tag "Binary" "t")) | |
1711 :group 'gud | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
1712 :version "22.1") |
59808 | 1713 |
1714 (defcustom gdb-memory-unit "w" | |
1715 "Unit size of data items in memory window." | |
1716 :type '(choice (const :tag "Byte" "b") | |
1717 (const :tag "Halfword" "h") | |
1718 (const :tag "Word" "w") | |
1719 (const :tag "Giant word" "g")) | |
1720 :group 'gud | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
1721 :version "22.1") |
59808 | 1722 |
1723 (gdb-set-buffer-rules 'gdb-memory-buffer | |
1724 'gdb-memory-buffer-name | |
1725 'gdb-memory-mode) | |
1726 | |
1727 (def-gdb-auto-updated-buffer gdb-memory-buffer | |
1728 gdb-invalidate-memory | |
1729 (concat gdb-server-prefix "x/" (number-to-string gdb-memory-repeat-count) | |
1730 gdb-memory-format gdb-memory-unit " " gdb-memory-address "\n") | |
1731 gdb-read-memory-handler | |
1732 gdb-read-memory-custom) | |
1733 | |
1734 (defun gdb-read-memory-custom ()) | |
1735 | |
1736 (defvar gdb-memory-mode-map | |
1737 (let ((map (make-sparse-keymap))) | |
1738 (suppress-keymap map) | |
1739 (define-key map "q" 'kill-this-buffer) | |
1740 map)) | |
1741 | |
1742 (defun gdb-memory-set-address (event) | |
1743 "Set the start memory address." | |
1744 (interactive "e") | |
1745 (save-selected-window | |
1746 (select-window (posn-window (event-start event))) | |
1747 (let ((arg (read-from-minibuffer "Memory address: "))) | |
1748 (setq gdb-memory-address arg)) | |
1749 (gdb-invalidate-memory))) | |
1750 | |
1751 (defun gdb-memory-set-repeat-count (event) | |
1752 "Set the number of data items in memory window." | |
1753 (interactive "e") | |
1754 (save-selected-window | |
1755 (select-window (posn-window (event-start event))) | |
1756 (let* ((arg (read-from-minibuffer "Repeat count: ")) | |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
1757 (count (string-to-number arg))) |
59808 | 1758 (if (< count 0) |
1759 (error "Non-negative numbers only") | |
1760 (customize-set-variable 'gdb-memory-repeat-count count) | |
1761 (gdb-invalidate-memory))))) | |
1762 | |
1763 (defun gdb-memory-format-binary () | |
1764 "Set the display format to binary." | |
1765 (interactive) | |
1766 (customize-set-variable 'gdb-memory-format "t") | |
1767 (gdb-invalidate-memory)) | |
1768 | |
1769 (defun gdb-memory-format-octal () | |
1770 "Set the display format to octal." | |
1771 (interactive) | |
1772 (customize-set-variable 'gdb-memory-format "o") | |
1773 (gdb-invalidate-memory)) | |
1774 | |
1775 (defun gdb-memory-format-unsigned () | |
1776 "Set the display format to unsigned decimal." | |
1777 (interactive) | |
1778 (customize-set-variable 'gdb-memory-format "u") | |
1779 (gdb-invalidate-memory)) | |
1780 | |
1781 (defun gdb-memory-format-signed () | |
1782 "Set the display format to decimal." | |
1783 (interactive) | |
1784 (customize-set-variable 'gdb-memory-format "d") | |
1785 (gdb-invalidate-memory)) | |
1786 | |
1787 (defun gdb-memory-format-hexadecimal () | |
1788 "Set the display format to hexadecimal." | |
1789 (interactive) | |
1790 (customize-set-variable 'gdb-memory-format "x") | |
1791 (gdb-invalidate-memory)) | |
1792 | |
1793 (defvar gdb-memory-format-keymap | |
1794 (let ((map (make-sparse-keymap))) | |
1795 (define-key map [header-line down-mouse-3] 'gdb-memory-format-menu-1) | |
1796 map) | |
1797 "Keymap to select format in the header line.") | |
1798 | |
1799 (defvar gdb-memory-format-menu (make-sparse-keymap "Format") | |
1800 "Menu of display formats in the header line.") | |
1801 | |
1802 (define-key gdb-memory-format-menu [binary] | |
1803 '(menu-item "Binary" gdb-memory-format-binary | |
1804 :button (:radio . (equal gdb-memory-format "t")))) | |
1805 (define-key gdb-memory-format-menu [octal] | |
1806 '(menu-item "Octal" gdb-memory-format-octal | |
1807 :button (:radio . (equal gdb-memory-format "o")))) | |
1808 (define-key gdb-memory-format-menu [unsigned] | |
1809 '(menu-item "Unsigned Decimal" gdb-memory-format-unsigned | |
1810 :button (:radio . (equal gdb-memory-format "u")))) | |
1811 (define-key gdb-memory-format-menu [signed] | |
1812 '(menu-item "Signed Decimal" gdb-memory-format-signed | |
1813 :button (:radio . (equal gdb-memory-format "d")))) | |
1814 (define-key gdb-memory-format-menu [hexadecimal] | |
1815 '(menu-item "Hexadecimal" gdb-memory-format-hexadecimal | |
1816 :button (:radio . (equal gdb-memory-format "x")))) | |
1817 | |
1818 (defun gdb-memory-format-menu (event) | |
1819 (interactive "@e") | |
1820 (x-popup-menu event gdb-memory-format-menu)) | |
1821 | |
1822 (defun gdb-memory-format-menu-1 (event) | |
1823 (interactive "e") | |
1824 (save-selected-window | |
1825 (select-window (posn-window (event-start event))) | |
1826 (let* ((selection (gdb-memory-format-menu event)) | |
1827 (binding (and selection (lookup-key gdb-memory-format-menu | |
1828 (vector (car selection)))))) | |
1829 (if binding (call-interactively binding))))) | |
1830 | |
1831 (defun gdb-memory-unit-giant () | |
1832 "Set the unit size to giant words (eight bytes)." | |
1833 (interactive) | |
1834 (customize-set-variable 'gdb-memory-unit "g") | |
1835 (gdb-invalidate-memory)) | |
1836 | |
1837 (defun gdb-memory-unit-word () | |
1838 "Set the unit size to words (four bytes)." | |
1839 (interactive) | |
1840 (customize-set-variable 'gdb-memory-unit "w") | |
1841 (gdb-invalidate-memory)) | |
1842 | |
1843 (defun gdb-memory-unit-halfword () | |
1844 "Set the unit size to halfwords (two bytes)." | |
1845 (interactive) | |
1846 (customize-set-variable 'gdb-memory-unit "h") | |
1847 (gdb-invalidate-memory)) | |
1848 | |
1849 (defun gdb-memory-unit-byte () | |
1850 "Set the unit size to bytes." | |
1851 (interactive) | |
1852 (customize-set-variable 'gdb-memory-unit "b") | |
1853 (gdb-invalidate-memory)) | |
1854 | |
1855 (defvar gdb-memory-unit-keymap | |
1856 (let ((map (make-sparse-keymap))) | |
1857 (define-key map [header-line down-mouse-3] 'gdb-memory-unit-menu-1) | |
1858 map) | |
1859 "Keymap to select units in the header line.") | |
1860 | |
1861 (defvar gdb-memory-unit-menu (make-sparse-keymap "Unit") | |
1862 "Menu of units in the header line.") | |
1863 | |
1864 (define-key gdb-memory-unit-menu [giantwords] | |
1865 '(menu-item "Giant words" gdb-memory-unit-giant | |
1866 :button (:radio . (equal gdb-memory-unit "g")))) | |
1867 (define-key gdb-memory-unit-menu [words] | |
1868 '(menu-item "Words" gdb-memory-unit-word | |
1869 :button (:radio . (equal gdb-memory-unit "w")))) | |
1870 (define-key gdb-memory-unit-menu [halfwords] | |
1871 '(menu-item "Halfwords" gdb-memory-unit-halfword | |
1872 :button (:radio . (equal gdb-memory-unit "h")))) | |
1873 (define-key gdb-memory-unit-menu [bytes] | |
1874 '(menu-item "Bytes" gdb-memory-unit-byte | |
1875 :button (:radio . (equal gdb-memory-unit "b")))) | |
1876 | |
1877 (defun gdb-memory-unit-menu (event) | |
1878 (interactive "@e") | |
1879 (x-popup-menu event gdb-memory-unit-menu)) | |
1880 | |
1881 (defun gdb-memory-unit-menu-1 (event) | |
1882 (interactive "e") | |
1883 (save-selected-window | |
1884 (select-window (posn-window (event-start event))) | |
1885 (let* ((selection (gdb-memory-unit-menu event)) | |
1886 (binding (and selection (lookup-key gdb-memory-unit-menu | |
1887 (vector (car selection)))))) | |
1888 (if binding (call-interactively binding))))) | |
1889 | |
1890 ;;from make-mode-line-mouse-map | |
1891 (defun gdb-make-header-line-mouse-map (mouse function) "\ | |
1892 Return a keymap with single entry for mouse key MOUSE on the header line. | |
1893 MOUSE is defined to run function FUNCTION with no args in the buffer | |
1894 corresponding to the mode line clicked." | |
1895 (let ((map (make-sparse-keymap))) | |
1896 (define-key map (vector 'header-line mouse) function) | |
1897 (define-key map (vector 'header-line 'down-mouse-1) 'ignore) | |
1898 map)) | |
1899 | |
1900 (defun gdb-memory-mode () | |
1901 "Major mode for examining memory. | |
1902 | |
1903 \\{gdb-memory-mode-map}" | |
1904 (kill-all-local-variables) | |
1905 (setq major-mode 'gdb-memory-mode) | |
1906 (setq mode-name "Memory") | |
1907 (setq buffer-read-only t) | |
1908 (use-local-map gdb-memory-mode-map) | |
1909 (setq header-line-format | |
1910 '(:eval | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
1911 (concat |
59808 | 1912 "Read address: " |
1913 (propertize gdb-memory-address | |
1914 'face font-lock-warning-face | |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1915 'help-echo "mouse-1: Set memory address" |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1916 'local-map (gdb-make-header-line-mouse-map |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1917 'mouse-1 |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1918 #'gdb-memory-set-address)) |
59808 | 1919 " Repeat Count: " |
1920 (propertize (number-to-string gdb-memory-repeat-count) | |
1921 'face font-lock-warning-face | |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1922 'help-echo "mouse-1: Set repeat count" |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1923 'local-map (gdb-make-header-line-mouse-map |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1924 'mouse-1 |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1925 #'gdb-memory-set-repeat-count)) |
59808 | 1926 " Display Format: " |
1927 (propertize gdb-memory-format | |
1928 'face font-lock-warning-face | |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1929 'help-echo "mouse-3: Select display format" |
59808 | 1930 'local-map gdb-memory-format-keymap) |
1931 " Unit Size: " | |
1932 (propertize gdb-memory-unit | |
1933 'face font-lock-warning-face | |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
1934 'help-echo "mouse-3: Select unit size" |
59808 | 1935 'local-map gdb-memory-unit-keymap)))) |
1936 (run-mode-hooks 'gdb-memory-mode-hook) | |
1937 'gdb-invalidate-memory) | |
1938 | |
1939 (defun gdb-memory-buffer-name () | |
1940 (with-current-buffer gud-comint-buffer | |
1941 (concat "*memory of " (gdb-get-target-string) "*"))) | |
1942 | |
1943 (defun gdb-display-memory-buffer () | |
1944 "Display memory contents." | |
1945 (interactive) | |
1946 (gdb-display-buffer | |
1947 (gdb-get-create-buffer 'gdb-memory-buffer))) | |
1948 | |
1949 (defun gdb-frame-memory-buffer () | |
1950 "Display memory contents in a new frame." | |
1951 (interactive) | |
1952 (let ((special-display-regexps (append special-display-regexps '(".*"))) | |
1953 (special-display-frame-alist gdb-frame-parameters)) | |
1954 (display-buffer (gdb-get-create-buffer 'gdb-memory-buffer)))) | |
54538 | 1955 |
59808 | 1956 |
54538 | 1957 ;; Locals buffer. |
1958 ;; | |
1959 (gdb-set-buffer-rules 'gdb-locals-buffer | |
1960 'gdb-locals-buffer-name | |
1961 'gdb-locals-mode) | |
1962 | |
1963 (def-gdb-auto-updated-buffer gdb-locals-buffer | |
1964 gdb-invalidate-locals | |
1965 "server info locals\n" | |
1966 gdb-info-locals-handler | |
1967 gdb-info-locals-custom) | |
1968 | |
1969 ;; Abbreviate for arrays and structures. | |
1970 ;; These can be expanded using gud-display. | |
1971 (defun gdb-info-locals-handler nil | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1972 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
1973 gdb-pending-triggers)) |
54538 | 1974 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer))) |
1975 (with-current-buffer buf | |
1976 (goto-char (point-min)) | |
1977 (while (re-search-forward "^ .*\n" nil t) | |
1978 (replace-match "" nil nil)) | |
1979 (goto-char (point-min)) | |
1980 (while (re-search-forward "{[-0-9, {}\]*\n" nil t) | |
1981 (replace-match "(array);\n" nil nil)) | |
1982 (goto-char (point-min)) | |
1983 (while (re-search-forward "{.*=.*\n" nil t) | |
1984 (replace-match "(structure);\n" nil nil)))) | |
1985 (let ((buf (gdb-get-buffer 'gdb-locals-buffer))) | |
1986 (and buf (with-current-buffer buf | |
1987 (let ((p (point)) | |
1988 (buffer-read-only nil)) | |
1989 (delete-region (point-min) (point-max)) | |
1990 (insert-buffer-substring (gdb-get-create-buffer | |
1991 'gdb-partial-output-buffer)) | |
1992 (goto-char p))))) | |
1993 (run-hooks 'gdb-info-locals-hook)) | |
1994 | |
1995 (defun gdb-info-locals-custom () | |
1996 nil) | |
1997 | |
1998 (defvar gdb-locals-mode-map | |
1999 (let ((map (make-sparse-keymap))) | |
2000 (suppress-keymap map) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2001 (define-key map "q" 'kill-this-buffer) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2002 map)) |
54538 | 2003 |
2004 (defun gdb-locals-mode () | |
2005 "Major mode for gdb locals. | |
2006 | |
2007 \\{gdb-locals-mode-map}" | |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2008 (kill-all-local-variables) |
54538 | 2009 (setq major-mode 'gdb-locals-mode) |
55850
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
2010 (setq mode-name (concat "Locals:" gdb-current-frame)) |
54538 | 2011 (setq buffer-read-only t) |
2012 (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
|
2013 (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
|
2014 (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
|
2015 'gdb-invalidate-locals |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2016 'gdbmi-invalidate-locals)) |
54538 | 2017 |
2018 (defun gdb-locals-buffer-name () | |
2019 (with-current-buffer gud-comint-buffer | |
2020 (concat "*locals of " (gdb-get-target-string) "*"))) | |
2021 | |
2022 (defun gdb-display-locals-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
2023 "Display local variables of current stack and their values." |
54538 | 2024 (interactive) |
2025 (gdb-display-buffer | |
2026 (gdb-get-create-buffer 'gdb-locals-buffer))) | |
2027 | |
2028 (defun gdb-frame-locals-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
2029 "Display local variables of current stack and their values in a new frame." |
54538 | 2030 (interactive) |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
2031 (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
|
2032 (special-display-frame-alist gdb-frame-parameters)) |
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
2033 (display-buffer (gdb-get-create-buffer 'gdb-locals-buffer)))) |
54538 | 2034 |
2035 | |
2036 ;;;; Window management | |
2037 (defun gdb-display-buffer (buf &optional size) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2038 (let ((answer (get-buffer-window buf 0)) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2039 (must-split nil)) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2040 (if answer |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2041 (display-buffer buf nil 0) ;Raise the frame if necessary. |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2042 ;; The buffer is not yet displayed. |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2043 (pop-to-buffer gud-comint-buffer) ;Select the right frame. |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2044 (let ((window (get-lru-window))) |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2045 (if (and window |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2046 (not (eq window (get-buffer-window gud-comint-buffer)))) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2047 (progn |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2048 (set-window-buffer window buf) |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2049 (setq answer window)) |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2050 (setq must-split t))) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2051 (if must-split |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2052 (let* ((largest (get-largest-window)) |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2053 (cur-size (window-height largest)) |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2054 (new-size (and size (< size cur-size) (- cur-size size)))) |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2055 (setq answer (split-window largest new-size)) |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2056 (set-window-buffer answer buf) |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2057 (set-window-dedicated-p answer t))) |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2058 answer))) |
54538 | 2059 |
2060 | |
2061 ;;; Shared keymap initialization: | |
2062 | |
59922
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2063 (let ((menu (make-sparse-keymap "GDB-Windows"))) |
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2064 (define-key gud-menu-map [displays] |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2065 `(menu-item "GDB-Windows" ,menu |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2066 :visible (memq gud-minor-mode '(gdbmi gdba)))) |
59922
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2067 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer)) |
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2068 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer)) |
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2069 (define-key menu [memory] '("Memory" . gdb-display-memory-buffer)) |
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2070 (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer)) |
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2071 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer)) |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2072 (define-key menu [inferior] |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2073 '(menu-item "Inferior IO" gdb-display-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2074 :enable gdb-use-inferior-io-buffer)) |
59922
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2075 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) |
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2076 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer)) |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2077 (define-key menu [breakpoints] |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2078 '("Breakpoints" . gdb-display-breakpoints-buffer))) |
59922
79e9767b47c8
Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents:
59852
diff
changeset
|
2079 |
54538 | 2080 (let ((menu (make-sparse-keymap "GDB-Frames"))) |
2081 (define-key gud-menu-map [frames] | |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2082 `(menu-item "GDB-Frames" ,menu |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2083 :visible (memq gud-minor-mode '(gdbmi gdba)))) |
54538 | 2084 (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
|
2085 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer)) |
59808 | 2086 (define-key menu [memory] '("Memory" . gdb-frame-memory-buffer)) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2087 (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
|
2088 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer)) |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2089 (define-key menu [inferior] |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2090 '(menu-item "Inferior IO" gdb-frame-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2091 :enable gdb-use-inferior-io-buffer)) |
54538 | 2092 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer)) |
2093 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer)) | |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2094 (define-key menu [breakpoints] |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2095 '("Breakpoints" . gdb-frame-breakpoints-buffer))) |
54538 | 2096 |
2097 (let ((menu (make-sparse-keymap "GDB-UI"))) | |
2098 (define-key gud-menu-map [ui] | |
2099 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba))) | |
2100 (define-key menu [gdb-restore-windows] | |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2101 '(menu-item "Restore Window Layout" gdb-restore-windows |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2102 :help "Restore standard layout for debug session.")) |
54538 | 2103 (define-key menu [gdb-many-windows] |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2104 '(menu-item "Display Other Windows" gdb-many-windows |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2105 :help "Toggle display of locals, stack and breakpoint information" |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2106 :button (:toggle . gdb-many-windows))) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2107 (define-key menu [gdb-use-inferior-io] |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2108 (menu-bar-make-toggle toggle-gdb-use-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2109 gdb-use-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2110 "Separate inferior IO" "Use separate IO %s" |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2111 "Toggle separate IO for inferior."))) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2112 |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2113 (defadvice toggle-gdb-use-inferior-io-buffer (after gdb-kill-io-buffer activate) |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2114 (unless gdb-use-inferior-io-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2115 (kill-buffer (gdb-inferior-io-name)))) |
54538 | 2116 |
2117 (defun gdb-frame-gdb-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
2118 "Display GUD buffer in a new frame." |
54538 | 2119 (interactive) |
54993
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
2120 (select-frame (make-frame gdb-frame-parameters)) |
08b0ee9a9b35
(gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents:
54962
diff
changeset
|
2121 (switch-to-buffer (gdb-get-create-buffer 'gdba)) |
55217
97d0e3a1174f
(gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
54993
diff
changeset
|
2122 (set-window-dedicated-p (selected-window) t)) |
54538 | 2123 |
2124 (defun gdb-display-gdb-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
2125 "Display GUD buffer." |
54538 | 2126 (interactive) |
2127 (gdb-display-buffer | |
2128 (gdb-get-create-buffer 'gdba))) | |
2129 | |
2130 (defvar gdb-main-file nil "Source file from which program execution begins.") | |
2131 | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
2132 (defcustom gdb-show-main nil |
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
2133 "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
|
2134 :type 'boolean |
57851
67b88e92a24d
(gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents:
57791
diff
changeset
|
2135 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
2136 :version "22.1") |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
2137 |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2138 (defun gdb-set-window-buffer (name) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2139 (set-window-buffer (selected-window) (get-buffer name)) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2140 (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
|
2141 |
54538 | 2142 (defun gdb-setup-windows () |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
2143 "Layout the window pattern for gdb-many-windows." |
54538 | 2144 (gdb-display-locals-buffer) |
2145 (gdb-display-stack-buffer) | |
2146 (delete-other-windows) | |
2147 (gdb-display-breakpoints-buffer) | |
2148 (delete-other-windows) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2149 ; Don't dedicate. |
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2150 (pop-to-buffer gud-comint-buffer) |
54538 | 2151 (split-window nil ( / ( * (window-height) 3) 4)) |
2152 (split-window nil ( / (window-height) 3)) | |
2153 (split-window-horizontally) | |
2154 (other-window 1) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2155 (gdb-set-window-buffer (gdb-locals-buffer-name)) |
54538 | 2156 (other-window 1) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2157 (switch-to-buffer |
54538 | 2158 (if gud-last-last-frame |
2159 (gud-find-file (car gud-last-last-frame)) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2160 (gud-find-file gdb-main-file))) |
54729
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
2161 (when gdb-use-inferior-io-buffer |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
2162 (split-window-horizontally) |
7bfccd78beed
(gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents:
54668
diff
changeset
|
2163 (other-window 1) |
61459
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2164 (gdb-set-window-buffer |
c1538e237b52
(gdb-display-inferior-io-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
60946
diff
changeset
|
2165 (gdb-get-create-buffer 'gdb-inferior-io))) |
54538 | 2166 (other-window 1) |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2167 (gdb-set-window-buffer (gdb-stack-buffer-name)) |
54538 | 2168 (split-window-horizontally) |
2169 (other-window 1) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2170 (gdb-set-window-buffer (gdb-breakpoints-buffer-name)) |
54538 | 2171 (other-window 1)) |
2172 | |
2173 (defcustom gdb-many-windows nil | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
2174 "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
|
2175 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
|
2176 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
|
2177 of the inferior. Non-nil means display the layout shown for |
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
2178 `gdba'." |
54538 | 2179 :type 'boolean |
57851
67b88e92a24d
(gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents:
57791
diff
changeset
|
2180 :group 'gud |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59988
diff
changeset
|
2181 :version "22.1") |
54538 | 2182 |
2183 (defun gdb-many-windows (arg) | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2184 "Toggle the number of windows in the basic arrangement." |
54538 | 2185 (interactive "P") |
2186 (setq gdb-many-windows | |
2187 (if (null arg) | |
2188 (not gdb-many-windows) | |
2189 (> (prefix-numeric-value arg) 0))) | |
54760
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
2190 (condition-case nil |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
2191 (gdb-restore-windows) |
c6ccb7a82f9f
(gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
54729
diff
changeset
|
2192 (error nil))) |
54538 | 2193 |
2194 (defun gdb-restore-windows () | |
2195 "Restore the basic arrangement of windows used by gdba. | |
2196 This arrangement depends on the value of `gdb-many-windows'." | |
2197 (interactive) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2198 (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
|
2199 (delete-other-windows) |
54538 | 2200 (if gdb-many-windows |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2201 (gdb-setup-windows) |
54538 | 2202 (split-window) |
2203 (other-window 1) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2204 (switch-to-buffer |
54538 | 2205 (if gud-last-last-frame |
2206 (gud-find-file (car gud-last-last-frame)) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2207 (gud-find-file gdb-main-file))) |
54538 | 2208 (other-window 1))) |
2209 | |
2210 (defun gdb-reset () | |
57791
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
2211 "Exit a debugging session cleanly. |
d1b93fc4ce47
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57664
diff
changeset
|
2212 Kills the gdb buffers and resets the source buffers." |
54538 | 2213 (dolist (buffer (buffer-list)) |
55696
ed6e91c53c82
(gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55507
diff
changeset
|
2214 (unless (eq buffer gud-comint-buffer) |
ed6e91c53c82
(gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55507
diff
changeset
|
2215 (with-current-buffer buffer |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2216 (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
|
2217 (if (string-match "\\`\\*.+\\*\\'" (buffer-name)) |
ed6e91c53c82
(gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55507
diff
changeset
|
2218 (kill-buffer nil) |
ed6e91c53c82
(gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55507
diff
changeset
|
2219 (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
|
2220 (setq gud-minor-mode nil) |
ed6e91c53c82
(gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55507
diff
changeset
|
2221 (kill-local-variable 'tool-bar-map) |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2222 (kill-local-variable 'gdb-define-alist)))))) |
54538 | 2223 (when (markerp gdb-overlay-arrow-position) |
2224 (move-marker gdb-overlay-arrow-position nil) | |
2225 (setq gdb-overlay-arrow-position nil)) | |
2226 (setq overlay-arrow-variable-list | |
62050
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2227 (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list)) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2228 (setq gud-running nil) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2229 (setq gdb-active-process nil) |
9658387c7d01
(gdb-cpp-define-alist-program)
Nick Roberts <nickrob@snap.net.nz>
parents:
61896
diff
changeset
|
2230 (remove-hook 'after-save-hook 'gdb-create-define-alist t)) |
54538 | 2231 |
2232 (defun gdb-source-info () | |
2233 "Find the source file where the program starts and displays it with related | |
2234 buffers." | |
2235 (goto-char (point-min)) | |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2236 (if (and (search-forward "Located in " nil t) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2237 (looking-at "\\S-*")) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2238 (setq gdb-main-file (match-string 0))) |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2239 (goto-char (point-min)) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2240 (if (search-forward "Includes preprocessor macro info." nil t) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2241 (setq gdb-macro-info t)) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2242 (if gdb-many-windows |
54538 | 2243 (gdb-setup-windows) |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
2244 (gdb-get-create-buffer 'gdb-breakpoints-buffer) |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2245 (if gdb-show-main |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2246 (let ((pop-up-windows t)) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2247 (display-buffer (gud-find-file gdb-main-file)))))) |
54538 | 2248 |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
2249 (defun gdb-get-location (bptno line flag) |
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
2250 "Find the directory containing the relevant source file. |
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
2251 Put in buffer and place breakpoint icon." |
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
2252 (goto-char (point-min)) |
60326
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2253 (catch 'file-not-found |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2254 (if (search-forward "Located in " nil t) |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2255 (when (looking-at "\\S-*") |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2256 (delete (cons bptno "File not found") gdb-location-alist) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2257 (push (cons bptno (match-string 0)) gdb-location-alist)) |
60326
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2258 (gdb-resync) |
62202
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2259 (unless (assoc bptno gdb-location-alist) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2260 (push (cons bptno "File not found") gdb-location-alist) |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2261 (message-box "Cannot find source file for breakpoint location.\n\ |
327af4f748d5
(gdb-macro-info): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
62136
diff
changeset
|
2262 Add directory to search path for source files using the GDB command, dir.")) |
60326
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2263 (throw 'file-not-found nil)) |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2264 (with-current-buffer |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2265 (find-file-noselect (match-string 0)) |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2266 (save-current-buffer |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2267 (set (make-local-variable 'gud-minor-mode) 'gdba) |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2268 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)) |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2269 ;; only want one breakpoint icon at each location |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2270 (save-excursion |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2271 (goto-line (string-to-number line)) |
47c96976e43d
(gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents:
60153
diff
changeset
|
2272 (gdb-put-breakpoint-icon (eq flag ?y) bptno))))) |
59988
fb52ec059049
(gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59922
diff
changeset
|
2273 |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2274 (add-hook 'find-file-hook 'gdb-find-file-hook) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2275 |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2276 (defun gdb-find-file-hook () |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2277 (if (and (not gdb-find-file-unhook) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2278 ;; in case gud or gdb-ui is just loaded |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2279 gud-comint-buffer |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2280 (buffer-name gud-comint-buffer) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2281 (with-current-buffer gud-comint-buffer |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2282 (eq gud-minor-mode 'gdba))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2283 (condition-case nil |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2284 (gdb-enqueue-input |
60124
106946a8423d
(gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents:
60073
diff
changeset
|
2285 (list (concat gdb-server-prefix "list " |
106946a8423d
(gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents:
60073
diff
changeset
|
2286 (file-name-nondirectory buffer-file-name) |
60073
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2287 ":1\n") |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2288 `(lambda () (gdb-set-gud-minor-mode ,(current-buffer))))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2289 (error (setq gdb-find-file-unhook t))))) |
6fba1da8f37e
(gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
59998
diff
changeset
|
2290 |
54538 | 2291 ;;from put-image |
2292 (defun gdb-put-string (putstring pos &optional dprop) | |
2293 "Put string PUTSTRING in front of POS in the current buffer. | |
2294 PUTSTRING is displayed by putting an overlay into the current buffer with a | |
2295 `before-string' STRING that has a `display' property whose value is | |
2296 PUTSTRING." | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2297 (let ((string (make-string 1 ?x)) |
54538 | 2298 (buffer (current-buffer))) |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2299 (setq putstring (copy-sequence putstring)) |
54538 | 2300 (let ((overlay (make-overlay pos pos buffer)) |
2301 (prop (or dprop | |
2302 (list (list 'margin 'left-margin) putstring)))) | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2303 (put-text-property 0 (length string) 'display prop string) |
54538 | 2304 (overlay-put overlay 'put-break t) |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2305 (overlay-put overlay 'before-string string)))) |
54538 | 2306 |
2307 ;;from remove-images | |
2308 (defun gdb-remove-strings (start end &optional buffer) | |
2309 "Remove strings between START and END in BUFFER. | |
2310 Remove only strings that were put in BUFFER with calls to `gdb-put-string'. | |
2311 BUFFER nil or omitted means use the current buffer." | |
2312 (unless buffer | |
2313 (setq buffer (current-buffer))) | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2314 (dolist (overlay (overlays-in start end)) |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2315 (when (overlay-get overlay 'put-break) |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2316 (delete-overlay overlay)))) |
54538 | 2317 |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2318 (defun gdb-put-breakpoint-icon (enabled bptno) |
54538 | 2319 (let ((start (progn (beginning-of-line) (- (point) 1))) |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2320 (end (progn (end-of-line) (+ (point) 1))) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2321 (putstring (if enabled "B" "b"))) |
59635
4d7bfec0bb4a
(gdb-put-breakpoint-icon): Add help-echo for
Nick Roberts <nickrob@snap.net.nz>
parents:
59617
diff
changeset
|
2322 (add-text-properties |
4d7bfec0bb4a
(gdb-put-breakpoint-icon): Add help-echo for
Nick Roberts <nickrob@snap.net.nz>
parents:
59617
diff
changeset
|
2323 0 1 '(help-echo "mouse-1: set/clear bkpt, mouse-3: enable/disable bkpt") |
4d7bfec0bb4a
(gdb-put-breakpoint-icon): Add help-echo for
Nick Roberts <nickrob@snap.net.nz>
parents:
59617
diff
changeset
|
2324 putstring) |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2325 (if enabled (add-text-properties |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2326 0 1 `(gdb-bptno ,bptno gdb-enabled t) putstring) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2327 (add-text-properties |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2328 0 1 `(gdb-bptno ,bptno gdb-enabled nil) putstring)) |
54538 | 2329 (gdb-remove-breakpoint-icons start end) |
2330 (if (display-images-p) | |
2331 (if (>= (car (window-fringes)) 8) | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
2332 (gdb-put-string |
54538 | 2333 nil (1+ start) |
57262
df4b0ff293d8
(breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents:
56330
diff
changeset
|
2334 `(left-fringe breakpoint |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2335 ,(if enabled |
60760
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
2336 'breakpoint-enabled |
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
2337 'breakpoint-disabled))) |
54538 | 2338 (when (< left-margin-width 2) |
2339 (save-current-buffer | |
2340 (setq left-margin-width 2) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2341 (if (get-buffer-window (current-buffer) 0) |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
2342 (set-window-margins |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2343 (get-buffer-window (current-buffer) 0) |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
2344 left-margin-width right-margin-width)))) |
54538 | 2345 (put-image |
2346 (if enabled | |
2347 (or breakpoint-enabled-icon | |
2348 (setq breakpoint-enabled-icon | |
54668
69a699e79a0d
(gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents:
54617
diff
changeset
|
2349 (find-image `((:type xpm :data |
54538 | 2350 ,breakpoint-xpm-data |
2351 :ascent 100 :pointer hand) | |
2352 (:type pbm :data | |
2353 ,breakpoint-enabled-pbm-data | |
2354 :ascent 100 :pointer hand))))) | |
2355 (or breakpoint-disabled-icon | |
2356 (setq breakpoint-disabled-icon | |
2357 (find-image `((:type xpm :data | |
2358 ,breakpoint-xpm-data | |
2359 :conversion disabled | |
2360 :ascent 100) | |
2361 (:type pbm :data | |
2362 ,breakpoint-disabled-pbm-data | |
2363 :ascent 100)))))) | |
59617
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2364 (+ start 1) |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2365 putstring |
4988bdf5db77
(gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents:
58534
diff
changeset
|
2366 'left-margin)) |
54538 | 2367 (when (< left-margin-width 2) |
2368 (save-current-buffer | |
2369 (setq left-margin-width 2) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2370 (if (get-buffer-window (current-buffer) 0) |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
2371 (set-window-margins |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2372 (get-buffer-window (current-buffer) 0) |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
2373 left-margin-width right-margin-width)))) |
60760
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
2374 (gdb-put-string |
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
2375 (propertize putstring |
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
2376 'face (if enabled 'breakpoint-enabled 'breakpoint-disabled)) |
a706fe4203bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents:
60541
diff
changeset
|
2377 (1+ start))))) |
54538 | 2378 |
2379 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin) | |
2380 (gdb-remove-strings start end) | |
2381 (if (display-images-p) | |
2382 (remove-images start end)) | |
2383 (when remove-margin | |
2384 (setq left-margin-width 0) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2385 (if (get-buffer-window (current-buffer) 0) |
56285
313e3a9f34ca
(breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents:
56258
diff
changeset
|
2386 (set-window-margins |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2387 (get-buffer-window (current-buffer) 0) |
55328
4440fe0e7dc6
(gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents:
55217
diff
changeset
|
2388 left-margin-width right-margin-width)))) |
54538 | 2389 |
2390 | |
2391 ;; | |
2392 ;; Assembler buffer. | |
2393 ;; | |
2394 (gdb-set-buffer-rules 'gdb-assembler-buffer | |
2395 'gdb-assembler-buffer-name | |
2396 'gdb-assembler-mode) | |
2397 | |
2398 (def-gdb-auto-updated-buffer gdb-assembler-buffer | |
2399 gdb-invalidate-assembler | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2400 (concat gdb-server-prefix "disassemble " gdb-current-address "\n") |
54538 | 2401 gdb-assembler-handler |
2402 gdb-assembler-custom) | |
2403 | |
2404 (defun gdb-assembler-custom () | |
2405 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer)) | |
59766
8d2464efeb2e
(gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents:
59763
diff
changeset
|
2406 (pos 1) (address) (flag) (bptno)) |
54538 | 2407 (with-current-buffer buffer |
2408 (if (not (equal gdb-current-address "main")) | |
2409 (progn | |
2410 (goto-char (point-min)) | |
2411 (if (re-search-forward gdb-current-address nil t) | |
2412 (progn | |
2413 (setq pos (point)) | |
2414 (beginning-of-line) | |
2415 (or gdb-overlay-arrow-position | |
2416 (setq gdb-overlay-arrow-position (make-marker))) | |
2417 (set-marker gdb-overlay-arrow-position | |
2418 (point) (current-buffer)))))) | |
2419 ;; remove all breakpoint-icons in assembler buffer before updating. | |
2420 (gdb-remove-breakpoint-icons (point-min) (point-max))) | |
2421 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer) | |
2422 (goto-char (point-min)) | |
2423 (while (< (point) (- (point-max) 1)) | |
2424 (forward-line 1) | |
2425 (if (looking-at "[^\t].*breakpoint") | |
2426 (progn | |
2427 (looking-at | |
59766
8d2464efeb2e
(gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents:
59763
diff
changeset
|
2428 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x\\(\\S-+\\)") |
8d2464efeb2e
(gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents:
59763
diff
changeset
|
2429 (setq bptno (match-string 1)) |
8d2464efeb2e
(gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents:
59763
diff
changeset
|
2430 (setq flag (char-after (match-beginning 2))) |
8d2464efeb2e
(gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents:
59763
diff
changeset
|
2431 (setq address (match-string 3)) |
54538 | 2432 ;; remove leading 0s from output of info break. |
2433 (if (string-match "^0+\\(.*\\)" address) | |
2434 (setq address (match-string 1 address))) | |
2435 (with-current-buffer buffer | |
2436 (goto-char (point-min)) | |
2437 (if (re-search-forward address nil t) | |
59766
8d2464efeb2e
(gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents:
59763
diff
changeset
|
2438 (gdb-put-breakpoint-icon (eq flag ?y) bptno))))))) |
54538 | 2439 (if (not (equal gdb-current-address "main")) |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2440 (set-window-point (get-buffer-window buffer 0) pos)))) |
54538 | 2441 |
2442 (defvar gdb-assembler-mode-map | |
2443 (let ((map (make-sparse-keymap))) | |
2444 (suppress-keymap map) | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2445 (define-key map "q" 'kill-this-buffer) |
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2446 map)) |
54538 | 2447 |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2448 (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
|
2449 '(;; <__function.name+n> |
4d6eec4c1ef8
* progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents:
57661
diff
changeset
|
2450 ("<\\(\\(\\sw\\|[_.]\\)+\\)\\(\\+[0-9]+\\)?>" |
4d6eec4c1ef8
* progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents:
57661
diff
changeset
|
2451 (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
|
2452 ;; 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
|
2453 ("^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
|
2454 (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
|
2455 ;; %register(at least i386) |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2456 ("%\\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
|
2457 ("^\\(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
|
2458 (1 font-lock-comment-face) |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2459 (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
|
2460 ("^\\(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
|
2461 "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
|
2462 |
54538 | 2463 (defun gdb-assembler-mode () |
2464 "Major mode for viewing code assembler. | |
2465 | |
2466 \\{gdb-assembler-mode-map}" | |
57661
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2467 (kill-all-local-variables) |
54538 | 2468 (setq major-mode 'gdb-assembler-mode) |
2469 (setq mode-name "Machine") | |
2470 (setq gdb-overlay-arrow-position nil) | |
2471 (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position) | |
2472 (setq fringes-outside-margins t) | |
2473 (setq buffer-read-only t) | |
2474 (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
|
2475 (gdb-invalidate-assembler) |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2476 (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
|
2477 '(gdb-assembler-font-lock-keywords)) |
b59713cd72a2
(gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents:
57350
diff
changeset
|
2478 (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
|
2479 'gdb-invalidate-assembler) |
54538 | 2480 |
2481 (defun gdb-assembler-buffer-name () | |
2482 (with-current-buffer gud-comint-buffer | |
2483 (concat "*Machine Code " (gdb-get-target-string) "*"))) | |
2484 | |
2485 (defun gdb-display-assembler-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
2486 "Display disassembly view." |
54538 | 2487 (interactive) |
2488 (gdb-display-buffer | |
2489 (gdb-get-create-buffer 'gdb-assembler-buffer))) | |
2490 | |
2491 (defun gdb-frame-assembler-buffer () | |
55400
1aaa031e318c
Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents:
55330
diff
changeset
|
2492 "Display disassembly view in a new frame." |
54538 | 2493 (interactive) |
58521
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
2494 (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
|
2495 (special-display-frame-alist gdb-frame-parameters)) |
54bb21951d18
(gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents:
58485
diff
changeset
|
2496 (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)))) |
54538 | 2497 |
2498 ;; modified because if gdb-current-address has changed value a new command | |
2499 ;; must be enqueued to update the buffer with the new output | |
2500 (defun gdb-invalidate-assembler (&optional ignored) | |
2501 (if (gdb-get-buffer 'gdb-assembler-buffer) | |
2502 (progn | |
2503 (unless (string-equal gdb-current-frame gdb-previous-frame) | |
2504 (if (or (not (member 'gdb-invalidate-assembler | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2505 gdb-pending-triggers)) |
54538 | 2506 (not (string-equal gdb-current-address |
2507 gdb-previous-address))) | |
2508 (progn | |
2509 ;; take previous disassemble command off the queue | |
2510 (with-current-buffer gud-comint-buffer | |
58485
31d7630f91d4
(gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents:
58470
diff
changeset
|
2511 (let ((queue gdb-input-queue)) |
54538 | 2512 (dolist (item queue) |
2513 (if (equal (cdr item) '(gdb-assembler-handler)) | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2514 (setq gdb-input-queue |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2515 (delete item gdb-input-queue)))))) |
54538 | 2516 (gdb-enqueue-input |
61870
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2517 (list (concat gdb-server-prefix "disassemble " |
584906b2e6d5
(gdb-location-alist): Rename from
Nick Roberts <nickrob@snap.net.nz>
parents:
61494
diff
changeset
|
2518 gdb-current-address "\n") |
54538 | 2519 'gdb-assembler-handler)) |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2520 (push 'gdb-invalidate-assembler gdb-pending-triggers) |
54538 | 2521 (setq gdb-previous-address gdb-current-address) |
2522 (setq gdb-previous-frame gdb-current-frame))))))) | |
2523 | |
2524 (defun gdb-get-current-frame () | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2525 (if (not (member 'gdb-get-current-frame gdb-pending-triggers)) |
54538 | 2526 (progn |
2527 (gdb-enqueue-input | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2528 (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
|
2529 (push 'gdb-get-current-frame |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2530 gdb-pending-triggers)))) |
54538 | 2531 |
2532 (defun gdb-frame-handler () | |
55749
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2533 (setq gdb-pending-triggers |
230865f1c59d
(gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
55696
diff
changeset
|
2534 (delq 'gdb-get-current-frame gdb-pending-triggers)) |
54538 | 2535 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) |
2536 (goto-char (point-min)) | |
58049
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
2537 (if (looking-at "Stack level \\([0-9]+\\)") |
fd0093bd412a
(gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents:
57982
diff
changeset
|
2538 (setq gdb-current-stack-level (match-string 1))) |
54538 | 2539 (forward-line) |
54962
c3272c09f927
(gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents:
54901
diff
changeset
|
2540 (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ") |
54538 | 2541 (progn |
2542 (setq gdb-current-frame (match-string 2)) | |
55850
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
2543 (if (gdb-get-buffer 'gdb-locals-buffer) |
63ca25eb73a1
(gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents:
55764
diff
changeset
|
2544 (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
|
2545 (setq mode-name (concat "Locals:" gdb-current-frame)))) |
54538 | 2546 (let ((address (match-string 1))) |
2547 ;; remove leading 0s from output of info frame command. | |
2548 (if (string-match "^0+\\(.*\\)" address) | |
2549 (setq gdb-current-address | |
2550 (concat "0x" (match-string 1 address))) | |
2551 (setq gdb-current-address (concat "0x" address)))) | |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2552 (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t)) |
54538 | 2553 ;;update with new frame for machine code if necessary |
58534
c655bc81dfc0
(gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents:
58521
diff
changeset
|
2554 (gdb-invalidate-assembler))))) |
54538 | 2555 (if (re-search-forward " source language \\(\\S-*\\)\." nil t) |
2556 (setq gdb-current-language (match-string 1)))) | |
2557 | |
2558 (provide 'gdb-ui) | |
2559 | |
55696
ed6e91c53c82
(gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55507
diff
changeset
|
2560 ;; arch-tag: e9fb00c5-74ef-469f-a088-37384caae352 |
54538 | 2561 ;;; gdb-ui.el ends here |