branch: master commit bd45ec939c37cbf0f8239c9d63b6f20ca8748608 Author: rocky <ro...@gnu.org> Commit: rocky <ro...@gnu.org>
backtrace.el: fix some bugs and remove some warnings posix-shell.el: remove python constants nodejs/init.el Add backtrace regexp to nodejs Add more FSF copyrights --- realgud/common/attach.el | 17 +++++- realgud/common/backtrack-mode.el | 26 +++++++-- realgud/common/buffer/backtrace.el | 4 +- realgud/common/track.el | 5 +- realgud/debugger/bashdb/bashdb.el | 18 +++++- realgud/debugger/nodejs/core.el | 18 +++++- realgud/debugger/nodejs/init.el | 54 +++++++++++++----- realgud/lang/posix-shell.el | 9 --- test/test-loc-regexp-nodejs.el | 109 ++++++++++++++++++++++++++++++++++++ test/test-regexp-nodejs.el | 14 +++++ 10 files changed, 240 insertions(+), 34 deletions(-) diff --git a/realgud/common/attach.el b/realgud/common/attach.el index 32734b0..f0efbff 100644 --- a/realgud/common/attach.el +++ b/realgud/common/attach.el @@ -1,4 +1,19 @@ -;;; Copyright (C) 2014 Rocky Bernstein <ro...@gnu.org> +;; Copyright (C) 2015 Free Software Foundation, Inc + +;; Author: Rocky Bernstein <ro...@gnu.org> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;; Emacs Commands to associate or attach a source buffer to a command ;;; buffer and vice versa. diff --git a/realgud/common/backtrack-mode.el b/realgud/common/backtrack-mode.el index 46ef27c..9fe1157 100644 --- a/realgud/common/backtrack-mode.el +++ b/realgud/common/backtrack-mode.el @@ -1,8 +1,24 @@ -;;; Copyright (C) 2011, 2013, 2014 Rocky Bernstein <ro...@gnu.org> -;;; Used to parse programming-language backtrace-like tracks -;;; output. In contrast to track-mode, there doesn't have to be a -;;; process shell arround Compare with backtrace-mode.el which -;;; handles backtraces inside the debugger +;; Copyright (C) 2015 Free Software Foundation, Inc + +;; Author: Rocky Bernstein <ro...@gnu.org> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;; Used to parse programming-language backtrace-like tracks +;; output. In contrast to track-mode, there doesn't have to be a +;; process shell arround Compare with backtrace-mode.el which +;; handles backtraces inside the debugger (eval-when-compile (require 'cl)) (require 'shell) diff --git a/realgud/common/buffer/backtrace.el b/realgud/common/buffer/backtrace.el index 08a3faa..98b1ec5 100644 --- a/realgud/common/buffer/backtrace.el +++ b/realgud/common/buffer/backtrace.el @@ -22,6 +22,8 @@ ;; along with this program. If not, see ;; <http://www.gnu.org/licenses/>. +(require 'ansi-color) +(require 'ring) (require 'load-relative) (eval-when-compile (require 'cl-lib)) (require-relative-list @@ -142,7 +144,7 @@ (if divert-string (let* ((triple (realgud:backtrace-add-text-properties - frame-pat cmdbuf indicator-re)) + frame-pat cmdbuf divert-string indicator-re)) (string-with-props (ansi-color-filter-apply (car triple))) (frame-num-pos-list (caddr triple)) diff --git a/realgud/common/track.el b/realgud/common/track.el index a087615..f6dc1f5 100644 --- a/realgud/common/track.el +++ b/realgud/common/track.el @@ -103,7 +103,10 @@ marks set in buffer-local variables to extract text" (curr-proc (get-buffer-process cmd-buff)) (cmdbuf-last-output-end (realgud-cmdbuf-info-last-input-end realgud-cmdbuf-info)) - (last-output-end (process-mark curr-proc)) + (last-output-end + (if curr-proc + (process-mark curr-proc) + cmdbuf-last-output-end)) (last-output-start (max comint-last-input-start (- last-output-end realgud-track-char-range)))) ;; Sometimes we get called twice and the second time nothing diff --git a/realgud/debugger/bashdb/bashdb.el b/realgud/debugger/bashdb/bashdb.el index d8d10a9..81324de 100644 --- a/realgud/debugger/bashdb/bashdb.el +++ b/realgud/debugger/bashdb/bashdb.el @@ -1,4 +1,20 @@ -;;; Copyright (C) 2011, 2013-2015 Rocky Bernstein <ro...@gnu.org> +;; Copyright (C) 2015 Free Software Foundation, Inc + +;; Author: Rocky Bernstein <ro...@gnu.org> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + ;; `bashdb' Main interface to bashdb via Emacs (require 'list-utils) (require 'load-relative) diff --git a/realgud/debugger/nodejs/core.el b/realgud/debugger/nodejs/core.el index 9cc5aa2..cc09972 100644 --- a/realgud/debugger/nodejs/core.el +++ b/realgud/debugger/nodejs/core.el @@ -1,4 +1,20 @@ -;;; Copyright (C) 2014 Rocky Bernstein <ro...@gnu.org> +;; Copyright (C) 2015 Free Software Foundation, Inc + +;; Author: Rocky Bernstein <ro...@gnu.org> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + (eval-when-compile (require 'cl)) (require 'load-relative) diff --git a/realgud/debugger/nodejs/init.el b/realgud/debugger/nodejs/init.el index 66ad725..25c7e27 100644 --- a/realgud/debugger/nodejs/init.el +++ b/realgud/debugger/nodejs/init.el @@ -1,4 +1,19 @@ -;;; Copyright (C) 2014 Rocky Bernstein <ro...@gnu.org> +;; Copyright (C) 2015 Free Software Foundation, Inc + +;; Author: Rocky Bernstein <ro...@gnu.org> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;; Regular expressions for nodejs Javascript debugger. (eval-when-compile (require 'cl)) @@ -18,9 +33,16 @@ backtrace, prompt, etc. The values of a hash entry is a realgud-loc-pat struct") -(defvar realgud:nodejs-term-escape "[[0-9]+[GKJ]" +(defconst realgud:nodejs-term-escape "[[0-9]+[GKJ]" "Escape sequence regular expression pattern nodejs often puts in around prompts") +(defconst realgud:nodejs-frame-start-regexp "\\(?:^\\|\n\\)\\(?:#\\)") +(defconst realgud:nodejs-frame-num-regexp "\\([0-9]+\\)") +(defconst realgud:nodejs-frame-module-regexp "[^ \t\n]+") +(defconst realgud:nodejs-frame-file-regexp "[^ \t\n]+") +(defconst realgud:nodejs-frame-line-regexp realgud:nodejs-frame-num-regexp) +(defconst realgud:nodejs-frame-column-regexp realgud:nodejs-frame-num-regexp) + ;; Regular expression that describes a nodejs location generally shown ;; before a command prompt. ;; For example: @@ -66,19 +88,21 @@ realgud-loc-pat struct") ;; #5 Module._load module.js:312:12 ;; #6 Module.runMain module.js:497:10 ; ;#7 timers.js:110:15 - -;; (setf (gethash "debugger-backtrace" realgud:nodejs-pat-hash) -;; (make-realgud-loc-pat -;; :regexp (concat realgud-shell-frame-start-regexp -;; realgud-shell-frame-num-regexp "[ ]?" -;; "\\(.*\\)" -;; realgud-shell-frame-file-regexp -;; "\\(?:" realgud-shell-frame-line-regexp "\\)?" -;; ) -;; :num 2 -;; :file-group 4 -;; :line-group 5) -;; ) +(setf (gethash "debugger-backtrace" realgud:nodejs-pat-hash) + (make-realgud-loc-pat + :regexp (concat realgud:nodejs-frame-start-regexp + realgud:nodejs-frame-num-regexp " " + "\\(?:" realgud:nodejs-frame-module-regexp " \\)?" + "\\(" realgud:nodejs-frame-file-regexp "\\)" + ":" + realgud:nodejs-frame-line-regexp + ":" + realgud:nodejs-frame-column-regexp + ) + :num 1 + :file-group 2 + :line-group 3 + :char-offset-group 4)) ;; ;; Regular expression that for a termination message. ;; (setf (gethash "termination" realgud:nodejs-pat-hash) diff --git a/realgud/lang/posix-shell.el b/realgud/lang/posix-shell.el index a3fdc7e..3cbc51a 100644 --- a/realgud/lang/posix-shell.el +++ b/realgud/lang/posix-shell.el @@ -40,15 +40,6 @@ traceback) line." ) (define-key map (kbd "C-c !!") 'realgud:goto-lang-backtrace-line) ) - -;; Patterns common to the my POSIX shell debuggers - -(defconst realgud:python-trepan-frame-start-regexp - "\\(?:^\\|\n\\)\\(->\\|##\\)") - -(defconst realgud:python-trepan-frame-num-regexp - "\\([0-9]+\\)") - ;; Regular expression that describes a bashdb/zshdb location generally shown ;; before a command prompt. ;; For example: diff --git a/test/test-loc-regexp-nodejs.el b/test/test-loc-regexp-nodejs.el new file mode 100644 index 0000000..0f17553 --- /dev/null +++ b/test/test-loc-regexp-nodejs.el @@ -0,0 +1,109 @@ +(load-file "./regexp-helper.el") +(load-file "../realgud/common/regexp.el") +(load-file "../realgud/debugger/nodejs/init.el") + +(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command) +(declare-function cmdbuf-loc-match 'realgud-regexp-helper) +(declare-function realgud-loc-pat-regexp 'realgud-regexp) +(declare-function realgud-loc-pat-file-group 'realgud-regexp) +(declare-function realgud-loc-pat-line-group 'realgud-regexp) +(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp) +(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp) +(declare-function realgud-cmdbuf-info 'realgud-regexp) +(declare-function make-realgud-cmdbuf-info 'realgud-regexp) +(declare-function realgud-loc-pat-num 'realgud-regexp) +(declare-function test-simple-start 'test-simple) +(declare-function assert-t 'test-simple) +(declare-function assert-equal 'test-simple) +(declare-function note 'test-simple) +(declare-function end-tests 'test-simple) + +(test-simple-start) + +(eval-when-compile + (defvar file-group) + (defvar frame-re) + (defvar line-group) + (defvar num-group) + (defvar test-pos) + (defvar dbg-name) + (defvar realgud-pat-hash) + (defvar loc-pat) + (defvar test-dbgr) + (defvar test-s1) + (defvar realgud-pat-bt) + (defvar realgud:trepanpl-pat-hash) +) + +; Some setup usually done in setting up the buffer. +; We customize this for the debugger trepan. Others may follow. +; FIXME: encapsulate this. +(setq dbg-name "nodejs") +(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash))) + +(setq test-dbgr (make-realgud-cmdbuf-info + :debugger-name dbg-name + :loc-regexp (realgud-loc-pat-regexp loc-pat) + :file-group (realgud-loc-pat-file-group loc-pat) + :line-group (realgud-loc-pat-line-group loc-pat))) + + +(note "debugger-backtrace") +(setq realgud-pat-bt (gethash "debugger-backtrace" + realgud:nodejs-pat-hash)) +(setq test-s1 + "#0 module.js:380:17 +#1 Module._compile module2.js:456:26 +#2 Module._extensions..js module.js:474:10 +#3 Module.load module.js:356:32 +") + +(setq bt-re (realgud-loc-pat-regexp realgud-pat-bt)) +(setq num-group (realgud-loc-pat-num realgud-pat-bt)) +(setq file-group (realgud-loc-pat-file-group realgud-pat-bt)) +(setq line-group (realgud-loc-pat-line-group realgud-pat-bt)) +(setq col-group (realgud-loc-pat-char-offset-group realgud-pat-bt)) +(assert-equal 0 (string-match bt-re test-s1)) +(assert-equal "0" (substring test-s1 + (match-beginning num-group) + (match-end num-group))) +(assert-equal "module.js" + (substring test-s1 + (match-beginning file-group) + (match-end file-group))) +(assert-equal "380" + (substring test-s1 + (match-beginning line-group) + (match-end line-group))) +(assert-equal "17" (substring test-s1 + (match-beginning col-group) + (match-end col-group))) + +(setq test-pos (match-end 0)) +(assert-equal 19 (string-match bt-re test-s1 test-pos)) + +(setq test-s1 + "#1 Module._compile module2.js:456:26 +#2 Module._extensions..js module.js:474:10 +#3 Module.load module.js:356:32 +") +(assert-equal 0 (string-match bt-re test-s1)) + +(assert-equal "1" (substring test-s1 + (match-beginning num-group) + (match-end num-group))) +(assert-equal "module2.js" + (substring test-s1 + (match-beginning file-group) + (match-end file-group))) +(assert-equal "456" + (substring test-s1 + (match-beginning line-group) + (match-end line-group))) +(assert-equal "26" (substring test-s1 + (match-beginning col-group) + (match-end col-group))) +(setq test-pos (match-end 0)) +(assert-equal 36 test-pos) + +(end-tests) diff --git a/test/test-regexp-nodejs.el b/test/test-regexp-nodejs.el index c1f4064..f05fd8a 100644 --- a/test/test-regexp-nodejs.el +++ b/test/test-regexp-nodejs.el @@ -10,6 +10,9 @@ (declare-function realgud-loc-pat-regexp 'realgud-regexp) (declare-function realgud-loc-pat-file-group 'realgud-regexp) (declare-function realgud-loc-pat-line-group 'realgud-regexp) +(declare-function make-realgud-cmdbuf-info 'realgud-regexp) +(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp) +(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp) (declare-function __FILE__ 'load-relative) (test-simple-start) @@ -17,11 +20,13 @@ (eval-when-compile (defvar dbg-name) (defvar loc-pat) + (defvar bt-pat) (defvar prompt-pat) (defvar realgud:nodejs-pat-hash) (defvar realgud-pat-hash) (defvar test-dbgr) (defvar test-text) + (defvar test-s1) ) (note "nodejs prompt matching") @@ -54,4 +59,13 @@ (realgud-cmdbuf-info-line-group test-dbgr) test-text) "extract line number") +(note "debugger-backtrace") +(set (make-local-variable 'test-s1) + "#0 module.js:380:17 +") + +(set (make-local-variable + 'bt-pat) + (gethash "debugger-backtrace" realgud:nodejs-pat-hash)) + (end-tests)