1 ;;; Copyright (C) 2010, 2011 Rocky Bernstein <rocky@gnu.org>
2 ;;; Ruby 1.8 debugger: ruby-debug (rdebug)
4 (eval-when-compile (require 'cl))
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
8 (require-relative-list '("../../lang/ruby") "realgud-lang-")
10 (defvar realgud-pat-hash)
11 (declare-function make-realgud-loc-pat (realgud-loc))
13 (defvar realgud-rdebug-pat-hash (make-hash-table :test 'equal)
14 "Hash key is the what kind of pattern we want to match:
15 backtrace, prompt, etc. The values of a hash entry is a
16 realgud-loc-pat struct")
18 ;; Regular expression that describes a rdebug location generally shown
19 ;; before a command prompt.
21 ;;
\1a\1a/usr/lib/ruby/1.8/rubygems/custom_require.rb:31 # in Emacs
23 (setf (gethash "loc" realgud-rdebug-pat-hash)
25 :regexp "
\1a\1a\\(?:source \\)?\\(\\(?:[a-zA-Z]:\\)?\\(?:.+\\)\\):\\([0-9]+\\).*\\(?:\n\\|$\\)"
28 :ignore-file-re "(eval)"
31 ;; Regular expression that describes a rdebug command prompt
34 (setf (gethash "prompt" realgud-rdebug-pat-hash)
36 :regexp "^(rdb:[0-9]+) "
39 ;; Regular expression that describes a Ruby backtrace line.
40 (setf (gethash "lang-backtrace" realgud-rdebug-pat-hash)
41 realgud-ruby-backtrace-loc-pat)
43 ;; Regular expression that describes a ruby $! backtrace
44 (setf (gethash "dollar-bang-backtrace" realgud-rdebug-pat-hash)
45 realgud-ruby-dollar-bang-loc-pat)
47 ;; Regular expression that describes a rdebug "breakpoint set" line
49 ;; Breakpoint 1 file /test/gcd.rb, line 6
50 ;; -----------^------^^^^^^^^^^^^-------^
51 (setf (gethash "brkpt-set" realgud-rdebug-pat-hash)
53 :regexp "^Breakpoint \\([0-9]+\\) file \\(.+\\), line \\([0-9]+\\)\n"
58 (defconst realgud-rdebug-frame-file-line-regexp
59 "[ \t\n]+at line \\(.*\\):\\([0-9]+\\)$")
61 (defconst realgud-rdebug-frame-start-regexp realgud:trepan-frame-start-regexp)
62 (defconst realgud-rdebug-frame-num-regexp realgud:trepan-frame-num-regexp)
64 ;; Regular expression that describes a Ruby $! string
65 (setf (gethash "dollar-bang" realgud-rdebug-pat-hash)
66 realgud-ruby-dollar-bang-loc-pat)
68 ;; Regular expression that describes a Ruby $! string
69 (setf (gethash "rails-backtrace" realgud-rdebug-pat-hash)
70 realgud-rails-backtrace-loc-pat)
72 ;; Regular expression that describes a debugger "backtrace" command line.
74 ;; --> #0 at line /usr/bin/irb:12
75 ;; #1 main.__script__ at /tmp/fact.rb:1
76 ;; #1 main.__script__ at /tmp/fact.rb:1
77 ;; #0 IRB.start(ap_path#String) at line /usr/lib/ruby/1.8/irb.rb:52
78 (setf (gethash "debugger-backtrace" realgud-rdebug-pat-hash)
80 :regexp (concat realgud-rdebug-frame-start-regexp " "
81 realgud-rdebug-frame-num-regexp
82 "\\(?: \\(?:\\(.+\\)(\\(.*\\))\\)\\)?"
83 realgud-rdebug-frame-file-line-regexp
90 (setf (gethash "font-lock-keywords" realgud-rdebug-pat-hash)
92 ;; Parameters and first type entry. E.g Object.gcd(a#Fixnum, b#Fixnum)
94 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)#\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\>"
95 (1 font-lock-variable-name-face)
96 (2 font-lock-constant-face))
98 ;; "::Type", which occurs in class name of function and in
100 ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
101 (1 font-lock-type-face))
103 ;; The frame number and first type name, if present.
104 ;; E.g. --> #0 Object.gcd(a#Fixnum, b#Fixnum)
106 ("^\\(-->\\)? *#\\([0-9]+\\) *\\(\\([a-zA-Z_][a-zA-Z0-9_]*\\)[.:]\\)?"
107 (2 realgud-backtrace-number-face)
108 (4 font-lock-constant-face nil t)) ; t means optional.
110 ;; File name and line number. E.g. at line /test/gcd.rb:6
111 ;; -------^^^^^^^^^^^^^-^
112 ("at line \\(.*\\):\\([0-9]+\\)$"
113 (1 realgud-file-name-face)
114 (2 realgud-line-number-face))
117 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
118 (1 font-lock-type-face)
119 (2 font-lock-function-name-face))
120 ;; (rdebug-frames-match-current-line
121 ;; (0 rdebug-frames-current-frame-face append))
125 (setf (gethash "rdebug" realgud-pat-hash) realgud-rdebug-pat-hash)
127 (defvar realgud-rdebug-command-hash (make-hash-table :test 'equal)
128 "Hash key is command name like 'quit' and the value is
129 the trepanx command to use, like 'quit!'")
131 (setf (gethash "quit" realgud-rdebug-command-hash) "quit!")
132 (setf (gethash "shell" realgud-rdebug-command-hash) "irb")
133 (setf (gethash "rdebug" realgud-command-hash) realgud-rdebug-command-hash)
135 (provide-me "realgud-rdebug-")