]> code.delx.au - gnu-emacs-elpa/blob - dbgr/lang/ruby.el
Create ring of frame positions. Next/prev motion uses this. Also we have
[gnu-emacs-elpa] / dbgr / lang / ruby.el
1 ;;; Copyright (C) 2010 Rocky Bernstein <rocky@gnu.org>
2 ;;; Common Ruby regular expressions and things
3 (eval-when-compile (require 'cl))
4
5 (require 'load-relative)
6 (require-relative-list '("../common/regexp" "../common/loc" "../common/track")
7 "dbgr-")
8
9
10 (defconst dbgr-ruby-backtrace-loc-pat
11 (make-dbgr-loc-pat
12 :regexp "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\(?: in `.*'\\)?"
13 :file-group 1
14 :line-group 2)
15 "A dbgr-loc-pat struct that describes a Ruby backtrace (or
16 traceback) line." )
17
18 (defconst dbgr-rubinius-backtrace-loc-pat
19 (make-dbgr-loc-pat
20 :regexp "^\\(\e\\[0;3[1-4]m\\)?[ \t]+.* at \\([^:]+\\):\\([0-9]+\\)"
21 :file-group 2
22 :line-group 3)
23 "A dbgr-loc-pat struct that describes a Rubinius backtrace (or
24 traceback) line." )
25
26 (defconst dbgr-ruby-dollar-bang
27 (make-dbgr-loc-pat
28 :regexp "^[ \t]*[[]?\\(.+\\):\\([0-9]+\\):in `.*'"
29 :file-group 1
30 :line-group 2)
31 "A dbgr-loc-pat that struct that describes a Ruby $! string."
32 )
33
34 ;; FIXME: there is probably a less redundant way to do the following
35 ;; FNS.
36 (defun dbgr-ruby-goto-backtrace-line (pt)
37 "Display the location mentioned by the Ruby backtrace line
38 described by PT."
39 (interactive "d")
40 (dbgr-goto-line-for-pt pt "backtrace"))
41
42 (defun dbgr-ruby-goto-dollarbang-backtrace-line (pt)
43 "Display the location mentioned by a Ruby $! backtrace line
44 described by PT."
45 (interactive "d")
46 (dbgr-goto-line-for-pt pt "dollar-bang"))
47
48 (defun dbgr-ruby-populate-command-keys (&optional map)
49 "Bind the debugger function key layout used by many debuggers.
50
51 \\{dbgr-example-map-standard}"
52 (define-key map (kbd "C-c !!") 'dbgr-ruby-goto-dollarbang-backtrace-line)
53 (define-key map (kbd "C-c !b") 'dbgr-ruby-goto-backtrace-line)
54 )
55
56
57 ;; Some things common to all trepan debuggers (Rubinius and Ruby 1.9.2)
58 (defconst dbgr-trepan-frame-start-regexp
59 "\\(?:^\\|\n\\)\\(-->\\| \\)")
60
61 (defconst dbgr-trepan-frame-num-regexp
62 "#\\([0-9]+\\)")
63
64 (defconst dbgr-trepan-frame-line-regexp
65 "[ \t\n]+at line \\([0-9]+\\)\\(?:\n\\|$\\)")
66
67
68 (provide-me "dbgr-lang-")