;;; Copyright (C) 2011 Rocky Bernstein <rocky@gnu.org>
-;;; Regular expressions for Z shell debugger: remake
+;;; Regular expressions for GNU Make debugger: remake
(eval-when-compile (require 'cl))
"../../common/loc"
"../../common/init")
"dbgr-")
-(require-relative-list '("../../lang/posix-shell") "dbgr-lang-")
(defvar dbgr-pat-hash)
(declare-function make-dbgr-loc-pat (dbgr-loc))
;; For example:
;; remake<10>
-;; remake<(5)>
;; remake<<1>>
(setf (gethash "prompt" dbgr-remake-pat-hash)
(make-dbgr-loc-pat
- :regexp "^remake<\\([0-9]\\)+> "
+ :regexp "^remake[<]+\\([0-9]+\\)[>]+ "
:num 1
))
:regexp "^Breakpoint \\([0-9]+\\) on target .* cleared\n"
:num 1))
-;; FIXME: add these.
-;; ;; Regular expression that describes a debugger "backtrace" command line.
-;; ;; For example:
-;; ;; ->0 in file `/etc/apparmor/fns' at line 24
-;; ;; ##1 /etc/apparmor/fns called from file `/etc/init.d/apparmor' at line 35
-;; ;; ##2 /etc/init.d/apparmor called from file `/usr/bin/remake' at line 129
-;; (setf (gethash "frame" dbgr-remake-pat-hash)
-;; (make-dbgr-loc-pat
-;; :regexp (concat dbgr-shell-frame-start-regexp
-;; dbgr-shell-frame-num-regexp "[ ]?"
-;; "\\(.*\\)"
-;; dbgr-shell-frame-file-regexp
-;; "\\(?:" dbgr-shell-frame-line-regexp "\\)?"
-;; )
-;; :num 2
-;; :file-group 4
-;; :line-group 5)
-;; )
-
-;; (setf (gethash "font-lock-keywords" dbgr-remake-pat-hash)
-;; '(
-;; ;; The frame number and first type name, if present.
-;; ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
-;; ;; --^-
-;; ("^\\(->\\|##\\)\\([0-9]+\\) "
-;; (2 dbgr-backtrace-number-face))
-
-;; ;; File name.
-;; ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
-;; ;; ---------^^^^^^^^^^^^^^^^^^^^-
-;; ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
-;; (2 dbgr-file-name-face))
-
-;; ;; File name.
-;; ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
-;; ;; --------^^
-;; ;; Line number.
-;; ("[ \t]+at line \\([0-9]+\\)$"
-;; (1 dbgr-line-number-face))
-;; ;; (trepan-frames-match-current-line
-;; ;; (0 trepan-frames-current-frame-face append))
-;; ))
+(defconst dbgr-remake-frame-start-regexp
+ "\\(?:^\\|\n\\)\\(=>\\| \\)#")
+(defconst dbgr-remake-frame-num-regexp
+ "\\([0-9]+\\)")
+
+(defconst dbgr-remake-frame-file-regexp "\\(.*\\):\\([0-9]+\\)")
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; =>#0 Makefile.in at /tmp/Makefile:216
+;; #1 Makefile at /tmp/Makefile:230
+(setf (gethash "frame" dbgr-remake-pat-hash)
+ (make-dbgr-loc-pat
+ :regexp (concat dbgr-remake-frame-start-regexp
+ dbgr-remake-frame-num-regexp " "
+ "\\(.*\\)" " at "
+ dbgr-remake-frame-file-regexp
+ )
+ :num 2
+ :file-group 4
+ :line-group 5)
+ )
+
+(setf (gethash "font-lock-keywords" dbgr-remake-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ---^
+ ((concat dbgr-remake-frame-start-regexp
+ dbgr-remake-frame-num-regexp)
+ (2 dbgr-backtrace-number-face))
+
+ ;; File name.
+ ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ---------------^^^^^^^^^^^^^^^^^
+ ((concat " \\(.*\\)" " at " dbgr-remake-frame-file-regexp)
+ (2 dbgr-file-name-face)
+ (3 dbgr-line-number-face)
+ )
+ ))
(setf (gethash "remake" dbgr-pat-hash) dbgr-remake-pat-hash)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/common/buffer/backtrace.el")
+(load-file "../dbgr/common/backtrace-mode.el")
(load-file "../dbgr/common/init.el")
(load-file "../dbgr/debugger/pydbgr/init.el")
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/common/buffer/backtrace.el")
+(load-file "../dbgr/common/backtrace-mode.el")
(load-file "../dbgr/debugger/rdebug/init.el")
+(load-file "../dbgr/common/buffer/backtrace.el")
(test-unit-clear-contexts)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/common/buffer/backtrace.el")
+(load-file "../dbgr/common/backtrace-mode.el")
(load-file "../dbgr/debugger/trepan/init.el")
(test-unit-clear-contexts)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/common/buffer/backtrace.el")
+(load-file "../dbgr/common/backtrace-mode.el")
(load-file "../dbgr/debugger/trepanx/init.el")
(test-unit-clear-contexts)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/common/buffer/backtrace.el")
+(load-file "../dbgr/common/backtrace-mode.el")
(load-file "../dbgr/common/init.el")
(load-file "../dbgr/debugger/zshdb/init.el")
--- /dev/null
+(require 'test-unit)
+(load-file "../dbgr/debugger/remake/init.el")
+
+(test-unit-clear-contexts)
+
+(setq prompt-pat (gethash "prompt" dbgr-remake-pat-hash))
+(setq frame-pat (gethash "frame" dbgr-remake-pat-hash))
+
+(defun prompt-match(prompt-str num-str)
+ (assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
+ prompt-str))
+ (assert-equal num-str (substring prompt-str
+ (match-beginning 1) (match-end 1)))
+)
+
+(context "remake prompt matching"
+ (tag regexp-remake)
+ (specify "prompt"
+ (prompt-match "remake<10> " "10")
+ (prompt-match "remake<<1>> " "1")
+ )
+ )
+
+(context "remake frame matching"
+ (tag regexp-remake)
+
+ (specify "frame"
+ (setq s1
+ "=>#0 Makefile.in at /tmp/Makefile:216
+ #1 Makefile at /tmp/Makefile:230
+")
+ (setq frame-re (dbgr-loc-pat-regexp frame-pat))
+ (setq num-group (dbgr-loc-pat-num frame-pat))
+ (setq file-group (dbgr-loc-pat-file-group frame-pat))
+ (setq line-group (dbgr-loc-pat-line-group frame-pat))
+ (assert-equal 0 (string-match frame-re s1))
+ (assert-equal "0" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+ (assert-equal "/tmp/Makefile"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+ (assert-equal "216"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+ (setq pos (match-end 0))
+
+ (assert-equal 38 (string-match frame-re s1 pos))
+ (assert-equal "1" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+ (assert-equal "/tmp/Makefile"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+ (assert-equal "230"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+ )
+ )
+
+(test-unit "regexp-remake")
+