branch: master commit 6a41dc7bfbbf0cf68e9e660d82493fe2548f0ee6 Author: rocky <ro...@gnu.org> Commit: rocky <ro...@gnu.org>
Add starting directory in info and... set top-frame-num in various debuggers --- realgud/common/buffer/command.el | 10 ++++++++-- realgud/common/core.el | 21 +++++++++++++-------- realgud/common/file.el | 4 ++-- realgud/common/run.el | 5 +++++ realgud/common/track.el | 19 +++++++++++++++---- realgud/debugger/bashdb/init.el | 3 +++ realgud/debugger/jdb/init.el | 21 +++++++++++---------- realgud/debugger/kshdb/init.el | 3 +++ realgud/debugger/remake/init.el | 15 +++++++++------ realgud/debugger/trepan.pl/init.el | 2 +- 10 files changed, 70 insertions(+), 33 deletions(-) diff --git a/realgud/common/buffer/command.el b/realgud/common/buffer/command.el index fb80190..760db53 100644 --- a/realgud/common/buffer/command.el +++ b/realgud/common/buffer/command.el @@ -102,7 +102,9 @@ loc-hist ;; ring of locations seen in the course of execution ;; see realgud-lochist -) + starting-directory ;; directory where initial debug command was issued. + ;; this can be used to resolve relative file names + ) (make-variable-buffer-local 'realgud-cmdbuf-info) (make-variable-buffer-local 'realgud-last-output-start) @@ -122,6 +124,7 @@ (realgud-struct-field-setter "realgud-cmdbuf-info" "in-debugger?") (realgud-struct-field-setter "realgud-cmdbuf-info" "callback-loc-fn") (realgud-struct-field-setter "realgud-cmdbuf-info" "callback-eval-filter") +(realgud-struct-field-setter "realgud-cmdbuf-info" "starting-directory") (defun realgud:cmdbuf-follow-buffer(event) (interactive "e") @@ -167,6 +170,8 @@ Information is put in an internal buffer called *Describe*." (json-encode (realgud-cmdbuf-info-debugger-name info))) (format " - Command-line args ::\t%s\n" (json-encode (realgud-cmdbuf-info-cmd-args info))) + (format " - Starting directory ::\t%s\n" + (realgud-cmdbuf-info-starting-directory info)) (format " - Selected window should contain source? :: %s\n" (realgud-cmdbuf-info-in-srcbuf? info)) (format " - Last input end ::\t%s\n" @@ -286,7 +291,8 @@ Information is put in an internal buffer called *Describe*." ;; removed. (defun realgud-cmdbuf-init - (cmd-buf debugger-name regexp-hash &optional cmd-hash base-variable-name) + (cmd-buf debugger-name regexp-hash &optional cmd-hash base-variable-name + starting-directory) "Initialize CMD-BUF for a working with a debugger. DEBUGGER-NAME is the name of the debugger; REGEXP-HASH are debugger-specific values set in the debugger's init.el." diff --git a/realgud/common/core.el b/realgud/common/core.el index ad5dd6a..e97c440 100644 --- a/realgud/common/core.el +++ b/realgud/common/core.el @@ -36,6 +36,7 @@ (declare-function realgud-cmdbuf-debugger-name 'realgud-buffer-command) (declare-function realgud-cmdbuf-info-bp-list= 'realgud-buffer-command) (declare-function realgud-cmdbuf-info-in-debugger?= 'realgud-buffer-command) +(declare-function realgud-cmdbuf-info-starting-directory= 'realgud-buffer-command) (declare-function realgud-cmdbuf-mode-line-update 'realgud-buffer-command) (declare-function realgud-cmdbuf? 'realgud-helper) (declare-function realgud-command-string 'realgud-buffer-command) @@ -50,6 +51,7 @@ (declare-function realgud-suggest-lang-file 'realgud-lang) (defvar realgud-srcbuf-info) +(defvar starting-directory) (defun realgud:expand-file-name-if-exists (filename) "Return FILENAME expanded using `expand-file-name' if that name exists. @@ -227,20 +229,20 @@ 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." - (let* ((starting-directory + (let* ((current-directory (or (file-name-directory script-filename) default-directory "./")) (cmdproc-buffer-name - (replace-regexp-in-string "\s+" "\s" - (format "*%s %s shell*" - (file-name-nondirectory debugger-name) - (file-name-nondirectory script-filename)))) + (replace-regexp-in-string + "\s+" "\s" + (format "*%s %s shell*" + (file-name-nondirectory debugger-name) + (file-name-nondirectory script-filename)))) (cmdproc-buffer (get-buffer-create cmdproc-buffer-name)) (realgud-buf (current-buffer)) (cmd-args (cons program args)) (process (get-buffer-process cmdproc-buffer))) - (with-current-buffer cmdproc-buffer ;; If the found command buffer isn't for the same debugger ;; invocation command, rename that and start a new one. @@ -262,10 +264,13 @@ marginal icons is reset." cmdproc-buffer (with-current-buffer cmdproc-buffer (and (realgud-cmdbuf?) (not no-reset) (realgud:reset)) - (setq default-directory default-directory) - (insert "Current directory: " default-directory "\n") + (make-local-variable 'starting-directory) + (setq starting-directory current-directory) + + (insert "Current directory: " current-directory "\n") (insert "Command: " (mapconcat 'identity cmd-args " ") "\n") + ;; For term.el ;; (term-mode) ;; (set (make-local-variable 'term-term-name) realgud-term-name) diff --git a/realgud/common/file.el b/realgud/common/file.el index 15a3e67..257ffc3 100644 --- a/realgud/common/file.el +++ b/realgud/common/file.el @@ -60,7 +60,7 @@ at LINE-NUMBER or nil if it is not there" &optional cmd-marker source-text bp-num ;; FIXME: remove ignore-file-re and cover with ;; find-file-fn. - ignore-file-re find-file-fn) + ignore-file-re find-file-fn directory) "Return a realgud-loc for FILENAME and LINE-NUMBER and the other optional position information. @@ -93,7 +93,7 @@ problem as best as we can determine." (progn (setq remapped-filename (buffer-file-name - (compilation-find-file (point-marker) filename nil))) + (compilation-find-file (point-marker) filename directory))) (when (and remapped-filename (file-exists-p remapped-filename)) (puthash filename remapped-filename realgud-file-remap) (setq filename remapped-filename) diff --git a/realgud/common/run.el b/realgud/common/run.el index f8cf09d..a24e123 100644 --- a/realgud/common/run.el +++ b/realgud/common/run.el @@ -26,10 +26,13 @@ (declare-function realgud-cmdbuf-info-in-debugger?= 'realgud-buffer-command) (declare-function realgud-cmdbuf-info-cmd-args= 'realgud-buffer-command) (declare-function realgud:track-set-debugger 'realgud-track) +(declare-function realgud-cmdbuf-info-starting-directory= 'realgud-buffer-command) (declare-function realgud-parse-command-arg 'realgud-core) (declare-function realgud:expand-file-name-if-exists 'realgud-core) (declare-function realgud:flatten 'realgud-utils) +(defvar starting-directory) + (defun realgud:parse-cmd-args(args two-args opt-two-args interp-regexp debugger-regexp path-args-list annotate-args) "Parse command line ARGS for the annotate level and name of script to debug. @@ -146,6 +149,8 @@ marginal icons is reset." (let* ((info realgud-cmdbuf-info) (cmd-args (realgud-cmdbuf-info-cmd-args info)) (cmd-str (mapconcat 'identity cmd-args " "))) + (if (boundp 'starting-directory) + (realgud-cmdbuf-info-starting-directory= starting-directory)) (set minibuffer-history (remove-duplicates (cons cmd-str (eval minibuffer-history)) :from-end) diff --git a/realgud/common/track.el b/realgud/common/track.el index f047c13..36f8e98 100644 --- a/realgud/common/track.el +++ b/realgud/common/track.el @@ -81,6 +81,7 @@ (fn-p-to-fn?-alias 'realgud-loc-p) (defvar realgud-track-divert-string) +(defvar starting-directory) (defun realgud-track-comint-output-filter-hook(text) "An output-filter hook custom for comint shells. Find @@ -411,7 +412,11 @@ Otherwise return nil." (match-string alt-line-group text))) (source-str (and text-group (match-string text-group text))) - (lineno (string-to-number (or line-str "1")))) + (lineno (string-to-number (or line-str "1"))) + (directory + (cond ((boundp 'starting-directory) starting-directory) + (t nil))) + ) (when source-str (setq source-str (ansi-color-filter-apply source-str))) @@ -426,7 +431,10 @@ Otherwise return nil." (realgud:file-loc-from-line filename lineno cmd-mark source-str nil - ignore-file-re) + ignore-file-re + nil + directory + ) ;; else nil))))) ;; else @@ -472,13 +480,16 @@ Otherwise return nil. CMD-MARK is set in the realgud-loc object created. (unless line-str (message "line number not found -- using 1")) (if (and filename lineno) - (let ((loc-or-error + (let* ((directory + (cond ((boundp 'starting-directory) staring-directory) + (t nil))) + (loc-or-error (realgud:file-loc-from-line filename lineno cmd-mark source-str (string-to-number bp-num) - ignore-file-re + ignore-file-re nil directory ))) (if (stringp loc-or-error) (progn diff --git a/realgud/debugger/bashdb/init.el b/realgud/debugger/bashdb/init.el index 49a58dd..2e3f8a3 100644 --- a/realgud/debugger/bashdb/init.el +++ b/realgud/debugger/bashdb/init.el @@ -40,6 +40,9 @@ realgud-loc-pat struct") ;; (/etc/init.d/apparmor:35): (setf (gethash "loc" realgud:bashdb-pat-hash) realgud:POSIX-debugger-loc-pat) +;; Top frame number +(setf (gethash "top-frame-num" realgud:bashdb-pat-hash) 0) + ;; Regular expression that describes a bashdb command prompt ;; For example: ;; bashdb<10> diff --git a/realgud/debugger/jdb/init.el b/realgud/debugger/jdb/init.el index 185edab..13548e0 100644 --- a/realgud/debugger/jdb/init.el +++ b/realgud/debugger/jdb/init.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2014-2015 Free Software Foundation, Inc +;; Copyright (C) 2014-2016 Free Software Foundation, Inc ;; Author: Rocky Bernstein <ro...@gnu.org> @@ -31,7 +31,7 @@ realgud-loc-pat struct") (setf (gethash "loc-callback-fn" realgud:jdb-pat-hash) 'realgud:jdb-loc-fn-callback) -;; Regular expression that describes a jdb location generally shown +;; realgud-loc-pat that describes a jdb location generally shown ;; before a command prompt. For example: ;; Breakpoint hit: "thread=main", TestMe.main(), line=7 bci=0 ;; Step completed: "thread=main", TestMe.<init>(), line=15 bci=0 @@ -43,7 +43,7 @@ realgud-loc-pat struct") :line-group 3 :text-group 6)) -;; Regular expression that describes a jdb command prompt +;; realgud-loc-pat that describes a jdb command prompt ;; For example: ;; main[1] ;; main[2] @@ -56,11 +56,11 @@ realgud-loc-pat struct") :num 1 )) -;; Regular expression that describes a Java syntax error line. +;; realgud-loc-pat that describes a Java syntax error line. ;; (setf (gethash "syntax-error" realgud:jdb-pat-hash) ;; realgud-java-syntax-error-pat) -;; Regular expression that describes a Java backtrace line. +;; realgud-loc-pat that describes a Java backtrace line. ;; For example: ;; [1] ca.snpEffect.commandLine.SnpEff.run (SnpEff.java:7) (setf (gethash "lang-backtrace" realgud:jdb-pat-hash) @@ -70,7 +70,7 @@ realgud-loc-pat struct") :file-group 1 :line-group 2)) -;; Regular expression that describes a "breakpoint set" line. +;; realgud-loc-pat that describes a "breakpoint set" line. ;; For example: ;; Set breakpoint TestMe:7 (setf (gethash "brkpt-set" realgud:jdb-pat-hash) @@ -79,7 +79,7 @@ realgud-loc-pat struct") :num 1 :line-group 2)) -;; Regular expression that describes a debugger "delete" (breakpoint) response. +;; realgud-loc-pat that describes a debugger "delete" (breakpoint) response. ;; For example: ;; Removed: breakpoint TestMe:7 (setf (gethash "brkpt-del" realgud:jdb-pat-hash) @@ -99,10 +99,11 @@ backtrace listing.") ;; Top frame number (setf (gethash "top-frame-num" realgud:jdb-pat-hash) 0) -;; Regular expression that describes a debugger "selected" frame in in +;; realgud-loc-pat that describes a debugger "selected" frame in ;; a frame-motion command. ;; For example: -;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at line 9 +;; --> #1 [1] TestMe.main (TestMe.java:7) +;; Rocky: sometimes I am not getting the frame indicator. (setf (gethash "selected-frame" realgud:jdb-pat-hash) (make-realgud-loc-pat :regexp @@ -111,7 +112,7 @@ backtrace listing.") realgud:jdb-frame-file-regexp) :num 1)) -;; Regular expression that describes a jdb backtrace line. +;; realgud-loc-pat that describes a jdb backtrace line. ;; For example: ;; [1] TestMe.main (TestMe.java:7) ;; [2] java.lang.Class.privateGetDeclaredMethods (Class.java:2,570) diff --git a/realgud/debugger/kshdb/init.el b/realgud/debugger/kshdb/init.el index 3f392f1..44fcdb8 100644 --- a/realgud/debugger/kshdb/init.el +++ b/realgud/debugger/kshdb/init.el @@ -26,6 +26,9 @@ backtrace, prompt, etc. The values of a hash entry is a realgud-loc-pat struct") +;; Top frame number +(setf (gethash "top-frame-num" realgud:kshdb-pat-hash) 0) + ;; Regular expression that describes a kshdb location generally shown ;; before a command prompt. ;; For example: diff --git a/realgud/debugger/remake/init.el b/realgud/debugger/remake/init.el index fbaa643..6e398a2 100644 --- a/realgud/debugger/remake/init.el +++ b/realgud/debugger/remake/init.el @@ -31,7 +31,10 @@ backtrace, prompt, etc. The values of a hash entry is a realgud-loc-pat struct") -;; Regular expression that describes a remake location generally shown +;; Top frame number +(setf (gethash "top-frame-num" realgud:remake-pat-hash) 0) + +;; realgud-loc-pat that describes a remake location generally shown ;; before a command prompt. ;; For example: ;; -- (emacs-dbgr/realgud/debugger/Makefile:168) @@ -51,7 +54,7 @@ realgud-loc-pat struct") :num 1 )) -;; Regular expression that describes a "breakpoint set" line +;; realgud-loc-pat that describes a "breakpoint set" line (setf (gethash "brkpt-set" realgud:remake-pat-hash) (make-realgud-loc-pat :regexp "^Breakpoint \\([0-9]+\\) on target \\([^:]*\\): file \\(.+\\), line \\([0-9]+\\).\n" @@ -59,7 +62,7 @@ realgud-loc-pat struct") :file-group 3 :line-group 4)) -;; Regular expression that describes a debugger "delete" (breakpoint) response. +;; realgud-loc-pat that describes a debugger "delete" (breakpoint) response. ;; For example: ;; Removed 1 breakpoint(s). (setf (gethash "brkpt-del" realgud:remake-pat-hash) @@ -77,7 +80,7 @@ backtrace listing.") (defconst realgud:remake-frame-file-regexp " at \\(.*\\):\\([0-9]+\\)") -;; Regular expression that describes a remake "backtrace" command line. +;; realgud-loc-pat that describes a remake "backtrace" command line. ;; For example: ;; #0 Makefile.in at /tmp/Makefile:216 ;; #1 Makefile at /tmp/Makefile:230 @@ -93,7 +96,7 @@ backtrace listing.") :line-group 4) ) -;; Regular expression that describes a debugger "backtrace" command line. +;; realgud-loc-pat that describes a debugger "backtrace" command line. ;; For example: ;; =>#0 Makefile.in at /tmp/Makefile:216 ;; #1 Makefile at /tmp/Makefile:230 @@ -110,7 +113,7 @@ backtrace listing.") :line-group 5) ) -;; Regular expression that describes which frame is selected in +;; realgud-loc-pat that describes which frame is selected in ;; a debugger backtrace listing. (setf (gethash "selected-frame-indicator" realgud:remake-pat-hash) realgud:remake-selected-frame-arrow) diff --git a/realgud/debugger/trepan.pl/init.el b/realgud/debugger/trepan.pl/init.el index c66041c..d201d10 100644 --- a/realgud/debugger/trepan.pl/init.el +++ b/realgud/debugger/trepan.pl/init.el @@ -173,7 +173,7 @@ backtrace listing.") ;; Top frame number (setf (gethash "top-frame-num" realgud:trepanpl-pat-hash) 0) -;; Regular expression that describes a debugger "selected" frame in in +;; realgud-loc-pat that describes a debugger "selected" frame in in ;; a frame-motion command. ;; For example: ;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/ipl at line 9