branch: externals/realgud commit 0b5ebbfb35e4a17b88865594f4a7828c3fcfda43 Merge: da2a74b ba85207 Author: R. Bernstein <ro...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Merge pull request #223 from realgud/better-bp-track Better bp track and misc tweaks --- configure.ac | 6 +++--- realgud/common/buffer/command.el | 6 +++++- realgud/common/file.el | 3 +++ realgud/common/track.el | 10 +++++++--- realgud/lang/Makefile.am | 1 + realgud/lang/js.el | 19 ++++++++++++++++++- test/test-lang-js.el | 19 +++++++++++++++++++ 7 files changed, 56 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 8914c39..de0d932 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ AC_ARG_WITH(emacs, AC_HELP_STRING([--with-emacs], AC_MSG_NOTICE("Checking emacs version") $EMACS -batch -q --no-site-file -eval \ - '(if (<= emacs-major-version 23) + '(if (< emacs-major-version 24) (progn (error "You need GNU Emacs 24 or better.") (kill-emacs 1) @@ -33,8 +33,8 @@ if test $? -ne 0 ; then fi ################################################################## -# See if --with-lispdir was set. If not, set it to a reasonable default -# based on where bash thinks bashdb is supposed to be installed. +# See if --with-lispdir was set. If not, set it to a reasonable +#default. ################################################################## AM_MISSING_PROG(GIT2CL, git2cl, $missing_dir) diff --git a/realgud/common/buffer/command.el b/realgud/common/buffer/command.el index bfb870a..31d3767 100644 --- a/realgud/common/buffer/command.el +++ b/realgud/common/buffer/command.el @@ -81,6 +81,8 @@ ;; this debugger. Eventually loc-regexp, file-group ;; and line-group below will removed and stored here. srcbuf-list ;; list of source buffers we have stopped at + source-path ;; last source-code path we've seen + bt-buf ;; backtrace buffer if it exists bp-list ;; list of breakpoints divert-output? ;; Output is part of a conversation between front-end @@ -95,7 +97,6 @@ ;; when evaluating an expression. For example, ;; some trepan debuggers expression values prefaced with: ;; $DB::D[0] = - ;; FIXME: REMOVE THIS and use regexp-hash loc-regexp ;; Location regular expression string file-group @@ -155,6 +156,7 @@ (realgud-struct-field-setter "realgud-cmdbuf-info" "no-record?") (realgud-struct-field-setter "realgud-cmdbuf-info" "prior-prompt-regexp") (realgud-struct-field-setter "realgud-cmdbuf-info" "src-shortkey?") +(realgud-struct-field-setter "realgud-cmdbuf-info" "source-path") (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") @@ -280,6 +282,8 @@ This is based on an org-mode buffer. Hit tab to expand/contract sections. (json-encode (realgud-cmdbuf-info-cmd-args info))) (format " - Starting directory ::\t%s\n" (realgud-cmdbuf-info-starting-directory info)) + (format " - Current source-code path ::\t[[%s]]\n" + (realgud-cmdbuf-info-source-path info)) (format " - Selected window should contain source? :: %s\n" (realgud-cmdbuf-info-in-srcbuf? info)) (format " - Last input end ::\t%s\n" diff --git a/realgud/common/file.el b/realgud/common/file.el index 06ef03f..51746e6 100644 --- a/realgud/common/file.el +++ b/realgud/common/file.el @@ -156,6 +156,9 @@ problem as best as we can determine." (source-buffer (find-file-noselect filename)) (source-mark)) + ;; Set this filename as the last one seen in cmdbuf + (realgud-cmdbuf-info-source-path= filename) + ;; And you thought we'd never get around to ;; doing something other than validation? (with-current-buffer source-buffer diff --git a/realgud/common/track.el b/realgud/common/track.el index db808ff..0250700 100644 --- a/realgud/common/track.el +++ b/realgud/common/track.el @@ -492,7 +492,7 @@ Otherwise return nil." ) (defun realgud-track-bp-loc(text &optional cmd-mark cmdbuf opt-ignore-re-file-list) - "Do regular-expression matching to find a file name and line number inside + "Do regular-expression matching to find a file name and line number inside string TEXT. If we match, we will turn the result into a realgud-loc struct. Otherwise return nil. CMD-MARK is set in the realgud-loc object created. " @@ -526,8 +526,12 @@ Otherwise return nil. CMD-MARK is set in the realgud-loc object created. ) (if loc-regexp (if (string-match loc-regexp text) - (let* ((bp-num (match-string bp-num-group text)) - (filename (match-string file-group text)) + (let* ((bp-num (and bp-num-group (match-string bp-num-group text))) + (filename + (if file-group + (match-string file-group text) + (realgud-sget 'cmdbuf-info 'source-path) + )) (line-str (match-string line-group text)) (source-str (and text-group (match-string text-group text))) (lineno (string-to-number (or line-str "1"))) diff --git a/realgud/lang/Makefile.am b/realgud/lang/Makefile.am index a6f5e4c..58c16cf 100644 --- a/realgud/lang/Makefile.am +++ b/realgud/lang/Makefile.am @@ -1,3 +1,4 @@ +include $(top_srcdir)/common.mk lispdir = @lispdir_realgud@/$(notdir $(subdir)) lisp_files := $(wildcard *.el) lisp_LISP = $(lisp_files) diff --git a/realgud/lang/js.el b/realgud/lang/js.el index 8d19847..6ef388b 100644 --- a/realgud/lang/js.el +++ b/realgud/lang/js.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2015-2016 Free Software Foundation, Inc +;; Copyright (C) 2015-2016, 2018 Free Software Foundation, Inc ;; Author: Rocky Bernstein <ro...@gnu.org> @@ -19,6 +19,8 @@ (require-relative-list '("../common/regexp" "../common/loc" "../common/track") "realgud-") +(declare-function realgud-goto-line-for-pt 'realgud-track) + (defconst realgud:js-term-escape "[[0-9]+[GKJ]" "Escape sequence regular expression pattern trepanjs often puts in around prompts") @@ -38,4 +40,19 @@ :char-offset-group 4) "A realgud-loc-pat struct that describes a V8 backtrace location") +(defconst realgud:js-file-line-loc-pat + (make-realgud-loc-pat + :regexp (format "^\\([^:]+\\):%s" realgud:regexp-captured-num) + :file-group 1 + :line-group 2) + "A realgud-loc-pat struct that describes a V8 file/line location") + +;; FIXME: there is probably a less redundant way to do the following +;; FNS. +(defun realgud:js-goto-file-line (pt) + "Display the location mentioned by the js file/line warning or error." + (interactive "d") + (realgud-goto-line-for-pt pt "file-line")) + + (provide-me "realgud-lang-") diff --git a/test/test-lang-js.el b/test/test-lang-js.el new file mode 100644 index 0000000..19ec308 --- /dev/null +++ b/test/test-lang-js.el @@ -0,0 +1,19 @@ +;; Press C-x C-e at the end of the next line to run this file test non-interactively +;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory (locate-library "test-simple.elc")) buffer-file-name) + +(require 'test-simple) +(require 'load-relative) + +(load-file "../realgud/lang/js.el") +(test-simple-start) + +(setq test-text "/src/external-vcs/github/rocky/trepan-ni/lib/internal/inspect_repl.js:637") +(assert-t (string-match (realgud-loc-pat-regexp realgud:js-file-line-loc-pat) + test-text) "basic location") +(assert-equal "/src/external-vcs/github/rocky/trepan-ni/lib/internal/inspect_repl.js" + (match-string 1 test-text) "extract file name") +(assert-equal "637" + (match-string 2 test-text) "extract line number") + + +(end-tests)