]> code.delx.au - gnu-emacs-elpa/commitdiff
Add ability to ignore file in tracking based on a re. For example
authorrocky <rocky@gnu.org>
Wed, 26 Oct 2011 04:14:40 +0000 (00:14 -0400)
committerrocky <rocky@gnu.org>
Wed, 26 Oct 2011 04:14:40 +0000 (00:14 -0400)
(eval) in Ruby 1.8 or (eval 10)[../foo/bar.pl:10] in Perl. Todo: add <string> in Python.

dbgr/common/buffer/command.el
dbgr/common/file.el
dbgr/common/regexp.el
dbgr/common/track.el
dbgr/debugger/rdebug/init.el
dbgr/debugger/trepanpl/init.el
dbgr/debugger/trepanpl/trepanpl.el
dbgr/lang/perl.el
test/test-regexp-perldb.el

index 613dd45bee66f4dfb1287892dee7e2353625871d..88955b6952b00455efbd3fd9a271137c279ed2aa 100644 (file)
@@ -64,6 +64,7 @@
   loc-regexp   ;; Location regular expression string
   file-group
   line-group
+  ignore-file-re
 
   loc-hist     ;; ring of locations seen in the course of execution
                ;; see dbgr-lochist
@@ -226,6 +227,7 @@ as a main program."
             :loc-regexp (dbgr-sget 'loc-pat 'regexp)
             :file-group (dbgr-sget 'loc-pat 'file-group)
             :line-group (dbgr-sget 'loc-pat 'line-group)
+            :ignore-file-re (dbgr-sget 'loc-pat 'ignore-file-re)
             :loc-hist (make-dbgr-loc-hist)
             :regexp-hash regexp-hash
             :bt-buf nil
index b1625b40a541cca11df74f0ff0e7b73c0b3e3e93..da0ecbd3628857b03b22e627088512e0ec370f59 100644 (file)
@@ -16,16 +16,26 @@ found"
          (line-number-at-pos (point-max))))
     nil))
 
-(defun dbgr-file-loc-from-line(filename line-number &optional cmd-marker bp-num)
+(defun dbgr-file-loc-from-line(filename line-number 
+                                       &optional cmd-marker bp-num ignore-file-re)
   "Return a dbgr-loc for FILENAME and LINE-NUMBER
 
+CMD-MARKER and BP-NUM get stored in the dbgr-loc object. IGNORE-FILE-RE 
+is a regular expression describing things that aren't expected to be 
+found. For example many debuggers create a pseudo file name for eval
+expressions. For example (eval 1) of Perl <string> of Python.
+
 If we're unable find the source code we return a string describing the
 problem as best as we can determine."
 
   (unless (file-exists? filename)
-    (setq filename 
-         (buffer-file-name 
-          (compilation-find-file (point-marker) filename nil)))
+    (if (and ignore-file-re (string-match ignore-file-re filename))
+       (message "tracking ignored for psuedo-file %s" filename)
+      ; else 
+      (setq filename 
+           (buffer-file-name 
+            (compilation-find-file (point-marker) filename nil)))
+      )
     )
   (if (file-exists? filename)
       (if (integerp line-number)
index 704e033e3103c4b85f23ac87c2538ac5ad4c79ec..1bb50df82a7035df76cac254751b592fda6f93ad 100644 (file)
@@ -1,4 +1,4 @@
-;;; Copyright (C) 2010 Rocky Bernstein <rocky@gnu.org>
+;;; Copyright (C) 2010, 2011 Rocky Bernstein <rocky@gnu.org>
 ;;; FIXME - think of a better name.
 ;;; Debugger regular expressions for many kinds of
 ;;;  debuggers
@@ -22,6 +22,7 @@ a string output by a debugger inside a process shell"
   (char-offset-group)
   (instruction-address-group)
   (column-group)
+  (ignore-file-re)
 )
 
 (defvar dbgr-pat-hash (make-hash-table :test 'equal)
index 405325a0a27257996688d9e45163fc1443065aec..f118efa3eef8d966090a188b37ee34a77d105ce4 100644 (file)
@@ -1,3 +1,4 @@
+;;; Copyright (C) 2011 Rocky Bernstein <rocky@gnu.org>
 (defconst dbgr-track-char-range 10000
   "Max number of characters from end of buffer to search for stack entry.")
 
@@ -261,7 +262,8 @@ encountering a new loc."
   )
 
 (defun dbgr-track-loc(text cmd-mark &optional opt-regexp opt-file-group 
-                          opt-line-group no-warn-on-no-match?)
+                          opt-line-group no-warn-on-no-match? 
+                          opt-ignore-file-re)
   "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 dbgr-loc struct.
 Otherwise return nil."
@@ -279,7 +281,10 @@ Otherwise return nil."
           (file-group (or opt-file-group 
                           (dbgr-sget 'cmdbuf-info 'file-group)))
           (line-group (or opt-line-group 
-                          (dbgr-sget 'cmdbuf-info 'line-group))))
+                          (dbgr-sget 'cmdbuf-info 'line-group)))
+          (ignore-file-re (or opt-ignore-file-re
+                              (dbgr-sget 'cmdbuf-info 'ignore-file-re)))
+          )
        (if loc-regexp
            (if (string-match loc-regexp text)
                (let* ((filename (match-string file-group text))
@@ -287,7 +292,8 @@ Otherwise return nil."
                       (lineno (string-to-number (or line-str "1"))))
                  (unless line-str (message "line number not found -- using 1"))
                  (if (and filename lineno)
-                     (dbgr-file-loc-from-line filename lineno cmd-mark)
+                     (dbgr-file-loc-from-line filename lineno cmd-mark nil
+                                              ignore-file-re)
                    nil))
              (unless no-warn-on-no-match? 
                (message "Unable to file and line number for given line"))
@@ -299,10 +305,11 @@ Otherwise return nil."
     )
   )
   
