comparison lisp/gud.el @ 2960:372386917f03

(gud-def): Fix inclusion of the define-key. (gdb, sdb, dbx): Change bindings from letters to control chars. (gud-common-init): Add save-excursion. (gud-display-line): Don't mess with buffer-read-only. (gud-filter): Set output-after-point *after* deleting old prompt.
author Richard M. Stallman <rms@gnu.org>
date Sat, 22 May 1993 21:25:32 +0000
parents e1277aec1738
children d5fde107dbe3
comparison
equal deleted inserted replaced
2959:d3f30c15d39f 2960:372386917f03
2 2
3 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> 3 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
4 ;; Version: 1.3 4 ;; Version: 1.3
5 ;; Keywords: unix, tools 5 ;; Keywords: unix, tools
6 6
7 ;; Copyright (C) 1992 Free Software Foundation, Inc. 7 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
10 10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify 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 12 ;; it under the terms of the GNU General Public License as published by
98 (list 'defun func '(arg) 98 (list 'defun func '(arg)
99 (or doc "") 99 (or doc "")
100 '(interactive "p") 100 '(interactive "p")
101 (list 'gud-call cmd 'arg)) 101 (list 'gud-call cmd 'arg))
102 (if key 102 (if key
103 (progn 103 (list 'define-key
104 (list 'define-key 104 '(current-local-map)
105 '(current-local-map) 105 (concat "\C-c" key)
106 (concat "\C-c" key) 106 (list 'quote func)))
107 (list 'quote func)) 107 (if key
108 (list 'global-set-key 108 (list 'global-set-key
109 (concat gud-key-prefix key) 109 (concat gud-key-prefix key)
110 (list 'quote func)) 110 (list 'quote func)))))
111 ))))
112 111
113 ;; Where gud-display-frame should put the debugging arrow. This is 112 ;; Where gud-display-frame should put the debugging arrow. This is
114 ;; set by the marker-filter, which scans the debugger's output for 113 ;; set by the marker-filter, which scans the debugger's output for
115 ;; indications of the current program counter. 114 ;; indications of the current program counter.
116 (defvar gud-last-frame nil) 115 (defvar gud-last-frame nil)
176 (gud-find-file . gud-gdb-find-file) 175 (gud-find-file . gud-gdb-find-file)
177 )) 176 ))
178 177
179 (gud-common-init args) 178 (gud-common-init args)
180 179
181 (gud-def gud-break "break %f:%l" "b" "Set breakpoint at current line.") 180 (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.")
182 (gud-def gud-tbreak "tbreak %f:%l" "t" "Set breakpoint at current line.") 181 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set breakpoint at current line.")
183 (gud-def gud-remove "clear %l" "d" "Remove breakpoint at current line") 182 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
184 (gud-def gud-step "step %p" "s" "Step one source line with display.") 183 (gud-def gud-step "step %p" "\C-s" "Step one source line with display.")
185 (gud-def gud-stepi "stepi %p" "i" "Step one instruction with display.") 184 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
186 (gud-def gud-next "next %p" "n" "Step one line (skip functions).") 185 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).")
187 (gud-def gud-cont "cont" "r" "Continue with display.") 186 (gud-def gud-cont "cont" "\C-r" "Continue with display.")
188 (gud-def gud-finish "finish" "f" "Finish executing current function.") 187 (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
189 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") 188 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
190 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") 189 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
191 (gud-def gud-print "print %e" "p" "Evaluate C expression at point.") 190 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
192 191
193 (setq comint-prompt-regexp "^(.*gdb[+]?) *") 192 (setq comint-prompt-regexp "^(.*gdb[+]?) *")
194 (run-hooks 'gdb-mode-hook) 193 (run-hooks 'gdb-mode-hook)
195 ) 194 )
196 195
250 (gud-find-file . gud-sdb-find-file) 249 (gud-find-file . gud-sdb-find-file)
251 )) 250 ))
252 251
253 (gud-common-init args) 252 (gud-common-init args)
254 253
255 (gud-def gud-break "%l b" "b" "Set breakpoint at current line.") 254 (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.")
256 (gud-def gud-tbreak "%l c" "t" "Set temporary breakpoint at current line.") 255 (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.")
257 (gud-def gud-remove "%l d" "d" "Remove breakpoint at current line") 256 (gud-def gud-remove "%l d" "\C-d" "Remove breakpoint at current line")
258 (gud-def gud-step "s %p" "s" "Step one source line with display.") 257 (gud-def gud-step "s %p" "\C-s" "Step one source line with display.")
259 (gud-def gud-stepi "i %p" "i" "Step one instruction with display.") 258 (gud-def gud-stepi "i %p" "\C-i" "Step one instruction with display.")
260 (gud-def gud-next "S %p" "n" "Step one line (skip functions).") 259 (gud-def gud-next "S %p" "\C-n" "Step one line (skip functions).")
261 (gud-def gud-cont "c" "r" "Continue with display.") 260 (gud-def gud-cont "c" "\C-r" "Continue with display.")
262 (gud-def gud-print "%e/" "p" "Evaluate C expression at point.") 261 (gud-def gud-print "%e/" "\C-p" "Evaluate C expression at point.")
263 262
264 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*") 263 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*")
265 (run-hooks 'sdb-mode-hook) 264 (run-hooks 'sdb-mode-hook)
266 ) 265 )
267 266
296 )) 295 ))
297 296
298 (gud-common-init args) 297 (gud-common-init args)
299 298
300 (gud-def gud-break "stop at \"%f\":%l" 299 (gud-def gud-break "stop at \"%f\":%l"
301 "b" "Set breakpoint at current line.") 300 "\C-b" "Set breakpoint at current line.")
302 (gud-def gud-remove "clear %l" "d" "Remove breakpoint at current line") 301 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
303 (gud-def gud-step "step %p" "s" "Step one line with display.") 302 (gud-def gud-step "step %p" "\C-s" "Step one line with display.")
304 (gud-def gud-stepi "stepi %p" "i" "Step one instruction with display.") 303 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
305 (gud-def gud-next "next %p" "n" "Step one line (skip functions).") 304 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).")
306 (gud-def gud-cont "cont" "r" "Continue with display.") 305 (gud-def gud-cont "cont" "\C-r" "Continue with display.")
307 (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.") 306 (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.")
308 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.") 307 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.")
309 (gud-def gud-print "print %e" "p" "Evaluate C expression at point.") 308 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
310 309
311 (setq comint-prompt-regexp "^[^)]*dbx) *") 310 (setq comint-prompt-regexp "^[^)]*dbx) *")
312 (run-hooks 'dbx-mode-hook) 311 (run-hooks 'dbx-mode-hook)
313 ) 312 )
314 313
431 ;; Perform initializations common to all debuggers 430 ;; Perform initializations common to all debuggers
432 ;; There *must* be a cleaner way to lex the arglist... 431 ;; There *must* be a cleaner way to lex the arglist...
433 (let (file i) 432 (let (file i)
434 (if (string= args "") 433 (if (string= args "")
435 (setq args nil) 434 (setq args nil)
436 (set-buffer (get-buffer-create "*gud-scratch*")) 435 (save-excursion
437 (erase-buffer) 436 (set-buffer (get-buffer-create "*gud-scratch*"))
438 (insert args) 437 (erase-buffer)
439 (goto-char (point-max)) 438 (insert args)
440 (insert "\")") 439 (goto-char (point-max))
441 (goto-char (point-min)) 440 (insert "\")")
442 (insert "(\"") 441 (goto-char (point-min))
443 (while (re-search-forward " +" nil t) 442 (insert "(\"")
444 (replace-match "\" \"" nil nil)) 443 (while (re-search-forward " +" nil t)
445 (goto-char (point-min)) 444 (replace-match "\" \"" nil nil))
446 (while (re-search-forward "\"\"" nil t) 445 (goto-char (point-min))
447 (replace-match "" nil nil)) 446 (while (re-search-forward "\"\"" nil t)
448 (setq args (read (buffer-string))) 447 (replace-match "" nil nil))
449 (kill-buffer (current-buffer))) 448 (setq args (read (buffer-string)))
449 (kill-buffer (current-buffer))))
450 (setq i (1- (length args))) 450 (setq i (1- (length args)))
451 (while (and (>= i 0) (not (= (aref (nth i args) 0) ?-))) 451 (while (and (>= i 0) (not (= (aref (nth i args) 0) ?-)))
452 (setq file (nth i args)) (setq i (1- i))) 452 (setq file (nth i args)) (setq i (1- i)))
453 (let* ((path (expand-file-name file)) 453 (let* ((path (expand-file-name file))
454 (filepart (file-name-nondirectory path))) 454 (filepart (file-name-nondirectory path)))
474 (defun gud-filter (proc string) 474 (defun gud-filter (proc string)
475 ;; Here's where the actual buffer insertion is done 475 ;; Here's where the actual buffer insertion is done
476 (let ((inhibit-quit t)) 476 (let ((inhibit-quit t))
477 (save-excursion 477 (save-excursion
478 (set-buffer (process-buffer proc)) 478 (set-buffer (process-buffer proc))
479 (let ((moving (= (point) (process-mark proc))) 479 (let (moving output-after-point)
480 (output-after-point (< (point) (process-mark proc))))
481 (save-excursion 480 (save-excursion
482 (goto-char (process-mark proc)) 481 (goto-char (process-mark proc))
483 ;; If we have been so requested, delete the debugger prompt. 482 ;; If we have been so requested, delete the debugger prompt.
484 (if (marker-buffer gud-delete-prompt-marker) 483 (if (marker-buffer gud-delete-prompt-marker)
485 (progn 484 (progn
486 (delete-region (point) gud-delete-prompt-marker) 485 (delete-region (point) gud-delete-prompt-marker)
487 (set-marker gud-delete-prompt-marker nil))) 486 (set-marker gud-delete-prompt-marker nil)))
488 (insert-before-markers (gud-marker-filter string)) 487 (insert-before-markers (gud-marker-filter string))
488 (setq moving (= (point) (process-mark proc)))
489 (setq output-after-point (< (point) (process-mark proc)))
489 ;; Check for a filename-and-line number. 490 ;; Check for a filename-and-line number.
490 ;; Don't display the specified file 491 ;; Don't display the specified file
491 ;; unless (1) point is at or after the position where output appears 492 ;; unless (1) point is at or after the position where output appears
492 ;; and (2) this buffer is on the screen. 493 ;; and (2) this buffer is on the screen.
493 (if (and gud-last-frame 494 (if (and gud-last-frame
550 551
551 (defun gud-display-line (true-file line) 552 (defun gud-display-line (true-file line)
552 (let* ((buffer (gud-find-file true-file)) 553 (let* ((buffer (gud-find-file true-file))
553 (window (display-buffer buffer)) 554 (window (display-buffer buffer))
554 (pos)) 555 (pos))
555 (if (equal buffer (current-buffer)) 556 ;;; (if (equal buffer (current-buffer))
556 nil 557 ;;; nil
557 (setq buffer-read-only nil)) 558 ;;; (setq buffer-read-only nil))
558 (save-excursion 559 (save-excursion
560 ;;; (setq buffer-read-only t)
559 (set-buffer buffer) 561 (set-buffer buffer)
560 (setq buffer-read-only t)
561 (save-restriction 562 (save-restriction
562 (widen) 563 (widen)
563 (goto-line line) 564 (goto-line line)
564 (setq pos (point)) 565 (setq pos (point))
565 (setq overlay-arrow-string "=>") 566 (setq overlay-arrow-string "=>")