(eval) in Ruby 1.8 or (eval 10)[../foo/bar.pl:10] in Perl. Todo: add <string> in Python.
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
: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
(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)
-;;; 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
(char-offset-group)
(instruction-address-group)
(column-group)
+ (ignore-file-re)
)
(defvar dbgr-pat-hash (make-hash-table :test 'equal)
+;;; 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.")
)
(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."
(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))
(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"))
)
)
-(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
(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))
(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)
(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)
-;;; 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))
(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:
;; 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:
(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)
: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:
-;;; 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-")
;; 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")
;; 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.
(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)
))
))
: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)
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"