-(defun dbgr-track-bp-loc(text &optional cmd-mark cmdbuf)
+(defun dbgr-track-bp-loc(text &optional cmd-mark cmdbuf ignore-file-re)
   "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 dbgr-loc struct.
-Otherwise return nil."
+Otherwise return nil. CMD-MARK is set in the dbgr-loc object created.
+"
   
   ; NOTE: dbgr-cmdbuf-info is a buffer variable local to the process
   ; running the debugger. It contains a dbgr-cmdbuf-info "struct". In
@@ -315,10 +322,12 @@ Otherwise return nil."
     (if (dbgr-cmdbuf?)
        (let* ((loc-pat (dbgr-cmdbuf-pat "brkpt-set")))
          (if loc-pat
-             (let ((bp-num-group (dbgr-loc-pat-num loc-pat))
-                   (loc-regexp   (dbgr-loc-pat-regexp loc-pat))
-                   (file-group   (dbgr-loc-pat-file-group loc-pat))
-                   (line-group   (dbgr-loc-pat-line-group loc-pat)))
+             (let ((bp-num-group   (dbgr-loc-pat-num loc-pat))
+                   (loc-regexp     (dbgr-loc-pat-regexp loc-pat))
+                   (file-group     (dbgr-loc-pat-file-group loc-pat))
+                   (line-group     (dbgr-loc-pat-line-group loc-pat))
+                   (ignore-file-re (dbgr-loc-pat-ignore-file-re loc-pat))
+                   )
                (if loc-regexp
                    (if (string-match loc-regexp text)
                        (let* ((bp-num (match-string bp-num-group text))
@@ -333,7 +342,9 @@ Otherwise return nil."
                                     (dbgr-file-loc-from-line 
                                      filename lineno 
                                      cmd-mark 
-                                     (string-to-number bp-num))))
+                                     (string-to-number bp-num)
+                                     ignore-file-re
+                                     )))
                                (if (stringp loc-or-error)
                                    (progn 
                                      (message loc-or-error) 
@@ -453,6 +464,8 @@ find a location. non-nil if we can find a location.
                                (dbgr-loc-pat-regexp loc-pat)
                                (dbgr-loc-pat-file-group loc-pat)
                                (dbgr-loc-pat-line-group loc-pat)
+                               nil
+                               (dbgr-loc-pat-ignore-file-re loc-pat)
                                ))
       (if (stringp loc)
          (message loc)
index b50e2531bc8526f7f471bdfca2fb7844a6c8388e..02379b666ff38950f574c26aa702793f36258eed 100644 (file)
@@ -1,5 +1,5 @@
-;;; Copyright (C) 2010 Rocky Bernstein <rocky@gnu.org>
-;;; Ruby 1.8 debuggger: ruby-debug (rdebug)
+;;; Copyright (C) 2010, 2011 Rocky Bernstein <rocky@gnu.org>
+;;; Ruby 1.8 debugger: ruby-debug (rdebug)
 
 (eval-when-compile (require 'cl))
 
@@ -24,7 +24,9 @@ dbgr-loc-pat struct")
       (make-dbgr-loc-pat
        :regexp "\1a\1a\\(?:source \\)?\\(\\(?:[a-zA-Z]:\\)?\\(?:.+\\)\\):\\([0-9]+\\).*\\(?:\n\\|$\\)"
        :file-group 1
-       :line-group 2))
+       :line-group 2
+       :ignore-file-re  "(eval)"
+      ))
 
 ;; Regular expression that describes a rdebug command prompt
 ;; For example:
index 757dd1d34691c724b7e015daf16d72aa11f76c42..fabf631f5430b9ae62d29d807f93187efd74ae62 100644 (file)
@@ -21,12 +21,13 @@ dbgr-loc-pat struct")
 ;; before a command prompt.
 ;; For example: 
 ;; -- (/tmp/linecache.pl:64)
-;; C> (/tmp/eval.pl:2)
 (setf (gethash "loc" dbgr-trepanpl-pat-hash)
       (make-dbgr-loc-pat
        :regexp ".. (\\(?:.+ \\(?:via\\|remapped\\) \\)?\\(.+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?)"
        :file-group 1
-       :line-group 2))
+       :line-group 2
+       :ignore-file-re  dbgr-perl-ignore-file-re)
+      )
 
 ;; Regular expression that describes a trepanpl command prompt
 ;; For example: 
@@ -47,7 +48,9 @@ dbgr-loc-pat struct")
   (make-dbgr-loc-pat
    :regexp "^\\(?:[\t]from \\)?\\([^:]+\\):\\([0-9]+\\)\\(?:in `.*'\\)?"
    :file-group 1
-   :line-group 2))
+   :line-group 2
+   :ignore-file-re  dbgr-perl-ignore-file-re)
+  )
 
 ;;  Regular expression that describes location in a Perl errmsg
 (setf (gethash "perl-errmsg" dbgr-trepanpl-pat-hash) 
@@ -71,7 +74,9 @@ dbgr-loc-pat struct")
        :regexp "^Breakpoint \\([0-9]+\\) set at .*[\n\t ]+line \\([0-9]+\\)[ \t\n]+in file \\(.+\\)."
        :num 1
        :file-group 3
-       :line-group 2))
+       :line-group 2
+       :ignore-file-re  dbgr-perl-ignore-file-re)
+      )
 
 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
 ;; For example:
