Mercurial > emacs
annotate lisp/gud.el @ 1300:b13b79e28eb5
* alloc.c: #include "intervals.h".
(init_intervals, make_interval,
mark_interval, mark_interval_tree): New functions conditionally
defined.
(make_uninit_string): Call INITIALIZE_INTERVAL.
(INIT_INTERVALS, UNMARK_BALANCE_INTERVALS, MARK_INTERVAL_TREE):
New macros, conditionally defined.
(mark_object): Call MARK_INTERVAL_TREE in case Lisp_String.
(gc_sweep): If text properties are in use, place all unmarked
intervals on the free list. Call UNMARK_BALANCE_INTERVALS on
`buffer->intervals' when unmarking `buffer'.
(compact_strings): Include INTERVAL_PTR_SIZE in calculation for
target of bcopy when relocating strings.
(init_alloc_once): Call INIT_INTERVALS.
(make_pure_string): Include INTERVAL_PTR_SIZE in calculation of
`size'.
author | Joseph Arceneaux <jla@gnu.org> |
---|---|
date | Fri, 02 Oct 1992 19:59:42 +0000 |
parents | 68f025a5fdaa |
children | 6eb6b48f6bf1 |
rev | line source |
---|---|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
1 ;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, or dbx under Emacs |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
2 |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
3 ;; Author: Eric S. Raymond <eric@snark.thyrsus.com> |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
4 ;; Keywords: unix, tools |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
5 |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
6 ;; %W% |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
7 |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
8 ;; Copyright (C) 1992 Free Software Foundation, Inc. |
460 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
460 | 15 ;; any later version. |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
25 | |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
26 ;;; Commentary: |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
27 |
460 | 28 ;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu> |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
29 ;; It was later rewritten by rms. Some ideas were due to Masanobu. |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
30 ;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com> |
460 | 31 ;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>, |
32 ;; who also hacked the mode to use comint.el. | |
33 | |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
34 ;; Note: use of this package with sdb requires that your tags.el support |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
35 ;; the find-tag-noselect entry point. Stock distributions up to 18.57 do |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
36 ;; *not* include this feature; if it's not included with this file, email |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
37 ;; esr@snark.thyrsus.com for it or get 18.58. |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
38 |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
39 ;; Further note: due to lossage in the Emacs-18 byte compiler, compiled |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
40 ;; versions of this code will fail with a complaint about gud-step if |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
41 ;; you invoke the gdb or sdb initializers. This should be fixed in 19. |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
42 |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
43 ;;; Code: |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
44 |
460 | 45 (require 'comint) |
923 | 46 (require 'etags) |
460 | 47 |
48 ;; ====================================================================== | |
49 ;; the overloading mechanism | |
50 | |
51 (defun gud-overload-functions (gud-overload-alist) | |
52 "Overload functions defined in GUD-OVERLOAD-ALIST. | |
53 This association list has elements of the form | |
54 (ORIGINAL-FUNCTION-NAME OVERLOAD-FUNCTION)" | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
55 (mapcar |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
56 (function (lambda (p) (fset (car p) (symbol-function (cdr p))))) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
57 gud-overload-alist)) |
460 | 58 |
59 (defun gud-debugger-startup (f d) | |
60 (error "GUD not properly entered.")) | |
61 | |
62 (defun gud-marker-filter (proc s) | |
63 (error "GUD not properly entered.")) | |
64 | |
65 (defun gud-visit-file (f) | |
66 (error "GUD not properly entered.")) | |
67 | |
68 (defun gud-set-break (proc f n) | |
69 (error "GUD not properly entered.")) | |
70 | |
71 ;; This macro is used below to define some basic debugger interface commands. | |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
72 ;; Of course you may use `gud-def' with any other debugger command, including |
1255 | 73 ;; user defined ones. |
74 | |
75 ;; A macro call like (gud-def FUNC NAME KEY DOC) expands to a form | |
76 ;; which defines FUNC to send the command NAME to the debugger, gives | |
77 ;; it the docstring DOC, and binds that function to KEY. NAME should | |
78 ;; be a string. If a numeric prefix argument is given to FUNC, it | |
79 ;; gets sent after NAME. | |
460 | 80 |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
81 (defmacro gud-def (func name key &optional doc) |
460 | 82 (let* ((cstr (list 'if '(not (= 1 arg)) |
1255 | 83 (list 'format "%s %s" name 'arg) |
84 name))) | |
460 | 85 (list 'progn |
86 (list 'defun func '(arg) | |
87 (or doc "") | |
88 '(interactive "p") | |
89 (list 'gud-call cstr)) | |
914
3122c9756a56
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
889
diff
changeset
|
90 (if key |
3122c9756a56
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
889
diff
changeset
|
91 (list 'define-key 'gud-mode-map key (list 'quote func)))))) |
460 | 92 |
1275
68f025a5fdaa
* gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents:
1274
diff
changeset
|
93 ;; Where gud-display-frame should put the debugging arrow. This is |
68f025a5fdaa
* gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents:
1274
diff
changeset
|
94 ;; set by the marker-filter, which scans the debugger's output for |
68f025a5fdaa
* gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents:
1274
diff
changeset
|
95 ;; indications of the current pc. |
68f025a5fdaa
* gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents:
1274
diff
changeset
|
96 (defvar gud-last-frame nil) |
68f025a5fdaa
* gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents:
1274
diff
changeset
|
97 |
460 | 98 ;; All debugger-specific information is collected here |
99 ;; Here's how it works, in case you ever need to add a debugger to the table. | |
100 ;; | |
101 ;; Each entry must define the following at startup: | |
102 ;; | |
103 ;;<name> | |
104 ;; comint-prompt-regexp | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
105 ;; gud-<name>-debugger-startup |
460 | 106 ;; gud-<name>-marker-filter |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
107 ;; gud-<name>-visit-file |
460 | 108 ;; gud-<name>-set-break |
109 ;; | |
477 | 110 ;; The job of the startup-command method is to fire up a copy of the debugger, |
111 ;; given an object file and source directory. | |
112 ;; | |
113 ;; The job of the marker-filter method is to detect file/line markers in | |
114 ;; strings and set the global gud-last-frame to indicate what display | |
115 ;; action (if any) should be triggered by the marker. Note that only | |
116 ;; whetever the method *returns* is displayed in the buffer; thus, you | |
117 ;; can filter the debugger's output, interpreting some and passing on | |
118 ;; the rest. | |
119 ;; | |
120 ;; The job of the visit-file method is to visit and return the buffer indicated | |
121 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or | |
122 ;; something else. | |
123 ;; | |
124 ;; The job of the gud-set-break method is to send the commands necessary | |
125 ;; to set a breakpoint at a given line in a given source file. | |
126 ;; | |
127 ;; Debugger-specific information begins here: | |
460 | 128 |
129 ;; ====================================================================== | |
130 ;; gdb functions | |
131 | |
132 (defun gud-gdb-debugger-startup (f d) | |
133 (make-comint (concat "gud-" f) "gdb" nil "-fullname" "-cd" d f)) | |
134 | |
1255 | 135 (defun gud-gdb-marker-filter (proc string) |
136 (if (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" string) | |
460 | 137 (progn |
138 (setq gud-last-frame | |
139 (cons | |
140 (substring string (match-beginning 1) (match-end 1)) | |
141 (string-to-int | |
142 (substring string (match-beginning 2) (match-end 2))))) | |
143 ;; this computation means the ^Z^Z-initiated marker in the | |
144 ;; input string is never emitted. | |
145 (concat | |
146 (substring string 0 (match-beginning 0)) | |
147 (substring string (match-end 0)) | |
148 )) | |
149 string)) | |
150 | |
151 (defun gud-gdb-visit-file (f) | |
152 (find-file-noselect f)) | |
153 | |
154 (defun gud-gdb-set-break (proc f n) | |
155 (gud-call "break %s:%d" f n)) | |
156 | |
477 | 157 ;;;###autoload |
460 | 158 (defun gdb (path) |
159 "Run gdb on program FILE in buffer *gud-FILE*. | |
160 The directory containing FILE becomes the initial working directory | |
161 and source-file directory for your debugger." | |
162 (interactive "fRun gdb on file: ") | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
163 (gud-overload-functions '((gud-debugger-startup . gud-gdb-debugger-startup) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
164 (gud-marker-filter . gud-gdb-marker-filter) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
165 (gud-visit-file . gud-gdb-visit-file) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
166 (gud-set-break . gud-gdb-set-break))) |
460 | 167 |
889
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
168 (gud-def gud-step "step" "\C-c\C-s" "Step one source line with display") |
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
169 (gud-def gud-stepi "stepi" "\C-c\C-i" "Step one instruction with display") |
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
170 (gud-def gud-next "next" "\C-c\C-n" "Step one line (skip functions)") |
1255 | 171 (gud-def gud-cont "cont" "\C-c\C-r" "Continue with display") |
460 | 172 |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
173 (gud-def gud-finish "finish" "\C-c\C-f" "Finish executing current function") |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
174 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)") |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
175 (gud-def gud-down "down" "\C-c>" "Down N stack frames (numeric arg)") |
460 | 176 |
177 (gud-common-init path) | |
178 | |
179 (setq comint-prompt-regexp "^(.*gdb[+]?) *") | |
180 (run-hooks 'gdb-mode-hook) | |
181 ) | |
182 | |
183 | |
184 ;; ====================================================================== | |
185 ;; sdb functions | |
186 | |
187 (defun gud-sdb-debugger-startup (f d) | |
188 (make-comint (concat "gud-" f) "sdb" nil f "-" d)) | |
189 | |
1255 | 190 (defun gud-sdb-marker-filter (proc string) |
460 | 191 (if (string-match "\\(^0x\\w* in \\|^\\|\n\\)\\([^:\n]*\\):\\([0-9]*\\):.*\n" |
1255 | 192 string) |
460 | 193 (setq gud-last-frame |
194 (cons | |
195 (substring string (match-beginning 2) (match-end 2)) | |
196 (string-to-int | |
197 (substring string (match-beginning 3) (match-end 3)))))) | |
198 string) | |
199 | |
200 (defun gud-sdb-visit-file (f) | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
201 (find-tag-noselect f)) |
460 | 202 |
203 (defun gud-sdb-set-break (proc f n) | |
204 (gud-queue-send (format "e %s" f) (format "%d b" n))) | |
205 | |
477 | 206 ;;;###autoload |
460 | 207 (defun sdb (path) |
208 "Run sdb on program FILE in buffer *gud-FILE*. | |
209 The directory containing FILE becomes the initial working directory | |
210 and source-file directory for your debugger." | |
923 | 211 (interactive "fRun sdb on file: ") |
460 | 212 (if (not (and (boundp 'tags-file-name) (file-exists-p tags-file-name))) |
213 (error "The sdb support requires a valid tags table to work.")) | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
214 (gud-overload-functions '((gud-debugger-startup . gud-sdb-debugger-startup) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
215 (gud-marker-filter . gud-sdb-marker-filter) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
216 (gud-visit-file . gud-sdb-visit-file) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
217 (gud-set-break . gud-sdb-set-break))) |
460 | 218 |
889
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
219 (gud-def gud-step "s" "\C-c\C-s" "Step one source line with display") |
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
220 (gud-def gud-stepi "i" "\C-c\C-i" "Step one instruction with display") |
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
221 (gud-def gud-next "S" "\C-c\C-n" "Step one source line (skip functions)") |
1255 | 222 (gud-def gud-cont "c" "\C-c\C-r" "Continue with display (`resume')") |
460 | 223 |
224 (gud-common-init path) | |
225 | |
1255 | 226 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*") |
460 | 227 (run-hooks 'sdb-mode-hook) |
228 ) | |
229 | |
230 ;; ====================================================================== | |
231 ;; dbx functions | |
232 | |
233 (defun gud-dbx-debugger-startup (f d) | |
1255 | 234 (make-comint (concat "gud-" f) "dbx" nil f)) |
460 | 235 |
1255 | 236 (defun gud-dbx-marker-filter (proc string) |
460 | 237 (if (string-match |
1255 | 238 "stopped in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\"" string) |
460 | 239 (setq gud-last-frame |
240 (cons | |
241 (substring string (match-beginning 2) (match-end 2)) | |
242 (string-to-int | |
243 (substring string (match-beginning 1) (match-end 1)))))) | |
244 string) | |
245 | |
246 (defun gud-dbx-visit-file (f) | |
247 (find-file-noselect f)) | |
248 | |
249 (defun gud-dbx-set-break (proc f n) | |
250 (gud-call "stop at \"%s\":%d" f n)) | |
251 | |
477 | 252 ;;;###autoload |
460 | 253 (defun dbx (path) |
254 "Run dbx on program FILE in buffer *gud-FILE*. | |
255 The directory containing FILE becomes the initial working directory | |
256 and source-file directory for your debugger." | |
257 (interactive "fRun dbx on file: ") | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
258 (gud-overload-functions '((gud-debugger-startup . gud-dbx-debugger-startup) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
259 (gud-marker-filter . gud-dbx-marker-filter) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
260 (gud-visit-file . gud-dbx-visit-file) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
261 (gud-set-break . gud-dbx-set-break))) |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
262 |
889
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
263 (gud-def gud-step "step" "\C-c\C-s" "Step one source line with display") |
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
264 (gud-def gud-stepi "stepi" "\C-c\C-i" "Step one instruction with display") |
b2fef2e0c761
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
868
diff
changeset
|
265 (gud-def gud-next "next" "\C-c\C-n" "Step one line (skip functions)") |
1255 | 266 (gud-def gud-cont "cont" "\C-c\C-r" "Continue with display (`resume')") |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
267 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
268 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)") |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
269 (gud-def gud-down "down" "\C-c>" "Down N stack frames (numeric arg)") |
460 | 270 |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
271 (gud-common-init path) |
460 | 272 (setq comint-prompt-regexp "^[^)]*dbx) *") |
273 | |
274 (run-hooks 'dbx-mode-hook) | |
275 ) | |
276 | |
277 ;; | |
278 ;; End of debugger-specific information | |
477 | 279 ;; |
460 | 280 |
281 (defvar gud-mode-map nil | |
282 "Keymap for gud-mode.") | |
283 | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
284 (defvar gud-commands nil |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
285 "List of strings or functions used by send-gud-command. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
286 It is for customization by you.") |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
287 |
460 | 288 (defvar gud-command-queue nil) |
289 | |
1256
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
290 ;;; When we send a command to the debugger via gud-call, it's annoying |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
291 ;;; to see the command and the new prompt inserted into the debugger's |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
292 ;;; buffer; we have other ways of knowing the command has completed. |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
293 ;;; |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
294 ;;; If the buffer looks like this: |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
295 ;;; -------------------- |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
296 ;;; (gdb) set args foo bar |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
297 ;;; (gdb) -!- |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
298 ;;; -------------------- |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
299 ;;; (the -!- marks the location of point), and we type `C-x SPC' in a |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
300 ;;; source file to set a breakpoint, we want the buffer to end up like |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
301 ;;; this: |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
302 ;;; -------------------- |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
303 ;;; (gdb) set args foo bar |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
304 ;;; Breakpoint 1 at 0x92: file make-docfile.c, line 49. |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
305 ;;; (gdb) -!- |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
306 ;;; -------------------- |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
307 ;;; Essentially, the old prompt is deleted, and the command's output |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
308 ;;; and the new prompt take its place. |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
309 ;;; |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
310 ;;; Not echoing the command is easy enough; you send it directly using |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
311 ;;; process-send-string, and it never enters the buffer. However, |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
312 ;;; getting rid of the old prompt is trickier; you don't want to do it |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
313 ;;; when you send the command, since that will result in an annoying |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
314 ;;; flicker as the prompt is deleted, redisplay occurs while Emacs |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
315 ;;; waits for a response from the debugger, and the new prompt is |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
316 ;;; inserted. Instead, we'll wait until we actually get some output |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
317 ;;; from the subprocess before we delete the prompt. If the command |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
318 ;;; produced no output other than a new prompt, that prompt will most |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
319 ;;; likely be in the first chunk of output received, so we will delete |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
320 ;;; the prompt and then replace it with an identical one. If the |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
321 ;;; command produces output, the prompt is moving anyway, so the |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
322 ;;; flicker won't be annoying. |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
323 ;;; |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
324 ;;; So - when we want to delete the prompt upon receipt of the next |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
325 ;;; chunk of debugger output, we position gud-delete-prompt-marker at |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
326 ;;; the start of the prompt; the process filter will notice this, and |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
327 ;;; delete all text between it and the process output marker. If |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
328 ;;; gud-delete-prompt-marker points nowhere, we leave the current |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
329 ;;; prompt alone. |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
330 (defvar gud-delete-prompt-marker nil) |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
331 |
460 | 332 (if gud-mode-map |
333 nil | |
334 (setq gud-mode-map (copy-keymap comint-mode-map)) | |
1255 | 335 (define-key gud-mode-map "\C-c\C-l" 'gud-refresh)) |
460 | 336 |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
337 ;; Global mappings --- we'll invoke these from a source buffer. |
460 | 338 (define-key ctl-x-map " " 'gud-break) |
339 (define-key ctl-x-map "&" 'send-gud-command) | |
340 | |
341 | |
342 (defun gud-mode () | |
343 "Major mode for interacting with an inferior debugger process. | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
344 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
345 You start it up with one of the commands M-x gdb, M-x sdb, or |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
346 M-x dbx. Each entry point finishes by executing a hook; gdb-mode-hook, |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
347 sdb-mode-hook or dbx-mode-hook respectively. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
348 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
349 After startup, the following commands are available: |
460 | 350 |
351 \\{gud-mode-map} | |
352 | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
353 \\[gud-refresh] displays in the other window the last line referred to |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
354 in the gud buffer. |
460 | 355 |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
356 \\[gud-step], \\[gud-next], and \\[gud-stepi] in the gud window, |
460 | 357 do a step-one-line, step-one-line (not entering function calls), and |
358 step-one-instruction and then update the other window | |
359 with the current file and position. \\[gud-cont] continues | |
360 execution. | |
361 | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
362 The above commands are common to all supported debuggers. If you are |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
363 using gdb or dbx, the following additional commands will be available: |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
364 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
365 \\[gud-up] pops up through an enclosing stack frame. \\[gud-down] drops |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
366 back down through one. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
367 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
368 If you are using gdb, \\[gdb-finish] runs execution to the return from |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
369 the current function and stops. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
370 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
371 These functions repeat themselves the appropriate number of times if you give a |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
372 prefix argument. |
460 | 373 |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
374 If you are in a source file, you may do the following: |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
375 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
376 Set a breakpoint at the current line by doing \\[gud-break]. This causes |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
377 an appropriate set-break to be send to the debugger; of course, if the file |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
378 you're visiting doesn't correspond to any code in the executable this will |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
379 have no effect or raise an error. |
460 | 380 |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
381 Execute a user-defined command at point with \\[send-gud-command]; the |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
382 prefix argument is taken as an index into the list of strings gud-commands. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
383 A %s in a gud-commands string is substituted with a number or address picked |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
384 up from point. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
385 |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
386 Other commands for interacting with the debugger process are inherited from |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
387 comint mode, which see." |
460 | 388 (interactive) |
389 (comint-mode) | |
390 ; (kill-all-local-variables) | |
391 (setq major-mode 'gud-mode) | |
392 (setq mode-name "Debugger") | |
393 (setq mode-line-process '(": %s")) | |
394 (use-local-map gud-mode-map) | |
395 (make-local-variable 'gud-last-frame) | |
396 (setq gud-last-frame nil) | |
397 (make-local-variable 'comint-prompt-regexp) | |
1256
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
398 (make-local-variable 'gud-delete-prompt-marker) |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
399 (setq gud-delete-prompt-marker (make-marker)) |
460 | 400 (run-hooks 'gud-mode-hook) |
401 ) | |
402 | |
403 (defvar current-gud-buffer nil) | |
404 | |
405 (defun gud-common-init (path) | |
406 ;; perform initializations common to all debuggers | |
407 (setq path (expand-file-name path)) | |
408 (let ((file (file-name-nondirectory path))) | |
409 (switch-to-buffer (concat "*gud-" file "*")) | |
410 (setq default-directory (file-name-directory path)) | |
411 (or (bolp) (newline)) | |
412 (insert "Current directory is " default-directory "\n") | |
413 (gud-debugger-startup file default-directory)) | |
414 (gud-mode) | |
415 (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter) | |
416 (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel) | |
417 (setq gud-command-queue nil) | |
418 (gud-set-buffer) | |
419 ) | |
420 | |
421 (defun gud-set-buffer () | |
422 (cond ((eq major-mode 'gud-mode) | |
423 (setq current-gud-buffer (current-buffer))))) | |
424 | |
425 (defun gud-filter (proc string) | |
426 ;; This function is responsible for inserting output from your debugger | |
427 ;; into the buffer. The hard work is done by the method that is | |
428 ;; the value of gud-marker-filter. | |
429 (let ((inhibit-quit t)) | |
430 (gud-filter-insert proc (gud-marker-filter proc string)) | |
431 ;; If we've got queued commands and we see a prompt, pop one and send it. | |
432 ;; In theory we should check that a prompt has been issued before sending | |
433 ;; queued commands. In practice, command responses from the first through | |
434 ;; penultimate elements of a command sequence are short enough that we | |
435 ;; don't really have to bother. | |
436 (if gud-command-queue | |
437 (progn | |
438 (gud-call (car gud-command-queue)) | |
439 (setq gud-command-queue (cdr gud-command-queue)) | |
440 ) | |
441 ))) | |
442 | |
443 (defun gud-filter-insert (proc string) | |
444 ;; Here's where the actual buffer insertion is done | |
1255 | 445 (save-excursion |
460 | 446 (set-buffer (process-buffer proc)) |
1274
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
447 (let ((moving (= (point) (process-mark proc))) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
448 (output-after-point (< (point) (process-mark proc)))) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
449 (save-excursion |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
450 (goto-char (process-mark proc)) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
451 ;; If we have been so requested, delete the debugger prompt. |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
452 (if (marker-buffer gud-delete-prompt-marker) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
453 (progn |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
454 (delete-region (point) gud-delete-prompt-marker) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
455 (set-marker gud-delete-prompt-marker nil))) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
456 (insert-before-markers string) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
457 ;; Check for a filename-and-line number. |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
458 ;; Don't display the specified file |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
459 ;; unless (1) point is at or after the position where output appears |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
460 ;; and (2) this buffer is on the screen. |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
461 (if (and gud-last-frame |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
462 (not output-after-point) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
463 (get-buffer-window (current-buffer))) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
464 (gud-display-frame))) |
4d867d1bedda
* gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents:
1257
diff
changeset
|
465 (if moving (goto-char (process-mark proc)))))) |
460 | 466 |
467 (defun gud-sentinel (proc msg) | |
468 (cond ((null (buffer-name (process-buffer proc))) | |
469 ;; buffer killed | |
470 ;; Stop displaying an arrow in a source file. | |
471 (setq overlay-arrow-position nil) | |
472 (set-process-buffer proc nil)) | |
473 ((memq (process-status proc) '(signal exit)) | |
474 ;; Stop displaying an arrow in a source file. | |
475 (setq overlay-arrow-position nil) | |
476 ;; Fix the mode line. | |
477 (setq mode-line-process | |
478 (concat ": " | |
479 (symbol-name (process-status proc)))) | |
480 (let* ((obuf (current-buffer))) | |
481 ;; save-excursion isn't the right thing if | |
482 ;; process-buffer is current-buffer | |
483 (unwind-protect | |
484 (progn | |
485 ;; Write something in *compilation* and hack its mode line, | |
486 (set-buffer (process-buffer proc)) | |
487 ;; Force mode line redisplay soon | |
488 (set-buffer-modified-p (buffer-modified-p)) | |
489 (if (eobp) | |
490 (insert ?\n mode-name " " msg) | |
491 (save-excursion | |
492 (goto-char (point-max)) | |
493 (insert ?\n mode-name " " msg))) | |
494 ;; If buffer and mode line will show that the process | |
495 ;; is dead, we can delete it now. Otherwise it | |
496 ;; will stay around until M-x list-processes. | |
497 (delete-process proc)) | |
498 ;; Restore old buffer, but don't restore old point | |
499 ;; if obuf is the gud buffer. | |
500 (set-buffer obuf)))))) | |
501 | |
502 | |
503 (defun gud-refresh (&optional arg) | |
504 "Fix up a possibly garbled display, and redraw the arrow." | |
505 (interactive "P") | |
506 (recenter arg) | |
507 (gud-display-frame)) | |
508 | |
509 (defun gud-display-frame () | |
510 "Find and obey the last filename-and-line marker from the debugger. | |
511 Obeying it means displaying in another window the specified file and line." | |
512 (interactive) | |
513 (if gud-last-frame | |
514 (progn | |
515 (gud-set-buffer) | |
516 (gud-display-line (car gud-last-frame) (cdr gud-last-frame)) | |
517 (setq gud-last-frame nil)))) | |
518 | |
519 ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen | |
520 ;; and that its line LINE is visible. | |
521 ;; Put the overlay-arrow on the line LINE in that buffer. | |
522 | |
523 (defun gud-display-line (true-file line) | |
524 (let* ((buffer (gud-visit-file true-file)) | |
525 (window (display-buffer buffer t)) | |
526 (pos)) | |
527 (save-excursion | |
528 (set-buffer buffer) | |
529 (save-restriction | |
530 (widen) | |
531 (goto-line line) | |
532 (setq pos (point)) | |
533 (setq overlay-arrow-string "=>") | |
534 (or overlay-arrow-position | |
535 (setq overlay-arrow-position (make-marker))) | |
536 (set-marker overlay-arrow-position (point) (current-buffer))) | |
537 (cond ((or (< pos (point-min)) (> pos (point-max))) | |
538 (widen) | |
539 (goto-char pos)))) | |
540 (set-window-point window overlay-arrow-position))) | |
541 | |
542 (defun gud-call (command &rest args) | |
543 "Invoke the debugger COMMAND displaying source in other window." | |
544 (interactive) | |
545 (gud-set-buffer) | |
546 (let ((command (concat (apply 'format command args) "\n")) | |
547 (proc (get-buffer-process current-gud-buffer))) | |
1256
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
548 |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
549 ;; Arrange for the current prompt to get deleted. |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
550 (save-excursion |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
551 (set-buffer current-gud-buffer) |
1257 | 552 (goto-char (process-mark proc)) |
1256
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
553 (beginning-of-line) |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
554 (if (looking-at comint-prompt-regexp) |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
555 (set-marker gud-delete-prompt-marker (point)))) |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
556 |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
557 (goto-char (point-max)) |
ff24725192d3
* gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents:
1255
diff
changeset
|
558 (process-send-string proc command))) |
460 | 559 |
560 (defun gud-queue-send (&rest cmdlist) | |
561 ;; Send the first command, queue the rest for send after successive | |
562 ;; send on subsequent prompts | |
563 (interactive) | |
564 (gud-call (car cmdlist)) | |
565 (setq gud-command-queue (append gud-command-queue (cdr cmdlist)))) | |
566 | |
567 (defun gud-apply-from-source (func) | |
568 ;; Apply a method from the gud buffer environment, passing it file and line. | |
569 ;; This is intended to be used for gud commands called from a source file. | |
570 (if (not buffer-file-name) | |
571 (error "There is no file associated with this buffer")) | |
572 (let ((file (file-name-nondirectory buffer-file-name)) | |
573 (line (save-restriction (widen) (1+ (count-lines 1 (point)))))) | |
574 (save-excursion | |
575 (gud-set-buffer) | |
576 (funcall func | |
577 (get-buffer-process current-gud-buffer) | |
578 file | |
579 line) | |
580 ))) | |
581 | |
582 (defun gud-break () | |
583 "Set breakpoint at this source line." | |
584 (interactive) | |
585 (gud-apply-from-source 'gud-set-break)) | |
586 | |
1255 | 587 (defun gud-read-address () |
460 | 588 "Return a string containing the core-address found in the buffer at point." |
589 (save-excursion | |
1255 | 590 (let ((pt (point)) found begin) |
591 (setq found (if (search-backward "0x" (- pt 7) t)(point))) | |
592 (cond | |
593 (found (forward-char 2) | |
594 (buffer-substring found | |
595 (progn (re-search-forward "[^0-9a-f]") | |
596 (forward-char -1) | |
597 (point)))) | |
598 (t (setq begin (progn (re-search-backward "[^0-9]") | |
599 (forward-char 1) | |
600 (point))) | |
601 (forward-char 1) | |
602 (re-search-forward "[^0-9]") | |
603 (forward-char -1) | |
604 (buffer-substring begin (point))))))) | |
460 | 605 |
606 | |
607 (defun send-gud-command (arg) | |
868
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
608 "This command reads the number where the cursor is positioned. A numeric arg |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
609 selects the ARG'th member COMMAND of the list gud-commands. If COMMAND is a |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
610 string, (format COMMAND ADDR) is inserted at the end of the debugger buffer, |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
611 otherwise (funcall COMMAND ADDR) is inserted. |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
612 For example, \"p (rtx)%s->fld[0].rtint\" is a possible string to be a |
0cda1f7b154e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
810
diff
changeset
|
613 member of gud-commands." |
460 | 614 (interactive "P") |
615 (let (comm addr) | |
616 (if arg (setq comm (nth arg gud-commands))) | |
617 (setq addr (gud-read-address)) | |
618 (if (eq (current-buffer) current-gud-buffer) | |
619 (set-mark (point))) | |
620 (cond (comm | |
621 (setq comm | |
622 (if (stringp comm) (format comm addr) (funcall comm addr)))) | |
623 (t (setq comm addr))) | |
624 (switch-to-buffer current-gud-buffer) | |
923 | 625 (goto-char (point-max)) |
460 | 626 (insert-string comm))) |
477 | 627 |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
628 ;;; gud.el ends here |