aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond1992-07-24 21:00:20 +0000
committerEric S. Raymond1992-07-24 21:00:20 +0000
commit24d725c2f3970b80d27f1ebcf59f74ce689519fb (patch)
tree9349ffc7528d4efb13920a8bb591aa6044a55884
parent1164bae9fdb9048648ceca52051becdd40cbcf99 (diff)
downloademacs-24d725c2f3970b80d27f1ebcf59f74ce689519fb.tar.gz
emacs-24d725c2f3970b80d27f1ebcf59f74ce689519fb.zip
*** empty log message ***
-rw-r--r--lisp/gud.el139
1 files changed, 81 insertions, 58 deletions
diff --git a/lisp/gud.el b/lisp/gud.el
index 0a6558d35bc..4451c0b7bc8 100644
--- a/lisp/gud.el
+++ b/lisp/gud.el
@@ -3,7 +3,7 @@
3;; Author: Eric S. Raymond <eric@snark.thyrsus.com> 3;; Author: Eric S. Raymond <eric@snark.thyrsus.com>
4;; Keywords: unix, tools 4;; Keywords: unix, tools
5 5
6;; @(#)gud.el 1.18 6;; %W%
7 7
8;; Copyright (C) 1992 Free Software Foundation, Inc. 8;; Copyright (C) 1992 Free Software Foundation, Inc.
9 9
@@ -11,7 +11,7 @@
11 11
12;; GNU Emacs is free software; you can redistribute it and/or modify 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 13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation; either version 1, or (at your option) 14;; the Free Software Foundation; either version 2, or (at your option)
15;; any later version. 15;; any later version.
16 16
17;; GNU Emacs is distributed in the hope that it will be useful, 17;; GNU Emacs is distributed in the hope that it will be useful,
@@ -26,7 +26,7 @@
26;;; Commentary: 26;;; Commentary:
27 27
28;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu> 28;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu>
29;; It was later ewritten by rms. Some ideas were due to Masanobu. 29;; It was later rewritten by rms. Some ideas were due to Masanobu.
30;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com> 30;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com>
31;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>, 31;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>,
32;; who also hacked the mode to use comint.el. 32;; who also hacked the mode to use comint.el.
@@ -51,15 +51,10 @@
51(defun gud-overload-functions (gud-overload-alist) 51(defun gud-overload-functions (gud-overload-alist)
52 "Overload functions defined in GUD-OVERLOAD-ALIST. 52 "Overload functions defined in GUD-OVERLOAD-ALIST.
53This association list has elements of the form 53This association list has elements of the form
54
55 (ORIGINAL-FUNCTION-NAME OVERLOAD-FUNCTION)" 54 (ORIGINAL-FUNCTION-NAME OVERLOAD-FUNCTION)"
56 (let ((binding nil) 55 (mapcar
57 (overloads gud-overload-alist)) 56 (function (lambda (p) (fset (car p) (symbol-function (cdr p)))))
58 (while overloads 57 gud-overload-alist))
59 (setq binding (car overloads)
60 overloads (cdr overloads))
61 (fset (car binding) (symbol-function (car (cdr binding))))
62 )))
63 58
64(defun gud-debugger-startup (f d) 59(defun gud-debugger-startup (f d)
65 (error "GUD not properly entered.")) 60 (error "GUD not properly entered."))
@@ -94,9 +89,9 @@ This association list has elements of the form
94;; 89;;
95;;<name> 90;;<name>
96;; comint-prompt-regexp 91;; comint-prompt-regexp
97;; gud-<name>-startup-command 92;; gud-<name>-debugger-startup
98;; gud-<name>-marker-filter 93;; gud-<name>-marker-filter
99;; gud-<name>-file-visit 94;; gud-<name>-visit-file
100;; gud-<name>-set-break 95;; gud-<name>-set-break
101;; 96;;
102;; The job of the startup-command method is to fire up a copy of the debugger, 97;; The job of the startup-command method is to fire up a copy of the debugger,
@@ -152,15 +147,16 @@ This association list has elements of the form
152The directory containing FILE becomes the initial working directory 147The directory containing FILE becomes the initial working directory
153and source-file directory for your debugger." 148and source-file directory for your debugger."
154 (interactive "fRun gdb on file: ") 149 (interactive "fRun gdb on file: ")
155 (gud-overload-functions '((gud-debugger-startup gud-gdb-debugger-startup) 150 (gud-overload-functions '((gud-debugger-startup . gud-gdb-debugger-startup)
156 (gud-marker-filter gud-gdb-marker-filter) 151 (gud-marker-filter . gud-gdb-marker-filter)
157 (gud-visit-file gud-gdb-visit-file) 152 (gud-visit-file . gud-gdb-visit-file)
158 (gud-set-break gud-gdb-set-break))) 153 (gud-set-break . gud-gdb-set-break)))
159 154
160 (gud-def gud-step "step" "\C-cs" "Step one source line with display") 155 (gud-def gud-step "step" "\C-cs" "Step one source line with display")
161 (gud-def gud-stepi "stepi" "\C-ci" "Step one instruction with display") 156 (gud-def gud-stepi "stepi" "\C-ci" "Step one instruction with display")
162 (gud-def gud-next "next" "\C-cn" "Step one line (skip functions)") 157 (gud-def gud-next "next" "\C-cn" "Step one line (skip functions)")
163 (gud-def gud-cont "cont" "\C-c\C-c" "Continue with display") 158 (gud-def gud-cont "cont" "\C-c\C-c" "Continue with display")
159 (gud-def gud-cont "cont" "\C-cc" "Continue with display")
164 160
165 (gud-def gud-finish "finish" "\C-c\C-f" "Finish executing current function") 161 (gud-def gud-finish "finish" "\C-c\C-f" "Finish executing current function")
166 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)") 162 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)")
@@ -190,7 +186,7 @@ and source-file directory for your debugger."
190 string) 186 string)
191 187
192(defun gud-sdb-visit-file (f) 188(defun gud-sdb-visit-file (f)
193 (find-tag-noselect f t)) 189 (find-tag-noselect f))
194 190
195(defun gud-sdb-set-break (proc f n) 191(defun gud-sdb-set-break (proc f n)
196 (gud-queue-send (format "e %s" f) (format "%d b" n))) 192 (gud-queue-send (format "e %s" f) (format "%d b" n)))
@@ -203,15 +199,16 @@ and source-file directory for your debugger."
203 (if (not (and (boundp 'tags-file-name) (file-exists-p tags-file-name))) 199 (if (not (and (boundp 'tags-file-name) (file-exists-p tags-file-name)))
204 (error "The sdb support requires a valid tags table to work.")) 200 (error "The sdb support requires a valid tags table to work."))
205 (interactive "fRun sdb on file: ") 201 (interactive "fRun sdb on file: ")
206 (gud-overload-functions '((gud-debugger-startup gud-sdb-debugger-startup) 202 (gud-overload-functions '((gud-debugger-startup . gud-sdb-debugger-startup)
207 (gud-marker-filter gud-sdb-marker-filter) 203 (gud-marker-filter . gud-sdb-marker-filter)
208 (gud-visit-file gud-sdb-visit-file) 204 (gud-visit-file . gud-sdb-visit-file)
209 (gud-set-break gud-sdb-set-break))) 205 (gud-set-break . gud-sdb-set-break)))
210 206
211 (gud-def gud-step "s" "\C-cs" "Step one source line with display") 207 (gud-def gud-step "s" "\C-cs" "Step one source line with display")
212 (gud-def gud-stepi "i" "\C-ci" "Step one instruction with display") 208 (gud-def gud-stepi "i" "\C-ci" "Step one instruction with display")
213 (gud-def gud-next "S" "\C-cn" "Step one source line (skip functions)") 209 (gud-def gud-next "S" "\C-cn" "Step one source line (skip functions)")
214 (gud-def gud-cont "c" "\C-cc" "Continue with display") 210 (gud-def gud-cont "c" "\C-c\C-c" "Continue with display")
211 (gud-def gud-cont "c" "\C-cc" "Continue with display")
215 212
216 (gud-common-init path) 213 (gud-common-init path)
217 214
@@ -247,10 +244,19 @@ and source-file directory for your debugger."
247The directory containing FILE becomes the initial working directory 244The directory containing FILE becomes the initial working directory
248and source-file directory for your debugger." 245and source-file directory for your debugger."
249 (interactive "fRun dbx on file: ") 246 (interactive "fRun dbx on file: ")
250 (gud-overload-functions '((gud-debugger-startup gud-dbx-debugger-startup) 247 (gud-overload-functions '((gud-debugger-startup . gud-dbx-debugger-startup)
251 (gud-marker-filter gud-dbx-marker-filter) 248 (gud-marker-filter . gud-dbx-marker-filter)
252 (gud-visit-file gud-dbx-visit-file) 249 (gud-visit-file . gud-dbx-visit-file)
253 (gud-set-break gud-dbx-set-break))) 250 (gud-set-break . gud-dbx-set-break)))
251
252 (gud-def gud-step "step" "\C-cs" "Step one source line with display")
253 (gud-def gud-stepi "stepi" "\C-ci" "Step one instruction with display")
254 (gud-def gud-next "next" "\C-cn" "Step one line (skip functions)")
255 (gud-def gud-cont "cont" "\C-c\C-c" "Continue with display")
256 (gud-def gud-cont "cont" "\C-c" "Continue with display")
257
258 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)")
259 (gud-def gud-down "down" "\C-c>" "Down N stack frames (numeric arg)")
254 260
255 (gud-common-init path) 261 (gud-common-init path)
256 (setq comint-prompt-regexp "^[^)]*dbx) *") 262 (setq comint-prompt-regexp "^[^)]*dbx) *")
@@ -265,44 +271,68 @@ and source-file directory for your debugger."
265(defvar gud-mode-map nil 271(defvar gud-mode-map nil
266 "Keymap for gud-mode.") 272 "Keymap for gud-mode.")
267 273
274(defvar gud-commands nil
275 "List of strings or functions used by send-gud-command.
276It is for customization by you.")
277
268(defvar gud-command-queue nil) 278(defvar gud-command-queue nil)
269 279
270(if gud-mode-map 280(if gud-mode-map
271 nil 281 nil
272 (setq gud-mode-map (copy-keymap comint-mode-map)) 282 (setq gud-mode-map (copy-keymap comint-mode-map))
273 (define-key gud-mode-map "\C-l" 'gud-refresh)) 283 (define-key gud-mode-map "\C-cl" 'gud-refresh))
274 284
285;; Global mappings --- we'll invoke these from a source buffer.
275(define-key ctl-x-map " " 'gud-break) 286(define-key ctl-x-map " " 'gud-break)
276(define-key ctl-x-map "&" 'send-gud-command) 287(define-key ctl-x-map "&" 'send-gud-command)
277 288
278 289
279(defun gud-mode () 290(defun gud-mode ()
280 "Major mode for interacting with an inferior debugger process. 291 "Major mode for interacting with an inferior debugger process.
281The following commands are available: 292
293 You start it up with one of the commands M-x gdb, M-x sdb, or
294M-x dbx. Each entry point finishes by executing a hook; gdb-mode-hook,
295sdb-mode-hook or dbx-mode-hook respectively.
296
297After startup, the following commands are available:
282 298
283\\{gud-mode-map} 299\\{gud-mode-map}
284 300
285\\[gud-display-frame] displays in the other window 301\\[gud-refresh] displays in the other window the last line referred to
286the last line referred to in the gud buffer. 302in the gud buffer.
287 303
288\\[gud-step],\\[gud-next], and \\[gud-nexti] in the gud window, 304\\[gud-step], \\[gud-next], and \\[gud-stepi] in the gud window,
289do a step-one-line, step-one-line (not entering function calls), and 305do a step-one-line, step-one-line (not entering function calls), and
290step-one-instruction and then update the other window 306step-one-instruction and then update the other window
291with the current file and position. \\[gud-cont] continues 307with the current file and position. \\[gud-cont] continues
292execution. 308execution.
293 309
294If you are in a source file, you may set a breakpoint at the current 310The above commands are common to all supported debuggers. If you are
295line in the current source file by doing \\[gud-break]. 311using gdb or dbx, the following additional commands will be available:
312
313\\[gud-up] pops up through an enclosing stack frame. \\[gud-down] drops
314back down through one.
315
316If you are using gdb, \\[gdb-finish] runs execution to the return from
317the current function and stops.
318
319These functions repeat themselves the appropriate number of times if you give a
320prefix argument.
321
322If you are in a source file, you may do the following:
323
324Set a breakpoint at the current line by doing \\[gud-break]. This causes
325an appropriate set-break to be send to the debugger; of course, if the file
326you're visiting doesn't correspond to any code in the executable this will
327have no effect or raise an error.
296 328
297Commands: 329Execute a user-defined command at point with \\[send-gud-command]; the
298Many commands are inherited from comint mode. 330prefix argument is taken as an index into the list of strings gud-commands.
299Additionally we have: 331A %s in a gud-commands string is substituted with a number or address picked
332up from point.
300 333
301\\[gud-display-frame] display frames file in other window 334Other commands for interacting with the debugger process are inherited from
302\\[gud-step] advance one line in program 335comint mode, which see."
303\\[gud-next] advance one line in program (skip over calls).
304\\[send-gud-command] used for special printing of an arg at the current point.
305C-x SPACE sets break point at current line."
306 (interactive) 336 (interactive)
307 (comint-mode) 337 (comint-mode)
308; (kill-all-local-variables) 338; (kill-all-local-variables)
@@ -513,20 +543,13 @@ Obeying it means displaying in another window the specified file and line."
513 (buffer-substring begin (dot))))))) 543 (buffer-substring begin (dot)))))))
514 544
515 545
516(defvar gud-commands nil
517 "List of strings or functions used by send-gud-command.
518It is for customization by you.")
519
520(defun send-gud-command (arg) 546(defun send-gud-command (arg)
521 547 "This command reads the number where the cursor is positioned. A numeric arg
522 "This command reads the number where the cursor is positioned. It 548selects the ARG'th member COMMAND of the list gud-commands. If COMMAND is a
523 then inserts this ADDR at the end of the debugger buffer. A numeric arg 549string, (format COMMAND ADDR) is inserted at the end of the debugger buffer,
524 selects the ARG'th member COMMAND of the list gud-print-command. If 550otherwise (funcall COMMAND ADDR) is inserted.
525 COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise 551 For example, \"p (rtx)%s->fld[0].rtint\" is a possible string to be a
526 (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\" 552member of gud-commands."
527 is a possible string to be a member of gud-commands. "
528
529
530 (interactive "P") 553 (interactive "P")
531 (let (comm addr) 554 (let (comm addr)
532 (if arg (setq comm (nth arg gud-commands))) 555 (if arg (setq comm (nth arg gud-commands)))