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