]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/rdebug/init.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / rdebug / init.el
1 ;;; Copyright (C) 2010, 2011 Rocky Bernstein <rocky@gnu.org>
2 ;;; Ruby 1.8 debugger: ruby-debug (rdebug)
3
4 (eval-when-compile (require 'cl))
5
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
8 (require-relative-list '("../../lang/ruby") "realgud-lang-")
9
10 (defvar realgud-pat-hash)
11 (declare-function make-realgud-loc-pat (realgud-loc))
12
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")
17
18 ;; Regular expression that describes a rdebug location generally shown
19 ;; before a command prompt.
20 ;; For example:
21 ;; \1a\1a/usr/lib/ruby/1.8/rubygems/custom_require.rb:31 # in Emacs
22 ;; /usr/bin/irb:12
23 (setf (gethash "loc" realgud-rdebug-pat-hash)
24 (make-realgud-loc-pat
25 :regexp "\1a\1a\\(?:source \\)?\\(\\(?:[a-zA-Z]:\\)?\\(?:.+\\)\\):\\([0-9]+\\).*\\(?:\n\\|$\\)"
26 :file-group 1
27 :line-group 2
28 :ignore-file-re "(eval)"
29 ))
30
31 ;; Regular expression that describes a rdebug command prompt
32 ;; For example:
33 ;; (rdb:1)
34 (setf (gethash "prompt" realgud-rdebug-pat-hash)
35 (make-realgud-loc-pat
36 :regexp "^(rdb:[0-9]+) "
37 ))
38
39 ;; Regular expression that describes a Ruby backtrace line.
40 (setf (gethash "lang-backtrace" realgud-rdebug-pat-hash)
41 realgud-ruby-backtrace-loc-pat)
42
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)
46
47 ;; Regular expression that describes a rdebug "breakpoint set" line
48 ;; For example:
49 ;; Breakpoint 1 file /test/gcd.rb, line 6
50 ;; -----------^------^^^^^^^^^^^^-------^
51 (setf (gethash "brkpt-set" realgud-rdebug-pat-hash)
52 (make-realgud-loc-pat
53 :regexp "^Breakpoint \\([0-9]+\\) file \\(.+\\), line \\([0-9]+\\)\n"
54 :num 1
55 :file-group 2
56 :line-group 3))
57
58 (defconst realgud-rdebug-frame-file-line-regexp
59 "[ \t\n]+at line \\(.*\\):\\([0-9]+\\)$")
60
61 (defconst realgud-rdebug-frame-start-regexp realgud:trepan-frame-start-regexp)
62 (defconst realgud-rdebug-frame-num-regexp realgud:trepan-frame-num-regexp)
63
64 ;; Regular expression that describes a Ruby $! string
65 (setf (gethash "dollar-bang" realgud-rdebug-pat-hash)
66 realgud-ruby-dollar-bang-loc-pat)
67
68 ;; Regular expression that describes a Ruby $! string
69 (setf (gethash "rails-backtrace" realgud-rdebug-pat-hash)
70 realgud-rails-backtrace-loc-pat)
71
72 ;; Regular expression that describes a debugger "backtrace" command line.
73 ;; e.g.
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)
79 (make-realgud-loc-pat
80 :regexp (concat realgud-rdebug-frame-start-regexp " "
81 realgud-rdebug-frame-num-regexp
82 "\\(?: \\(?:\\(.+\\)(\\(.*\\))\\)\\)?"
83 realgud-rdebug-frame-file-line-regexp
84 )
85 :num 2
86 :file-group 5
87 :line-group 6)
88 )
89
90 (setf (gethash "font-lock-keywords" realgud-rdebug-pat-hash)
91 '(
92 ;; Parameters and first type entry. E.g Object.gcd(a#Fixnum, b#Fixnum)
93 ;; ^-^^^^^^ ^-^^^^^^
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))
97
98 ;; "::Type", which occurs in class name of function and in
99 ;; parameter list.
100 ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
101 (1 font-lock-type-face))
102
103 ;; The frame number and first type name, if present.
104 ;; E.g. --> #0 Object.gcd(a#Fixnum, b#Fixnum)
105 ;; -----^-^^^^^^.^^^
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.
109
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))
115
116 ;; Function name.
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))
122 ))
123
124
125 (setf (gethash "rdebug" realgud-pat-hash) realgud-rdebug-pat-hash)
126
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!'")
130
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)
134
135 (provide-me "realgud-rdebug-")