index 51ccd77b7ef25095672eb55db7ec70d0bbfd163d..008c864e6fd1cf36fe19c67e31f58d87cc124e49 100644 (file)
@@ -1,4 +1,4 @@
-;;; Copyright (C) 2010, 2011 Rocky Bernstein <rocky@gnu.org>
+;;; Copyright (C) 2011 Rocky Bernstein <rocky@gnu.org>
 ;;  `trepanpl' Main interface to trepanpl via Emacs
 (require 'load-relative)
 (require-relative-list '("../../common/helper") "dbgr-")
@@ -7,9 +7,9 @@
 ;; This is needed, or at least the docstring part of it is needed to
 ;; get the customization menu to work in Emacs 23.
 (defgroup trepanpl nil
-  "The Ruby 1.9.2 \"trepanning\" debugger"
+  "The Perl \"trepanning\" debugger"
   :group 'processes
-  :group 'ruby
+  :group 'perl
   :group 'dbgr
   :version "23.1")
 
@@ -17,7 +17,7 @@
 ;; User definable variables
 ;;
 
-(defcustom trepan-command-name
+(defcustom dbgr-trepanpl-command-name
   ;;"trepanpl --emacs 3"
   "trepanpl"
   "File name for executing the Ruby debugger and command options.
@@ -50,7 +50,7 @@ marginal icons is reset."
         (script-name (car script-args))
         (cmd-buf
           (dbgr-run-process "trepanpl" script-name cmd-args 
-                            'trepanpl-track-mode no-reset)
+                            'dbgr-trepanpl-track-mode no-reset)
           ))
   ))
 
index c518d3d96644c193432654490b871dbd1dd76856..08a31e6c114f9f277b7519b04805c000e1243456 100644 (file)
        :line-group 2)
   "A dbgr-loc-pat struct that describes a line used in an error message"  )
 
+;;  Regular expression that pseudo-files in caller. For example:
+;;    (eval 1006)[../example/eval.pl:5]
+(defconst dbgr-perl-ignore-file-re "(eval [0-9]+)\\(\\[.+\\]\\)?"
+  "Regular expression that pseudo-files of caller()")
+
 ;; FIXME: there is probably a less redundant way to do the following
 ;; FNS. 
 (defun dbgr-perl-goto-errmsg-line (pt)
index 4e6bb14238003ee6c08f7d31ceaf692b142f23ca..2fcaedce89481534a92dd06ae174c974c4de4975 100644 (file)
                                prompt-str))
 )
 
+(context "perldb prompt matching"
+        (tag regexp-perldb)
+        (specify "prompt"
+                 (prompt-match "  DB<2> "  "2")
+                 (prompt-match "[pid=6489->6502]  DB<1> " "1")
+                 )
+        )
+
+(context "perldb file ignore matching"
+        (tag regexp-perldb)
+        (assert-equal 0 (string-match dbgr-perl-ignore-file-re
+                                      "(eval 1006)[../example/eval.pl:5]"))
+)
+
+
 (context "perldb prompt matching"
         (tag regexp-perldb)
         (specify "prompt"