Add keys for buffer switching in backtrace-buffer.
Try to guard against sending to process via comint when it is dead and set comint-last-output-start to avoid a ansi-color-apply-on-region doesn't bomb.
(require-relative-list '("menu") "dbgr-")
(defvar dbgr-backtrace-mode-map
(let ((map (dbgr-populate-debugger-menu (make-sparse-keymap))))
+ (dbgr-populate-common-keys map)
(define-key map "." 'dbgr-backtrace-moveto-frame-selected)
(define-key map "r" 'dbgr-backtrace-init)
(define-key map [double-mouse-1] 'dbgr-goto-frame-mouse)
(define-key map [mouse-3] 'dbgr-goto-frame-mouse)
(define-key map [up] 'dbgr-backtrace-moveto-frame-prev)
(define-key map [down] 'dbgr-backtrace-moveto-frame-next)
+
+ ;; FIXME: these can go to a common routine. See also shortkey.el
+ (define-key map "<" 'dbgr-cmd-newer-frame)
+ (define-key map ">" 'dbgr-cmd-older-frame)
+ (define-key map "d" 'dbgr-cmd-newer-frame)
+ (define-key map "u" 'dbgr-cmd-older-frame)
+ (define-key map "l" 'dbgr-recenter-arrow)
+ (define-key map "C" 'dbgr-window-cmd-undisturb-src)
+ (define-key map "S" 'dbgr-window-src-undisturb-cmd)
+
(define-key map "n" 'dbgr-backtrace-moveto-frame-next)
(define-key map "p" 'dbgr-backtrace-moveto-frame-prev)
+ (define-key map "0" 'dbgr-goto-frame-n)
+ (define-key map "1" 'dbgr-goto-frame-n)
+ (define-key map "2" 'dbgr-goto-frame-n)
+ (define-key map "3" 'dbgr-goto-frame-n)
+ (define-key map "4" 'dbgr-goto-frame-n)
+ (define-key map "5" 'dbgr-goto-frame-n)
+ (define-key map "6" 'dbgr-goto-frame-n)
+ (define-key map "7" 'dbgr-goto-frame-n)
+ (define-key map "8" 'dbgr-goto-frame-n)
+ (define-key map "9" 'dbgr-goto-frame-n)
(define-key map [(control m)] 'dbgr-goto-frame)
- (define-key map "0" 'dbgr-goto-frame-n)
- (define-key map "1" 'dbgr-goto-frame-n)
- (define-key map "2" 'dbgr-goto-frame-n)
- (define-key map "3" 'dbgr-goto-frame-n)
- (define-key map "4" 'dbgr-goto-frame-n)
- (define-key map "5" 'dbgr-goto-frame-n)
- (define-key map "6" 'dbgr-goto-frame-n)
- (define-key map "7" 'dbgr-goto-frame-n)
- (define-key map "8" 'dbgr-goto-frame-n)
- (define-key map "9" 'dbgr-goto-frame-n)
- (dbgr-populate-common-keys map)
;; ;; --------------------
;; ;; The "Stack window" submenu.
(sleep-count 0)
)
(unless frame-pat
- (error "No 'frame' regular expression recorded for debugger %s"
+ (error "No 'debugger-backtrace' regular expression recorded for debugger %s"
(dbgr-cmdbuf-debugger-name)))
(setq process (get-buffer-process (current-buffer)))
(dbgr-cmdbuf-info-in-srcbuf?= (not (dbgr-cmdbuf? buffer)))
(cons (list arg) (list remaining))))
(t (cons (list arg) (list remaining))))))
+(defun dbgr-run-process(debugger-name script-filename cmd-args
+ track-mode-func &optional no-reset)
+ "Runs `dbgr-exec-shell with DEBUGGER-NAME SCRIPT-FILENAME PROGRAM-ARGS
+NO-RESET and SCRIPT-ARGS. If this succeeeds we call TRACK-MODE-FUNC
+and save cmd-args in command-buffer for use if we want to restarting.
+If we don't succeed in running the program we will switch to the command buffer
+which shows details of the error. The command buffer or nil is returned"
+
+ (let ((cmd-buf))
+ (condition-case nil
+ (setq cmd-buf
+ (apply 'dbgr-exec-shell debugger-name script-filename
+ (car cmd-args) no-reset (cdr cmd-args)))
+ (error nil))
+ ;; FIXME: Is there probably is a way to remove the
+ ;; below test and combine in condition-case?
+ (let ((process (get-buffer-process cmd-buf)))
+ (if (and process (eq 'run (process-status process)))
+ (progn
+ (switch-to-buffer cmd-buf)
+ (funcall track-mode-func 't)
+ (dbgr-cmdbuf-info-cmd-args= cmd-args)
+ )
+ (progn
+ (if cmd-buf (switch-to-buffer cmd-buf))
+ (message "Error running command: %s %s" debugger-name script-filename)
+ )
+ )
+ )
+ cmd-buf
+ )
+ )
+
+
(defun dbgr-terminate (&optional buf)
"Resets state in all buffers associated with source or command buffer BUF)
This does things like remove fringe arrows breakpoint icons and
(defun dbgr-send-command-comint (process command-str)
"Assume we are in a comint buffer. Insert COMMAND-STR and
-send that input onto the process. Parameter PROCESS not used."
- (comint-goto-process-mark)
- (setq dbgr-last-output-start (point-marker))
- (insert command-str)
- (comint-send-input))
+send that input onto the process."
+ (if (eq 'run (process-status process))
+ (progn
+ (comint-goto-process-mark)
+ (setq comint-last-output-start
+ (setq dbgr-last-output-start (point-marker)))
+ (insert command-str)
+ (comint-send-input)
+ )
+ ;; else
+ (message "Process %s not in `run' state; not issuing %s"
+ process command-str)
+ )
+ )
(defalias 'comint-output-filter-orig
(symbol-function 'comint-output-filter))
(require-relative-list '("custom" "key" "menu") "dbgr-")
(require-relative-list '("buffer/helper") "dbgr-buffer-")
-(defvar dbgr-short-key-mode-map (make-sparse-keymap)
+(defvar dbgr-short-key-mode-map
+ (let ((map (make-sparse-keymap)))
+ (dbgr-populate-common-keys map)
+ (dbgr-populate-src-buffer-map-plain map)
+ (dbgr-populate-debugger-menu map)
+ (define-key map "1" 'dbgr-goto-arrow1)
+ (define-key map "2" 'dbgr-goto-arrow2)
+ (define-key map "3" 'dbgr-goto-arrow3)
+ (define-key map "b" 'dbgr-cmd-break)
+ (define-key map "c" 'dbgr-cmd-continue)
+ (define-key map "e" 'dbgr-cmd-eval-region)
+
+ ;; FIXME: these can go to a common routine
+ (define-key map "<" 'dbgr-cmd-newer-frame)
+ (define-key map ">" 'dbgr-cmd-older-frame)
+ (define-key map "d" 'dbgr-cmd-newer-frame)
+ (define-key map "u" 'dbgr-cmd-older-frame)
+ (define-key map "l" 'dbgr-recenter-arrow)
+ (define-key map "C" 'dbgr-window-cmd-undisturb-src)
+ (define-key map "S" 'dbgr-window-src-undisturb-cmd)
+
+ (define-key map "R" 'dbgr-cmd-restart)
+ (define-key map "!" 'dbgr-cmd-shell)
+ (define-key map [insert] 'dbgr-short-key-mode)
+ (define-key map [M-insert] 'dbgr-short-key-mode)
+ map)
"Keymap used in `dbgr-short-key-mode'.")
-(define-key dbgr-short-key-mode-map
- (kbd "1") 'dbgr-goto-arrow1)
-(define-key dbgr-short-key-mode-map
- (kbd "2") 'dbgr-goto-arrow2)
-(define-key dbgr-short-key-mode-map
- (kbd "3") 'dbgr-goto-arrow3)
-(define-key dbgr-short-key-mode-map
- (kbd "b") 'dbgr-cmd-break)
-(define-key dbgr-short-key-mode-map
- (kbd "c") 'dbgr-cmd-continue)
-(define-key dbgr-short-key-mode-map
- (kbd "e") 'dbgr-cmd-eval-region)
-(define-key dbgr-short-key-mode-map
- (kbd "<") 'dbgr-cmd-newer-frame)
-(define-key dbgr-short-key-mode-map
- (kbd ">") 'dbgr-cmd-older-frame)
-(define-key dbgr-short-key-mode-map
- (kbd "l") 'dbgr-recenter-arrow)
-(define-key dbgr-short-key-mode-map
- (kbd "C") 'dbgr-window-cmd-undisturb-src)
-(define-key dbgr-short-key-mode-map
- (kbd "S") 'dbgr-window-src-undisturb-cmd)
-(define-key dbgr-short-key-mode-map
- (kbd "R") 'dbgr-cmd-restart)
-(define-key dbgr-short-key-mode-map
- (kbd "!") 'dbgr-cmd-shell)
-(define-key dbgr-short-key-mode-map [insert] 'dbgr-short-key-mode)
-(define-key dbgr-short-key-mode-map [M-insert] 'dbgr-short-key-mode)
-(dbgr-populate-common-keys dbgr-short-key-mode-map)
-(dbgr-populate-src-buffer-map-plain dbgr-short-key-mode-map)
-(dbgr-populate-debugger-menu dbgr-short-key-mode-map)
;; Implementation note: This is the mode that does all the work, it's
;; local to the buffer that is affected.
NO-RESET is nil, then that information which may point into other
buffers and source buffers which may contain marks and fringe or
marginal icons is reset."
-
-
(interactive)
- (let* (
- (cmd-str (or opt-command-line (bashdb-query-cmdline "bashdb")))
+ (let* ((cmd-str (or opt-command-line (bashdb-query-cmdline "bashdb")))
(cmd-args (split-string-and-unquote cmd-str))
(parsed-args (bashdb-parse-cmd-args cmd-args))
(script-args (cdr cmd-args))
(script-name (car script-args))
(cmd-buf))
-
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
-
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "bashdb" script-name
- (car cmd-args) no-reset (cdr cmd-args)))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (bashdb-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running bashdb command"))
- )))
+ (dbgr-run-process "bashdb" script-name cmd-args
+ 'bashdb-track-mode no-reset)
+ ))
(defalias 'bashdb 'dbgr-bashdb)
:type 'string
:group 'dbgr-gdb)
-(declare-function dbgr-gdb-track-mode (bool))
-
;; -------------------------------------------------------------------
;; The end.
;;
marginal icons is reset."
(interactive)
- (let* (
- (cmd-str (or opt-command-line (dbgr-gdb-query-cmdline "gdb")))
+ (let* ((cmd-str (or opt-command-line (dbgr-gdb-query-cmdline "gdb")))
(cmd-args (split-string-and-unquote cmd-str))
(parsed-args (dbgr-gdb-parse-cmd-args cmd-args))
(script-args (cdr cmd-args))
(script-name (expand-file-name (car script-args)))
- (cmd-buf))
+ (cmd-buf (dbgr-run-process "gdb" (car script-args) cmd-args
+ 'dbgr-gdb-track-mode nil))
+ )
+ (if cmd-buf
+ (with-current-buffer cmd-buf
+ (dbgr-command "set annotate 1" nil nil nil)
+ )
+ )
+ )
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
+ ;; ;; Parse the command line and pick out the script name and whether
+ ;; ;; --annotate has been set.
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "gdb" (car script-args)
- (car cmd-args) nil
- (cons script-name (cddr cmd-args))))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (dbgr-gdb-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running gdb command"))
- )))
+ ;; (condition-case nil
+ ;; (setq cmd-buf
+ ;; (apply 'dbgr-exec-shell "gdb" (car script-args)
+ ;; (car cmd-args) nil
+ ;; (cons script-name (cddr cmd-args))))
+ ;; (error nil))
+ ;; ;; FIXME: Is there probably is a way to remove the
+ ;; ;; below test and combine in condition-case?
+ ;; (let ((process (get-buffer-process cmd-buf)))
+ ;; (if (and process (eq 'run (process-status process)))
+ ;; (progn
+ ;; (switch-to-buffer cmd-buf)
+ ;; (dbgr-gdb-track-mode 't)
+ ;; (dbgr-cmdbuf-info-cmd-args= cmd-args)
+ ;; )
+ ;; (message "Error running gdb command"))
+ ;; )
+ )
(provide-me "dbgr-")
:global nil
:group 'dbgr-gdb
:keymap dbgr-gdb-track-mode-map
- (dbgr-track-set-debugger "dbgr-gdb")
(if dbgr-gdb-track-mode
(progn
+ (dbgr-track-set-debugger "gdb")
(dbgr-track-mode 't)
(run-mode-hooks (intern (dbgr-gdb-track-mode-hook))))
(progn
(script-args (cdr cmd-args))
(script-name (car script-args))
(cmd-buf))
-
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
-
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "pydbgr" script-name
- (car cmd-args) no-reset (cdr cmd-args)))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (pydbgr-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running pydbgr command"))
- )))
+ (dbgr-run-process "pydbgr" script-name cmd-args
+ 'pydbgr-track-mode no-reset)
+ )
+ )
+
(defalias 'pydbgr 'dbgr-pydbgr)
NO-RESET is nil, then that information which may point into other
buffers and source buffers which may contain marks and fringe or
marginal icons is reset."
-
-
(interactive)
- (let* (
- (cmd-str (or opt-command-line (rdebug-query-cmdline "rdebug")))
+ (let* ((cmd-str (or opt-command-line (rdebug-query-cmdline "rdebug")))
(cmd-args (split-string-and-unquote cmd-str))
(parsed-args (rdebug-parse-cmd-args cmd-args))
(script-name-annotate-p (rdebug-get-script-name cmd-args))
(annotate-p (cadr script-name-annotate-p))
(script-args (cdr cmd-args))
(cmd-buf))
-
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
-
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "rdebug" script-name
- (car cmd-args) no-reset (cdr cmd-args)))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (rdebug-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running rdebug command"))
- )))
+ (dbgr-run-process "rdebug" script-name cmd-args
+ 'rdebug-track-mode no-reset)
+ )
+ )
(defalias 'rdebug 'dbgr-rdebug)
-
(provide-me "dbgr-")
:type 'string
:group 'remake)
-(declare-function remake-track-mode (bool))
-
;; -------------------------------------------------------------------
;; The end.
;;
(interactive)
- (let* (
- (cmd-str (or opt-command-line (remake-query-cmdline "remake")))
+ (let* ((cmd-str (or opt-command-line (remake-query-cmdline "remake")))
(cmd-args (split-string-and-unquote cmd-str))
(parsed-args (remake-parse-cmd-args cmd-args))
(remake-program (car parsed-args))
(makefile-name (or (cadr parsed-args) "Makefile"))
(makefile-args (caddr parsed-args))
(cmd-buf))
+ (dbgr-run-process "remake" makefile-name
+ (cons remake-program makefile-args)
+ 'remake-track-mode no-reset)
+
+ ;; ;; Parse the command line and pick out the script name and whether
+ ;; ;; --annotate has been set.
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
-
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "remake" makefile-name
- remake-program no-reset makefile-args))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (remake-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running remake command"))
- )))
+ ;; (condition-case nil
+ ;; (setq cmd-buf
+ ;; (apply 'dbgr-exec-shell "remake" makefile-name
+ ;; remake-program no-reset makefile-args))
+ ;; (error nil))
+ ;; ;; FIXME: Is there probably is a way to remove the
+ ;; ;; below test and combine in condition-case?
+ ;; (let ((process (get-buffer-process cmd-buf)))
+ ;; (if (and process (eq 'run (process-status process)))
+ ;; (progn
+ ;; (switch-to-buffer cmd-buf)
+ ;; (remake-track-mode 't)
+ ;; (dbgr-cmdbuf-info-cmd-args= cmd-args)
+ ;; )
+ ;; (message "Error running remake command"))
+ ;; )
+ )
+ )
(defalias 'remake 'dbgr-remake)
(provide-me "dbgr-")
-
;;; remake.el ends here
:type 'string
:group 'trepan)
-(declare-function trepan-track-mode (bool))
-
;; -------------------------------------------------------------------
;; The end.
;;
NO-RESET is nil, then that information which may point into other
buffers and source buffers which may contain marks and fringe or
marginal icons is reset."
-
-
(interactive)
(let* (
(cmd-str (or opt-command-line (trepan-query-cmdline "trepan")))
(script-args (cdr cmd-args))
(script-name (car script-args))
(cmd-buf))
-
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
-
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "trepan" script-name
- (car cmd-args) no-reset (cdr cmd-args)))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (trepan-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running trepan command"))
- )))
+ (dbgr-run-process "trepan" script-name cmd-args 'trepan-track-mode no-reset)
+ )
+ )
(defalias 'trepan 'dbgr-trepan)
(provide-me "dbgr-")
-
;;; trepan.el ends here
:type 'string
:group 'trepanx)
-(declare-function trepanx-track-mode (bool))
-
;; -------------------------------------------------------------------
;; The end.
;;
NO-RESET is nil, then that information which may point into other
buffers and source buffers which may contain marks and fringe or
marginal icons is reset."
-
-
(interactive)
(let* (
(cmd-str (or opt-command-line (trepanx-query-cmdline "trepanx")))
(script-args (cdr cmd-args))
(script-name (car script-args))
(cmd-buf))
-
- ;; Parse the command line and pick out the script name and whether
- ;; --annotate has been set.
-
- (condition-case nil
- (setq cmd-buf
- (apply 'dbgr-exec-shell "trepanx" script-name
- (car cmd-args) no-reset (cdr cmd-args)))
- (error nil))
- ;; FIXME: Is there probably is a way to remove the
- ;; below test and combine in condition-case?
- (let ((process (get-buffer-process cmd-buf)))
- (if (and process (eq 'run (process-status process)))
- (progn
- (switch-to-buffer cmd-buf)
- (trepanx-track-mode 't)
- (dbgr-cmdbuf-info-cmd-args= cmd-args)
- )
- (message "Error running trepanx command"))
- )))
+ (dbgr-run-process "trepanx" script-name cmd-args
+ 'trepanx-track-mode no-reset)
+ )
+ )
(defalias 'trepanx 'dbgr-trepanx)
(provide-me "dbgr-")
-
;;; trepanx.el ends here