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