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